Skip to content

compute: expand packed D16 into FLOAT4 heap views - #2230

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
RavenCurseBurg:compute/heap-d16-float4
Nov 25, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
RavenCurseBurg:compute/heap-d16-float4

Conversation

@RavenCurseBurg

Copy link
Copy Markdown
Contributor

Refs #2022, follow-up to the UINT4 store in #2224. The heap-view route now accepts gfx1013 buffer_store_format_d16_xyzw with two source VGPRs and a live identity BUF_FMT_32_32_32_32_FLOAT view (77). Each packed half expands to a binary32 component in X/Y/Z/W order. The bounds check uses the full 16-byte destination texel. Selecting a UINT4 view with the packed opcode leaves the destination untouched, as does selecting a FLOAT4 view with the ordinary UINT opcode. AMD RDNA 2 instruction set · Microsoft HLSL conversion

Verification on Windows at 5971d011

  • On the parent revision, LLVM 15.0.7 assembled and disassembled buffer_store_format_d16_xyzw v[10:11], v8, s[20:23], 0 idxen offset:4; the heap-view lowering refused it. On this branch the source assembly, LLVM-C disassembly lowering and container CLI emit identical HLSL for both the packed and original program.
  • Ran python -B tests/compute_heap_store_check.py draw <dxc> <offscreen_check> warp and repeated it with hardware. Each device passed all 12 D16 cases and detected 11 wrong shaders. The original UINT4 path passed all 12 cases and detected its 8 wrong shaders on both devices. Each case compares all 320 words. The packed inputs include successive binary16 values at 1.0, −2.0, the smallest positive binary16 subnormal and negative zero. Dropping the conversion, duplicating the low half or sourcing W from the wrong VGPR each caused a readback mismatch. Used DXC 1.9.2609 and the source-built renderer.
  • python -B tests/compute_heap_store_check.py controls, the adjacent heap-load, format-load, entry-layout, population-count and integer-comparison controls passed. Documentation link and bidi checks and git diff --check passed.
  • The registered binary test exercises both programs with python -B tests/compute_heap_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1.

AI-assisted with Codex (GPT-6.2 Astra xhigh).

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 5971d0110b982506d1fa18d8d0fa8be55608f475 (files: tools/compute_store_aot.py, tests/compute_heap_store_check.py, docs/experiments.md).

Result: 0 P1, 0 P2.

Semantics:

  • buffer_store_format_d16_xyzw with two source VGPRs expands X/Y from the low/high half of the first VGPR and Z/W from the second. Each half goes through f16tof32 into a binary32 word of a live format 77 (BUF_FMT_32_32_32_32_FLOAT) view. This matches the RDNA2 D16 format-store model.
  • The record's format word must match the opcode: a D16 opcode on a UINT4 record, or a UINT opcode on a FLOAT4 record, stores nothing. The bounds check keeps the full 16-byte texel, and span reserves four bytes per component for the heap route.
  • Overlap check: #2165 (d16 buffer loads), #2192 (10-bit-x format decode) and #2205 (LLVM path in tests) touch other code paths. This PR only changes the heap-view store helper and its lowering, so there is no duplicated opcode or slice. The two compute_store_aot.py edits may need a trivial rebase if #2165 merges first.
  • Caveat, not a blocker: the D16 cases are checked against a CPU reference and D3D12 WARP/hardware adapters. They were not checked against console hardware.

Linux checks executed locally:

  • python3 tests/docs_links_check.py: pass (18 files, 414 links)
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: pass
  • python3 -B tests/compute_heap_store_check.py controls: pass

Mutation (restored with git checkout -- . afterwards):

  • Removing d16_xyzw from the accepted heap-store channels makes controls fail with ValueError: Heap store view requires buffer_store_format_xyzw or buffer_store_format_d16_xyzw. Killed.
  • Changing the conversion's second lane to value.x: the Linux controls test does not catch it, since it only checks the HLSL text. The PR's WARP/hardware readback fixture is the guard for it, and it covers this mutation by design. Its runtime results come from the author and from CI.

CI: Build and test on Windows = SUCCESS (run 45560989329), Linux checks and gfx1013 fixtures = SUCCESS.

AI-assisted; commands listed were executed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants