shader: lower DWORD atomics through the SPIR-V address window #1081
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1088"
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-24T00:46:54Z.
Change
Refs #218. Extend the bounded SPIR-V address-window bridge from #553 to accept eight unsigned DWORD atomics. Direct casts and indexed physical addresses use the existing window checks and storage buffer bindings. The lowering preserves each atomic instruction, including its result, scope, memory semantics and compare-exchange operand order.
Verification
Linux, Python 3.14.8 and SPIRV-Tools 2025.1. Tested commit
6dad87b0.python3 -B tests/spirv_window/check.pypassed. Both physical and logical modules assembled and passedspirv-val --target-env vulkan1.2. The test checked all eight atomic instructions, both pointer forms and rejection ofOpAtomicISub.ed983c1c(origin/main), the same command exited 1 at the first atomic withValueError: unhandled physical word pointer use, after validation of the physical input.python3 -B tests/spirv_window/sampler.py spirv-as spirv-val spirv-crosspassed.python3 -B tests/spirv_window/ballot.py spirv-as spirv-val spirv-crosspassed.python3 -B tests/spirv_window/compare_sampler.py spirv-as spirv-val spirv-crosspassed.python3 -B tests/docs_links_check.py,python3 -B tests/bidi_controls_check.pyandgit diff --checkpassed.Evidence and follow-up
The MIT synthetic variant is generated from the existing source-built fixture in
tests/spirv_window/check.py. The reproduction command and scope are recorded indocs/experiments.md. GPU execution and out-of-bounds atomic behavior require separate readback evidence.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:01:54Z.
Review: CHANGES_REQUESTED
I confirmed that all eight operations assemble and validate with the pinned SPIR-V tools. The address rewrite currently substitutes an out-of-range sentinel index when a pointer is misaligned or outside the window. Passing spirv-val does not define the effect or returned old value of an atomic issued at that index. Please keep invalid addresses from issuing an atomic, or constrain this profile to addresses proven in range. Add a source-built check that verifies the valid atomic's old value and bound buffer, and that misaligned/out-of-range inputs cannot change any bound word. Keep this separate from earlier load/store observations.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:47:46Z.
Review: APPROVED
On
423c2e0a, Windows Release passed both spirv_address_window_atomic checks on RTX 4060 Laptop and WARP. Valid, misaligned, out-of-window and wrapped-index cases matched all 16 words, with no debug-layer diagnostics. I separately forced the atomic branch to take invalid addresses, keeping the substitute word inside the UAV. WARP caught the misaligned old value at word 11 (expected 0, observed cba98765). This clears the earlier request. The GPU readback evidence is for atomic add, and the other seven forms have the structural validation recorded in the PR.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T00:47:05Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
6dad87bℹ️ 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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:07:50Z.
Added the source-built
OpAtomicIAddreadback in423c2e0a(AI-assisted). The valid case expects word 11 to contain the old valuefedcba98and word 3 to becomefedcba9f. Each invalid case expects word 11 to contain zero and all other words to retain their initial contents.For the negative control, the driver maps the lowering’s substitute index to the last bound DWORD (word 15) in this fixture. I assembled and validated the physical and logical modules with SPIRV-Tools and converted them with SPIRV-Cross on Linux. The pre-guard lowering (
6dad87b0) emits an unconditionalInterlockedAdd; the current lowering emits it inside the validity branch. On Windows, the pre-guard variant would fail first at word 11 for the misaligned case (expected00000000, predictedcba98765), and it would change word 15 fromcba98765tocba9876c. The word 15 check would also catch a mutation that issues the atomic unconditionally but still masks its return value to zero.python3 -B tests/spirv_window/check.pypassed on Linux. Windows compilation and D3D12 readback on WARP and hardware were not run locally. Reproduce withctest --preset dev --no-tests=error -R '^spirv_address_window_atomic_' -Vafter building.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:12:18Z.
Addressed in
fba92c8fand423c2e0a.AI-assisted.