Repository navigation
Conversation
…omic, which cannot tear (SHADER-868) global_atomic_swap_x2 and buffer_atomic_swap_x2 did one 32-bit OpAtomicExchange per dword, so lanes swapping into one element at once could leave it, and the pairs they got back, torn. With --int64-atomics they are one 64-bit OpAtomicExchange on a 64-bit PhysicalStorageBuffer pointer (capability Int64Atomics, index feature shaderBufferInt64Atomics); bounds, alignment and the returned pair are unchanged. Off by default: the two-dword form stays for devices without the feature. The D3D12 device and vk_harness enable shaderBufferInt64Atomics where the GPU has it; vk_compute_test enables it for a module that declares Int64Atomics and skips with 77 without it. make_game.py --int64-atomics and LEONIDA_INT64_ATOMICS=1 (build.py, run_gpu_tests.py) choose it. spirv_mini_interp runs a 64-bit exchange on device-address memory; the two _x2 test files get a class each. docs/design.md and docs/testing.md say so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent check of Environment: Windows 11, CPython 3.15.2, no GPU run, no game files.
Overlap: #4984 (kotekompotek, already independently checked — pass) adds the same AI-assisted (Devin). |
|
Tested c0fa059 on AMD Radeon 610M (RADV RAPHAEL_MENDOCINO, subgroup 32..64), CachyOS Linux, LEONIDA_VK_DEVICE=RADV: pass. The flag removes the tearing on this GPU. I built #4964's cs_w32_swap_x2_contend fixture (with its swap_x2_contend.py and check.py taken from #4964 at 3f49c14, in the test slot only) twice through runtime/test/shaders/build.py:
swap_x2_contend.py, 200 runs of 2048 invocations each:
AI-assisted. |
kacper-serewis
left a comment
There was a problem hiding this comment.
At c0fa0599 on Windows RTX 5070 driver 616.56, the fallback returned 93,730 torn pairs out of 98,304 global swaps and 89,700 out of 98,304 buffer swaps. The opt-in returned zero torn pairs in both sets. Final memory was intact in every dispatch, including the fallback controls. Each invocation saved its returned pair, which exposed the difference. All four synthetic modules passed Vulkan 1.2 validation and the opt-in advertised shaderBufferInt64Atomics. AI-assisted.
|
Tested c0fa059 on Intel UHD 630 (CFL GT2, subgroup 8..32), Mesa 25.2.8 ANV, Ubuntu 24.04, LEONIDA_VK_DEVICE=Intel: pass, and the tearing on this GPU is heavy without the flag. Same setup as the 610M run above (#4964's cs_w32_swap_x2_contend, swap_x2_contend.py and check.py at 3f49c14, in the test slot only):
AI-assisted. |
|
Tested
|
Claim: #4933 (comment) (SHADER-868, found by @Etr0p)
AI-assisted (Claude Code). Tested by running the code below on Windows; see "Tested". No game files.
Problem
Gen.global_atomic_x2andGen.buffer_atomic_x2(tools/rdna2spirv.py) doswap_x2as one 32-bitOpAtomicExchangeper dword. When lanes swap into one element at once, the element and the returned pairs can tear (A.lo with B.hi). #4964 measured 96.7% torn pairs on an RTX 5070 Ti.Change
rdna2spirv.py --int64-atomics:global_atomic_swap_x2andbuffer_atomic_swap_x2become one 64-bitOpAtomicExchangeon a 64-bit PhysicalStorageBuffer pointer (Gen.atomic_swap_int64). The module declaresInt64Atomics, and the index'sfeatureslistsshaderBufferInt64Atomics. Bounds, alignment, the inactive/out-of-range/unaligned behaviour and the returned (low, high) pair are unchanged. The bitwise_x2forms keep one atomic per dword, which is exact for them.d3d12_vulkan_device.cppenablesshaderBufferInt64Atomicswhere the GPU has it.vk_compute_testenables it for a module that declaresInt64Atomics, and exits 77 when the device lacks it.vk_harnessenables it where present.make_game.py --int64-atomics(recorded with the other translator flags, so changing it re-translates), andLEONIDA_INT64_ATOMICS=1forbuild.pyandrun_gpu_tests.py.docs/design.md(global and buffer atomics rows) anddocs/testing.md(a short section).tests/semantic/spirv_mini_interp.pyruns a 64-bitOpAtomicExchangeon device-address memory (two words, low first).Not changed
make_game.py's device probe, or the runtime). Happy to add it if wanted; I kept it opt-in so the default output doesn't change.Tested
Windows 11 (build 26300), AMD Radeon RX 9060 XT (RDNA4, driver 32.0.32029.2010, Vulkan 1.4.359;
shaderBufferInt64Atomicspresent), MSVC 19.44, Python 3.14, llvm-mc 21.1.8, SPIRV-Tools from the Vulkan SDK 1.4.363.tests/semantic/test_global_atomics_x2.pyandtest_buffer_atomics_x2.py: new classes check that with the option there is exactly oneOpAtomicExchange %ulong,Int64Atomicsis declared, and no 32-bit exchange is left. They also check every seed/value pair, withoutglc, the instruction offset, the bounds (partly and wholly out of range) and an unaligned element, the bitwise forms unchanged, and the option off by default. 8 + 8 tests OK. The other atomic test files pass unchanged.python -I -m unittest discover -s tests/semantic: 6252 tests, 3 failures + 2 errors, all intest_loop_ballot_barrier(wave64 emulation of divergent loops); the same 3 + 2 onmainwithout this change (they have owners: tests/semantic: restore test_loop_ballot_barrier after structured wave64 emulation #3953 and Vonsek's claim).spirv-val --target-env vulkan1.2.global_atomic_swap_x2and withbuffer_atomic_swap_x2(glc), and dumps the old pair and the memory after. Throughvk_compute_teston the RX 9060 XT both translations give the same exact words (old0xB0000001:A0000001/0xB0000002:A0000002, new0xD0000001:C0000001/0xD0000002:C0000002), and the--int64-atomicsmodule (twoOpAtomicExchange %ulong) loads with the feature enabled.run_gpu_tests.pywithLEONIDA_INT64_ATOMICS=1: 202/217 passed, 15 skipped, 0 failed (the same as without it). Fullctest -C Release: 169 run, 168 passed. The 1 failure isd3d12_sparse_queue_family_contract, which crashes inside the Vulkan SDK's API dump layer on this AMD driver (TEST-843; the same onmain).tests/test_make_game_translator_flags.py,test_shader_checks.py,test_run_gpu_tests.py,test_run_gpu_tests_paths.py,test_gpu_build_dir.py,test_text_write_line_endings.pyOK;python -m compileall -q make_game.py tools testsclean.🤖 Generated with Claude Code