Shaders: 64-bit image atomics as DXIL's 64-bit typed atomics #1467
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1467
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1467/head"
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?
@paulomatias97-create on GitHub · 2026-11-24 18:15 UTC · original
paulomatias97-create:shader/image-atomic-64→main· +167 −25 · 3 files · 2 commits · closed without mergingThe README lists 64-bit image atomics among what world shaders still need. This adds them.
An image atomic with two data dwords (four for
cmpswap) is a 64-bit atomic on an R32G32 view. It used to stop the program with "a 64-bit image atomic". DXIL does these in SM 6.6 on a texture of 64-bit integers. On D3D12 that texture is viewed asR32G32_UINTtoo (there is no R64 DXGI format), so only the shader changes:atomicBinOp.i64/atomicCompareExchange.i64run on a handle annotatedRWTexture2D<U64>(element properties0x107);glc, the old value is split back into the data VGPRs;0x8000,0x400000and0x10000000. These are the flags DXC'sDxilShaderFlags.cppsets for a 64-bit atomic on a typed resource from the heap.Second commit: handle cache key
The handle cache was keyed by the first word of the resource properties only. An access that wanted different element properties on a descriptor already used therefore reused the earlier handle. In the new test, the image atomic came after the size query, so its texture was annotated as
RWTexture2D<4xF32>. The key now includes both words. The same bug affected 32-bit image atomics.Tests
emit::tests::a_64_bit_image_atomic_is_a_64_bit_atomic: a hand-assembled wave32 compute program runningimage_atomic_umax(64-bit, no return),image_atomic_cmpswap(64-bit,glc) andimage_atomic_swapof the returned value on a 2D UAV. The test checks the SFI0 bits. Without the change it fails with the old error.dxv(DXC built from source, main branch): "Validation succeeded".dxc -dumpbinshows the three atomics asi64operations on aRWTexture2D<U64>handle. On Windows the test also runsdxil.dllwhen present.cargo test -p victory-shaderpasses.cargo clippy -p victory-shader --all-targets --all-features --target x86_64-pc-windows-msvc -- -D warningsis clean.Not verified
AtomicInt64OnTypedResourceSupported(D3D12 options 9); I did not add a check for that.🤖 Generated with Claude Code
https://claude.ai/code/session_01CL4QZxTrzfn3nkthzLyAtV
An image atomic with two data dwords (four for cmpswap) is a 64-bit atomic on an R32G32 view; it stopped the program ("a 64-bit image atomic"). DXIL does these (SM 6.6) on a texture of 64-bit integers, which the host views as R32G32_UINT as well, so only the shader changes: the value (and compare) is joined from its two dwords, the handle's elements are U64, the old value returns split into the data VGPRs with glc, and the module declares Int64Ops and 64-bit atomics on typed and heap resources (shader flags bits 20, 27, 32; SFI0 0x8000, 0x400000, 0x10000000, as DXC sets them). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CL4QZxTrzfn3nkthzLyAtV@geiyiliyabumo on GitHub · 2026-11-24 18:21 UTC · original
Verified commit \
4d4834d\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, SM 6.6) + WARP:@0xKaji on GitHub · 2026-11-24 19:40 UTC · original
Verified
4d4834don NVIDIA — Linux + Wine11.22+vkd3d-proton 3.2.0(GE-Proton11-14) + RTX 3060 8 GB (Ampere, driver620.73.04), cross-built withcargo xwin(x86_64-pc-windows-msvc,VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains). Complements the RDNA4/WARP check above with an NVIDIA driver and a whole-corpus host-pipeline sweep.GPU test
a_64_bit_image_atomic_is_a_64_bit_atomic --test-threads=1: 1 passed, 0 failed on Ampere +vkd3d-proton 3.2.0.Full
shaders.rpfoffline sweep (translate --pipelines --jobs 4)Compared against
ffe310e + #177on the same machine and driver stack:0, no SPIR-V compiler crashes in the NVIDIA driver (26,084 programs translated, 22,406 emitted and handed to the driver) — covers both the 64-bit typed image atomic lowering and theHandleKeychange.emit: a 64-bit image atomicfailures:653→0.vkd3d-proton 3.2.0+ NVIDIA620.73.04:12,231→12,749emitted (+518), all12,749host pipelines created1,441→1,443emitted (+2),1,123host pipelines (+2)8,214→8,214(unchanged, all created)21,566→22,086(+520)320, all pre-existing Ampere Wave64 refusals (Required WaveSize range [64, 64], but supported range is [32, 32], #817); none from the new 64-bit image atomics.@sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: +520 programs over
main, 0 lost.Offline. I merged head
4d4834dontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 22,244 with this PR.mainAll 520 are the same programs that #1127 gains, and the same ones that #1402 gains through #305 (64-bit image atomics). So #305, #539, #1127 and #1467 cover one set. On this data, review can pick between them on correctness and coverage alone.
Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@paulomatias97-create on GitHub · 2026-11-24 22:01 UTC · original
Superseded by the 64-bit atomics in main; the remaining fix is in the new PR.
Pull request closed