shader: lower signed atomic add, bitwise and compare-exchange in address window #1323
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1330"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:17:14Z.
Change
The SPIR-V address-window adapter now lowers signed (
%int)OpAtomicIAdd,OpAtomicExchange,OpAtomicAnd,OpAtomicOr,OpAtomicXorandOpAtomicCompareExchangeon%_ptr_PSB_int, which origin/main rejected ("unhandled physical word pointer use"). Each runs in the same guarded branch plusOpPhishape as the unsigned atomics: operands are bit-cast, the atomic runs on the unsigned word with its scope and semantics, the result is cast back to%int, and a misaligned, out-of-window or wrapping address issues nothing and yields zero. No substitute index is used.OpAtomicUMin/OpAtomicUMaxon a signed pointer stay rejected. Builds on the signed access work already merged.Files: tools/spirv_address_window.py, tests/spirv_window/address_signed.{py,spvasm}, tests/spirv_window/readback.cpp (the fixture's own readback and CPU model), docs/experiments.md.
Verification
Linux, spirv-as/val/cross from the distro:
python3 -B tests/spirv_window/address_signed.py spirv-as spirv-val spirv-cross: passes (validates, guards, per-step operation and operand wiring, HLSL has one each of InterlockedAdd/Exchange/And/Or/Xor and four compare-exchanges, 5 rejections, 13 mutations caught by the shape check).python3 -B tests/spirv_window/check.py: passes (unchanged).ValueError: unhandled physical word pointer use.GPU: not run (no D3D12 adapter on the Linux author machine).
ctest -R '^spirv_address_window_signed_'needs a WARP/hardware run; it covers 12 cases of 16 DWORDs and 13 mutations, each of which must first diverge at a named case and word (values predicted with a separate model, not yet confirmed on an adapter). Part of the existing--preset prtestspirv_address_window_signed_warp.Evidence and follow-up
The fixture is a synthetic source-built module. The sequence runs on one signed word so each old value feeds the next, with a compare-exchange that misses on the sign bit alone and one that hits. Invalid addresses leave every target and output word unchanged. The diff touches 5 files because the readback harness is the fixture's own.
AI-assisted.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:23:17Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
60ddf53943dada424dde801e679bd58f864cf021:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 6):4.81s(configure1.62s)ctest --preset dev -R '^spirv_address_window_warp$' --no-tests=error --output-on-failure): 1/1 passed (0.41s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 6):2.51s(configure1.60s)ctest --preset release -R '^spirv_address_window_warp$' --no-tests=error --output-on-failure): 1/1 passed (0.35s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:23:27Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
60ddf53ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.