Skip to content

[SPIRV] DXC SPIRV OpStore type mismatch #8379

@bob80905

Description

@bob80905

When compiling HLSL shaders that use local resource arrays to SPIR-V via DXC (-spirv), DXC produces invalid SPIR-V that fails validation.

Reproducer:

 RWByteAddressBuffer gBufArray[4] : register(u0);
 
 [numthreads(1,1,1)]
 void main(uint3 tid : SV_DispatchThreadID) {
     RWByteAddressBuffer arr[2];
     arr[0] = gBufArray[0];
     arr[1] = gBufArray[1];
     arr[tid.x & 1].Store(0, 42);
 }

Command:

dxc -spirv -fspv-target-env=vulkan1.3 -T cs_6_0 -Fo out.spv source.hlsl

Error output:

fatal error: generated SPIR-V is invalid: OpStore Pointer '29[%29]'s type does not match Object '28[%28]'s type.
OpStore %29 %28

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Note: DXC does not produce a stack trace for this — it's a SPIR-V validation error, not an assertion/crash. The compilation produces SPIR-V output that fails DXC's internal SPIR-V validator.

Impact: Local resource arrays fail SPIR-V validation when compiled through DXC's SPIRV backend. The same shader compiles and runs correctly when targeting DXIL (dxc -T cs_6_0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions