microsoft / microsoft/DirectXShaderCompiler

[SPIRV] DXC SPIRV OpStore type mismatch

Open
#8,379 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided HLSL reproducer with the documented dxc -spirv command and inspect the generated OpStore operands and SPIR-V validation failure. Trace the SPIR-V backend handling of local resource arrays and compare against the valid DXIL result; done means the reproducer produces SPIR-V that passes DXC's validator.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.