microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.11k stars 696 forks source link

[DXIL] Decorating CS float argument with SV_DispatchThreadID semantic crashes the compiler (float2, float3 and float4 works) #3444

Open Dredhog opened 3 years ago

Dredhog commented 3 years ago

Title

[DXIL] Decorating CS float argument with SV_DispatchThreadID semantic crashes the compiler (float2, float3 and float4 works)

Functional impact

Compiler crashes

Minimal repro steps

  1. Compile the following shader with dxc.exe -T cs_6_0 -E CSMain issue_shader.txt:
    
    RWStructuredBuffer<float4> rwTexture;

[numthreads(1, 1, 1)] void CSMain(float id : SV_DispatchThreadID) { rwTexture[3] = id.xxxx; }


### Expected result
Shader compiles correctly, as it does for vector float arguments: `float2`, `float3`, `float4`

### Actual result
Compiler crashes

### Further technical details
Ran test on [shader playground](http://shader-playground.timjones.io/fabe1b8db0f4b2e668dbf311d7ae6620) with DXC from 2020 12 16
The SPIR-V backend produces validation errors (reported here https://github.com/microsoft/DirectXShaderCompiler/issues/3443 )
vcsharma commented 3 years ago

@Dredhog Thanks for reporting this crash. The compiler was lacking in the area of checking for unsupported types for SV semantics that lead to random crashes reported here or in #2954. We expect to soon deploy a change #3043 which would start reporting compilation error for unsupported types.

pow2clk commented 1 year ago

Reverted change resurfaced this bug

https://godbolt.org/z/r4e3jW1Y1

damyanp commented 4 months ago

With current DXC this crashes the compiler with:

error: cast<X>() argument of incompatible type!

For float, float2, float3 and float4.