Shaders: a 64-bit texture add carries out of the low dword #3133

Open
FoxxoOwO wants to merge 1 commit from upstream-pr/3135 into main
FoxxoOwO commented 2026-11-26 09:42:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by FoxxoOwO on 2026-11-26T09:42:28Z.


Split out of #2241 as its triage asked: the lowering that PR described is already on main (commit 0b35b7f), and image_atomics_of_64_bits already covers umax, swap and cmpswap. What that test does not cover is an add: the R32G32 view's two dwords are one i64, so the adds every lane makes to one texel carry into the high dword instead of wrapping in place the way two separate 32-bit atomics would.

  • Built with the existing image_atomic and lower_cs32 helpers, not new ones.
  • No rustfmt-only churn in unrelated tests.
  • No cmpswap test (already covered).
  • Checked on hardware and WARP: cargo test -p victory-shader wide_image_atomic_add passes on both.

#2241 can be closed.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6623836240 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3135). Originally posted by [FoxxoOwO](https://github.com/FoxxoOwO) on 2026-11-26T09:42:28Z. --- Split out of #2241 as its triage asked: the lowering that PR described is already on `main` (commit `0b35b7f`), and `image_atomics_of_64_bits` already covers umax, swap and cmpswap. What that test does not cover is an add: the R32G32 view's two dwords are one i64, so the adds every lane makes to one texel carry into the high dword instead of wrapping in place the way two separate 32-bit atomics would. - Built with the existing `image_atomic` and `lower_cs32` helpers, not new ones. - No rustfmt-only churn in unrelated tests. - No cmpswap test (already covered). - Checked on hardware and WARP: `cargo test -p victory-shader wide_image_atomic_add` passes on both. #2241 can be closed.
smaxxey commented 2026-11-26 10:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by smaxxey on 2026-11-26T10:02:47Z.


Ran this on an RTX 4060 Laptop GPU (Ada, driver 32.0.16.1742), Windows 11 26300, Rust 1.98.1. No game files. Head 9e22db3 merged locally onto main 63bcca4, then cargo test -p victory-shader --lib --locked -- --test-threads=1 --nocapture image_atomic, three runs.

  • wide_image_atomic_add: ok in 3 of 3, on the hardware device and on WARP (no "skipped" line, so the hardware path ran and this card takes the 64-bit typed atomics in the heap).
  • image_atomics_of_64_bits: ok in 3 of 3.

The test does tell a carry from a wrap: the expected texel is [0xFFFFFBE0, 63], so an add that wrapped within the low dword would leave the high dword at 0 and fail.

Tested with Claude Code's help.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188834754 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3135#issuecomment-7188834754). Originally posted by [smaxxey](https://github.com/smaxxey) on 2026-11-26T10:02:47Z. --- Ran this on an **RTX 4060 Laptop GPU** (Ada, driver 32.0.16.1742), Windows 11 26300, Rust 1.98.1. No game files. Head `9e22db3` merged locally onto `main` 63bcca4, then `cargo test -p victory-shader --lib --locked -- --test-threads=1 --nocapture image_atomic`, three runs. - `wide_image_atomic_add`: ok in 3 of 3, on the hardware device and on WARP (no "skipped" line, so the hardware path ran and this card takes the 64-bit typed atomics in the heap). - `image_atomics_of_64_bits`: ok in 3 of 3. The test does tell a carry from a wrap: the expected texel is `[0xFFFFFBE0, 63]`, so an add that wrapped within the low dword would leave the high dword at 0 and fail. Tested with Claude Code's help.
Dukestar69 commented 2026-11-26 13:04:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T12:31:53Z.

Review: APPROVED


Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib image_atomic -- --test-threads=1: 2/2 passed on RTX 5090 and WARP (including wide_image_atomic_add).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Clean synthetic GPU test verifying 64-bit texture atomic add carry-out from the low dword.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6074167902 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3135#pullrequestreview-6074167902). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T12:31:53Z. **Review:** APPROVED --- Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib image_atomic -- --test-threads=1`: 2/2 passed on RTX 5090 and WARP (including `wide_image_atomic_add`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Clean synthetic GPU test verifying 64-bit texture atomic add carry-out from the low dword. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3135:upstream-pr/3135'
git switch 'upstream-pr/3135'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3135'
git switch 'upstream-pr/3135'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3135'
git switch 'upstream-pr/3135'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3135'
git switch 'main'
git merge --squash 'upstream-pr/3135'
git switch 'main'
git merge --ff-only 'upstream-pr/3135'
git switch 'main'
git merge 'upstream-pr/3135'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3133
No description provided.