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
{{ message }}
Repository navigation
[SPIR-V] Env Vulkan 1.1 Validation error: Bad OpSelect instruction produced with optimizations enabled. #8603
Description
Attempting to compile HLSL to SPIR-V with the SPIR-V target environment set as Vulkan 1.1 and optimizations enabled (-O3) will produce invalid SPIR-V with a incorrect OpSelect instruction under certain circumstances.
The following code produces the aforementioned error:
With the specific error output in one such test case appearing as:
fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the condition to be equal: Select
%80 = OpSelect %v3float %79 %33 %34
This may be due to a bugged optimization around the ternary operation when assigning to 'tileBorder' followed by the multiplication of 'tileBorder' with a 3-component vector 'tileColor.rgb'. Judging by the error, the 'OpSelect' op's result type is a float3, whilst 'tileBorder' is a scalar float. The resultant type in this case should be a scalar float, or the arguments for 'OpSelect' should all be 3-component float vectors.
Steps to Reproduce
Checkout and build DXC at SHA: 99400dc80ffa0eb6aef56fc6e482f5eff40185e4 ('main' branch)
Run the built dxc.exe on the following provided HLSL source file in: problemhlsl.zip
with arguments: -T cs_6_0 -E csScreenSpaceRaytraceDebug problemhlsl.hlsl -Fo problemshader.spv -spirv -O3 -fspv-target-env=vulkan1.1
Observe output for the aforementioned error.
Actual Behavior
Compilation to SPIR-V will fail with a SPIR-V validation failure.
The error output when running dxc.exe with the above reproduction steps is:
fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the condition to be equal: Select
%80 = OpSelect %v3float %79 %33 %34
Activity
Update SPIRV-Tools to pick up invalid OpSelect folding fix (microsoft…
opt: Fix invalid OpSelect folding in spirv-opt (KhronosGroup#6827)
Update SPIRV-Tools to 1c336172 (#8739)
Update SPIRV-Tools to 1c336172 (microsoft#8738)