shader: lower indexed gfx1030 raw subword stores #1281

Merged
stan495 merged 1 commit from upstream-pr/1288 into main 2026-11-24 07:03:59 +00:00
stan495 commented 2026-11-24 06:50:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T06:50:09Z.


Change

Lower the gfx1030 raw MUBUF buffer_store_byte, buffer_store_short, buffer_store_byte_d16_hi, and buffer_store_short_d16_hi forms in the compute store profile. Write the low or high-half source field into a naturally aligned byte or halfword at idxen with zero scalar offset. The UAV descriptor must be ready, and each invocation must own an in-range, DWORD-aligned record in the caller-bound raw UAV.

The generated DXIL preserves neighboring bytes with a full-DWORD read/modify/write. The existing address-layout and overlap checks give each containing DWORD one writer. The translator rejects another write to that DWORD, including a disjoint byte write. The binding requires initialized, unswizzled records and exclusive access during dispatch. Concurrent shared-word updates, native descriptor bounds and other address modes are outside the supported subset.

This extends the raw MUBUF compute store fixtures after #1254. The load follow-up in #1282 is independent. Both landing orders were simulated on 02f2f3dcd83ed0b2a202a5f72b92589af06aa021 and produced tree 146a096ab732d3d3645d232b9e2eca5e3dac436c. Before publication both landing orders again produced the same tree on current main 3212a9c24fd05e263bf7c4e28f0ab84b6dc6d4d0 (5e3edea61f32d8d712ecfb590c9628d56d4d9901). The earlier combined shader sources also passed both new fixture modes on WARP and the physical GPU.

Verification

Tested clean head 06e764bfd90a0db86fbc8a3df7486f81cc20b752.

$python = (Get-Command python).Source
cmake --preset dev "-DINTAKE_PYTHON=$python"
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit (Join-Path $PWD out/stores-06e764bf.xml)
python -B tools/form_coverage.py out/stores-06e764bf.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/stores-06e764bf-coverage.json
python -B tests/docs_links_check.py
python -B tests/form_coverage_check.py

36 passed, 0 failed, 0 skipped. Both compute_store_aot_mubuf_store_subword_{hardware,warp} fixtures recorded all four gfx1030 forms. Windows build 26300.9974, Intel Arc B390 (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818). The debug layer was unavailable on both backends. Each program compared all 320 DWORDs against a CPU byte-slice reference for one and three groups, including adjacent bytes, records and the untouched tail. For buffer_store_byte, selecting the other VGPR half or overwriting the containing DWORD first differed at word 1 (c5c578c5 expected, c5c534c5 and 12345678 actual). Rejection controls cover same-DWORD overlap, non-separating addresses, record overruns, misaligned shorts and missing descriptor waits.

python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

Passed on Ubuntu 22.04.5 with LLVM 15.0.7. The check assembles all four wave32 fixtures and verifies that the synthetic container CLI and direct lowering emit the same HLSL. The GPU tests execute the translated desktop DXIL. Markdown links and coverage self-tests also passed.

The original synthetic fixtures use the repository's MIT License. The AMD RDNA 2 Shader ISA documents MUBUF opcodes 24 through 27.

This change was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576325075 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1288). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T06:50:09Z. --- ## Change Lower the gfx1030 raw MUBUF `buffer_store_byte`, `buffer_store_short`, `buffer_store_byte_d16_hi`, and `buffer_store_short_d16_hi` forms in the compute store profile. Write the low or high-half source field into a naturally aligned byte or halfword at `idxen` with zero scalar offset. The UAV descriptor must be ready, and each invocation must own an in-range, DWORD-aligned record in the caller-bound raw UAV. The generated DXIL preserves neighboring bytes with a full-DWORD read/modify/write. The existing address-layout and overlap checks give each containing DWORD one writer. The translator rejects another write to that DWORD, including a disjoint byte write. The binding requires initialized, unswizzled records and exclusive access during dispatch. Concurrent shared-word updates, native descriptor bounds and other address modes are outside the supported subset. This extends the raw MUBUF compute store fixtures after #1254. The load follow-up in #1282 is independent. Both landing orders were simulated on `02f2f3dcd83ed0b2a202a5f72b92589af06aa021` and produced tree `146a096ab732d3d3645d232b9e2eca5e3dac436c`. Before publication both landing orders again produced the same tree on current main `3212a9c24fd05e263bf7c4e28f0ab84b6dc6d4d0` (`5e3edea61f32d8d712ecfb590c9628d56d4d9901`). The earlier combined shader sources also passed both new fixture modes on WARP and the physical GPU. ## Verification Tested clean head `06e764bfd90a0db86fbc8a3df7486f81cc20b752`. ```powershell $python = (Get-Command python).Source cmake --preset dev "-DINTAKE_PYTHON=$python" cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit (Join-Path $PWD out/stores-06e764bf.xml) python -B tools/form_coverage.py out/stores-06e764bf.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/stores-06e764bf-coverage.json python -B tests/docs_links_check.py python -B tests/form_coverage_check.py ``` 36 passed, 0 failed, 0 skipped. Both `compute_store_aot_mubuf_store_subword_{hardware,warp}` fixtures recorded all four gfx1030 forms. Windows build 26300.9974, Intel Arc B390 (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818). The debug layer was unavailable on both backends. Each program compared all 320 DWORDs against a CPU byte-slice reference for one and three groups, including adjacent bytes, records and the untouched tail. For `buffer_store_byte`, selecting the other VGPR half or overwriting the containing DWORD first differed at word 1 (`c5c578c5` expected, `c5c534c5` and `12345678` actual). Rejection controls cover same-DWORD overlap, non-separating addresses, record overruns, misaligned shorts and missing descriptor waits. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` Passed on Ubuntu 22.04.5 with LLVM 15.0.7. The check assembles all four wave32 fixtures and verifies that the synthetic container CLI and direct lowering emit the same HLSL. The GPU tests execute the translated desktop DXIL. Markdown links and coverage self-tests also passed. The original synthetic fixtures use the repository's MIT License. The AMD RDNA 2 Shader ISA documents MUBUF opcodes 24 through 27. This change was AI-assisted.
upstream-sync closed this pull request 2026-11-24 07:07:40 +00:00
tedin7 commented 2026-11-24 07:07:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:05:53Z.

Review: COMMENTED


Dual-platform review at commit 06e764bfd90a0db86fbc8a3df7486f81cc20b752 (note: PR was merged during the Windows verification run):

Linux checks

  • git diff --check origin/main...HEAD: passed
  • python -B tests/docs_links_check.py: passed (16 Markdown files, 287 links)
  • python -B tests/bidi_controls_check.py: passed (1076 tracked files)
  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/compute_store_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passed (exit 0)

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Debug (--preset dev):
    • cmake --build --preset dev --target offscreen_check -- -j 6: 2.80s
    • ctest --preset dev -R '^compute_store_aot_mubuf_store_subword_' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (compute_store_aot_mubuf_store_subword_warp, compute_store_aot_mubuf_store_subword_hardware)
  • Release /O2 (--preset release):
    • cmake --build --preset release --target offscreen_check -- -j 6: 0.35s
    • ctest --preset release -R '^compute_store_aot_mubuf_store_subword_' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed

Notes & Edge Cases

  • tools/compute_store_aot.py cleanly reserves the full containing DWORD (offset &= ~3, written_spans.append((offset, offset + 4))) and masks/shifts the selected byte or halfword from bit 0 or bit 16.
  • Stride DWORD-alignment check: docs/experiments.md specifies a DWORD-aligned record, and offset + 4 * count <= stride checks record bounds, but stride % 4 == 0 is not explicitly enforced in lower() for subword (unlike ByteAddressBuffer.Load/Store which require 4-byte-aligned addresses and would otherwise collide across adjacent records if stride were e.g. 6).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035028903 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1288#pullrequestreview-6035028903). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T07:05:53Z. **Review:** COMMENTED --- Dual-platform review at commit `06e764bfd90a0db86fbc8a3df7486f81cc20b752` (note: PR was merged during the Windows verification run): ### Linux checks - `git diff --check origin/main...HEAD`: passed - `python -B tests/docs_links_check.py`: passed (16 Markdown files, 287 links) - `python -B tests/bidi_controls_check.py`: passed (1076 tracked files) - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/compute_store_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passed (exit 0) ### Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target offscreen_check -- -j 6`: `2.80s` - `ctest --preset dev -R '^compute_store_aot_mubuf_store_subword_' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** (`compute_store_aot_mubuf_store_subword_warp`, `compute_store_aot_mubuf_store_subword_hardware`) - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target offscreen_check -- -j 6`: `0.35s` - `ctest --preset release -R '^compute_store_aot_mubuf_store_subword_' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** ### Notes & Edge Cases - `tools/compute_store_aot.py` cleanly reserves the full containing DWORD (`offset &= ~3`, `written_spans.append((offset, offset + 4))`) and masks/shifts the selected byte or halfword from bit 0 or bit 16. - **Stride DWORD-alignment check**: `docs/experiments.md` specifies a DWORD-aligned record, and `offset + 4 * count <= stride` checks record bounds, but `stride % 4 == 0` is not explicitly enforced in `lower()` for `subword` (unlike `ByteAddressBuffer.Load/Store` which require 4-byte-aligned addresses and would otherwise collide across adjacent records if `stride` were e.g. `6`).
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!1281
No description provided.