shader: lower gfx1030 fixed-address atomic exchanges #1384

Manually merged
github merged 1 commit from gh-pr/1384/head into gh-pr/1384/base 2026-11-26 23:02:56 +00:00
Owner

@⁠stan495 on GitHub · 2026-11-24 10:03 UTC · original
stan495:codex/gfx1030-mubuf-atomic-exchanges-upstream → main · +131 −9 · 5 files · 1 commits · merged 2026-11-24 10:33 UTC

Behavior

Lower buffer_atomic_swap, buffer_atomic_cmpswap and their _x2 variants for fixed, aligned addresses in a caller-supplied in-range raw UAV. The compare-swap lowering maps the ISA replacement and comparison operands to the HLSL comparison and replacement arguments. The profile accepts one atomic UAV instruction, with no return flag or extra cache flags. The _x2 forms use SM 6.6 and require Int64ShaderOps. Builds on #1372.

Verification

Tested clean head 85523e79447d6ae665f5372557fe1d855dcb2181 from 7261ab67537b1c4547a640ca805f5b613a1621ee.

cmake --preset dev -DINTAKE_PYTHON=<absolute-path-to-Python>
cmake --build --preset dev --target offscreen_check
$env:CTEST_PARALLEL_LEVEL = '2'
ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit out/exchanges-junit.xml
python -B tools/form_coverage.py out/exchanges-junit.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/exchanges-coverage.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py

CTest passed 56 tests with zero failures and zero capability skips. Both widths and both adapters recorded the four forms from passing execution fixtures. The run covered 59 of 73 gfx1030 MUBUF forms within the tested profiles. The documentation and coverage-tool checks passed.

The execution fixtures run translated DXIL. One and two groups compare all 320 words with a CPU reference, including matches, misses and untouched words. The shifted swap first differs at word 0, expected c5c5c5c5, actual 89abcdef. Reversing compare-swap operands first differs at word 2, expected 89abcdef, actual c5c5c5c5. Windows build 26300.9974 used Microsoft Basic Render Driver 10.0.26100.9818 for WARP and Intel Arc B390 driver 32.0.101.8509 for hardware. The debug layer was unavailable on both.

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

The assembly, disassembly, container CLI and rejection checks passed on Ubuntu 22.04.5 with LLVM 15.0.7. git diff --check and git merge-tree --write-tree 7261ab67537b1c4547a640ca805f5b613a1621ee HEAD passed. Merge simulation with #1379 and ordered replay of the queued atomic batches completed without conflicts.

**@⁠stan495** on GitHub · 2026-11-24 10:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1384) `stan495:codex/gfx1030-mubuf-atomic-exchanges-upstream` → `main` · +131 −9 · 5 files · 1 commits · merged 2026-11-24 10:33 UTC ## Behavior Lower `buffer_atomic_swap`, `buffer_atomic_cmpswap` and their `_x2` variants for fixed, aligned addresses in a caller-supplied in-range raw UAV. The compare-swap lowering maps the ISA replacement and comparison operands to the HLSL comparison and replacement arguments. The profile accepts one atomic UAV instruction, with no return flag or extra cache flags. The `_x2` forms use SM 6.6 and require `Int64ShaderOps`. Builds on #1372. ## Verification Tested clean head `85523e79447d6ae665f5372557fe1d855dcb2181` from `7261ab67537b1c4547a640ca805f5b613a1621ee`. ```powershell cmake --preset dev -DINTAKE_PYTHON=<absolute-path-to-Python> cmake --build --preset dev --target offscreen_check $env:CTEST_PARALLEL_LEVEL = '2' ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit out/exchanges-junit.xml python -B tools/form_coverage.py out/exchanges-junit.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/exchanges-coverage.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py ``` CTest passed 56 tests with zero failures and zero capability skips. Both widths and both adapters recorded the four forms from passing execution fixtures. The run covered 59 of 73 gfx1030 MUBUF forms within the tested profiles. The documentation and coverage-tool checks passed. The execution fixtures run translated DXIL. One and two groups compare all 320 words with a CPU reference, including matches, misses and untouched words. The shifted swap first differs at word 0, expected `c5c5c5c5`, actual `89abcdef`. Reversing compare-swap operands first differs at word 2, expected `89abcdef`, actual `c5c5c5c5`. Windows build 26300.9974 used Microsoft Basic Render Driver 10.0.26100.9818 for WARP and Intel Arc B390 driver 32.0.101.8509 for hardware. The debug layer was unavailable on both. ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` The assembly, disassembly, container CLI and rejection checks passed on Ubuntu 22.04.5 with LLVM 15.0.7. `git diff --check` and `git merge-tree --write-tree 7261ab67537b1c4547a640ca805f5b613a1621ee HEAD` passed. Merge simulation with #1379 and ordered replay of the queued atomic batches completed without conflicts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:02:54 +00:00
github manually merged commit 85523e7944 into gh-pr/1384/base 2026-11-26 23:02:56 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 10:31 UTC · original · reviewed

Reviewed 85523e79 (shader: lower gfx1030 fixed-address atomic exchanges).

  • Diff & code audit:
    • git diff --check clean; 100% title-neutral.
    • tools/compute_store_aot.py: extends MUBUF_ATOMIC_METHODS with swap -> Exchange and cmpswap -> CompareExchange (plus 64 suffix for _x2), handles 1/2/4-VGPR vdata ranges (width = 2 if wide else 1, count = 2 * width if op == "cmpswap" else width), reorders cmpswap operands from ISA (replacement, compare) to HLSL (compare, replacement), discards the old value into ignoredAtomic (matching glc clear), and rejects glc and other unsupported forms.
    • tests/compute_store_check.py: adds mubuf_exchange_cases / mubuf_exchange_controls / mubuf_exchange_draw covering 32-bit and 64-bit swap and cmpswap, matching and non-matching compare cases, address/operand-order negative controls, and glc/missing-word/bad-range rejections.
  • Linux checks:
    • tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passed (assembles and disassembles buffer_atomic_swap, buffer_atomic_cmpswap, buffer_atomic_swap_x2, buffer_atomic_cmpswap_x2 and runs controls).
    • tests/pso_readiness_check.py, tests/docs_links_check.py (16 Markdown files, 311 links), tests/bidi_controls_check.py (1161 tracked files): all passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at 85523e79447d6ae665f5372557fe1d855dcb2181:
    • Debug (--preset dev): 4/4 passed (compute_store_aot_mubuf_exchange_hardware 3.27s, compute_store_aot_mubuf_exchange-x2_hardware 3.30s, compute_store_aot_mubuf_exchange-x2_warp 3.36s, compute_store_aot_mubuf_exchange_warp 3.40s).
    • Release /O2 (--preset release): 4/4 passed (compute_store_aot_mubuf_exchange-x2_hardware 3.33s, compute_store_aot_mubuf_exchange_hardware 3.41s, compute_store_aot_mubuf_exchange-x2_warp 3.45s, compute_store_aot_mubuf_exchange_warp 3.47s).
**@⁠tedin7** on GitHub · 2026-11-24 10:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1384#pullrequestreview-6037595714) · **reviewed** Reviewed `85523e79` (`shader: lower gfx1030 fixed-address atomic exchanges`). - **Diff & code audit**: - `git diff --check` clean; 100% title-neutral. - `tools/compute_store_aot.py`: extends `MUBUF_ATOMIC_METHODS` with `swap -> Exchange` and `cmpswap -> CompareExchange` (plus `64` suffix for `_x2`), handles 1/2/4-VGPR `vdata` ranges (`width = 2 if wide else 1`, `count = 2 * width if op == "cmpswap" else width`), reorders `cmpswap` operands from ISA `(replacement, compare)` to HLSL `(compare, replacement)`, discards the old value into `ignoredAtomic` (matching `glc` clear), and rejects `glc` and other unsupported forms. - `tests/compute_store_check.py`: adds `mubuf_exchange_cases` / `mubuf_exchange_controls` / `mubuf_exchange_draw` covering 32-bit and 64-bit `swap` and `cmpswap`, matching and non-matching compare cases, address/operand-order negative controls, and `glc`/missing-word/bad-range rejections. - **Linux checks**: - `tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passed (assembles and disassembles `buffer_atomic_swap`, `buffer_atomic_cmpswap`, `buffer_atomic_swap_x2`, `buffer_atomic_cmpswap_x2` and runs controls). - `tests/pso_readiness_check.py`, `tests/docs_links_check.py` (16 Markdown files, 311 links), `tests/bidi_controls_check.py` (1161 tracked files): all passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** at `85523e79447d6ae665f5372557fe1d855dcb2181`: - **Debug (`--preset dev`)**: 4/4 passed (`compute_store_aot_mubuf_exchange_hardware` 3.27s, `compute_store_aot_mubuf_exchange-x2_hardware` 3.30s, `compute_store_aot_mubuf_exchange-x2_warp` 3.36s, `compute_store_aot_mubuf_exchange_warp` 3.40s). - **Release `/O2` (`--preset release`)**: 4/4 passed (`compute_store_aot_mubuf_exchange-x2_hardware` 3.33s, `compute_store_aot_mubuf_exchange_hardware` 3.41s, `compute_store_aot_mubuf_exchange-x2_warp` 3.45s, `compute_store_aot_mubuf_exchange_warp` 3.47s).
This discussion has been locked. Commenting is limited to contributors.
No description provided.