microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] `uint64_t2/int64_t2` typed buffers emitted with `Unknown` image format

Open
#8,615 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

This is the DXC side of llvm/offload-test-suite#1037

Description
DXC's SPIR-V codegen emits an Unknown image format for [RW]Buffer<uint64_t2/int64_t2> because SPIR-V has no multi-component 64-bit image format for the 2-component 64-bit element to lower to. This ultimately generates incorrect outputs in the offload-test-suite (see the discussion in llvm/offload-test-suite#1037 for more explanation on how).

Repro
https://godbolt.org/z/bWshMxheq

RWBuffer<uint64_t2> U0 : register(u0);
RWBuffer<uint64_t> Out0 : register(u1);

[numthreads(4,1,1)]
void main(uint GI : SV_GroupIndex) {
  Out0[GI] = U0[GI].x;
}
OpTypeImage %ulong Buffer 2 0 0 2 Unknown

Requested Fix
DXC should pack 2-component 64-bit typed buffer elements into 4-component 32-bit images and bitcast during load/store. This matches how DirectX already handles these buffers: uint64_t2/int64_t2 elements are backed by 4x32-bit channels and reinterpreted in the shader.

This same fix was made in Clang: https://github.com/llvm/llvm-project/pull/208626

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 with the HLSL reproduction in the issue and inspect the generated SPIR-V OpTypeImage declaration, then compare the requested behavior with the linked Clang fix. Done means uint64_t2 and int64_t2 typed buffers use four 32-bit channels with bitcasts during load/store instead of an Unknown image format, while the reproduction produces correct output.

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
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.