shader: pack sparse gfx1030 image load masks #1303

Merged
stan495 merged 1 commit from upstream-pr/1310 into main 2026-11-24 07:46:05 +00:00
stan495 commented 2026-11-24 07:30:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T07:30:06Z.


Scope

Extend the gfx1030 compute translator from the four prefix DMASKs to all 15 nonzero XYZW masks for typed 2D image_load and image_load_mip. Bits select channels in XYZW order, and the selected values are packed into consecutive destination VGPRs. For dmask:0xa the two destination VGPRs receive Y and W. The existing 32-bit and a16 address forms, R32G32B32A32_UINT contract, waits and binding rules apply. Zero, out-of-range bits and a destination tuple whose width disagrees with the mask are rejected. This follows #1265.

Validation

Tested 2d60414d4de6c0ec3455278d26ab2a54714e6009 on Windows 11 build 26300.9974. The adapters were Intel Arc B390 with driver 32.0.101.8509 and WARP (Microsoft Basic Render Driver) with driver 10.0.26100.9818. Both reported debug_layer=unavailable.

.\tools\dev.ps1
cmake --preset dev -DINTAKE_PYTHON=<dev-python>
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^(compute_store_aot_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' -V --output-junit <absolute-path-to-dmask-junit.xml>
python -B tools/form_coverage.py <absolute-path-to-dmask-junit.xml> --records out/build/dev/form_coverage --json out/dmask-coverage.json --gaps gfx1030

CTest reported 45 passed, 0 failed and 0 skipped. Each backend executed 60 image cases, covering both opcodes, both address families and all 15 masks. Each case compared all 320 UAV words, including untouched words, with a CPU reference. Replacing Y and W with X and Y for dmask:0xa first differed at word=0 expected=20000001 actual=10000000 for both opcodes and both address families on both backends. The JUnit-backed coverage records retain two of 111 gfx1030 MIMG mnemonics. The additional masks are variants of those two mnemonics.

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

LLVM 15 assembled and decoded all 60 image cases. The synthetic container CLI emitted the same HLSL as direct text lowering. The coverage and documentation checks passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576875502 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1310). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T07:30:06Z. --- ## Scope Extend the gfx1030 compute translator from the four prefix DMASKs to all 15 nonzero XYZW masks for typed 2D `image_load` and `image_load_mip`. Bits select channels in XYZW order, and the selected values are packed into consecutive destination VGPRs. For `dmask:0xa` the two destination VGPRs receive Y and W. The existing 32-bit and `a16` address forms, `R32G32B32A32_UINT` contract, waits and binding rules apply. Zero, out-of-range bits and a destination tuple whose width disagrees with the mask are rejected. This follows #1265. ## Validation Tested `2d60414d4de6c0ec3455278d26ab2a54714e6009` on Windows 11 build 26300.9974. The adapters were Intel Arc B390 with driver 32.0.101.8509 and WARP (Microsoft Basic Render Driver) with driver 10.0.26100.9818. Both reported `debug_layer=unavailable`. ```powershell .\tools\dev.ps1 cmake --preset dev -DINTAKE_PYTHON=<dev-python> cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^(compute_store_aot_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' -V --output-junit <absolute-path-to-dmask-junit.xml> python -B tools/form_coverage.py <absolute-path-to-dmask-junit.xml> --records out/build/dev/form_coverage --json out/dmask-coverage.json --gaps gfx1030 ``` CTest reported 45 passed, 0 failed and 0 skipped. Each backend executed 60 image cases, covering both opcodes, both address families and all 15 masks. Each case compared all 320 UAV words, including untouched words, with a CPU reference. Replacing Y and W with X and Y for `dmask:0xa` first differed at `word=0 expected=20000001 actual=10000000` for both opcodes and both address families on both backends. The JUnit-backed coverage records retain two of 111 gfx1030 MIMG mnemonics. The additional masks are variants of those two mnemonics. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` LLVM 15 assembled and decoded all 60 image cases. The synthetic container CLI emitted the same HLSL as direct text lowering. The coverage and documentation checks passed.
upstream-sync closed this pull request 2026-11-24 08:01:33 +00:00
tedin7 commented 2026-11-24 08:01:33 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed at commit 2d60414d4de6c0ec3455278d26ab2a54714e6009.

Code Review

  • tools/compute_store_aot.py: replaces the contiguous dmask != (1 << count) - 1 restriction with 0 < dmask < (1 << IMAGE_FORMATS[image_format][1]) and packs enabled xyzw channels in ascending order (channels = [component for index, component in enumerate("xyzw") if dmask & (1 << index)]) into consecutive destination VGPRs (first + index). Zero masks and out-of-range bits (0x10) remain rejected, and last != first + count - 1 still enforces tuple width matching.
  • tests/compute_store_check.py: MIMG_CHANNELS independently enumerates all 15 nonzero masks (0x1..0xf), covering image_load and image_load_mip with both 2-dword and a16 addresses, plus negative controls (dmask:0x0, dmask:0x10, and mutating dmask:0xa from yw to xy).
  • README.md & docs/experiments.md: updated cleanly and accurately.

Verification

  • Linux (2d60414d):
    • git diff --check origin/main...HEAD: pass
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: pass (16 Markdown files, 289 links)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (1086 files)
    • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/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: pass
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP, --target offscreen_check):
    • Debug (--preset dev): ctest --preset dev -R '^compute_store_aot_mimg_.*_warp$' --parallel 4 --no-tests=error --output-on-failure — 2/2 passed (compute_store_aot_mimg_load_warp, compute_store_aot_mimg_mip_warp)
    • Release /O2 (--preset release): ctest --preset release -R '^compute_store_aot_mimg_.*_warp$' --parallel 4 --no-tests=error --output-on-failure — 2/2 passed (compute_store_aot_mimg_load_warp, compute_store_aot_mimg_mip_warp)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035405299 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1310#pullrequestreview-6035405299). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T07:42:32Z. **Review:** COMMENTED --- Reviewed at commit `2d60414d4de6c0ec3455278d26ab2a54714e6009`. ### Code Review - `tools/compute_store_aot.py`: replaces the contiguous `dmask != (1 << count) - 1` restriction with `0 < dmask < (1 << IMAGE_FORMATS[image_format][1])` and packs enabled `xyzw` channels in ascending order (`channels = [component for index, component in enumerate("xyzw") if dmask & (1 << index)]`) into consecutive destination VGPRs (`first + index`). Zero masks and out-of-range bits (`0x10`) remain rejected, and `last != first + count - 1` still enforces tuple width matching. - `tests/compute_store_check.py`: `MIMG_CHANNELS` independently enumerates all 15 nonzero masks (`0x1..0xf`), covering `image_load` and `image_load_mip` with both 2-dword and `a16` addresses, plus negative controls (`dmask:0x0`, `dmask:0x10`, and mutating `dmask:0xa` from `yw` to `xy`). - `README.md` & `docs/experiments.md`: updated cleanly and accurately. ### Verification - **Linux** (`2d60414d`): - `git diff --check origin/main...HEAD`: pass - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: pass (16 Markdown files, 289 links) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: pass (1086 files) - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/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`: pass - **Windows Server 2025** (Build 26100, MSVC 14.44.35207 + D3D12 WARP, `--target offscreen_check`): - **Debug (`--preset dev`)**: `ctest --preset dev -R '^compute_store_aot_mimg_.*_warp$' --parallel 4 --no-tests=error --output-on-failure` — **2/2 passed** (`compute_store_aot_mimg_load_warp`, `compute_store_aot_mimg_mip_warp`) - **Release `/O2` (`--preset release`)**: `ctest --preset release -R '^compute_store_aot_mimg_.*_warp$' --parallel 4 --no-tests=error --output-on-failure` — **2/2 passed** (`compute_store_aot_mimg_load_warp`, `compute_store_aot_mimg_mip_warp`)
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!1303
No description provided.