compute: accept dword buffer atomics through a byte-window raw UAV #3171

Manually merged
github merged 3 commits from github-bot/gh-3169 into gh-pr/3169/base 2026-11-27 21:30:36 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-27 19:58 UTC · original
Leyukaka:atomic-byte-window → main · +71 −21 · 3 files · 3 commits · merged 2026-11-27 21:25 UTC

Fixes #3170. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, Emit::binding): the byte-window case of a raw UAV now also covers non-indexed buffer_atomic_* (idxen clear), not only buffer_store_raw.

  • The descriptor is a raw UAV loaded from a table, then rewritten into a byte window by the six-op stride, count and OOB sequence that byte_descriptor_field tracks.
  • Before, an atomic through it was refused with "non-contiguous resource descriptor".
  • The atomic lowering in gfx1013_direct_compute.inl already issues dword atomics on the same raw UAV as buffer_store_raw, so the binding and the host window are the same.
  • Indexed atomics are bound as indexed_atomic_uav, so they never satisfy the raw-UAV test of this condition and stay refused. The idxen test inside the condition is a second guard.
  • 64-bit atomics stay refused earlier: buffer_atomic() has no _x2 entry and refuses them before binding.

Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on main 6057071b plus this commit.

  • native_bytewin_store_hardware now also reads back, through the rewritten descriptor and against a CPU reference with untouched sentinels:
    • buffer_atomic_add with and without GLC;
    • buffer_atomic_umin;
    • buffer_atomic_cmpswap.
  • native_bytewin_store_controls keeps an indexed atomic and a 64-bit atomic through the byte window refused.
  • The fixture's requests now set .sa dword 4 bit 20 (wave32, #2999). The store cases are unchanged.
  • native_direct_container, startup_compute_buffer_atomics, startup_compute_buffer_atomics_hardware, startup_compute_buffer_atomics_warp, compute_store_aot_gfx1013_buffer_atomics_hardware and compute_store_aot_gfx1013_buffer_atomics_warp pass.
  • Mutation checks, run by hand:
    • dropping the atomic case from the condition fails native_bytewin_store_hardware;
    • dropping the idxen test is not detected, because indexed atomics never reach this condition.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 6057071b.

Requests Compiled before Compiled after
Capture, 2,689 403 411
One start-up run, 2,718 416 424
  • 11 requests stopped first at this refusal: 7 buffer_atomic_add, 3 buffer_atomic_umin and 1 buffer_atomic_cmpswap.
  • 8 of them now compile: 6 buffer_atomic_add and 2 buffer_atomic_umin. Two of those are dispatched in the start-up run, 5 times in all. The one buffer_atomic_cmpswap request is among the 3 still refused, so compare-and-swap is covered by the synthetic fixture only.
  • The other 3 stop at "unbound numeric SGPR", "unsupported wave64 scalar operation" and "direct image opcode or descriptor modifiers".
  • No request that compiled before stops compiling.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-27 19:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3169) `Leyukaka:atomic-byte-window` → `main` · +71 −21 · 3 files · 3 commits · merged 2026-11-27 21:25 UTC Fixes #3170. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `Emit::binding`): the byte-window case of a raw UAV now also covers non-indexed `buffer_atomic_*` (idxen clear), not only `buffer_store_raw`. - The descriptor is a raw UAV loaded from a table, then rewritten into a byte window by the six-op stride, count and OOB sequence that `byte_descriptor_field` tracks. - Before, an atomic through it was refused with "non-contiguous resource descriptor". - The atomic lowering in `gfx1013_direct_compute.inl` already issues dword atomics on the same raw UAV as `buffer_store_raw`, so the binding and the host window are the same. - Indexed atomics are bound as `indexed_atomic_uav`, so they never satisfy the raw-UAV test of this condition and stay refused. The idxen test inside the condition is a second guard. - 64-bit atomics stay refused earlier: `buffer_atomic()` has no `_x2` entry and refuses them before binding. **Tests.** The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on `main` `6057071b` plus this commit. - `native_bytewin_store_hardware` now also reads back, through the rewritten descriptor and against a CPU reference with untouched sentinels: - `buffer_atomic_add` with and without GLC; - `buffer_atomic_umin`; - `buffer_atomic_cmpswap`. - `native_bytewin_store_controls` keeps an indexed atomic and a 64-bit atomic through the byte window refused. - The fixture's requests now set `.sa` dword 4 bit 20 (wave32, #2999). The store cases are unchanged. - `native_direct_container`, `startup_compute_buffer_atomics`, `startup_compute_buffer_atomics_hardware`, `startup_compute_buffer_atomics_warp`, `compute_store_aot_gfx1013_buffer_atomics_hardware` and `compute_store_aot_gfx1013_buffer_atomics_warp` pass. - Mutation checks, run by hand: - dropping the atomic case from the condition fails `native_bytewin_store_hardware`; - dropping the idxen test is not detected, because indexed atomics never reach this condition. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `6057071b`. | Requests | Compiled before | Compiled after | |---|---|---| | Capture, 2,689 | 403 | 411 | | One start-up run, 2,718 | 416 | 424 | - 11 requests stopped first at this refusal: 7 `buffer_atomic_add`, 3 `buffer_atomic_umin` and 1 `buffer_atomic_cmpswap`. - 8 of them now compile: 6 `buffer_atomic_add` and 2 `buffer_atomic_umin`. Two of those are dispatched in the start-up run, 5 times in all. The one `buffer_atomic_cmpswap` request is among the 3 still refused, so compare-and-swap is covered by the synthetic fixture only. - The other 3 stop at "unbound numeric SGPR", "unsupported wave64 scalar operation" and "direct image opcode or descriptor modifiers". - No request that compiled before stops compiling. AI-assisted.
A raw UAV descriptor rewritten into a byte window (the six-op stride,
count and OOB rewrite tracked by byte_descriptor_field) was accepted for
buffer_store_raw only; a non-indexed buffer atomic through the same
descriptor was refused as "non-contiguous resource descriptor". The
atomic lowering already uses the same raw UAV, so the byte-window check
now covers non-indexed buffer_atomic_* too. Indexed atomics take the
indexed_atomic_uav path and stay refused; the idxen test in the
condition is a second guard.

native_bytewin_store_hardware reads back add with and without GLC,
unsigned min and compare-and-swap through the rewritten descriptor;
the controls keep an indexed atomic and a 64-bit atomic refused.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:03:00 +00:00
github-bot changed target branch from main to gh-pr/3169/base 2026-11-27 21:30:34 +00:00
github manually merged commit 305500f9b8 into gh-pr/3169/base 2026-11-27 21:30:36 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 21:25 UTC · original · reviewed

Review of 305500f9b8 (updated with main). Comment only.

The byte-window raw UAV path in gfx1013_compute_native.cpp now accepts buffer_atomic_* next to buffer_store_raw, but only for 4-byte accesses and only when GLC (bit 13 of the first dword) is clear, so returning atomics keep their refusal. The change reuses the existing byte-window descriptor rewrite, so the atomic lands on the same rewritten view a store would use. The atomic readback in native_bytewin_store_hardware needs a wave32 adapter and skips on our WARP host, so it rests on the RTX 5080 run in the description, which also shows that dropping the atomic case fails it.

src/gfx1013_compute_native.cpp is also changed on cpp-migration; this merges cleanly there and the native sweep on that merge is in the comment below.

Commands: git diff origin/main...pull/3169/head (read), git merge-tree --write-tree origin/cpp-migration pull/3169/head, plus the Windows commands in the comment below.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 21:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3169#pullrequestreview-6093468460) · **reviewed** Review of 305500f9b83032db006ff5b508a0950156bc14f0 (updated with main). Comment only. The byte-window raw UAV path in `gfx1013_compute_native.cpp` now accepts `buffer_atomic_*` next to `buffer_store_raw`, but only for 4-byte accesses and only when GLC (bit 13 of the first dword) is clear, so returning atomics keep their refusal. The change reuses the existing byte-window descriptor rewrite, so the atomic lands on the same rewritten view a store would use. The atomic readback in `native_bytewin_store_hardware` needs a wave32 adapter and skips on our WARP host, so it rests on the RTX 5080 run in the description, which also shows that dropping the atomic case fails it. `src/gfx1013_compute_native.cpp` is also changed on `cpp-migration`; this merges cleanly there and the native sweep on that merge is in the comment below. Commands: `git diff origin/main...pull/3169/head` (read), `git merge-tree --write-tree origin/cpp-migration pull/3169/head`, plus the Windows commands in the comment below. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 21:25 UTC · original

Windows Server 2025 verification of 305500f9b83032db006ff5b508a0950156bc14f0 (D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump; ctest --preset dev -R <native sweep>: 100% tests passed out of 146 (84 passed, 62 skipped), including native_bytewin_store_controls and native_direct_container
  • release: same targets with --preset release; ctest --preset release -R <native sweep>: 100% tests passed out of 146 (84 passed, 62 skipped)
  • The same dev and release sweep on this head merged with cpp-migration (a0f67731): 100% tests passed out of 146 in both presets

<native sweep> = every native_* test except native_startup_request_cache_hardware, which fails on WARP-only hosts with or without this PR.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 21:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3169#issuecomment-7228432313) Windows Server 2025 verification of `305500f9b83032db006ff5b508a0950156bc14f0` (D3D12 WARP, MSVC 14.44.35207): - dev: `cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump`; `ctest --preset dev -R <native sweep>`: 100% tests passed out of 146 (84 passed, 62 skipped), including `native_bytewin_store_controls` and `native_direct_container` - release: same targets with `--preset release`; `ctest --preset release -R <native sweep>`: 100% tests passed out of 146 (84 passed, 62 skipped) - The same dev and release sweep on this head merged with `cpp-migration` (`a0f67731`): 100% tests passed out of 146 in both presets `<native sweep>` = every `native_*` test except `native_startup_request_cache_hardware`, which fails on WARP-only hosts with or without this PR. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.