compute: expand packed D16 into FLOAT4 heap views #2222

Merged
RavenCurseBurg merged 1 commit from upstream-pr/2230 into main 2026-11-25 06:39:15 +00:00
RavenCurseBurg commented 2026-11-25 06:29:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T06:29:31Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6598663910 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2230). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T06:29:31Z. --- 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](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) · [Microsoft HLSL conversion](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/f16tof32) **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](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45559657341). - `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).
upstream-sync closed this pull request 2026-11-25 07:01:08 +00:00
tedin7 commented 2026-11-25 07:01:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:33:47Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052899706 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2230#pullrequestreview-6052899706). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:33:47Z. **Review:** COMMENTED --- 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 in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2222
No description provided.