[SPIR-V] QuadReadLaneAt with a matrix input generates invalid SPIR-V

Open
#9,134 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the HLSL reproducer in the issue and compile it using the provided DXC SPIR-V command to confirm the invalid matrix result. Compare the generated SPIR-V behavior with the successful DXIL output, which uses six scalar quad reads. Done means SPIR-V validation succeeds and each result element reads the corresponding matrix element from the selected lane.

Written by the indexing model from the issue text.

Description

Description

QuadReadLaneAt accepts a float2x3 input, but DXC generates invalid
SPIR-V. It emits OpGroupNonUniformQuadBroadcast with a matrix result.
That instruction permits only scalar and vector results.

The same source compiles successfully for DXIL. That output contains six
scalar quad reads, one for each matrix element.

Reproducer

Save this as repro.hlsl:

StructuredBuffer<float2x3> In : register(t0);
RWStructuredBuffer<float2x3> Out : register(u1);

[numthreads(4, 1, 1)]
void main(uint3 ID : SV_DispatchThreadID) {
  Out[ID.x] = QuadReadLaneAt(In[ID.x], 0);
}

Compile with:

dxc -spirv -T cs_6_5 -E main -fspv-target-env=vulkan1.3 repro.hlsl

Actual result

Compilation fails during SPIR-V validation:

fatal error: generated SPIR-V is invalid: Result must be a scalar or vector of integer, floating-point, or boolean type
  %28 = OpGroupNonUniformQuadBroadcast %mat2v3float %uint_3 %27 %uint_0

Expected result

Compilation succeeds. DXC splits the matrix operation into valid scalar
or vector quad reads. Each result element comes from the same matrix
element in the selected source lane.

Dominant language
C++
Stars
3.7k
Forks
926
Avg merge
3d 22h
Merged PRs (30d)
45

Getting set up

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.

More from microsoft/DirectXShaderCompiler

All issues in microsoft/DirectXShaderCompiler

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.