Shaders: lower 64-bit texture atomics to DXIL i64 atomics #1897

Open
TansuoTro wants to merge 1 commit from upstream-pr/1899 into main
TansuoTro commented 2026-11-25 00:21:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TansuoTro on 2026-11-25T00:21:27Z.


Summary

Implements 64-bit image atomics (image_atomic_* with dmask=3, or xF for cmpswap), which previously stopped shader translation at emit/lower.rs.

  • Lowers to DXIL SM 6.6 dx.op.atomicBinOp.i64 / dx.op.atomicCompareExchange.i64 (opcodes 78/79) on the heap texture handle; supports add/sub/and/or/xor/smin/smax/umin/umax/swap/cmpswap, with glc returning the old 64-bit value via split registers.
  • Sets the required Int64, AtomicInt64OnTypedResource and AtomicInt64OnHeapResource shader flags / SFI0 feature bits (verified against DXC's DxilShaderFlags.h).
  • Documents the R32G32_UINT host-view contract; adds a Uint64TextureUav test view.
  • Adds a synthetic MIMG test covering all 11 operations plus 32-bit regressions, validated with dxil.dll when available (skips cleanly otherwise).

Verification

  • cargo test --workspace -q: pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass
  • dxil.dll validation of all generated 64-bit/32-bit atomic shaders: pass

Tested on Game

<!-- greyfinch-sync:Marvisak/VIctory:issue:6594210784 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1899). Originally posted by [TansuoTro](https://github.com/TansuoTro) on 2026-11-25T00:21:27Z. --- ## Summary Implements 64-bit image atomics (image_atomic_* with dmask=3, or xF for cmpswap), which previously stopped shader translation at `emit/lower.rs`. - Lowers to DXIL SM 6.6 `dx.op.atomicBinOp.i64` / `dx.op.atomicCompareExchange.i64` (opcodes 78/79) on the heap texture handle; supports add/sub/and/or/xor/smin/smax/umin/umax/swap/cmpswap, with glc returning the old 64-bit value via split registers. - Sets the required Int64, AtomicInt64OnTypedResource and AtomicInt64OnHeapResource shader flags / SFI0 feature bits (verified against DXC's DxilShaderFlags.h). - Documents the R32G32_UINT host-view contract; adds a `Uint64TextureUav` test view. - Adds a synthetic MIMG test covering all 11 operations plus 32-bit regressions, validated with `dxil.dll` when available (skips cleanly otherwise). ## Verification - `cargo test --workspace -q`: pass - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass - `dxil.dll` validation of all generated 64-bit/32-bit atomic shaders: pass Tested on Game
catminou4 commented 2026-11-25 01:07:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T00:32:49Z.

Review: COMMENTED


Mixed PR: shader/formats parts are macOS-tested in the batch; GPU/HLE parts are Windows-only statics.

64-bit texture atomics lowered to DXIL i64 atomics: gpu+shader mixed — shader part tested in batch, DXIL emission Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049697801 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1899#pullrequestreview-6049697801). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T00:32:49Z. **Review:** COMMENTED --- Mixed PR: shader/formats parts are macOS-tested in the batch; GPU/HLE parts are Windows-only statics. 64-bit texture atomics lowered to DXIL i64 atomics: gpu+shader mixed — shader part tested in batch, DXIL emission Windows-only.
upipibi commented 2026-11-25 01:07:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T00:26:51Z.


Heads-up from reading, not a run: this PR's base (ffe310e) predates 0b35b7f on main, which already lowers 64-bit image atomics. The R32G32_UINT view uses the low dword in R and the data as an i64. sub is done as add of the negation. It sets flags::INT64 | ATOMIC64_TYPED | ATOMIC64_HEAP (emit/lower.rs around line 7718), and valu_tests.rs has image_atomics_of_64_bits. GitHub reports this PR as conflicting with main now.

If something here isn't in main (the Uint64TextureUav test view, or an op main refuses), rebasing it down to that part would keep it reviewable.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148518902 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1899#issuecomment-7148518902). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T00:26:51Z. --- Heads-up from reading, not a run: this PR's base (`ffe310e`) predates 0b35b7f on `main`, which already lowers 64-bit image atomics. The `R32G32_UINT` view uses the low dword in R and the data as an i64. `sub` is done as add of the negation. It sets `flags::INT64 | ATOMIC64_TYPED | ATOMIC64_HEAP` (`emit/lower.rs` around line 7718), and `valu_tests.rs` has `image_atomics_of_64_bits`. GitHub reports this PR as conflicting with `main` now. If something here isn't in `main` (the `Uint64TextureUav` test view, or an op `main` refuses), rebasing it down to that part would keep it reviewable. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 03:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:17:50Z.


Automated triage for the maintainers.

This pull request does not merge cleanly into main. Conflicting files: crates/victory-gpu/src/descriptor/host.rs, crates/victory-shader/src/emit/host.rs, crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/mod.rs, crates/victory-shader/src/emit/shader.rs, crates/victory-shader/src/emit/valu_tests.rs.

It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150546921 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1899#issuecomment-7150546921). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:17:50Z. --- <!-- victory-triage v1 head=de9ca0c3842aae4b40f6917acae01cb67573467b verdict=needs-rebase at=2026-11-25T02:15:48Z --> Automated triage for the maintainers. This pull request does not merge cleanly into `main`. Conflicting files: `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-shader/src/emit/host.rs`, `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/mod.rs`, `crates/victory-shader/src/emit/shader.rs`, `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/1899:upstream-pr/1899'
git switch 'upstream-pr/1899'

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/1899'
git switch 'upstream-pr/1899'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1899'
git switch 'upstream-pr/1899'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1899'
git switch 'main'
git merge --squash 'upstream-pr/1899'
git switch 'main'
git merge --ff-only 'upstream-pr/1899'
git switch 'main'
git merge 'upstream-pr/1899'
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!1897
No description provided.