shader: lower gfx1030 image atomic arithmetic and bitwise operations #1478

Merged
stan495 merged 1 commit from upstream-pr/1485 into main 2026-11-24 13:07:12 +00:00
stan495 commented 2026-11-24 12:45:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T12:45:47Z.


Summary

Lower non-returning gfx1030 image_atomic_add, image_atomic_sub, image_atomic_and, image_atomic_or, and image_atomic_xor to typed D3D12 UAV operations. This profile accepts one unguarded operation with dmask:0x1, one 32-bit value, contiguous 32-bit XY coordinates, and a caller-declared in-bounds scalar R32_UINT 2D UAV at mip zero. It checks descriptor provenance and readiness and rejects unverified forms and flags. Subtraction uses modular negation of the add operand. Min/max, exchange, floating-point atomics and returned values are not part of this PR.

This is the arithmetic and bitwise slice of the fork prototype stan495/Xbox2Windows#11. The MSAA parent, #1444, is already in main.

Verification

Tested clean head a8815ee61e771fdad7bae1768e212b451ca19744.

. .\tools\dev.ps1
$root = (Get-Location).Path
cmake --preset dev -DINTAKE_PYTHON=<python.exe>
cmake --build --preset dev --target offscreen_check
$env:TEMP = "$root/out"
$env:TMP = $env:TEMP
ctest --preset dev --no-tests=error -j 1 -R '^(compute_store_aot_mimg_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' -V --output-junit "$root/out/atomic-rmw-a8815ee6.xml"
python -B tools/form_coverage.py out/atomic-rmw-a8815ee6.xml --records out/build/dev/form_coverage --json out/atomic-rmw-a8815ee6.coverage.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

CTest: 21 passed, 0 failed, 0 skipped. Each adapter ran all five operations plus a contended add, each at one and two group counts. The CPU reference checks all 336 words across three mips, including unwritten texels. The subtract-as-add negative control first differs at mip 0, word 32: 7fffffdf expected, 80000001 actual. Rejection controls include an unready descriptor, wrong format or mip, unsupported mask, bad registers, flags, and a second atomic. Both passing atomic fixture records contain exactly the five new gfx1030 mnemonics; the compute run covers 17/111 MIMG mnemonics in the RDNA2 reference.

Windows 11 build 26300.9974; Intel Arc B390 32.0.101.8509; Microsoft WARP 10.0.26100.9818. Debug layer unavailable on both backends.

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

LLVM 15 assembly, disassembly and synthetic-container CLI round trips passed. git diff --check origin/main...HEAD passed. git merge-tree --write-tree origin/main HEAD passed against 6df679bf979d21b1be32d6b5ac1513bebd82d6a8. This merge simulation is separate from the test run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582089917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1485). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T12:45:47Z. --- ## Summary Lower non-returning gfx1030 `image_atomic_add`, `image_atomic_sub`, `image_atomic_and`, `image_atomic_or`, and `image_atomic_xor` to typed D3D12 UAV operations. This profile accepts one unguarded operation with `dmask:0x1`, one 32-bit value, contiguous 32-bit XY coordinates, and a caller-declared in-bounds scalar `R32_UINT` 2D UAV at mip zero. It checks descriptor provenance and readiness and rejects unverified forms and flags. Subtraction uses modular negation of the add operand. Min/max, exchange, floating-point atomics and returned values are not part of this PR. This is the arithmetic and bitwise slice of the fork prototype stan495/Xbox2Windows#11. The MSAA parent, #1444, is already in main. ## Verification Tested clean head `a8815ee61e771fdad7bae1768e212b451ca19744`. ```powershell . .\tools\dev.ps1 $root = (Get-Location).Path cmake --preset dev -DINTAKE_PYTHON=<python.exe> cmake --build --preset dev --target offscreen_check $env:TEMP = "$root/out" $env:TMP = $env:TEMP ctest --preset dev --no-tests=error -j 1 -R '^(compute_store_aot_mimg_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' -V --output-junit "$root/out/atomic-rmw-a8815ee6.xml" python -B tools/form_coverage.py out/atomic-rmw-a8815ee6.xml --records out/build/dev/form_coverage --json out/atomic-rmw-a8815ee6.coverage.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` CTest: 21 passed, 0 failed, 0 skipped. Each adapter ran all five operations plus a contended add, each at one and two group counts. The CPU reference checks all 336 words across three mips, including unwritten texels. The subtract-as-add negative control first differs at mip 0, word 32: `7fffffdf` expected, `80000001` actual. Rejection controls include an unready descriptor, wrong format or mip, unsupported mask, bad registers, flags, and a second atomic. Both passing atomic fixture records contain exactly the five new gfx1030 mnemonics; the compute run covers 17/111 MIMG mnemonics in the RDNA2 reference. Windows 11 build `26300.9974`; Intel Arc B390 `32.0.101.8509`; Microsoft WARP `10.0.26100.9818`. Debug layer unavailable on both backends. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` LLVM 15 assembly, disassembly and synthetic-container CLI round trips passed. `git diff --check origin/main...HEAD` passed. `git merge-tree --write-tree origin/main HEAD` passed against `6df679bf979d21b1be32d6b5ac1513bebd82d6a8`. This merge simulation is separate from the test run.
upstream-sync closed this pull request 2026-11-24 14:02:52 +00:00
tedin7 commented 2026-11-24 14:02:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:04:46Z.

Review: COMMENTED


Peer review of PR #1485 (a8815ee61e771fdad7bae1768e212b451ca19744).

Code & Diff Audit

  • Lowering (tools/compute_store_aot.py):
    • Cleanly separates R32_UINT SRV (image_msaa) from R32_UINT UAV (image_atomic) by removing R32_UINT from IMAGE_FORMATS and gating image_atomic on gfx1030, image_uav_mip == 0, guard_span is None, and no prior stores.
    • Validates dmask:0x1, 8-bit VGPR indices (<= 255), contiguous 32-bit X/Y coordinates (y == x + 1), scalar R32_UINT RWTexture2D<uint>, and 8-dword descriptor provenance/readiness (pending.intersection check).
    • Lowers add, sub (via modular 0u - value), and, or, xor to Interlocked{Add,And,Or,Xor}(outputData[uint2(x, y)], value);.
  • Tests & Controls (tests/compute_check.cpp, tests/compute_store_check.py):
    • tests/compute_check.cpp adds texture_atomic_uint_flag (1u << 25), checks D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD | D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS, and enforces mip == 0.
    • tests/compute_store_check.py covers all 5 ops at 1 and 2 thread groups plus contended add, verifies all 336 texels across 3 mips against a CPU reference, includes a sub negative control (mip=0 word=32 expected=7fffffdf actual=80000001), and tests rejection diagnostics for bad masks, registers, descriptors, flags, dimensions, multiple atomics, and mismatched bindings.
  • Hygiene: tests/docs_links_check.py, tests/bidi_controls_check.py, and git diff --check origin/main...HEAD all pass on Linux. Title-neutral.

Win2025 Verification

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit a8815ee61e771fdad7bae1768e212b451ca19744:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 6): 22.21s (configure 1.76s)
    • Test (ctest --preset dev -R '^(compute_store_aot_mimg_atomic_integer_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' --parallel 4 --no-tests=error --output-on-failure): 7/7 passed (3.75s: compute_tables_warp 0.05s, compute_root_hardware 0.06s, compute_root_warp 0.05s, compute_tables_hardware 0.07s, offscreen_capability_table_self_test 0.03s, compute_store_aot_mimg_atomic_integer_warp 3.58s, compute_store_aot_mimg_atomic_integer_hardware 3.62s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 6): 23.28s (configure 1.82s)
    • Test (ctest --preset release -R '^(compute_store_aot_mimg_atomic_integer_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' --parallel 4 --no-tests=error --output-on-failure): 7/7 passed (3.95s: compute_tables_warp 0.05s, compute_root_hardware 0.05s, compute_tables_hardware 0.06s, offscreen_capability_table_self_test 0.03s, compute_root_warp 0.06s, compute_store_aot_mimg_atomic_integer_hardware 3.69s, compute_store_aot_mimg_atomic_integer_warp 3.80s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039687970 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1485#pullrequestreview-6039687970). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:04:46Z. **Review:** COMMENTED --- Peer review of PR #1485 (`a8815ee61e771fdad7bae1768e212b451ca19744`). ### Code & Diff Audit - **Lowering (`tools/compute_store_aot.py`)**: - Cleanly separates `R32_UINT` SRV (`image_msaa`) from `R32_UINT` UAV (`image_atomic`) by removing `R32_UINT` from `IMAGE_FORMATS` and gating `image_atomic` on `gfx1030`, `image_uav_mip == 0`, `guard_span is None`, and no prior `stores`. - Validates `dmask:0x1`, 8-bit VGPR indices (`<= 255`), contiguous 32-bit X/Y coordinates (`y == x + 1`), scalar `R32_UINT` `RWTexture2D<uint>`, and 8-dword descriptor provenance/readiness (`pending.intersection` check). - Lowers `add`, `sub` (via modular `0u - value`), `and`, `or`, `xor` to `Interlocked{Add,And,Or,Xor}(outputData[uint2(x, y)], value);`. - **Tests & Controls (`tests/compute_check.cpp`, `tests/compute_store_check.py`)**: - `tests/compute_check.cpp` adds `texture_atomic_uint_flag` (`1u << 25`), checks `D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD | D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS`, and enforces `mip == 0`. - `tests/compute_store_check.py` covers all 5 ops at 1 and 2 thread groups plus contended `add`, verifies all 336 texels across 3 mips against a CPU reference, includes a `sub` negative control (`mip=0 word=32 expected=7fffffdf actual=80000001`), and tests rejection diagnostics for bad masks, registers, descriptors, flags, dimensions, multiple atomics, and mismatched bindings. - **Hygiene**: `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, and `git diff --check origin/main...HEAD` all pass on Linux. Title-neutral. ### Win2025 Verification Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `a8815ee61e771fdad7bae1768e212b451ca19744`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 6`): `22.21s` (configure `1.76s`) - Test (`ctest --preset dev -R '^(compute_store_aot_mimg_atomic_integer_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' --parallel 4 --no-tests=error --output-on-failure`): **7/7 passed** (`3.75s`: `compute_tables_warp` `0.05s`, `compute_root_hardware` `0.06s`, `compute_root_warp` `0.05s`, `compute_tables_hardware` `0.07s`, `offscreen_capability_table_self_test` `0.03s`, `compute_store_aot_mimg_atomic_integer_warp` `3.58s`, `compute_store_aot_mimg_atomic_integer_hardware` `3.62s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 6`): `23.28s` (configure `1.82s`) - Test (`ctest --preset release -R '^(compute_store_aot_mimg_atomic_integer_|compute_root_|compute_tables_|offscreen_capability_table_self_test$)' --parallel 4 --no-tests=error --output-on-failure`): **7/7 passed** (`3.95s`: `compute_tables_warp` `0.05s`, `compute_root_hardware` `0.05s`, `compute_tables_hardware` `0.06s`, `offscreen_capability_table_self_test` `0.03s`, `compute_root_warp` `0.06s`, `compute_store_aot_mimg_atomic_integer_hardware` `3.69s`, `compute_store_aot_mimg_atomic_integer_warp` `3.80s`)
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!1478
No description provided.