microsoft / DirectXShaderCompiler

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

[SPIR-V] Compiler throws an exception on mesh shader compilation when one entry point calls another. #7009

Open neversleeping opened 1 week ago

neversleeping commented 1 week ago

Description

When trying to compile a mesh shader, where 2 entry points exist and one of them is called inside another, dxcompiler.dll throws an exception. Specifically, exception is happening when function which have indices parameter modifier is called.

Steps to Reproduce Compile this code with arguments -E MSMain -T ms_6_5 -spirv. This will result in exception. If delete indices from MSMainCalled declaration, compilation will succeed.

struct MeshOutput {
    float4 position: SV_Position;
    float3 color: COLOR0;
};

[outputtopology("triangle")]
[numthreads(1, 1, 1)]
void MSMainCalled(out indices uint3 triangles[1], out vertices MeshOutput verts[3]) {
    SetMeshOutputCounts(3, 1);
    triangles[0] = uint3(0, 1, 2);

    verts[0].position = float4(-0.5, 0.5, 0.0, 1.0);
    verts[0].color = float3(1.0, 0.0, 0.0);

    verts[1].position = float4(0.5, 0.5, 0.0, 1.0);
    verts[1].color = float3(0.0, 1.0, 0.0);

    verts[2].position = float4(0.0, -0.5, 0.0, 1.0);
    verts[2].color = float3(0.0, 0.0, 1.0);
}

[outputtopology("triangle")]
[numthreads(1, 1, 1)]
void MSMain(out indices uint3 triangles[1], out vertices MeshOutput verts[3]) {
    MSMainCalled(triangles, verts);
}

https://godbolt.org/z/1Tboc87rd

Actual Behavior Exception thrown at 0x00007FFDC9B7D034 (dxcompiler.dll) in Application.exe: 0xC0000005: Access violation reading location 0x000000000000005C.

Environment