microsoft / DirectXShaderCompiler

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

[SPIR-V] DXC crash #6568

Open jbright282 opened 2 months ago

jbright282 commented 2 months ago

Description Small shader crashes DXC. Verified with nightlies.

Steps to Reproduce

Commandline: dxc.exe -T cs_6_2 -E csAccumulate -spirv -fspv-target-env="vulkan1.1" -Fo output.spv .\badfile.hlsl

I've got the shader down to:

struct CommonParams
{
 float2 paramA;
};

void ComputeProj(const CommonParams params, out float2 paramA)
{
}

void RectifyHistory( inout float3 fHistoryColor, inout float3 fHistoryWeight)
{
}

CommonParams InitParams(int2 iPxHrPos)
{
 CommonParams params;
 ComputeProj(params, params.paramA);
 return params;
}

void Accumulate(int2 iPxHrPos)
{
 const CommonParams params = InitParams(iPxHrPos);

 float3 fHistoryColor = float3(0, 0, 0);
 float fHistoryWeight = float(0);
 RectifyHistory(fHistoryColor, fHistoryWeight);
}

[numthreads(8, 8, 1)]
void csAccumulate(int2 iDispatchThreadID : SV_DispatchThreadID, int2 iGroupId : SV_GroupID, int2 iGroupThreadId : SV_GroupThreadID, int iGroupThreadIndex : SV_GroupIndex)
{
    Accumulate(iDispatchThreadID);
}

Note the float/float3 mismatch with fHistoryWeight. This throws a warning compiling for DX. SPIRV crashes with no error.

Environment

sudonatalie commented 2 months ago

@jbright282 Thanks for reporting, we'll take a look.

s-perron commented 2 weeks ago

Here is a smaller test case that demonstrates the problem: https://godbolt.org/z/hzG9casr1