Shaders: lower 64-bit image atomics #305
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!305
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/305/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?
@tarcisioads on GitHub · 2026-11-24 02:12 UTC · original
tarcisioads:shader/image-atomics-64→main· +179 −26 · 2 files · 1 commits · closed without mergingImplement lowering for 64-bit
image_atomic_*instructions invictory-shader:flags::ATOMIC_INT64_ON_TYPED_RESOURCE(1 << 27inDxilShaderFlags) and map it to0x40_0000(ShaderFeatureInfo_AtomicInt64OnTypedResource) inSFI0(crates/victory-shader/src/emit/shader.rs).dmask == 3for binary ops,dmask == 0xFforcmpswap) incrates/victory-shader/src/emit/lower.rs, declaring typedU64resource properties (0x107), packing 2/4 VGPRs viapack64, emittingatomicBinOp.i64/atomicCompareExchange.i64, and splittingglcresults back intov[reg..reg+2].image_atomics_64_bit_lower_with_typed_int64_flagcovering 64-bitimage_atomic_addandimage_atomic_cmpswapand verifyingSFI0feature bits.Verification
cargo test -p victory-shader(57/57 passed on macOS; Windowsdxil.dllvalidation and host D3D12R32G32_UINTview mapping invictory-gpunot run)rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs crates/victory-shader/src/emit/shader.rs(ok)cargo xtask policy(ok)@jeremygold02 on GitHub · 2026-11-24 02:59 UTC · original
Thanks @tarcisioads and @flapwarp78. I compared the current diffs: both implement 64-bit image-atomic lowering. #48 also declares both typed-resource and descriptor-heap 64-bit atomic capabilities and adds an end-to-end synthetic
emit()test for 32- and 64-bit add/cmp-swap (capability and emitter test); #305 adds focused lowerer coverage for the typed-resource flag (lowering and test). If maintainers consolidate these, #48 looks broader after rebasing and resolving integration issues. Please carry over #305's focused test and credit, and preserve #48's independent branch-threading/handle-cache work. This is for maintainers to decide.@r4tedx on GitHub · 2026-11-24 03:14 UTC · original
Review note: running the DXIL validator (dxil.dll from the Windows SDK) on this PR's wide-add fixture fails with "Flags must match usage": the module declares the 64-bit-atomics-on-typed-resource feature but not the one for atomics on resources reached through the descriptor heap, which is how these handles are created here. DXC declares both for the same heap-based operation, and #48 does too. The validator's difference is
1 << 32(the heap-resource atomics flag).The three open PRs for this (#48, #305, and the closed #173) agree on the rest: the wide data masks (
0x3,0xF) and the replacement-before-comparand register order for cmpswap.D3D12 only checks the container hash, so a driver may still take the module; hence the test passing without the validator.
From the documents and synthetic tests only; I have no copy of the title and have not run this on console hardware.
@SpaghettiMaster545 on GitHub · 2026-11-24 03:20 UTC · original
Tested with the title
038a36f(this PR), againstmainand against #48 on the same machine.maind2a4bae, its own emptyVICTORY_CACHE_DIR, scripted keys into story mode, until the host GPU failure (#71, unrelated), compared program by program with amainrun made the same way.mainrun, 14 pixel programs stop witha 64-bit image atomic.mainstop.mainalso has), so the missing heap-resource atomics flag that the DXIL validator reports (review above) did not make the NVIDIA driver refuse anything here.mainwitha scalar memory read as data(7) anda descriptor read only as data(3).Not tested
(Claude Code, Claude Opus 5.5: ran the title on each build and compared the logs program by program.)
@GamingRipperDoc on GitHub · 2026-11-24 05:26 UTC · original
Validation data for this PR, from
victory translate <dump> --validate(offline, dxil.dll validator) on Windows 10 + RX 9070 XT, based2a4bae+ #175 + #336:Flags must match usageSo the ~524 programs this PR lets through (the 64-bit image atomic ones) are emitted, but every one fails validation with
error: Flags must match usage., which reads like the module's shader flags not declaring what the code uses (64-bit atomics on typed resources /Int64ops?). That's on this PR alone, with no other shader PR applied.Why it matters: VIctory doesn't validate at run time, so in game these go to the driver. In a play run with this PR in a larger shader stack, AMD's shader compiler crashed (
amdxc64.dll+0x85fd0f, access violation reading 0x8) after ~1 min in the world; I can't say which program it was compiling, but these were among ~1,200 non-validating programs in that stack.No game data in this comment.
AI-assisted (Claude Code); I ran the measurements on my machine.
@claude-GTA6 on GitHub · 2026-11-24 06:01 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
The lowering looks right to me, but on my machine
dxil.dllrejects every shader it newly emits until one more flag is set.What happens: every 64-bit atomic in the corpus is
image_atomic_umax, 2D, dmask 3 (653 programs, the*_AlphaPrepass*/*VBuffer*pixel shaders). With this PR they all emit, butvictory translate --validatefails 520 of them with:Cause: the image's handle comes from
createHandleFromHeap, and a 64-bit atomic on a descriptor-heap resource needsAtomicInt64OnDescriptorHeapResourceas well asAtomicInt64OnTypedResource: ShaderFlags bit 32, SFI00x1000_0000. (#48 sets it too.)Fix on top of this PR:
(plus
features & 0x1000_0000in the test's asserts).Measured (
translate --validate, dxil.dll from SDK 10.0.26100):d2a4bae+ this PR + #177,shaders.rpfonly: 520 programs fail with "Flags must match usage"; no other new failures.The 133 remaining 64-bit-atomic programs now stop on later causes (104 "a scalar memory read as data", 23 barycentrics). With
--pipelineson an RTX 5090 (driver 621.24), all emitted VS/PS and mesh pipelines are created.@slint6614-dev on GitHub · 2026-11-24 08:43 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines created on an AMD RX 9070, Adrenalin, Windows 11; dxil.dll from SDK 10.0.26100), against main1f858b0. Counts are emitted / validated / pipelines.@Exorion1er on GitHub · 2026-11-24 09:33 UTC · original
#705 matches this PR almost line for line: 157 of its 158 added lines are identical, including the
pack64helper, theATOMIC_INT64_ON_TYPED_RESOURCEflag and the testimage_atomics_64_bit_lower_with_typed_int64_flag. The difference that matters is merge state: #705 merges cleanly withmaintoday, and this PR conflicts.#539 is a different implementation of the same lowering. It also covers image atomics through the descriptor heap (
ATOMIC_INT64_HEAP), which neither of the other two handles, but it has no test. All three edit the same lowering function, so only one can land.Checked by comparing the diffs against
main. AI-assisted (Claude Code).@tarcisioads on GitHub · 2026-11-24 11:18 UTC · original
Rebased onto
main(ffe310e) and addressed the DXIL validator feedback:flags::ATOMIC_INT64_ON_HEAP_RESOURCE(1 << 32inShaderFlags,0x1000_0000inSFI0) and set it alongsideATOMIC_INT64_ON_TYPED_RESOURCEfor 64-bit image atomics in78dae83.image_atomics_64_bit_lower_with_typed_int64_flagto assert0x1000_0000inSFI0and passSome(&st)toresource::track.cargo test -p victory-shader(97 passed, 0 failed on macOS;dxil.dllvalidation still needs Windows).@h0useadv on GitHub · 2026-11-24 12:36 UTC · original
Offline coverage on
mainffe310e(full retail shader pack,victory translate --validate, programs matched one by one): +520 programs validate, 0 newly fail;a 64-bit image atomic653 → 0. #305, #539 and #705 give exactly the same 520 programs, so on coverage they're interchangeable and the choice can rest on review alone. Stacked with #180 and the lane-mask branch from #653: +1,193, 0 regressions. Full table: #293AI-assisted (Claude Code). Counts only, no game data.
@WALID1618Y on GitHub · 2026-11-24 17:11 UTC · original
Tested
78dae83head-to-head against #539 (719079f) on Windows 11 / Rust1.98.1/ RTX 3050 (32.0.16.2124) + WARP +dxil.dll(full table posted on #539).victory-shader121 passed / 0 failed,dxil.dllvalid, and real 64-bitimage_atomic_addGPU dispatch on a 1x1R32G32_UINTUAV produces the exact 32→64-bit carry sum andglcold-value readback on RTX 3050 and WARP.image_atomic_*still callsself.handle(...)(lower.rs:3311), which caches byprops.0withoutprops.1, so animage_get_resinfofollowed by a 64-bit atomic on the same 2D UAV reuses the cachedfloat4(0x409) handle.image_atomics_64_bit_lower_with_typed_int64_flag,0xF044_1388and0xF040_1F88set bit 7 (dlc=1) rather than bit 13 (glc=1), so theif cache.glc { split64 }return path isn't exercised by the test (norValidator::validate).AI-assisted; executed locally on RTX 3050 + WARP.
@alexdeliu on GitHub · 2026-11-24 17:44 UTC · original
Neither 64-bit image atomics PR had a GPU test, so I wrote one:
alexdeliu/VIctory@5f5ce1f(branchatomic64-test, onmain@ffe310eb). It is test-only:emit/image_atomic64_tests.rs.View::Uint64TextureUav(R32G32_UINT) in the test host.It is a synthetic RDNA2 compute shader. It first runs
image_get_resinfoon the same view, so a handle with another element type already exists in that block. Then it runs 64-bit atomics on a 4×1 texture:addtwice, for the carry into the high dword;cmpswap;umax;addthensub, for the borrow.The test checks the texels. It skips devices without
AtomicInt64OnTypedResourceSupported/AtomicInt64OnDescriptorHeapResourceSupported.On AMD RX 9070 (RDNA4) and WARP, merged onto
ffe310eb:cargo test --workspacemaina 64-bit image atomic719079f278dae836So both produce correct results on real hardware. The handle-cache concern I raised about #305 (no element type in the key) does not show up with a size query before the atomic in one block. Feel free to cherry-pick the test into either PR.
@justlovett0 on GitHub · 2026-11-24 18:48 UTC · original
Verified + integrated. Stack: main
ffe310e+ #175/#994/#747/#302/#193/#704/#309/#953/#1067/#986/#1260/#1267/#1254/#1276/#189 (wave64 emulation), RTX 3080 10 GB / Win10 21H2 (19044.7846) / driver 621.24 (32.0.16.2124). Re-census of captured runtime containers; world stable ~9 min, 0 device removals.The "a 64-bit image atomic" class in our captured runtime containers is cleared (2 → 0); compute emission 493/560. Clean merge, no regressions (148 logic tests pass; the GPU-readback failures are the permanent environmental SM 6.6 baseline on this Win10 box).
AI use: Qwen Code; local measurements, user-confirmed visuals. No game data posted.
@alessiodeia on GitHub · 2026-11-24 21:37 UTC · original
In-game data for
78dae83on an RTX 2070 SUPER (Turing), driver 621.40, Windows 11: the 64-bit image atomic pipelines are created and run.Tree:
mainffe310e+ #439 + #704 + #1130 + #1065 + #979's two commits + #493 #587 #282 #876 #67 #490 #464 #984 +fix/unaligned-buffer-srv. Diag build, Series X, DRED, 30 minutes with and without this PR.a 64-bit image atomic: 11 emit and validate withdxil.dll(10 pixel, 1 compute). The other 3 stop later: 2 onbarycentrics read directlyand 1 ona descriptor's address or format read as data.lower::Partsinitializer in this PR's test, which needs #439'starget,console_cfandper_lane_only(crate::emit::Target::ANYfrom insidelower.rs).cargo test -p victory-shader: 169 passed on the GPU.This one merges cleanly onto that tree. #539 conflicts there in
emit/mod.rs.No game data attached. AI-assisted (Claude Code).
Pull request closed