shader: lower indexed gfx1030 raw subword loads #1218

Merged
stan495 merged 3 commits from upstream-pr/1225 into main 2026-11-24 05:22:28 +00:00
stan495 commented 2026-11-24 04:22:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T04:22:55Z.


Change

Lower buffer_load_ubyte, buffer_load_sbyte, buffer_load_ushort and buffer_load_sshort in the gfx1030 compute store profile. Read the containing DWORD from the caller-bound raw t0 and extract and extend the selected field. Accept only verified idxen, a zero scalar offset, naturally aligned immediates, DWORD-aligned source records, and descriptor/result waits. The caller must provide valid, unswizzled, stable, in-range records disjoint from u0. This does not emulate native bounds or add D16, cache/status modifiers, or pixel bindings.

Verification

Tested clean head 8080458752a782d8bd5677d2b78a0ce8eaaae07d after merging upstream 3a156358b4d4a26b1243148e52a61a7f2329b164. The conflict resolution retains both the raw subword loads in this PR and the multichannel typed loads from #1206.

cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^compute_store_aot_(mubuf_subword|guard_read|mtbuf_load|mtbuf_store)_' -V --output-junit (Join-Path $PWD out/mubuf-subword-80804587.xml)
python -B tools/form_coverage.py out/mubuf-subword-80804587.xml --records out/build/dev/form_coverage --gaps gfx1030
python -B tests/docs_links_check.py
python -B tests/form_coverage_check.py

8 passed, 0 failed, 0 skipped. Both compute_store_aot_mubuf_subword_{hardware,warp} runs contributed all four new gfx1030 MUBUF forms. Intel Arc B390 GPU (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818), Windows build 26300.9974; debug layer unavailable on both. Each translated DXIL program matched all 320 CPU-reference words after one and three groups, including gaps and the untouched tail. The first wrong-byte control failed at word 1 (000000a7 expected, 000000f1 actual); the signed-byte zero-extension control failed there with ffffffbb expected and 000000bb actual. Additional controls include a misaligned halfword, a record overrun, and use before either wait.

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

Both Python checks passed. The binary command passed in Ubuntu 22.04 with LLVM 15.0.7: all four wave32 programs assembled and disassembled, and the synthetic container CLI emitted the same HLSL as direct lowering. The same JUnit and records also confirmed that all four upstream typed-load forms passed on both backends. Neither the binary round trip nor the desktop DXIL dispatch is native GPU execution of the original RDNA2 programs.

Evidence and follow-up

The original synthetic fixtures are submitted under the repository's MIT License. Indexed gfx1030 raw subword reads documents the assumptions and reproduction. This compute-only profile does not implement the pixel bound-buffer contract in #319, and it does not depend on the typed MTBUF changes.

This change was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6574563583 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1225). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T04:22:55Z. --- ## Change Lower `buffer_load_ubyte`, `buffer_load_sbyte`, `buffer_load_ushort` and `buffer_load_sshort` in the gfx1030 compute store profile. Read the containing DWORD from the caller-bound raw `t0` and extract and extend the selected field. Accept only verified `idxen`, a zero scalar offset, naturally aligned immediates, DWORD-aligned source records, and descriptor/result waits. The caller must provide valid, unswizzled, stable, in-range records disjoint from `u0`. This does not emulate native bounds or add D16, cache/status modifiers, or pixel bindings. ## Verification Tested clean head `8080458752a782d8bd5677d2b78a0ce8eaaae07d` after merging upstream `3a156358b4d4a26b1243148e52a61a7f2329b164`. The conflict resolution retains both the raw subword loads in this PR and the multichannel typed loads from #1206. ```powershell cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^compute_store_aot_(mubuf_subword|guard_read|mtbuf_load|mtbuf_store)_' -V --output-junit (Join-Path $PWD out/mubuf-subword-80804587.xml) python -B tools/form_coverage.py out/mubuf-subword-80804587.xml --records out/build/dev/form_coverage --gaps gfx1030 python -B tests/docs_links_check.py python -B tests/form_coverage_check.py ``` 8 passed, 0 failed, 0 skipped. Both `compute_store_aot_mubuf_subword_{hardware,warp}` runs contributed all four new gfx1030 MUBUF forms. Intel Arc B390 GPU (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818), Windows build 26300.9974; debug layer unavailable on both. Each translated DXIL program matched all 320 CPU-reference words after one and three groups, including gaps and the untouched tail. The first wrong-byte control failed at word 1 (`000000a7` expected, `000000f1` actual); the signed-byte zero-extension control failed there with `ffffffbb` expected and `000000bb` actual. Additional controls include a misaligned halfword, a record overrun, and use before either wait. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` Both Python checks passed. The binary command passed in Ubuntu 22.04 with LLVM 15.0.7: all four wave32 programs assembled and disassembled, and the synthetic container CLI emitted the same HLSL as direct lowering. The same JUnit and records also confirmed that all four upstream typed-load forms passed on both backends. Neither the binary round trip nor the desktop DXIL dispatch is native GPU execution of the original RDNA2 programs. ## Evidence and follow-up The original synthetic fixtures are submitted under the repository's MIT License. [Indexed gfx1030 raw subword reads](https://github.com/stan495/Xbox2Windows/blob/codex/gfx1030-mubuf-subword-loads/docs/experiments.md#indexed-gfx1030-raw-subword-reads) documents the assumptions and reproduction. This compute-only profile does not implement the pixel bound-buffer contract in #319, and it does not depend on the typed MTBUF changes. This change was AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:47:04 +00:00
tedin7 commented 2026-11-24 06:47:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:27:34Z.

Review: COMMENTED


Reviewed commit bd2fd808 (CMakeLists.txt, README.md, docs/experiments.md, tools/compute_store_aot.py, tests/compute_store_check.py).

Findings

  • Subword alignment, extension, and bounds (tools/compute_store_aot.py):
    • width is 1 (ubyte/sbyte) or 2 (ushort/sshort), and offset % width enforces natural alignment (offset <= 4095).
    • source_stride is already constrained to 4 <= source_stride <= 0x3fff and source_stride % 4 == 0 at entry (lower), so offset + width <= source_stride with natural alignment guarantees (offset & ~3) + 4 <= source_stride; the enclosing DWORD load at tid.{axis} * source_stride + (offset & ~3) stays within the source element.
    • Field extraction ((inputData.Load(...) >> ((offset % 4) * 8)u) & mask) and two's-complement sign extension ((field ^ sign) - sign) for sbyte/sshort produce the expected 32-bit unsigned/sign-extended representations, stored into loading[dst] so use before s_waitcnt vmcnt(0) is rejected.
    • Unsupported modifiers (glc, tfe, _d16), non-zero scalar offset, offen/idxen offen, non-gfx1030 targets, UAV descriptor reads, and missing lgkmcnt(0)/vmcnt(0) waits are rejected and covered by mubuf_subword_controls.
  • Docs & wording: README.md and docs/experiments.md are title-neutral and accurately state the assumptions and scope.

Checks (Linux / LLVM 19)

  • /root/.local/share/x2w-rev-venv/bin/python -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passed.
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: passed (form coverage checks passed).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (self-test passed; 16 Markdown files, 275 links).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (self-test passed; 1018 files).
  • git diff HEAD~1 --check: passed.
  • Windows build and CTest (compute_store_aot_mubuf_subword_{warp,hardware}) were not run locally.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033649843 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1225#pullrequestreview-6033649843). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:27:34Z. **Review:** COMMENTED --- Reviewed commit `bd2fd808` (`CMakeLists.txt`, `README.md`, `docs/experiments.md`, `tools/compute_store_aot.py`, `tests/compute_store_check.py`). ### Findings - **Subword alignment, extension, and bounds (`tools/compute_store_aot.py`)**: - `width` is `1` (`ubyte`/`sbyte`) or `2` (`ushort`/`sshort`), and `offset % width` enforces natural alignment (`offset <= 4095`). - `source_stride` is already constrained to `4 <= source_stride <= 0x3fff` and `source_stride % 4 == 0` at entry (`lower`), so `offset + width <= source_stride` with natural alignment guarantees `(offset & ~3) + 4 <= source_stride`; the enclosing DWORD load at `tid.{axis} * source_stride + (offset & ~3)` stays within the source element. - Field extraction `((inputData.Load(...) >> ((offset % 4) * 8)u) & mask)` and two's-complement sign extension `((field ^ sign) - sign)` for `sbyte`/`sshort` produce the expected 32-bit unsigned/sign-extended representations, stored into `loading[dst]` so use before `s_waitcnt vmcnt(0)` is rejected. - Unsupported modifiers (`glc`, `tfe`, `_d16`), non-zero scalar offset, `offen`/`idxen offen`, non-`gfx1030` targets, UAV descriptor reads, and missing `lgkmcnt(0)`/`vmcnt(0)` waits are rejected and covered by `mubuf_subword_controls`. - **Docs & wording**: `README.md` and `docs/experiments.md` are title-neutral and accurately state the assumptions and scope. ### Checks (Linux / LLVM 19) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passed. - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: passed (`form coverage checks passed`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (self-test passed; 16 Markdown files, 275 links). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (self-test passed; 1018 files). - `git diff HEAD~1 --check`: passed. - Windows build and CTest (`compute_store_aot_mubuf_subword_{warp,hardware}`) were not run 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!1218
No description provided.