You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
If the SV_ShadingRate semantic is used in any shader stage that supports it, the compiler seems to skip optimizing out unused resources as though the -fspv-preserve-bindings flag were set. Additionally it does not remove unused variables in the input. Directly appending just the SPV_KHR_fragment_shading_rate extension via inline SPIR-V produces the same result.
Compile 3 times with the following command line arguments:
normal: -E vertex -T vs_6_5 -spirv -fspv-target-env=vulkan1.2
with SV_ShadingRate: -E vertex -T vs_6_5 -spirv -fspv-target-env=vulkan1.2 -D SHADING_RATE
with just the extension: -E vertex -T vs_6_5 -spirv -fspv-target-env=vulkan1.2 -D EXT_ONLY
Behavior
This vertex shader outputs a constant 0, so we should expect that all the textures, samplers, and cbuffer should be removed and the input vertex and texcoord semantics should be optimized away as well. This happens when the base shader is compiled. When adding SV_ShadingRate to the output or simply declaring the extension via inline SPIR-V, no resources are removed and the unused position and texcoord semantics are loaded.
Activity
Error-mdl commentedon Sep 14, 2024
Managed to track down the issue. Its the SPIRV-Tools aggressive dead code elimination pass. There's a whitelist of allowed extensions, and if the code contains an extension not on it the pass exits: https://github.com/KhronosGroup/SPIRV-Tools/blob/4451f6ab13dda98bf255a7cd7b4d120132dc0dfd/source/opt/aggressive_dead_code_elim_pass.cpp#L952 . I see no reason why SPV_KHR_fragment_shading_rate isn't in the list, and adding myself seems to work fine.
s-perron commentedon Sep 14, 2024
Reopening to make sure we update the allow lists in spirv-opt. There are three passes that need to be updated.
s-perron commentedon Sep 14, 2024
Reopening to make sure we update the allow lists in spirv-opt. There are three passes that need to be updated.
deps: update SPIRV-Tools
deps: update SPIRV-Tools
deps: update SPIRV-Tools
hosea1008 commentedon Oct 25, 2024
This also fixes #6982
[SPIR-V] Fixes SPV_KHR_fragment_shading_rate preventing optimizations (…
[SPIR-V] Fixes SPV_KHR_fragment_shading_rate preventing optimizations (…
Update submodules: DirectX-Headers to 61c77189, SPIRV-Headers to 5c60…
Update submodules: DirectX-Headers to 61c77189, SPIRV-Headers to 5c60…
Update submodules: DirectX-Headers to 61c77189, SPIRV-Headers to fb13…