Shaders: lower 64-bit image atomics #305

Closed
github-bot wants to merge 1 commit from gh-pr/305/head into gh-pr/305/base
Owner

@⁠tarcisioads on GitHub · 2026-11-24 02:12 UTC · original
tarcisioads:shader/image-atomics-64 → main · +179 −26 · 2 files · 1 commits · closed without merging

Implement lowering for 64-bit image_atomic_* instructions in victory-shader:

  • Add flags::ATOMIC_INT64_ON_TYPED_RESOURCE (1 << 27 in DxilShaderFlags) and map it to 0x40_0000 (ShaderFeatureInfo_AtomicInt64OnTypedResource) in SFI0 (crates/victory-shader/src/emit/shader.rs).
  • Support 64-bit image atomics (dmask == 3 for binary ops, dmask == 0xF for cmpswap) in crates/victory-shader/src/emit/lower.rs, declaring typed U64 resource properties (0x107), packing 2/4 VGPRs via pack64, emitting atomicBinOp.i64 / atomicCompareExchange.i64, and splitting glc results back into v[reg..reg+2].
  • Add unit test image_atomics_64_bit_lower_with_typed_int64_flag covering 64-bit image_atomic_add and image_atomic_cmpswap and verifying SFI0 feature bits.

Verification

  • cargo test -p victory-shader (57/57 passed on macOS; Windows dxil.dll validation and host D3D12 R32G32_UINT view mapping in victory-gpu not run)
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs crates/victory-shader/src/emit/shader.rs (ok)
  • cargo xtask policy (ok)
**@⁠tarcisioads** on GitHub · 2026-11-24 02:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/305) `tarcisioads:shader/image-atomics-64` → `main` · +179 −26 · 2 files · 1 commits · closed without merging Implement lowering for 64-bit `image_atomic_*` instructions in `victory-shader`: - Add `flags::ATOMIC_INT64_ON_TYPED_RESOURCE` (`1 << 27` in `DxilShaderFlags`) and map it to `0x40_0000` (`ShaderFeatureInfo_AtomicInt64OnTypedResource`) in `SFI0` (`crates/victory-shader/src/emit/shader.rs`). - Support 64-bit image atomics (`dmask == 3` for binary ops, `dmask == 0xF` for `cmpswap`) in `crates/victory-shader/src/emit/lower.rs`, declaring typed `U64` resource properties (`0x107`), packing 2/4 VGPRs via `pack64`, emitting `atomicBinOp.i64` / `atomicCompareExchange.i64`, and splitting `glc` results back into `v[reg..reg+2]`. - Add unit test `image_atomics_64_bit_lower_with_typed_int64_flag` covering 64-bit `image_atomic_add` and `image_atomic_cmpswap` and verifying `SFI0` feature bits. ### Verification - `cargo test -p victory-shader` (57/57 passed on macOS; Windows `dxil.dll` validation and host D3D12 `R32G32_UINT` view mapping in `victory-gpu` not run) - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs crates/victory-shader/src/emit/shader.rs` (ok) - `cargo xtask policy` (ok)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:36 +00:00
github-bot closed this pull request 2026-11-26 03:58:36 +00:00
Author
Owner

@⁠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.

**@⁠jeremygold02** on GitHub · 2026-11-24 02:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7120673719) 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](https://github.com/Marvisak/VIctory/blob/56f0072318e7549320414f144d0088b0d9296c37/crates/victory-shader/src/emit/mod.rs)); #305 adds focused lowerer coverage for the typed-resource flag ([lowering and test](https://github.com/Marvisak/VIctory/blob/038a36f996e58884288c4fe15c08070e4605bfee/crates/victory-shader/src/emit/lower.rs)). 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.
Author
Owner

@⁠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.

**@⁠r4tedx** on GitHub · 2026-11-24 03:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7120906024) 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.
Author
Owner

@⁠SpaghettiMaster545 on GitHub · 2026-11-24 03:20 UTC · original

Tested with the title 038a36f (this PR), against main and against #48 on the same machine.

  • NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the PR merged alone onto main d2a4bae, its own empty VICTORY_CACHE_DIR, scripted keys into story mode, until the host GPU failure (#71, unrelated), compared program by program with a main run made the same way.
  • In the main run, 14 pixel programs stop with a 64-bit image atomic.
  • With this PR: 0 programs stop with that reason; 9 of the 14 translate and their pipelines are made; 3 stop at a later reason; 2 were not reached in this run. 0 programs that ran on main stop.
  • The driver accepted every pipeline it made with this PR (115 refused, all pre-existing compute ones that main also has), so the missing heap-resource atomics flag that the DXIL validator reports (review above) did not make the NVIDIA driver refuse anything here.
  • For comparison, #48 under the same conditions: 0 programs stop with that reason, 10 of the 14 run, and 10 more pixel programs run that stopped on main with a scalar memory read as data (7) and a descriptor read only as data (3).

Not tested

  • AMD GPUs, a release build, the image results themselves (only translation and pipeline creation are compared).

(Claude Code, Claude Opus 5.5: ran the title on each build and compared the logs program by program.)

**@⁠SpaghettiMaster545** on GitHub · 2026-11-24 03:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7121003993) **Tested with the title** `038a36f` (this PR), against `main` and against #48 on the same machine. - NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the PR merged alone onto `main` `d2a4bae`, its own empty `VICTORY_CACHE_DIR`, scripted keys into story mode, until the host GPU failure (#71, unrelated), compared program by program with a `main` run made the same way. - In the `main` run, 14 pixel programs stop with `a 64-bit image atomic`. - With this PR: 0 programs stop with that reason; 9 of the 14 translate and their pipelines are made; 3 stop at a later reason; 2 were not reached in this run. 0 programs that ran on `main` stop. - The driver accepted every pipeline it made with this PR (115 refused, all pre-existing compute ones that `main` also has), so the missing heap-resource atomics flag that the DXIL validator reports (review above) did not make the NVIDIA driver refuse anything here. - For comparison, #48 under the same conditions: 0 programs stop with that reason, 10 of the 14 run, and 10 more pixel programs run that stopped on `main` with `a scalar memory read as data` (7) and `a descriptor read only as data` (3). **Not tested** - AMD GPUs, a release build, the image results themselves (only translation and pipeline creation are compared). (Claude Code, Claude Opus 5.5: ran the title on each build and compared the logs program by program.)
Author
Owner

@⁠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, base d2a4bae + #175 + #336:

vertex/pixel emitted validated Flags must match usage
base 12,284 12,184 0
+ this PR alone +524 +0 520 (528 with #54 also applied)

So 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 / Int64 ops?). 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.

**@⁠GamingRipperDoc** on GitHub · 2026-11-24 05:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7122947599) Validation data for this PR, from `victory translate <dump> --validate` (offline, dxil.dll validator) on Windows 10 + RX 9070 XT, base `d2a4bae` + #175 + #336: | | vertex/pixel emitted | validated | `Flags must match usage` | |---|---|---|---| | base | 12,284 | 12,184 | 0 | | + this PR alone | +524 | **+0** | **520** (528 with #54 also applied) | So 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 / `Int64` ops?). 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.
Author
Owner

@⁠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.dll rejects 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, but victory translate --validate fails 520 of them with:

validator: error: Flags must match usage.

Cause: the image's handle comes from createHandleFromHeap, and a 64-bit atomic on a descriptor-heap resource needs AtomicInt64OnDescriptorHeapResource as well as AtomicInt64OnTypedResource: ShaderFlags bit 32, SFI0 0x1000_0000. (#48 sets it too.)

Fix on top of this PR:

// shader.rs, mod flags
pub const ATOMIC_INT64_ON_HEAP_RESOURCE: u64 = 1 << 32;

// shader.rs, SFI0 features
if self.flags & flags::ATOMIC_INT64_ON_HEAP_RESOURCE != 0 {
    features |= 0x1000_0000;
}

// lower.rs, the wide branch
self.s.flags |= flags::INT64
    | flags::ATOMIC_INT64_ON_TYPED_RESOURCE
    | flags::ATOMIC_INT64_ON_HEAP_RESOURCE;

(plus features & 0x1000_0000 in the test's asserts).

Measured (translate --validate, dxil.dll from SDK 10.0.26100):

  • d2a4bae + this PR + #177, shaders.rpf only: 520 programs fail with "Flags must match usage"; no other new failures.
  • Same + the heap flag, whole package: validated goes from 21,983 (main) to 22,503 (+520), and "Flags must match usage" is gone.

The 133 remaining 64-bit-atomic programs now stop on later causes (104 "a scalar memory read as data", 23 barycentrics). With --pipelines on an RTX 5090 (driver 621.24), all emitted VS/PS and mesh pipelines are created.

**@⁠claude-GTA6** on GitHub · 2026-11-24 06:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7123500832) *From a tester working with Claude (AI-assisted); measured on my own machine.* The lowering looks right to me, but on my machine `dxil.dll` rejects 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, but `victory translate --validate` fails 520 of them with: ``` validator: error: Flags must match usage. ``` **Cause:** the image's handle comes from `createHandleFromHeap`, and a 64-bit atomic on a descriptor-heap resource needs `AtomicInt64OnDescriptorHeapResource` as well as `AtomicInt64OnTypedResource`: ShaderFlags bit 32, SFI0 `0x1000_0000`. (#48 sets it too.) **Fix** on top of this PR: ```rust // shader.rs, mod flags pub const ATOMIC_INT64_ON_HEAP_RESOURCE: u64 = 1 << 32; // shader.rs, SFI0 features if self.flags & flags::ATOMIC_INT64_ON_HEAP_RESOURCE != 0 { features |= 0x1000_0000; } // lower.rs, the wide branch self.s.flags |= flags::INT64 | flags::ATOMIC_INT64_ON_TYPED_RESOURCE | flags::ATOMIC_INT64_ON_HEAP_RESOURCE; ``` (plus `features & 0x1000_0000` in the test's asserts). **Measured** (`translate --validate`, dxil.dll from SDK 10.0.26100): - `d2a4bae` + this PR + #177, `shaders.rpf` only: 520 programs fail with "Flags must match usage"; no other new failures. - Same + the heap flag, whole package: validated goes from 21,983 (main) to 22,503 (+520), and "Flags must match usage" is gone. The 133 remaining 64-bit-atomic programs now stop on later causes (104 "a scalar memory read as data", 23 barycentrics). With `--pipelines` on an RTX 5090 (driver 621.24), all emitted VS/PS and mesh pipelines are created.
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/305#issuecomment-7126488625) 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

@⁠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 pack64 helper, the ATOMIC_INT64_ON_TYPED_RESOURCE flag and the test image_atomics_64_bit_lower_with_typed_int64_flag. The difference that matters is merge state: #705 merges cleanly with main today, 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).

**@⁠Exorion1er** on GitHub · 2026-11-24 09:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7127577280) #705 matches this PR almost line for line: 157 of its 158 added lines are identical, including the `pack64` helper, the `ATOMIC_INT64_ON_TYPED_RESOURCE` flag and the test `image_atomics_64_bit_lower_with_typed_int64_flag`. The difference that matters is merge state: #705 merges cleanly with `main` today, 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).
Author
Owner

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

Rebased onto main (ffe310e) and addressed the DXIL validator feedback:

  • Added flags::ATOMIC_INT64_ON_HEAP_RESOURCE (1 << 32 in ShaderFlags, 0x1000_0000 in SFI0) and set it alongside ATOMIC_INT64_ON_TYPED_RESOURCE for 64-bit image atomics in 78dae83.
  • Updated image_atomics_64_bit_lower_with_typed_int64_flag to assert 0x1000_0000 in SFI0 and pass Some(&st) to resource::track.
  • cargo test -p victory-shader (97 passed, 0 failed on macOS; dxil.dll validation still needs Windows).
**@⁠tarcisioads** on GitHub · 2026-11-24 11:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7129936364) Rebased onto `main` (`ffe310e`) and addressed the DXIL validator feedback: - Added `flags::ATOMIC_INT64_ON_HEAP_RESOURCE` (`1 << 32` in `ShaderFlags`, `0x1000_0000` in `SFI0`) and set it alongside `ATOMIC_INT64_ON_TYPED_RESOURCE` for 64-bit image atomics in `78dae83`. - Updated `image_atomics_64_bit_lower_with_typed_int64_flag` to assert `0x1000_0000` in `SFI0` and pass `Some(&st)` to `resource::track`. - `cargo test -p victory-shader` (97 passed, 0 failed on macOS; `dxil.dll` validation still needs Windows).
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/305#issuecomment-7131684384) 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

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

Tested 78dae83 head-to-head against #539 (719079f) on Windows 11 / Rust 1.98.1 / RTX 3050 (32.0.16.2124) + WARP + dxil.dll (full table posted on #539).

  • Passes: both clippy checks clean, victory-shader 121 passed / 0 failed, dxil.dll valid, and real 64-bit image_atomic_add GPU dispatch on a 1x1 R32G32_UINT UAV produces the exact 32→64-bit carry sum and glc old-value readback on RTX 3050 and WARP.
  • Two small gaps vs #539:
    1. image_atomic_* still calls self.handle(...) (lower.rs:3311), which caches by props.0 without props.1, so an image_get_resinfo followed by a 64-bit atomic on the same 2D UAV reuses the cached float4 (0x409) handle.
    2. In image_atomics_64_bit_lower_with_typed_int64_flag, 0xF044_1388 and 0xF040_1F88 set bit 7 (dlc=1) rather than bit 13 (glc=1), so the if cache.glc { split64 } return path isn't exercised by the test (nor Validator::validate).

AI-assisted; executed locally on RTX 3050 + WARP.

**@⁠WALID1618Y** on GitHub · 2026-11-24 17:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7138824923) Tested `78dae83` head-to-head against #539 (`719079f`) on Windows 11 / Rust `1.98.1` / RTX 3050 (`32.0.16.2124`) + WARP + `dxil.dll` (full table posted on #539). - **Passes:** both clippy checks clean, `victory-shader` 121 passed / 0 failed, `dxil.dll` valid, and real 64-bit `image_atomic_add` GPU dispatch on a 1x1 `R32G32_UINT` UAV produces the exact 32→64-bit carry sum and `glc` old-value readback on RTX 3050 and WARP. - **Two small gaps vs #539:** 1. `image_atomic_*` still calls `self.handle(...)` (`lower.rs:3311`), which caches by `props.0` without `props.1`, so an `image_get_resinfo` followed by a 64-bit atomic on the same 2D UAV reuses the cached `float4` (`0x409`) handle. 2. In `image_atomics_64_bit_lower_with_typed_int64_flag`, `0xF044_1388` and `0xF040_1F88` set bit 7 (`dlc=1`) rather than bit 13 (`glc=1`), so the `if cache.glc { split64 }` return path isn't exercised by the test (nor `Validator::validate`). _AI-assisted; executed locally on RTX 3050 + WARP._
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/305#issuecomment-7139636180) 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

@⁠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.

**@⁠justlovett0** on GitHub · 2026-11-24 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7141178742) **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.
Author
Owner

@⁠alessiodeia on GitHub · 2026-11-24 21:37 UTC · original

In-game data for 78dae83 on an RTX 2070 SUPER (Turing), driver 621.40, Windows 11: the 64-bit image atomic pipelines are created and run.

Tree: main ffe310e + #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.

  • Offline, on the 14 programs the run without this PR refused for a 64-bit image atomic: 11 emit and validate with dxil.dll (10 pixel, 1 compute). The other 3 stop later: 2 on barycentrics read directly and 1 on a descriptor's address or format read as data.
  • In the title: unusable programs 213 → 195, 9 recovered (counting only programs both runs loaded), 0 regressions, 0 refused pipelines, no device removal.
  • On top of #439 the only change needed was the lower::Parts initializer in this PR's test, which needs #439's target, console_cf and per_lane_only (crate::emit::Target::ANY from inside lower.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).

**@⁠alessiodeia** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/305#issuecomment-7145171296) **In-game data for `78dae83` on an RTX 2070 SUPER (Turing), driver 621.40, Windows 11: the 64-bit image atomic pipelines are created and run.** Tree: `main` `ffe310e` + #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. - Offline, on the 14 programs the run without this PR refused for `a 64-bit image atomic`: 11 emit and validate with `dxil.dll` (10 pixel, 1 compute). The other 3 stop later: 2 on `barycentrics read directly` and 1 on `a descriptor's address or format read as data`. - In the title: unusable programs 213 → 195, 9 recovered (counting only programs both runs loaded), **0 regressions**, 0 refused pipelines, no device removal. - On top of #439 the only change needed was the `lower::Parts` initializer in this PR's test, which needs #439's `target`, `console_cf` and `per_lane_only` (`crate::emit::Target::ANY` from inside `lower.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

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!305
No description provided.