Shaders: 64-bit image atomics #539

Closed
github-bot wants to merge 5 commits from gh-pr/539/head into gh-pr/539/base
Owner

@⁠SAitken91 on GitHub · 2026-11-24 04:39 UTC · original
SAitken91:shader/64-bit-image-atomics → main · +363 −20 · 5 files · 5 commits · closed without merging

Image atomics with two data dwords per value (an R32G32 view) were refused as "a 64-bit image atomic". That was the largest single failure in translate: 653 programs in shaders.rpf, mostly fire, alpha-prepass and visibility passes.

Change

  • image_atomic_* with dmask 0x3 (0xF for cmpswap) now become dx.op.atomicBinOp.i64 / dx.op.atomicCompareExchange.i64 on the same texture UAV. Values are built from the VGPR pair (low dword first). With glc, the returned value is split back into the pair, and lanes the guard skips keep their registers.
  • New shader flags: ATOMIC_INT64_TYPED (bit 27) and ATOMIC_INT64_HEAP (bit 32, set when the descriptor comes from the heap). Their SFI0 bits are 0x400000 and 0x10000000.
  • The flags, SFI0 bits and handle properties match what DXC emits for the equivalent HLSL (RWTexture2D<uint64_t> from ResourceDescriptorHeap with InterlockedMax). DXC tags the handle U32 (0x105), and this does the same.

Results

victory translate --validate shaders.rpf, before → after:

validated
vertex/pixel 12172 → 12690
compute 1670 → 1672

The validator reports no new errors. The remaining 133 of the 653 now stop at other unsupported cases further in, mainly "a scalar memory read as data".

Testing

  • cargo test -p victory-shader: 69 passed. Clippy and rustfmt are clean on the changed files.
  • Host support checked on an RX 6950 XT: AtomicInt64OnTypedResourceSupported (OPTIONS9) and AtomicInt64OnDescriptorHeapResourceSupported (OPTIONS11) are both TRUE.
  • Not yet exercised at runtime in the world. Only validation has been checked. Hosts without these capabilities will fail to create these pipelines. No capability check is added here.

Written with the help of Claude (AI).

🤖 Generated with Claude Code

**@⁠SAitken91** on GitHub · 2026-11-24 04:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/539) `SAitken91:shader/64-bit-image-atomics` → `main` · +363 −20 · 5 files · 5 commits · closed without merging Image atomics with two data dwords per value (an R32G32 view) were refused as "a 64-bit image atomic". That was the largest single failure in `translate`: 653 programs in shaders.rpf, mostly fire, alpha-prepass and visibility passes. ## Change - `image_atomic_*` with dmask 0x3 (0xF for cmpswap) now become `dx.op.atomicBinOp.i64` / `dx.op.atomicCompareExchange.i64` on the same texture UAV. Values are built from the VGPR pair (low dword first). With glc, the returned value is split back into the pair, and lanes the guard skips keep their registers. - New shader flags: `ATOMIC_INT64_TYPED` (bit 27) and `ATOMIC_INT64_HEAP` (bit 32, set when the descriptor comes from the heap). Their SFI0 bits are 0x400000 and 0x10000000. - The flags, SFI0 bits and handle properties match what DXC emits for the equivalent HLSL (`RWTexture2D<uint64_t>` from `ResourceDescriptorHeap` with `InterlockedMax`). DXC tags the handle U32 (0x105), and this does the same. ## Results `victory translate --validate shaders.rpf`, before → after: | | validated | |---|---| | vertex/pixel | 12172 → 12690 | | compute | 1670 → 1672 | The validator reports no new errors. The remaining 133 of the 653 now stop at other unsupported cases further in, mainly "a scalar memory read as data". ## Testing - `cargo test -p victory-shader`: 69 passed. Clippy and rustfmt are clean on the changed files. - Host support checked on an RX 6950 XT: `AtomicInt64OnTypedResourceSupported` (OPTIONS9) and `AtomicInt64OnDescriptorHeapResourceSupported` (OPTIONS11) are both TRUE. - **Not yet exercised at runtime in the world.** Only validation has been checked. Hosts without these capabilities will fail to create these pipelines. No capability check is added here. Written with the help of Claude (AI). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Image atomics with two data dwords per value (an R32G32 view) were
refused as "a 64-bit image atomic", stopping 653 programs of the
title's shaders.rpf. They now become DXIL's i64 atomicBinOp and
atomicCompareExchange on the same texture UAV, with the shader flags
and SFI0 bits for 64-bit atomics on typed and on heap resources (the
bits DXC sets for the same HLSL). Returned values (glc) are split back
into the VGPR pair.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12690
validated, compute 1670 -> 1672; no new validator errors. The rest of
the 653 now stop at other unsupported cases further in.

Hosts need AtomicInt64OnTypedResourceSupported (OPTIONS9) and
AtomicInt64OnDescriptorHeapResourceSupported (OPTIONS11); checked on an
RX 6950 XT. Not yet exercised in the world at runtime.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
handle() keys its cache by resource kind only, so an image atomic that
followed a size query of the same view (getDimensions on a float4
handle) reused that handle: the i64 atomic ran on a RWTexture2D<float4>
annotation ({4098, 1033}) instead of DXC's {4098, 261}. Reported by
jeremygold02 on #539. The 64-bit path now makes its own heap handle; the
general fix of the cache key is #177.

translate --validate on shaders.rpf unchanged (vertex/pixel 12690,
compute 1672).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's heap_handle now takes whether the index may differ between lanes
(#566, waterfall loops over per-lane descriptors). The 64-bit atomic
path builds its own heap handle, so it passes the same answer handle()
does: per lane when the descriptor load belongs to a waterfall loop.

translate --validate on shaders.rpf against main ffe310e: VS/PS
12155 -> 12673, CS 1417 -> 1419; no 64-bit image atomic refusals or
"Flags must match usage" errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two edge cases alexander-src found in image_atomic64 (#539 review):

- ATOMIC_INT64_HEAP was set only for Source::Loaded, but handle() makes
  heap handles for Phi, Select, Fetched, Lanes and LanePhi sources too;
  an atomic through one of those would fail "Flags must match usage".
  The flag is now set for every source but a root view (Built).
- A guarded cmpswap built its compare pair after begin_guarded, while
  `pair` writes into the block it captured before the guard: a compare
  word that needs code in the guarded block would be used before it is
  defined. The compare is now built before the guard, like the value.

translate --validate on shaders.rpf unchanged (VS/PS 12673, CS 1419 on
main ffe310e); no 64-bit image atomic or "Flags must match" errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A synthetic RDNA2 compute shader queries a texture UAV's size and then
runs 64-bit add (carry into the high dword), sub (borrow from it),
cmpswap and umax on it, on an R32G32_UINT view through the host's 64-bit
typed atomics. Skipped on devices without 64-bit atomics on typed heap
views.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:39 +00:00
github-bot closed this pull request 2026-11-26 04:07:39 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:27 UTC · original

The SDK accepts these shaders on 55bac542, but I found a handle-annotation mismatch before the 64-bit unsigned max. Seven pixel shaders emitted 14 atomicBinOp.i64 UMax calls. At all 14 sites the call reused a RWTexture2D<float4> handle ({4098, 1033}) from a preceding getDimensions on the same heap index. All 14 queried values were unused.

I compiled a reference RWTexture2D<uint64_t> target = ResourceDescriptorHeap[1] with InterlockedMax using Windows SDK 10.0.26100.0 DXC, targeting cs_6_6. Its i64 UMax receives a handle with properties {4098, 261}, printed as RWTexture2D<U32>.

With #589 applied to this exact PR head, all 14 sites used the DXC reference annotation and the unused dimension queries disappeared. On Windows 11 with an RTX 5070 and an R32G32_UINT UAV, five bounded one-thread synthetic dispatches of the combined path returned the expected unsigned 64-bit maxima, including opposing high/low words and bit 63. Every fence completed, the device reported S_OK, and both the neighboring texel and a separate control descriptor retained their initial values. The stock mismatch was checked by SDK validation and disassembly only.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7122961286) The SDK accepts these shaders on `55bac542`, but I found a handle-annotation mismatch before the 64-bit unsigned max. Seven pixel shaders emitted 14 `atomicBinOp.i64` UMax calls. At all 14 sites the call reused a `RWTexture2D<float4>` handle (`{4098, 1033}`) from a preceding `getDimensions` on the same heap index. All 14 queried values were unused. I compiled a reference `RWTexture2D<uint64_t> target = ResourceDescriptorHeap[1]` with `InterlockedMax` using Windows SDK 10.0.26100.0 DXC, targeting `cs_6_6`. Its i64 UMax receives a handle with properties `{4098, 261}`, printed as `RWTexture2D<U32>`. With #589 applied to this exact PR head, all 14 sites used the DXC reference annotation and the unused dimension queries disappeared. On Windows 11 with an RTX 5070 and an `R32G32_UINT` UAV, five bounded one-thread synthetic dispatches of the combined path returned the expected unsigned 64-bit maxima, including opposing high/low words and bit 63. Every fence completed, the device reported `S_OK`, and both the neighboring texel and a separate control descriptor retained their initial values. The stock mismatch was checked by SDK validation and disassembly only.
Author
Owner

@⁠KoLolX3 on GitHub · 2026-11-24 05:33 UTC · original

Check on Linux, not Windows: pass. Head 55bac542c merged onto main d2a4bae1f (clean merge).

  • Native tests of the seven crates that build on Linux (core, formats, game, loader, pe, pipeline, shader): PR 92 passed, 7 failed, main 92 passed, 7 failed.
  • Windows cross type-check of the whole workspace (cargo xwin check --workspace --target x86_64-pc-windows-msvc, covers victory-gpu, victory-hle and the app): PR ok, main ok.
  • Tests this PR adds: 0 (so the native result only shows the existing tests still pass; the change itself is not covered by a test here).
  • rustfmt: unformatted hunks, PR 168, main 168.
  • Failing on main here as well (not this PR): 7 tests in victory-loader and victory-pe that parse their own test binary as a PE image, which is an ELF file on Linux.
  • Not run: victory-gpu / victory-hle tests and the game itself.

On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed.

**@⁠KoLolX3** on GitHub · 2026-11-24 05:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7123067014) Check on Linux, not Windows: **pass**. Head `55bac542c` merged onto `main` `d2a4bae1f` (clean merge). - Native tests of the seven crates that build on Linux (`core`, `formats`, `game`, `loader`, `pe`, `pipeline`, `shader`): PR `92 passed, 7 failed`, `main` `92 passed, 7 failed`. - Windows cross type-check of the whole workspace (`cargo xwin check --workspace --target x86_64-pc-windows-msvc`, covers `victory-gpu`, `victory-hle` and the app): PR ok, `main` ok. - Tests this PR adds: 0 (so the native result only shows the existing tests still pass; the change itself is not covered by a test here). - rustfmt: unformatted hunks, PR 168, `main` 168. - Failing on `main` here as well (not this PR): 7 tests in `victory-loader` and `victory-pe` that parse their own test binary as a PE image, which is an ELF file on Linux. - Not run: `victory-gpu` / `victory-hle` tests and the game itself. On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed.
Author
Owner

@⁠SAitken91 on GitHub · 2026-11-24 05:55 UTC · original

Thanks, good catch. Fixed in 29da300: the 64-bit path now makes its own heap handle ({4098, 261}) instead of going through the kind-only handle cache, so a preceding size query can't hand it the float4 annotation. #177 is the general fix of the cache key; with either one, #589's skip stays a separate improvement.

**@⁠SAitken91** on GitHub · 2026-11-24 05:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7123411179) Thanks, good catch. Fixed in 29da300: the 64-bit path now makes its own heap handle (`{4098, 261}`) instead of going through the kind-only handle cache, so a preceding size query can't hand it the float4 annotation. #177 is the general fix of the cache key; with either one, #589's skip stays a separate improvement.
Author
Owner

@⁠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 main 1f858b0. Counts are emitted / validated / pipelines.

VS/PS CS 64-bit image atomic refusals
main 12272 / 12172 / 12272 1693 / 1670 / 1693 653
#539 12790 / 12690 / 12790 1695 / 1672 / 1695 0
#305 12790 / 12172 / 12790 1695 / 1670 / 1695 0
#589 12272 / 12172 / 12272 1693 / 1670 / 1693 653
  • #539 and #305 clear all 653 and emit the same 518 extra pixel programs. With #539 they validate and the RX 9070 creates every pipeline.
  • With #305 those 520 programs all fail the validator with "Flags must match usage." (the AMD driver still creates the pipelines, but they are not valid DXIL). So there is no validated gain.
  • #589 changes nothing on this pack.
  • In both #539 and #305 about 100 programs move on to other refusals ("scalar memory read as data" 573 → 677, "barycentrics read directly" 6 → 29).
**@⁠slint6614-dev** on GitHub · 2026-11-24 08:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7126487874) 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 main 1f858b0. Counts are emitted / validated / pipelines. | | VS/PS | CS | 64-bit image atomic refusals | |---|---|---|---| | main | 12272 / 12172 / 12272 | 1693 / 1670 / 1693 | 653 | | #539 | 12790 / **12690** / 12790 | 1695 / 1672 / 1695 | 0 | | #305 | 12790 / 12172 / 12790 | 1695 / 1670 / 1695 | 0 | | #589 | 12272 / 12172 / 12272 | 1693 / 1670 / 1693 | 653 | - #539 and #305 clear all 653 and emit the same 518 extra pixel programs. With #539 they validate and the RX 9070 creates every pipeline. - With #305 those 520 programs all fail the validator with "Flags must match usage." (the AMD driver still creates the pipelines, but they are not valid DXIL). So there is no validated gain. - #589 changes nothing on this pack. - In both #539 and #305 about 100 programs move on to other refusals ("scalar memory read as data" 573 → 677, "barycentrics read directly" 6 → 29).
Author
Owner

@⁠justr4mzi on GitHub · 2026-11-24 09:18 UTC · original

Tested PR #539 (29da3005) merged cleanly on current main (02f404e) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2), Rust 1.98.1 (x86_64-pc-windows-msvc), and dxil.dll from Windows SDK 10.0.26100.0, against main (02f404e) as negative control.

victory translate --validate (26,599 containers / 26,148 programs)

Build VS/PS (emitted / validated) CS (emitted / validated) MS (emitted / validated) 64-bit image atomic refusals Flags must match usage. errors
main (02f404e, negative control) 12,236 / 12,160 1,440 / 1,417 8,163 / 8,101 653 0
PR #539 (29da300 on 02f404e) 12,754 / 12,678 1,442 / 1,419 8,163 / 8,101 0 0
  • All 653 emit: a 64-bit image atomic refusals are cleared, and all 520 newly emitted programs (+518 VS/PS, +2 CS) pass dxil.dll validation with zero Flags must match usage. failures (in contrast to #705 on the same main 02f404e, where all 520 emitted shaders failed DXIL validation on the missing heap atomic flag).
  • The remaining 133 unlocked programs advance cleanly to downstream refusals (scalar memory read as data 604 -> 708, barycentrics read directly 13 -> 36, lane mask read as data 248 -> 253, descriptor read only as data 388 -> 389).

Build and checks

  • Clean merge onto 02f404e (2 files changed in victory-shader: emit/lower.rs, emit/shader.rs).
  • cargo clippy -p victory-shader --lib: clean.
  • cargo xtask policy: 152 files ok.
  • cargo build --release -p victory: succeeded.
  • No game data included; the title itself was not launched.

AI-assisted test execution and comparison (reviewed locally).

**@⁠justr4mzi** on GitHub · 2026-11-24 09:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7127228392) Tested PR #539 (`29da3005`) merged cleanly on current `main` (`02f404e`) on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2), Rust 1.98.1 (`x86_64-pc-windows-msvc`), and `dxil.dll` from Windows SDK `10.0.26100.0`, against `main` (`02f404e`) as negative control. ### `victory translate --validate` (26,599 containers / 26,148 programs) | Build | VS/PS (emitted / validated) | CS (emitted / validated) | MS (emitted / validated) | `64-bit image atomic` refusals | `Flags must match usage.` errors | |---|---|---|---|---|---| | `main` (`02f404e`, negative control) | 12,236 / 12,160 | 1,440 / 1,417 | 8,163 / 8,101 | 653 | 0 | | PR #539 (`29da300` on `02f404e`) | **12,754 / 12,678** | **1,442 / 1,419** | 8,163 / 8,101 | **0** | **0** | - All 653 `emit: a 64-bit image atomic` refusals are cleared, and **all 520 newly emitted programs (+518 VS/PS, +2 CS) pass `dxil.dll` validation** with zero `Flags must match usage.` failures (in contrast to `#705` on the same `main` `02f404e`, where all 520 emitted shaders failed DXIL validation on the missing heap atomic flag). - The remaining 133 unlocked programs advance cleanly to downstream refusals (`scalar memory read as data` 604 -> 708, `barycentrics read directly` 13 -> 36, `lane mask read as data` 248 -> 253, `descriptor read only as data` 388 -> 389). ### Build and checks - Clean merge onto `02f404e` (2 files changed in `victory-shader`: `emit/lower.rs`, `emit/shader.rs`). - `cargo clippy -p victory-shader --lib`: clean. - `cargo xtask policy`: `152 files ok`. - `cargo build --release -p victory`: succeeded. - No game data included; the title itself was not launched. *AI-assisted test execution and comparison (reviewed locally).*
Author
Owner

@⁠SAitken91 on GitHub · 2026-11-24 10:46 UTC · original

@⁠alexander-src both confirmed and fixed in 719079f:

  1. ATOMIC_INT64_HEAP is now set for every source except a root view (Source::Built) — handle() makes heap handles for Phi, Select, Fetched, Lanes and LanePhi too, not just Phi.
  2. The cmpswap compare pair is built before begin_guarded, in the same block as the value.

Also rebased onto ffe310e earlier (909393a): heap_handle gained the nonuniform argument with #566, and the 64-bit path now passes the waterfall per-lane answer like handle() does. On shaders.rpf against ffe310e: VS/PS 12155 -> 12673, CS 1417 -> 1419, no 64-bit atomic refusals or "Flags must match usage" errors. A synthetic guarded-cmpswap test is still missing — fair point.

**@⁠SAitken91** on GitHub · 2026-11-24 10:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7129225311) @⁠alexander-src both confirmed and fixed in 719079f: 1. `ATOMIC_INT64_HEAP` is now set for every source except a root view (`Source::Built`) — `handle()` makes heap handles for `Phi`, `Select`, `Fetched`, `Lanes` and `LanePhi` too, not just `Phi`. 2. The cmpswap compare pair is built before `begin_guarded`, in the same block as the value. Also rebased onto `ffe310e` earlier (909393a): `heap_handle` gained the `nonuniform` argument with #566, and the 64-bit path now passes the waterfall per-lane answer like `handle()` does. On `shaders.rpf` against `ffe310e`: VS/PS 12155 -> 12673, CS 1417 -> 1419, no 64-bit atomic refusals or "Flags must match usage" errors. A synthetic guarded-cmpswap test is still missing — fair point.
Author
Owner

@⁠MrCloudy2 on GitHub · 2026-11-24 10:59 UTC · original

Tester result: +7 of 339 previously failing world programs now emit, all vertex/pixel (0 → 7 of 25). That is more than the three pixel programs that logged a 64-bit image atomic is not supported. Merged together with #160 and #571 the gains add up exactly: vertex/pixel 11, compute 41.

How measured: 339 shader containers from my own 1.0.2.1 copy, the distinct programs that logged shader does not translate in two world runs, each matched to its container by the BLAKE3 VIctory logs. Each PR was merged on its own onto one base: main 8e79c80 + #151 #190 #454 #493 #579 + #177's key fix + the wave64 stack via #439. I then ran victory translate <folder> (diag build, CPU only) and compared DXIL emitted per stage against the base (vertex/pixel 0 of 25, compute 32 of 272, mesh 0 of 13). Linux, Proton-CachyOS wine, cross-built with xwin, RTX 3060 host (only matters for the wave64 part of the base). Translation counts only, not image correctness. AI-assisted (Claude Code).

**@⁠MrCloudy2** on GitHub · 2026-11-24 10:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7129520088) Tester result: **+7 of 339** previously failing world programs now emit, all vertex/pixel (0 → 7 of 25). That is more than the three pixel programs that logged `a 64-bit image atomic is not supported`. Merged together with #160 and #571 the gains add up exactly: vertex/pixel 11, compute 41. **How measured:** 339 shader containers from my own 1.0.2.1 copy, the distinct programs that logged `shader does not translate` in two world runs, each matched to its container by the BLAKE3 VIctory logs. Each PR was merged on its own onto one base: `main` `8e79c80` + #151 #190 #454 #493 #579 + #177's key fix + the wave64 stack via #439. I then ran `victory translate <folder>` (diag build, CPU only) and compared DXIL emitted per stage against the base (vertex/pixel 0 of 25, compute 32 of 272, mesh 0 of 13). Linux, Proton-CachyOS wine, cross-built with xwin, RTX 3060 host (only matters for the wave64 part of the base). Translation counts only, not image correctness. AI-assisted (Claude Code).
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 11:01 UTC · original

Measured this on Linux against the world's shaders: it translates 4 more pixel programs, but under vkd3d-proton those 4 only come out valid together with #177.

Setup: RX 9070 XT, RADV (Mesa 26.3.1), CachyOS, vkd3d-proton master (30b0eb9, dxil-spirv 34f0ff8).

What I ran: I dumped every console shader container the title translated in a run from boot into the world (751 programs, 139 of them pixel) and re-translated them offline with victory_shader::emit::translate. Each DXIL went through dxil-spirv and spirv-val --target-env vulkan1.3.

programs translated pixel programs invalid as SPIR-V
main ffe310e 666 / 751 5
main + this PR 670 / 751 (+4 pixel, none lost) 9: the 4 new ones too, all OpAtomicUMin/UMax/IAdd with a non-integer result type
main + this PR + #177's handle-key change 670 / 751 0

The cause is the one #177 fixes: an image that is both read as float and updated atomically gets the cached float handle for its atomic, and dxil-spirv then emits a float OpAtomic*. The 64-bit atomics here hit it as well. So on Linux this PR needs #177 (or its two-line core, props.1 in the handles key) to land with it or before it.

Merge note: on top of #453 there is a small conflict in emit/shader.rs (BARYCENTRICS and ATOMIC_INT64_TYPED flags added at the same place); keeping both resolves it.

**@⁠pablogonz12** on GitHub · 2026-11-24 11:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7129561361) Measured this on Linux against the world's shaders: it translates 4 more pixel programs, but under vkd3d-proton those 4 only come out valid together with #177. **Setup:** RX 9070 XT, RADV (Mesa 26.3.1), CachyOS, vkd3d-proton master (`30b0eb9`, dxil-spirv `34f0ff8`). **What I ran:** I dumped every console shader container the title translated in a run from boot into the world (751 programs, 139 of them pixel) and re-translated them offline with `victory_shader::emit::translate`. Each DXIL went through dxil-spirv and `spirv-val --target-env vulkan1.3`. | | programs translated | pixel programs invalid as SPIR-V | |---|---|---| | `main` `ffe310e` | 666 / 751 | 5 | | `main` + this PR | 670 / 751 (+4 pixel, none lost) | 9: the 4 new ones too, all `OpAtomicUMin`/`UMax`/`IAdd` with a non-integer result type | | `main` + this PR + #177's handle-key change | 670 / 751 | **0** | The cause is the one #177 fixes: an image that is both read as float and updated atomically gets the cached float handle for its atomic, and dxil-spirv then emits a float `OpAtomic*`. The 64-bit atomics here hit it as well. So on Linux this PR needs #177 (or its two-line core, `props.1` in the `handles` key) to land with it or before it. Merge note: on top of #453 there is a small conflict in `emit/shader.rs` (`BARYCENTRICS` and `ATOMIC_INT64_TYPED` flags added at the same place); keeping both resolves it.
Author
Owner

@⁠SAitken91 on GitHub · 2026-11-24 11:42 UTC · original

@⁠pablogonz12 thanks — that matches the code. #539 only bypasses the kind-keyed handles cache for 64-bit atomics whose descriptor comes straight from a heap load (Source::Loaded, 29da300/909393a). Two paths still reach the cache: the 32-bit atomics in the newly unblocked programs (main's existing image_atomic_* path) and 64-bit atomics whose descriptor comes through a phi/select/waterfall source. Both get the cached float handle when the same view was read as float first, which is exactly what #177's props.1 key fixes. So on vkd3d-proton this should land with or after #177; I've noted the dependency. The emit/shader.rs flag conflict with #453 resolves by keeping both, as you say.

**@⁠SAitken91** on GitHub · 2026-11-24 11:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7130442615) @⁠pablogonz12 thanks — that matches the code. #539 only bypasses the kind-keyed `handles` cache for 64-bit atomics whose descriptor comes straight from a heap load (`Source::Loaded`, 29da300/909393a). Two paths still reach the cache: the 32-bit atomics in the newly unblocked programs (main's existing `image_atomic_*` path) and 64-bit atomics whose descriptor comes through a phi/select/waterfall source. Both get the cached float handle when the same view was read as float first, which is exactly what #177's `props.1` key fixes. So on vkd3d-proton this should land with or after #177; I've noted the dependency. The `emit/shader.rs` flag conflict with #453 resolves by keeping both, as you say.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 12:36 UTC · original

Triage note: direct overlap with #705 (Fix/typed image atomic int64) — both touch crates/victory-shader/src/emit/lower.rs and shader.rs for 64-bit image atomics, and both currently merge cleanly with main. Two competing implementations of the same feature; the maintainer should pick one (or ask the authors to reconcile) before either gets a full review.

**@⁠catminou4** on GitHub · 2026-11-24 12:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7131670349) Triage note: direct overlap with **#705** (`Fix/typed image atomic int64`) — both touch `crates/victory-shader/src/emit/lower.rs` and `shader.rs` for 64-bit image atomics, and both currently merge cleanly with main. Two competing implementations of the same feature; the maintainer should pick one (or ask the authors to reconcile) before either gets a full review.
Author
Owner

@⁠h0useadv on GitHub · 2026-11-24 12:36 UTC · original

Offline coverage on main ffe310e (full retail shader pack, victory translate --validate, programs matched one by one): +520 programs validate, 0 newly fail; a 64-bit image atomic 653 → 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: #293

AI-assisted (Claude Code). Counts only, no game data.

**@⁠h0useadv** on GitHub · 2026-11-24 12:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7131684915) Offline coverage on `main` `ffe310e` (full retail shader pack, `victory translate --validate`, programs matched one by one): **+520 programs validate, 0 newly fail**; `a 64-bit image atomic` 653 → 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: https://git.gtahub.st/github/Marvisak--VIctory/issues/293 AI-assisted (Claude Code). Counts only, no game data.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 13:14 UTC · original · edited 2026-11-24 13:25 UTC

Daniel checked the runtime behavior of exact head 719079f on RTX 4090 under Wine/vkd3d-proton 3.2. The adapter reported support for both typed-resource and descriptor-heap 64-bit atomics. Two source-built compute shaders used an R32G32_UINT texture UAV selected from the heap. Both emitted shaders passed Microsoft DXV.

The exchange/add sequence matched the independently compiled DXC shader on the final texture value and the returned original value, including carry from the low word into the high word. Compare-exchange also matched: a comparison differing only in the high word left the texel unchanged, then a full 64-bit match replaced it. The final HLSL references construct the constants with explicit uint64_t shifts; DXC truncated the UL literals in our first reference.

Daniel also checked per-lane descriptor selection on the g439w build with #539 applied (20a2a4b). Alternating lanes of a source-built Wave32 shader selected two R32G32_UINT UAVs. Each lane addressed its own texel so concurrent writes to the same texel could not mask a descriptor-selection error. All 32 low/high word pairs matched the DXC reference on the same RTX 4090. DXV accepted the emitted shader, and both heap-handle calls carried the nonuniform-index flag.

On the same integration, a separate guarded compare-exchange fixture gave each of 32 lanes its own texel and enabled only the even lanes for the atomic. All 16 active lanes replaced their texels and returned the original 64-bit value. All 16 skipped lanes retained both their texels and their pre-instruction destination registers. Microsoft DXV accepted the emitted shader. All 32 texels and 32 register pairs matched both the independently compiled DXC reference and the expected literal values.

Float/atomic handle reuse and effects on rendered title frames remain outside these tests.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 13:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7132554639) · edited 2026-11-24 13:25 UTC Daniel checked the runtime behavior of exact head `719079f` on RTX 4090 under Wine/vkd3d-proton 3.2. The adapter reported support for both typed-resource and descriptor-heap 64-bit atomics. Two source-built compute shaders used an R32G32_UINT texture UAV selected from the heap. Both emitted shaders passed Microsoft DXV. The exchange/add sequence matched the independently compiled DXC shader on the final texture value and the returned original value, including carry from the low word into the high word. Compare-exchange also matched: a comparison differing only in the high word left the texel unchanged, then a full 64-bit match replaced it. The final HLSL references construct the constants with explicit uint64_t shifts; DXC truncated the UL literals in our first reference. Daniel also checked per-lane descriptor selection on the g439w build with #539 applied (`20a2a4b`). Alternating lanes of a source-built Wave32 shader selected two R32G32_UINT UAVs. Each lane addressed its own texel so concurrent writes to the same texel could not mask a descriptor-selection error. All 32 low/high word pairs matched the DXC reference on the same RTX 4090. DXV accepted the emitted shader, and both heap-handle calls carried the nonuniform-index flag. On the same integration, a separate guarded compare-exchange fixture gave each of 32 lanes its own texel and enabled only the even lanes for the atomic. All 16 active lanes replaced their texels and returned the original 64-bit value. All 16 skipped lanes retained both their texels and their pre-instruction destination registers. Microsoft DXV accepted the emitted shader. All 32 texels and 32 register pairs matched both the independently compiled DXC reference and the expected literal values. Float/atomic handle reuse and effects on rendered title frames remain outside these tests.
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:10 UTC · original

Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head 719079f:

  • cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 102 passed, 0 failed.
  • cargo clippy -p victory-shader -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): a 64-bit image atomic is not supported refusals dropped to 0 with zero GPU/driver issues.
  • Code review: ATOMIC_INT64_TYPED + ATOMIC_INT64_HEAP SFI0 flags, separate (kind | 0x1000, 0x105) handle, and building cmp before begin_guarded(guard) are all clean. Ready to merge!
**@⁠Yaekai** on GitHub · 2026-11-24 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7137247322) Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `719079f`: - `cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests`: 102 passed, 0 failed. - `cargo clippy -p victory-shader -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): `a 64-bit image atomic is not supported` refusals dropped to **0** with zero GPU/driver issues. - Code review: `ATOMIC_INT64_TYPED` + `ATOMIC_INT64_HEAP` SFI0 flags, separate `(kind | 0x1000, 0x105)` handle, and building `cmp` before `begin_guarded(guard)` are all clean. Ready to merge!
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:23 UTC · original

Deep review on Windows 11 / Rust 1.98.1, 719079f on current main (ffe310e), so it merges as it stands. Ranked by usefulness.

Verified here: cargo test -p victory-shader --lib 120 passed, 1 ignored; cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds. (I ran the lib tests, not the dxc/GPU diff suite — that needs VICTORY_PC_DXC; @⁠Yaekai's 102-passed run covers it, and the live-title numbers below are his.) I used a throwaway target dir again, after catching a stale binary from a shared one earlier.

1. The one real gap: no automated test reaches the 64-bit path. The diff suite's texture atomics are all 32-bit, and HLSL cannot express a 64-bit typed atomic, so nothing in the tree would fail if wide, the argument order or the pair packing regressed — the only evidence today is the live-title run. The waterfall_tests style (synthetic GFX10 programs lowered to DXIL, validated by dxil.dll, run on the host GPU and WARP) is the place a 64-bit image_atomic fixture belongs; it is the same harness that caught the per-lane handle issue in 909393a. Until then, a change here is only covered by "the world still renders".

2. The dmask mapping is the part I could not derive from the code, and the live run is the evidence for it. (1,false)/(3,true) stay 32-bit, (3,false)/(0xF,true) become 64-bit, and every other mask now refuses with "an image atomic's data mask" instead of the old message that called all of them "a 64-bit image atomic" — a strictly better refusal, since dmask 2 or 5 was never a 64-bit atomic. That the two wide arms are the ones real programs use is exactly what @⁠Yaekai's 19-minute run with zero a 64-bit image atomic is not supported refusals shows; nothing in the diff lets me check it statically.

3. What I checked and it held. The handle props (kind | 0x1000, 0x105) are byte-identical to what the 32-bit image atomic already uses (lower.rs:5796), and handle's cache key includes props.0, so a float4 handle of the same view cannot be handed back for the U32-tagged one — that is the collision the comment describes, and it is avoided. cmpswap argument order [cmp, value] matches the 32-bit path's [vals[1], vals[0]], and the data layout (new.lo, new.hi, cmp.lo, cmp.hi) at reg..reg+3 is what pair(reg) / pair(reg+2) read. cmp and value are both built before begin_guarded, so nothing with a side effect sits inside the guard, and end_guarded restores the previous register pair on lanes the guard skips, as the comment says. The d16/a16 refusals happen before the wide branch is taken.

4. The SFI0 bits are only verified by the validator accepting them. 0x40_0000 for ATOMIC_INT64_TYPED and 0x1000_0000 for ATOMIC_INT64_HEAP go into the same sfi0 word as the existing INT64/RESOURCE_HEAP bits, and the runs that had dxil.dll validated the containers — but there is no in-repo list of what each bit means, so I cannot check the values against a spec, only against the validator's acceptance.

5. Two minors, neither blocking. The Source::Loaded arm re-implements handle's body (heap_index + per-lane heap_handle) instead of calling self.handle(site, src, false, props) — the cache key includes props.0, so calling it would work and would not drift if handle changes. And when !cache.glc the 64-bit path restores the real previous register pair on guarded-off lanes where the 32-bit path restores 0; both are undefined per DXIL, so this is a "do not harmonise blindly" note, not a bug.

Bottom line: the mechanics check out line by line, the props and argument order match the 32-bit path exactly, and the only thing standing between this and merge in my view is the missing fixture from point 1 — which the live-title result makes less urgent, not more.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7137599586) Deep review on Windows 11 / Rust 1.98.1, `719079f` on current `main` (`ffe310e`), so it merges as it stands. Ranked by usefulness. **Verified here:** `cargo test -p victory-shader --lib` 120 passed, 1 ignored; `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds. (I ran the lib tests, not the dxc/GPU diff suite — that needs `VICTORY_PC_DXC`; @⁠Yaekai's 102-passed run covers it, and the live-title numbers below are his.) I used a throwaway target dir again, after catching a stale binary from a shared one earlier. **1. The one real gap: no automated test reaches the 64-bit path.** The diff suite's texture atomics are all 32-bit, and HLSL cannot express a 64-bit typed atomic, so nothing in the tree would fail if `wide`, the argument order or the pair packing regressed — the only evidence today is the live-title run. The `waterfall_tests` style (synthetic GFX10 programs lowered to DXIL, validated by `dxil.dll`, run on the host GPU and WARP) is the place a 64-bit `image_atomic` fixture belongs; it is the same harness that caught the per-lane handle issue in `909393a`. Until then, a change here is only covered by "the world still renders". **2. The `dmask` mapping is the part I could not derive from the code, and the live run is the evidence for it.** `(1,false)`/`(3,true)` stay 32-bit, `(3,false)`/`(0xF,true)` become 64-bit, and every other mask now refuses with "an image atomic's data mask" instead of the old message that called all of them "a 64-bit image atomic" — a strictly better refusal, since dmask 2 or 5 was never a 64-bit atomic. That the two `wide` arms are the ones real programs use is exactly what @⁠Yaekai's 19-minute run with zero `a 64-bit image atomic is not supported` refusals shows; nothing in the diff lets me check it statically. **3. What I checked and it held.** The handle props `(kind | 0x1000, 0x105)` are byte-identical to what the 32-bit image atomic already uses (`lower.rs:5796`), and `handle`'s cache key includes `props.0`, so a float4 handle of the same view cannot be handed back for the U32-tagged one — that is the collision the comment describes, and it is avoided. cmpswap argument order `[cmp, value]` matches the 32-bit path's `[vals[1], vals[0]]`, and the data layout `(new.lo, new.hi, cmp.lo, cmp.hi)` at `reg..reg+3` is what `pair(reg)` / `pair(reg+2)` read. `cmp` and `value` are both built before `begin_guarded`, so nothing with a side effect sits inside the guard, and `end_guarded` restores the previous register pair on lanes the guard skips, as the comment says. The `d16`/`a16` refusals happen before the wide branch is taken. **4. The SFI0 bits are only verified by the validator accepting them.** `0x40_0000` for `ATOMIC_INT64_TYPED` and `0x1000_0000` for `ATOMIC_INT64_HEAP` go into the same `sfi0` word as the existing `INT64`/`RESOURCE_HEAP` bits, and the runs that had `dxil.dll` validated the containers — but there is no in-repo list of what each bit means, so I cannot check the values against a spec, only against the validator's acceptance. **5. Two minors, neither blocking.** The `Source::Loaded` arm re-implements `handle`'s body (heap_index + per-lane `heap_handle`) instead of calling `self.handle(site, src, false, props)` — the cache key includes `props.0`, so calling it would work and would not drift if `handle` changes. And when `!cache.glc` the 64-bit path restores the real previous register pair on guarded-off lanes where the 32-bit path restores 0; both are undefined per DXIL, so this is a "do not harmonise blindly" note, not a bug. Bottom line: the mechanics check out line by line, the props and argument order match the 32-bit path exactly, and the only thing standing between this and merge in my view is the missing fixture from point 1 — which the live-title result makes less urgent, not more.
Author
Owner

@⁠WALID1618Y on GitHub · 2026-11-24 17:11 UTC · original

Head-to-head synthetic dxil.dll + GPU execution comparison of #539 (719079f) vs #305 (78dae83) on main (ffe310e) — synthetic compute shaders only, no game data.

Environment: Windows 11, Rust 1.98.1, dxil.dll validation enabled (VICTORY_DXIL), NVIDIA GeForce RTX 3050 (driver 32.0.16.2124; AtomicInt64OnTypedResourceSupported=true, AtomicInt64OnDescriptorHeapResourceSupported=true) + Microsoft WARP (10.0.26100.9818; both caps true).

Build & Suite

PR Head clippy (default & --all-features) victory-shader tests (RTX 3050 + WARP + dxil.dll)
#539 719079f clean 120 passed, 0 failed, 1 ignored (38.51s)
#305 78dae83 clean 121 passed, 0 failed, 1 ignored (38.02s)

Synthetic 64-bit Image Atomic GPU Probe (both PRs)

Ran four synthetic wave32 shaders on both PRs against dxil.dll, RTX 3050, and WARP:

  1. add64_glc (real GPU dispatch on a 1x1 R32G32_UINT texture UAV): two image_atomic_add (dmask=3, glc=1 bit 13) calls adding 0x0000_0001_8000_0005 then 0x0000_0002_8000_0003 (exercising 32→64-bit carry and glc return readback to a raw UAV):
    • #539 (comp=0x105): dxil.dll valid, PSO OK on RTX 3050 & WARP; readback texel = [0x00000008, 0x00000004], returned old values = [0x00000000, 0x00000000] and [0x80000005, 0x00000001] on both RTX 3050 and WARP (removed=Ok(())).
    • #305 (comp=0x107): identical dxil.dll valid, PSO OK, and exact [0x00000008, 0x00000004] / old-value readback on both RTX 3050 and WARP.
  2. cmpswap64_glc (dmask=0xF, glc=1, unguarded): dxil.dll valid + PSO OK on RTX 3050 & WARP on both PRs.
  3. cmpswap64_guarded (dmask=0xF, glc=1, inside v_cmpx_eq_u32 divergent guard): dxil.dll valid + PSO OK on RTX 3050 & WARP on both PRs.
  4. resinfo_then_umax64 (image_get_resinfo followed by 64-bit image_atomic_umax on the same 2D UAV descriptor):
    • Both pass dxil.dll and Windows D3D12 PSO creation, but #305 still routes through self.handle(...), which caches handles by (block, load, first, sampler, props.0) without props.1 (lower.rs:3311), so image_atomic_* after image_get_resinfo reuses the cached float4 (0x409) handle — the exact mismatch that #539 (29da300/719079f) avoids for Source::Loaded via a dedicated heap_handle.

Summary

  • #539 is smaller (+110/-6), gates ATOMIC_INT64_HEAP on !matches!(src, Source::Built { .. }), and avoids the Source::Loaded handle-cache collision (it just lacks a unit/GPU test of its own).
  • #305 includes a unit test, but its MIMG words (0xF044_1388 / 0xF040_1F88) set bit 7 (dlc=1) instead of bit 13 (glc=1), so the test does not exercise the if cache.glc { split64 } return path or call Validator::validate.

Between the two, #539 (719079f) is the stronger merge candidate.

AI-assisted; all builds, DXIL validations, and GPU dispatches were executed locally on my RTX 3050 + WARP.

**@⁠WALID1618Y** on GitHub · 2026-11-24 17:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7138811273) Head-to-head synthetic `dxil.dll` + GPU execution comparison of **#539 (`719079f`)** vs **#305 (`78dae83`)** on `main` (`ffe310e`) — synthetic compute shaders only, no game data. **Environment:** Windows 11, Rust `1.98.1`, `dxil.dll` validation enabled (`VICTORY_DXIL`), **NVIDIA GeForce RTX 3050** (driver `32.0.16.2124`; `AtomicInt64OnTypedResourceSupported=true`, `AtomicInt64OnDescriptorHeapResourceSupported=true`) + **Microsoft WARP** (`10.0.26100.9818`; both caps `true`). ### Build & Suite | PR | Head | `clippy` (default & `--all-features`) | `victory-shader` tests (RTX 3050 + WARP + `dxil.dll`) | |---|---|---|---| | **#539** | `719079f` | clean | **120 passed**, 0 failed, 1 ignored (`38.51s`) | | **#305** | `78dae83` | clean | **121 passed**, 0 failed, 1 ignored (`38.02s`) | ### Synthetic 64-bit Image Atomic GPU Probe (both PRs) Ran four synthetic wave32 shaders on both PRs against `dxil.dll`, RTX 3050, and WARP: 1. **`add64_glc` (real GPU dispatch on a 1x1 `R32G32_UINT` texture UAV):** two `image_atomic_add` (`dmask=3`, `glc=1` bit 13) calls adding `0x0000_0001_8000_0005` then `0x0000_0002_8000_0003` (exercising 32→64-bit carry and `glc` return readback to a raw UAV): - **#539 (`comp=0x105`):** `dxil.dll` valid, PSO OK on RTX 3050 & WARP; readback texel = `[0x00000008, 0x00000004]`, returned old values = `[0x00000000, 0x00000000]` and `[0x80000005, 0x00000001]` on **both** RTX 3050 and WARP (`removed=Ok(())`). - **#305 (`comp=0x107`):** identical `dxil.dll` valid, PSO OK, and exact `[0x00000008, 0x00000004]` / old-value readback on both RTX 3050 and WARP. 2. **`cmpswap64_glc`** (`dmask=0xF`, `glc=1`, unguarded): `dxil.dll` valid + PSO OK on RTX 3050 & WARP on both PRs. 3. **`cmpswap64_guarded`** (`dmask=0xF`, `glc=1`, inside `v_cmpx_eq_u32` divergent guard): `dxil.dll` valid + PSO OK on RTX 3050 & WARP on both PRs. 4. **`resinfo_then_umax64`** (`image_get_resinfo` followed by 64-bit `image_atomic_umax` on the same 2D UAV descriptor): - Both pass `dxil.dll` and Windows D3D12 PSO creation, **but #305 still routes through `self.handle(...)`**, which caches handles by `(block, load, first, sampler, props.0)` without `props.1` (`lower.rs:3311`), so `image_atomic_*` after `image_get_resinfo` reuses the cached `float4` (`0x409`) handle — the exact mismatch that #539 (`29da300`/`719079f`) avoids for `Source::Loaded` via a dedicated `heap_handle`. ### Summary - **#539** is smaller (`+110/-6`), gates `ATOMIC_INT64_HEAP` on `!matches!(src, Source::Built { .. })`, and avoids the `Source::Loaded` handle-cache collision (it just lacks a unit/GPU test of its own). - **#305** includes a unit test, but its MIMG words (`0xF044_1388` / `0xF040_1F88`) set bit 7 (`dlc=1`) instead of bit 13 (`glc=1`), so the test does not exercise the `if cache.glc { split64 }` return path or call `Validator::validate`. Between the two, **#539 (`719079f`)** is the stronger merge candidate. _AI-assisted; all builds, DXIL validations, and GPU dispatches were executed locally on my RTX 3050 + WARP._
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 17:16 UTC · original

Thanks for the head-to-head @⁠WALID1618Y — independent dxil.dll + RTX 3050 + WARP runs agreeing with the earlier review that #539 is the stronger of the two: noted. One correction to the handle-cache point, checked against the trees: the (block, load, first, sampler, props.0) key without props.1 is not just #305 — it is also current main (lower.rs:3311 on ffe310e); the fix (key includes props.1) is carried by #1127 at f89a9d7, not merged yet. So #305's image_get_resinfo-then-atomic collision is a main bug too, fixed on #1127's branch, not something #305 introduced.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7138945391) Thanks for the head-to-head @⁠WALID1618Y — independent dxil.dll + RTX 3050 + WARP runs agreeing with the earlier review that #539 is the stronger of the two: noted. One correction to the handle-cache point, checked against the trees: the `(block, load, first, sampler, props.0)` key without `props.1` is not just #305 — it is also current `main` (`lower.rs:3311` on `ffe310e`); the fix (key includes `props.1`) is carried by #1127 at `f89a9d7`, not merged yet. So #305's `image_get_resinfo`-then-atomic collision is a main bug too, fixed on #1127's branch, not something #305 introduced.
Author
Owner

@⁠465d6a0eac on GitHub · 2026-11-24 16:28 UTC · original · edited 2026-11-24 17:20 UTC

Thank you for this, @⁠SAitken91! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/26. You're credited as the author there. This pull request stays the original.

Test results

  • Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): cargo clippy (both variants) and cargo test --workspace pass (342 passed, 0 failed).
  • victory translate over the 26,148 shader programs in my own copy of the game, any wave size: programs stopping at "a 64-bit image atomic" went from 653 to 0, and vertex/pixel programs emitted to DXIL from 12,243 to 12,761 of 14,039 (+518). Compute went from 1,441 to 1,443; the rest now stop at later, unrelated steps.
  • With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
**@⁠465d6a0eac** on GitHub · 2026-11-24 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7137734186) · edited 2026-11-24 17:20 UTC Thank you for this, @⁠SAitken91! Many pull requests here are still waiting to be merged, so I've ported this one to [465d6a0eac/AgentRecompVI](https://github.com/465d6a0eac/AgentRecompVI), a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/26. You're credited as the author there. This pull request stays the original. **Test results** - Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): `cargo clippy` (both variants) and `cargo test --workspace` pass (342 passed, 0 failed). - `victory translate` over the 26,148 shader programs in my own copy of the game, any wave size: programs stopping at "a 64-bit image atomic" went from 653 to 0, and vertex/pixel programs emitted to DXIL from 12,243 to 12,761 of 14,039 (+518). Compute went from 1,441 to 1,443; the rest now stop at later, unrelated steps. - With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
Author
Owner

@⁠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 (branch atomic64-test, on main @ ffe310eb). It is test-only:

  • emit/image_atomic64_tests.rs.
  • A View::Uint64TextureUav (R32G32_UINT) in the test host.

It is a synthetic RDNA2 compute shader. It first runs image_get_resinfo on 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:

  • add twice, for the carry into the high dword;
  • cmpswap;
  • umax;
  • add then sub, for the borrow.

The test checks the texels. It skips devices without AtomicInt64OnTypedResourceSupported / AtomicInt64OnDescriptorHeapResourceSupported.

On AMD RX 9070 (RDNA4) and WARP, merged onto ffe310eb:

64-bit atomic test cargo test --workspace clippy ×2
main fails in lowering: a 64-bit image atomic
#539 @ 719079f2 pass (hardware + WARP) 343 pass clean
#305 @ 78dae836 pass (hardware + WARP) 344 pass clean

So 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.

**@⁠alexdeliu** on GitHub · 2026-11-24 17:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7139634512) Neither 64-bit image atomics PR had a GPU test, so I wrote one: [`alexdeliu/VIctory@5f5ce1f`](https://github.com/alexdeliu/VIctory/commit/5f5ce1f65b0d71b372ceff9cc2f2ee12cc76fc2c) (branch `atomic64-test`, on `main` @ `ffe310eb`). It is test-only: - `emit/image_atomic64_tests.rs`. - A `View::Uint64TextureUav` (R32G32_UINT) in the test host. It is a synthetic RDNA2 compute shader. It first runs `image_get_resinfo` on 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: - `add` twice, for the carry into the high dword; - `cmpswap`; - `umax`; - `add` then `sub`, for the borrow. The test checks the texels. It skips devices without `AtomicInt64OnTypedResourceSupported` / `AtomicInt64OnDescriptorHeapResourceSupported`. On **AMD RX 9070 (RDNA4)** and WARP, merged onto `ffe310eb`: | | 64-bit atomic test | `cargo test --workspace` | clippy ×2 | |---|---|---|---| | `main` | fails in lowering: `a 64-bit image atomic` | | | | #539 @ `719079f2` | **pass** (hardware + WARP) | 343 pass | clean | | #305 @ `78dae836` | **pass** (hardware + WARP) | 344 pass | clean | So 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.
Author
Owner

@⁠SAitken91 on GitHub · 2026-11-24 18:42 UTC · original

@⁠alexdeliu thank you — cherry-picked your test into this PR as 404dbd9 (your authorship kept). On an RX 6950 XT (RDNA2) it runs (both 64-bit atomic caps reported) and passes: image_atomics_64_bit_add_sub_cmpswap_umax ... ok; cargo test -p victory-shader 121 passed, clippy clean. That covers the missing 64-bit fixture from the reviews above (add with carry, cmpswap, umax, add/sub with borrow, after a size query on the same view).

**@⁠SAitken91** on GitHub · 2026-11-24 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7141048091) @⁠alexdeliu thank you — cherry-picked your test into this PR as 404dbd9 (your authorship kept). On an **RX 6950 XT (RDNA2)** it runs (both 64-bit atomic caps reported) and passes: `image_atomics_64_bit_add_sub_cmpswap_umax ... ok`; `cargo test -p victory-shader` 121 passed, clippy clean. That covers the missing 64-bit fixture from the reviews above (add with carry, cmpswap, umax, add/sub with borrow, after a size query on the same view).
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 19:04 UTC · original

Verified the new head 404dbd9 here (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1): the gap @⁠WALID1618Y noted is closed — image_atomic64_tests.rs adds image_atomics_64_bit_add_sub_cmpswap_umax, which runs the 64-bit add/sub/cmpswap/umax probes on hardware and WARP through ONE_AT_A_TIME and really dispatched here (no "skipped" output under --nocapture). cargo test -p victory-shader --lib image_atomic 1 passed / 0 failed; full lib 121 passed / 0 failed / 1 ignored; clippy --all-targets --all-features --locked -D warnings clean; release build ok. The ATOMIC_INT64_HEAP gating on !Source::Built and the heap_handle path are unchanged from the version I reviewed, so the earlier findings stand: this remains the stronger of #539/#305, now with its own GPU evidence.

**@⁠adamdotpy** on GitHub · 2026-11-24 19:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7141566861) Verified the new head `404dbd9` here (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1): the gap @⁠WALID1618Y noted is closed — `image_atomic64_tests.rs` adds `image_atomics_64_bit_add_sub_cmpswap_umax`, which runs the 64-bit add/sub/cmpswap/umax probes on hardware and WARP through `ONE_AT_A_TIME` and really dispatched here (no "skipped" output under `--nocapture`). `cargo test -p victory-shader --lib image_atomic` 1 passed / 0 failed; full lib 121 passed / 0 failed / 1 ignored; clippy `--all-targets --all-features --locked -D warnings` clean; release build ok. The `ATOMIC_INT64_HEAP` gating on `!Source::Built` and the `heap_handle` path are unchanged from the version I reviewed, so the earlier findings stand: this remains the stronger of #539/#305, now with its own GPU evidence.
Author
Owner

@⁠Daniel333313131 on GitHub · 2026-11-24 22:18 UTC · original

Translation census with this PR merged alone onto main ffe310e, plus a note that #305 gives the same numbers.

Setup: release build, victory translate <dump>/shaders.rpf --list (26,084 programs, no --validate, no --pipelines), Windows 11, RX 7900 XTX. This PR's head is 404dbd9; #305's head is 78dae83.

vertex/pixel compute mesh
main 12,231 of 14,027 1,441 of 2,582 8,214 of 8,713
#539 12,749 (+518) 1,443 (+2) 8,214
#305 12,749 (+518) 1,443 (+2) 8,214
  • "a 64-bit image atomic" goes from 653 first refusals to 0.
  • Of those programs, 104 now stop at "a scalar memory read as data" (771 → 875) and 23 at "barycentrics read directly" (13 → 36). #437 removes the scalar-read refusal (#437).
  • #305 and this PR give identical census numbers, so one of the two is probably enough.

In game (diag build, two runs, stopped after 180 s): 1038 / 852 ms per world frame, against 981 / 976 on main. Both runs end in a page fault, one of them inside a freed texture, after 78 s and 128 s. That is the failure #431 addresses, so these runs cannot show whether the atomics render correctly.

AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the census and the title, compared the outputs and wrote this comment. The numbers come from the runs above.

**@⁠Daniel333313131** on GitHub · 2026-11-24 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7146070214) Translation census with this PR merged alone onto `main` `ffe310e`, plus a note that #305 gives the same numbers. **Setup:** release build, `victory translate <dump>/shaders.rpf --list` (26,084 programs, no `--validate`, no `--pipelines`), Windows 11, RX 7900 XTX. This PR's head is `404dbd9`; #305's head is `78dae83`. | | vertex/pixel | compute | mesh | |---|---|---|---| | `main` | 12,231 of 14,027 | 1,441 of 2,582 | 8,214 of 8,713 | | **#539** | **12,749** (+518) | 1,443 (+2) | 8,214 | | #305 | 12,749 (+518) | 1,443 (+2) | 8,214 | - "a 64-bit image atomic" goes from 653 first refusals to 0. - Of those programs, 104 now stop at "a scalar memory read as data" (771 → 875) and 23 at "barycentrics read directly" (13 → 36). #437 removes the scalar-read refusal (https://git.gtahub.st/github/Marvisak--VIctory/pulls/437). - #305 and this PR give identical census numbers, so one of the two is probably enough. **In game** (diag build, two runs, stopped after 180 s): 1038 / 852 ms per world frame, against 981 / 976 on `main`. Both runs end in a page fault, one of them inside a freed texture, after 78 s and 128 s. That is the failure #431 addresses, so these runs cannot show whether the atomics render correctly. **AI use:** Claude Code (Claude Opus 5.5) merged and built the commits, ran the census and the title, compared the outputs and wrote this comment. The numbers come from the runs above.
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 00:12 UTC · original

RTX 5080 validation and D3D12 pipeline-creation result for head 404dbd9 applied to ffe310e, on Windows 11 build 26200, NVIDIA 617.14, DXIL validator 1.9.2609.5.

I selected 169 records from the 1.0.2.1 build whose native programs contained a two-word 2D image UMAX. After deduplication, all 168 distinct pixel containers hit the 64-bit image atomic refusal on the baseline. With this patch, 162 passed DXIL validation and all 162 created real D3D12 graphics pipelines using VIctory's signature-matched stand-in vertex shaders. The other six reached the separate barycentrics read directly refusal. Counting the duplicate record gives 163/169. This sample was selected for the instruction and is not a full-pack coverage estimate.

For one of the recovered programs, the disassembled host module contains an i64 atomic unsigned maximum built from both source words. The patch's synthetic GPU readback test also passed on this card. These are offline translation, pipeline-creation and isolated GPU results; no in-game image or frame-time claim from this test.

AI-assisted testing with OpenAI Codex (GPT-6).

**@⁠iGoldenNinja** on GitHub · 2026-11-25 00:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/539#issuecomment-7148261475) RTX 5080 validation and D3D12 pipeline-creation result for head `404dbd9` applied to `ffe310e`, on Windows 11 build 26200, NVIDIA 617.14, DXIL validator 1.9.2609.5. I selected 169 records from the 1.0.2.1 build whose native programs contained a two-word 2D image UMAX. After deduplication, all 168 distinct pixel containers hit the 64-bit image atomic refusal on the baseline. With this patch, 162 passed DXIL validation and all 162 created real D3D12 graphics pipelines using VIctory's signature-matched stand-in vertex shaders. The other six reached the separate `barycentrics read directly` refusal. Counting the duplicate record gives 163/169. This sample was selected for the instruction and is not a full-pack coverage estimate. For one of the recovered programs, the disassembled host module contains an i64 atomic unsigned maximum built from both source words. The patch's synthetic GPU readback test also passed on this card. These are offline translation, pipeline-creation and isolated GPU results; no in-game image or frame-time claim from this test. AI-assisted testing with OpenAI Codex (GPT-6).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!539
No description provided.