shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

For `HLSL` targets, `select()` is emitted as `?:`, which is no longer supported for vector types in HLSL 2021 (default in DXC 1.7+) #4424

Open saipraveenb25 opened 1 week ago

saipraveenb25 commented 1 week ago

Slang emits select(bool3, float3, float3) as a ternary operation (?:) for HLSL target.

This has been removed in HLSL 2021 (with DXC 1.7, I believe), cause even simple code with select statements to fail to compile with DXC 1.7. The slang testing framework explicitly disables HLSL-2021 (in DXC 1.6, atleast) to side-step this issue, but this seems to be causing problems with users who are using the generated HLSL in their own frameworks with a more modern HLSL compiler.

Not quite sure what the fix should be, since emitting select as select in HLSL will mean that it does not compile with older DXC. Should this be a switch, since it feels like HLSL pre-2021 & 2021 are just altogether different targets?