Repository navigation
Conversation
… (SHADER item, claimed on ItsNotRexed#5032) An out-of-range OpImageTexelPointer is undefined in Vulkan, while RDNA2 leaves memory untouched and, with glc, returns 0. Query OpImageQuerySize, compare each coordinate unsigned (a negative one wraps) and run the texel pointer and the atomic only for active, in-range lanes; with glc an active out-of-range lane gets 0. The plain atomics and cmpswap share emit_image_atomic_core; the old 2D/3D copies and an unreachable image_store branch are removed. Contract row in docs/design.md updated. Not GPU-verified. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Ran this at e8382a704 on Windows 11, RTX 5070 Ti.
tests/semantic/test_image_atomics_bounds.py-> 3 tests, OK;git diff --checkclean.- GPU with this translator:
run_gpu_tests.py --filter imgatomic-> 3/3 passed, 4 shadersspirv-valclean:cs_imgatomic: all 64 words of the uint image, the sint image and the volume exactcs_imgatomic3d: all 64 words exactps_imgatomic: 0 of 256 texels wrong; 0 of 4096 render-target pixels wrong (odd columns discarded)
The image_atomic_* path now bounds-checks the 2D/3D r32ui storage-image address before the atomic, refusing a coordinate outside the subresource instead of emitting an unchecked access; the semantic test covers the in-bounds, edge and out-of-bounds forms, and the GPU fixtures keep the measured words. No blocking issue.
|
Independent hardware review of Note on overlap with #5059: This PR and #5059 (opened earlier by @Vonsek for Environment: Windows 11 x64, Python 3.12.10, SPIRV-Tools v2026.4 (Vulkan SDK 1.4.363.0), Results:
All tested semantic and in-range GPU checks pass; out-of-bounds coordinates are verified structurally in the new semantic tests (not executed on GPU by the stock AI-assisted (Gemini 4 Neon). |
|
Thanks @DenRakEiw and @Kam471 for the checks, and for flagging the overlap. I missed #5059: it is @Vonsek's PR for their own finding (EGEN-IMGATOMIC-OOB, #4933, "done" at 07:59), and I opened this one without re-searching the open PRs first. My claim on #5032 (07:48) was made before #5059 existed, but that doesn't change that the finder's PR came first. #5059 also has what this PR lacks: a gfx1036 measurement of the out-of-range behaviour with I suggest #5059 goes forward. I'm leaving this PR open until a maintainer decides, and will close it in favour of #5059 if that is what they want (@ItsNotRexed, @KoertLichtendonk). If anything here helps #5059, the 28-variant AI-assisted. |
|
Closing in favour of #5059, which is @Vonsek's PR for their own finding (EGEN-IMGATOMIC-OOB) and came first, with the gfx1036 measurement. Thanks to everyone who checked this one; the results carry over, since the two make the same change. AI-assisted. |
|
Tested e8382a7 on NVIDIA GeForce RTX 5070 (driver 617.42) and AMD Radeon Graphics (Ryzen 5 7600 iGPU, AMD proprietary driver 2026.04.17), Windows 11 26200, Vulkan SDK 1.4.363, Python 3.12, llvm-mc 23.1.6: pass
Code read: the guard is computed before the AI-assisted: yes |
|
Tested Built from this head (base
Code read: the per-axis Not covered by this run: none of the GPU fixtures hits an out-of-range texel, so the new path (memory untouched, 0 returned with No game files. AI-assisted (Claude Code). |
Claimed in the coordination issue as: #5032 (comment) (new SHADER item, from @Vonsek's finding #4933 (comment))
What and why
image_atomic_*on a 2D or 3Dr32uistorage image built itsOpImageTexelPointerfrom the raw coordinates with no bounds check. An out-of-range texel pointer is undefined in Vulkan, while RDNA2 leaves memory untouched and, withglc, returns 0.The translator now queries
OpImageQuerySize, compares each coordinate unsigned (a negative coordinate wraps to a large value, so it is rejected too), and runs the texel pointer and the atomic only for lanes that are active and in range. Withglcan active lane that is out of range gets 0 in vdata; an inactive lane keeps it. Covers add/sub/and/or/xor/smin/smax/umin/umax/cmpswap and swap/inc/dec/fmin/fmax/fcmpswap,a16included.The plain atomics and cmpswap now share
emit_image_atomic_core(the old 2D and 3D copies, and an unreachableimage_storebranch in the 2D block, are gone).docs/design.md: the "Image atomics" contract row records the rule.Tested
tests/semantic/test_image_atomics_bounds.py(new, 3 tests, 7 ops x 2D/3D x glc/no glc): fails on unchanged main (43 failures, run withLEONIDA_TOOLS_DIRpointing at the originaltools/), passes with this change.test_image_atomics_32.py,test_fspx_rules.py: pass.spirv-asandspirv-val(vulkan1.2).python -m unittest discover -s tests/semantic: 6,248 tests ran: 3 failures and 2 errors, the same five as unchanged main3faac557(test_loop_ballot_barrier, wave64-emulation tests that still expect the pre-Translator: structured --wave64-emulate and acyclic single-write execz folding (#884) #2089 form; open PRs tests: test_loop_ballot_barrier follows #2089's structured wave64 emulation (main red since 1cc7497b) #3995, tests/semantic: run structured wave64 emulation in the loop/ballot tests #4677, semantic: the ballot/barrier audit runs structured wave64 helper calls #4727 and tests/semantic: run test_loop_ballot_barrier's emulated cases through the structured form #5024 update them), and 3 more passing tests than main (the new file). No new failure.glc) is the report in the finding, not measured here. CPU only; Windows 11, Python 3.14, Vulkan SDK 1.4.363.AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed.