-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDAT: Check flags and WaveSize for min SM; fix flag detection and merging #6207
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
cbacb36
to
79f021c
Compare
Adding OptFeatureInfo_UsesDerivatives to track per-function derivative usage, otherwise we can't set DerivativesInMeshAndAmpShaders or min shader target properly. This uses a feature bit in a special optional set of flags defined by the runtime to be ignored if set and unrecognized. Since it's not a real feature requirement but a special flag used in computing feature requirements after accounting for all functions at link time, this is a good place for this special flag.
hasUAVs and hasWriteableMSAATextures were set based on global resource properties, instead of what the function actually used. This change fixes that, additionally detecting cases that would have been missed by catching all handle cases.
This check did not belong in per-function CollectShaderFlags. Moved to module.
OP::GetMinShaderModelAndMask needed to account for new Node shader. Also, the barrier op check was not robust to an invalid operand, hit by validation test.
…rget Feature flags were not taken into account when computing minimum shader targets. Also, once a function is known to be a particular shader, we can translate the UsesDerivatives into the correct min target and potential DerivativesInMeshAndAmpShaders feature flag. This also takes into account min target for WaveSize and WaveSize with Range.
ShaderCompatInfo was used to track per-function feature flag and min target for RDAT. But internal calls were not traversed and the global feature flag collection had to do all the same work as the RDAT writer did redundantly. This change moves this into DxilModule, where it can be computed once and cached for both the CollectShaderFlagsForModule, as well as the RDAT per-function lookup. Along the way, DxilModule& needed to be made non-const for DxilRDATWriter so it could update the compat info, in case it was unwritten.
7d883a9
to
e99711e
Compare
If you start here, then step through commits with [Next], it's a lot more digestible. |
Add tests for several classes of deriv ops in node. This also adds testing for barrier in node, which was a fix in this PR.
✅ With the latest revision this PR passed the Python code formatter. |
331747a
to
1f1649f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite done I'm afraid, but I wanted to give what I had.
A lot of this is nits to make it more readable, but there are some substantive comments too. Let me know if any are unclear which they are.
One notable change is the elimination of the optimization in ComputeShaderCompatInfo where a function would be skipped if it already had ShaderCompatInfo. This was incorrect, since this is happening inside the same loop that iterates intrinsics, which could add the compat info based on intrinsic usage. That doesn't mean flags have been computed for the function, so I removed this and clear the map at the beginning of ComputeShaderCompatInfo to ensure it's fresh. I also added IR tests, and ones that reorder intrinsics and the called function to ensure function ordering doesn't cause a problem. I made these and the sm66_derivatives.hlsl test they were based on go back to SM 6.6, since there was another detail on that validator version that was different - it didn't set min shader model properly for lib functions. The 1.6 validator is the one included in the latest Windows SDK, so going back this far seems good. I also added the OptFeatureInfo flags to disassembly.
Function-level UsesDerivatives flag is not necessary at global library level, so always clear it in CollectShaderFlagsForModule. Prior code used !(SM->IsCS() || SM->IsPS()), which covered any new shader stages. This flag only matters for VS, HS, DS, and GS. I fixed the code, but left the old logic in for validator version 1.7 and below for compatibility. Add bit index comments for the raw ShaderFlags bitfields to make decoding raw flags easier. Fix metadata for validator version 1.7 in SM 6.7 IL test. Add test for global ShaderFlags checking: - masking of UsesDerivatives - DerivativesInMeshAndAmpShaders from called function - removal of UAVsAtEveryStage for library profile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with a long change like this, my comments tend toward complaining about how hard it is to read and review. Sorry about that.
I tried to make suggested changes where possible. Overall, this improves more than I expected to fix this bug. Now that it's done, that's great!
I don't think much needs to change, I just have a couple concerns and many readability suggestions.
Co-authored-by: Greg Roth <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the pretty printing! Thanks for all the responses!
…ging (microsoft#6207) Add ShaderKind::Last_1_8 for shader mask Add shader model comments before flag groupings in DxilConstants.h and DxilShaderFlags. Add missing flag checks for min shader model in RDAT function info. Move ShaderCompatInfo computation into DxilModule, propagate callee info. Move computation of shader model requirements based on flags into DxilModule. Finalize requirements for entry functions in AdjustMinimumShaderModelAndFlags. Fixes for function level flag tracking: - DerivativesInMeshAndAmpShaders: use flag to track deriv use, then adjust for entry functions. - hasUAVs: based on resource use in function instead of global resources. - WriteableMSAATextures: based on use in function instead of global resources. - Also catch cases for dynamic res from any use by looking at create/annotate handle, not just the TextureStoreSample op. - RaytracingTier1_1: move module-level detection to CollectShaderFlagsForModule - Marked deriv and quad ops as being supported in node. - Fixed SampleCmpBias to be considered gradient op. - Update RDAT definitions to dump more useful info for testing Fixes microsoft#6218. (cherry picked from commit 9c518db)
…ging (#6207) (#6273) Add ShaderKind::Last_1_8 for shader mask Add shader model comments before flag groupings in DxilConstants.h and DxilShaderFlags. Add missing flag checks for min shader model in RDAT function info. Move ShaderCompatInfo computation into DxilModule, propagate callee info. Move computation of shader model requirements based on flags into DxilModule. Finalize requirements for entry functions in AdjustMinimumShaderModelAndFlags. Fixes for function level flag tracking: - DerivativesInMeshAndAmpShaders: use flag to track deriv use, then adjust for entry functions. - hasUAVs: based on resource use in function instead of global resources. - WriteableMSAATextures: based on use in function instead of global resources. - Also catch cases for dynamic res from any use by looking at create/annotate handle, not just the TextureStoreSample op. - RaytracingTier1_1: move module-level detection to CollectShaderFlagsForModule - Marked deriv and quad ops as being supported in node. - Fixed SampleCmpBias to be considered gradient op. - Update RDAT definitions to dump more useful info for testing Fixes #6218. (cherry picked from commit 9c518db)
Add ShaderKind::Last_1_8 for shader mask
Add shader model comments before flag groupings in DxilConstants.h and DxilShaderFlags.
Add missing flag checks for min shader model in RDAT function info. Move ShaderCompatInfo computation into DxilModule, propagate callee info.
Move computation of shader model requirements based on flags into DxilModule. Finalize requirements for entry functions in AdjustMinimumShaderModelAndFlags.
Fixes for function level flag tracking:
Fixes #6218.