shader: preserve the other half in gfx1030 raw D16 loads #1275

Merged
stan495 merged 1 commit from upstream-pr/1282 into main 2026-11-24 06:56:12 +00:00
stan495 commented 2026-11-24 06:41:48 +00:00 (Migrated from github.com)

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


Change

Lower the low and high halves of buffer_load_ubyte_d16, buffer_load_sbyte_d16, and buffer_load_short_d16 for gfx1030. The load reads a byte or short from the raw t0, extends a byte to 16 bits, and replaces only the selected half of a known VGPR word. Both the prior word and the new result must be ready before use. The accepted address remains a verified idxen index, zero scalar offset, and a naturally aligned immediate within an in-range, unswizzled source record. This does not add formatted MUBUF, native descriptor bounds, or status/cache modifiers.

Follow-up to merged #1254. The patch was replayed on upstream main at 79f0f84a92edee9f2ab5f14d44a73e38ea75610f and supersedes stan495/Xbox2Windows#5.

Verification

Tested clean head f61e4f3459eb1af916304c84c442a7123b00cf57:

$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/d16-f61e4f34.xml)
python -B tools/form_coverage.py out/d16-f61e4f34.xml --records out/build/dev/form_coverage --gaps gfx1030
python -B tests/docs_links_check.py
python -B tests/form_coverage_check.py

36 passed, 0 failed, 0 skipped; both Python checks passed. The two compute_store_aot_mubuf_d16_{hardware,warp} CTests each contributed all six new forms. Intel Arc B390 (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818), Windows build 26300.9974; debug layer unavailable on both. Both backends compared all 320 words for one and three groups, including untouched gaps and tail. Clearing the preserved half failed at word 1 (8b0200bb expected, 000000bb actual for the low unsigned byte). Zero-extending the signed high byte failed there (ffa2a7f1 expected, 00a2a7f1 actual). Rejection controls include unknown or partially known prior words, missing waits, read overrun and misaligned short offsets.

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

Passed in Ubuntu 22.04.5 with LLVM 15.0.7. It assembles and decodes the six original wave32 fixtures and checks the synthetic container CLI against direct lowering. The GPU tests execute translated desktop DXIL.

Evidence and follow-up

The original synthetic fixtures use the repository's MIT License. The README and docs/experiments.md document the tests and the input contract. Native expectations follow the AMD RDNA 2 Shader ISA, sections 8.1.6 and 12.14, MUBUF opcodes 32 to 37.

This change was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576217369 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1282). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T06:41:48Z. --- ## Change Lower the low and high halves of `buffer_load_ubyte_d16`, `buffer_load_sbyte_d16`, and `buffer_load_short_d16` for gfx1030. The load reads a byte or short from the raw `t0`, extends a byte to 16 bits, and replaces only the selected half of a known VGPR word. Both the prior word and the new result must be ready before use. The accepted address remains a verified `idxen` index, zero scalar offset, and a naturally aligned immediate within an in-range, unswizzled source record. This does not add formatted MUBUF, native descriptor bounds, or status/cache modifiers. Follow-up to merged #1254. The patch was replayed on upstream main at `79f0f84a92edee9f2ab5f14d44a73e38ea75610f` and supersedes stan495/Xbox2Windows#5. ## Verification Tested clean head `f61e4f3459eb1af916304c84c442a7123b00cf57`: ```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/d16-f61e4f34.xml) python -B tools/form_coverage.py out/d16-f61e4f34.xml --records out/build/dev/form_coverage --gaps gfx1030 python -B tests/docs_links_check.py python -B tests/form_coverage_check.py ``` 36 passed, 0 failed, 0 skipped; both Python checks passed. The two `compute_store_aot_mubuf_d16_{hardware,warp}` CTests each contributed all six new forms. Intel Arc B390 (32.0.101.8509) and Microsoft Basic Render Driver/WARP (10.0.26100.9818), Windows build 26300.9974; debug layer unavailable on both. Both backends compared all 320 words for one and three groups, including untouched gaps and tail. Clearing the preserved half failed at word 1 (`8b0200bb` expected, `000000bb` actual for the low unsigned byte). Zero-extending the signed high byte failed there (`ffa2a7f1` expected, `00a2a7f1` actual). Rejection controls include unknown or partially known prior words, missing waits, read overrun and misaligned short offsets. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` Passed in Ubuntu 22.04.5 with LLVM 15.0.7. It assembles and decodes the six original wave32 fixtures and checks the synthetic container CLI against direct lowering. The GPU tests execute translated desktop DXIL. ## Evidence and follow-up The original synthetic fixtures use the repository's MIT License. The README and `docs/experiments.md` document the tests and the input contract. Native expectations follow the [AMD RDNA 2 Shader ISA](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf), sections 8.1.6 and 12.14, MUBUF opcodes 32 to 37. This change was AI-assisted.
upstream-sync closed this pull request 2026-11-24 07:00:41 +00:00
tedin7 commented 2026-11-24 07:00:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:56:44Z.

Review: COMMENTED


Reviewed at f61e4f3459eb1af916304c84c442a7123b00cf57.

Verification

Linux (worktree from origin/main):

  • git diff --check origin/main...HEAD — clean
  • python -B tests/docs_links_check.py — passed (16 Markdown files, 287 links)
  • python -B tests/bidi_controls_check.py — passed (1072 tracked files)
  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so — passed (exit 0 across all fixtures including mubuf_d16_controls and all six buffer_load_*_d16* binary roundtrips)

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 6): 2.77s (configure 1.44s)
    • Test (ctest --preset dev -R 'compute_store_aot_mubuf_d16_warp' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (3.26s: compute_store_aot_mubuf_d16_warp 3.20s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 6): 0.34s (configure 1.45s)
    • Test (ctest --preset release -R 'compute_store_aot_mubuf_d16_warp' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (3.20s: compute_store_aot_mubuf_d16_warp 3.13s)

Findings

  • tools/compute_store_aot.py lowers all six gfx1030 raw D16 MUBUF loads (buffer_load_{ubyte,sbyte,short}_d16{,_hi}) under the existing idxen/zero-scalar-offset/aligned-offset contract, requiring a known full destination word (is_word(vector.get(dst))) beforehand, sign-extending sbyte to 16 bits via (... & 0xffffu) before shifting, preserving the untouched half (0xffffu / 0xffff0000u), and bounding expression growth with ALU_EXPRESSION_LIMIT.
  • tests/compute_store_check.py covers all six variants in both binary (LLVM-19) and draw-mubuf-d16 (WARP) modes, including negative controls for preserved-half clearing, signed-byte sign-extension, unknown destination input (e.g., after tbuffer_load_format_d16_x), missing waits, misaligned short offset, and record overrun. No issues found.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034942628 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1282#pullrequestreview-6034942628). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:56:44Z. **Review:** COMMENTED --- Reviewed at `f61e4f3459eb1af916304c84c442a7123b00cf57`. ### Verification **Linux** (worktree from `origin/main`): - `git diff --check origin/main...HEAD` — clean - `python -B tests/docs_links_check.py` — passed (16 Markdown files, 287 links) - `python -B tests/bidi_controls_check.py` — passed (1072 tracked files) - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so python -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so` — passed (exit 0 across all fixtures including `mubuf_d16_controls` and all six `buffer_load_*_d16*` binary roundtrips) **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** at `f61e4f3459eb1af916304c84c442a7123b00cf57`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 6`): `2.77s` (configure `1.44s`) - Test (`ctest --preset dev -R 'compute_store_aot_mubuf_d16_warp' --parallel 4 --no-tests=error --output-on-failure`): **1/1 passed** (`3.26s`: `compute_store_aot_mubuf_d16_warp` `3.20s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 6`): `0.34s` (configure `1.45s`) - Test (`ctest --preset release -R 'compute_store_aot_mubuf_d16_warp' --parallel 4 --no-tests=error --output-on-failure`): **1/1 passed** (`3.20s`: `compute_store_aot_mubuf_d16_warp` `3.13s`) ### Findings - `tools/compute_store_aot.py` lowers all six `gfx1030` raw D16 MUBUF loads (`buffer_load_{ubyte,sbyte,short}_d16{,_hi}`) under the existing `idxen`/zero-scalar-offset/aligned-offset contract, requiring a known full destination word (`is_word(vector.get(dst))`) beforehand, sign-extending `sbyte` to 16 bits via `(... & 0xffffu)` before shifting, preserving the untouched half (`0xffffu` / `0xffff0000u`), and bounding expression growth with `ALU_EXPRESSION_LIMIT`. - `tests/compute_store_check.py` covers all six variants in both `binary` (LLVM-19) and `draw-mubuf-d16` (WARP) modes, including negative controls for preserved-half clearing, signed-byte sign-extension, unknown destination input (e.g., after `tbuffer_load_format_d16_x`), missing waits, misaligned short offset, and record overrun. No issues found.
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!1275
No description provided.