Shaders: lower 64-bit shifts without INT64 #45

Open
scoresby13 wants to merge 1 commit from upstream-pr/45 into main
scoresby13 commented 2026-11-25 06:06:45 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by scoresby13 on 2026-11-25T05:48:01Z.


Summary

Lowers all six 64-bit scalar and vector shift instructions (s_lshl_b64, s_lshr_b64, s_ashr_i64, v_lshlrev_b64, v_lshrrev_b64, v_ashrrev_i64) in victory-shader using pure 32-bit DXIL operations on (lo, hi) dwords (shift64 + src64_dwords), removing flags::INT64 (SFI0 bit 0x8000 / Int64ShaderOps) from shaders that use 64-bit shifts.

Details

  • Masks shift counts with sh = shift & 31, wide = (shift & 32) != 0, and inv = 31 - sh, computing cross-dword carries via (lo >> 1) >> inv (Shl) and (hi << 1) << inv (LShr/AShr) so every 32-bit DXIL shift stays in 0..=31.
  • Preserves 64-bit operand modifier checks, inline constant and _i64 literal sign-extension, and scalar SCC updates.
  • Adds CPU-only SFI0 validation (shifts_64_bit_need_no_int64) and GPU/WARP tests (v_shift_64_matches_rdna2_without_int64, s_shift_64_matches_rdna2_without_int64) covering 126 (value, shift) pairs per instruction plus inline -1 and literal -100 cases.

Testing

  • cargo clippy --workspace --all-targets --locked -- -D warnings (passed)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (passed)
  • cargo xtask policy (asset policy: 169 files ok)
  • cargo test -p victory-shader --locked shift -- --nocapture (3 passed, 0 failed)

No game data was used. AI-assisted.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6598128194 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/45). Originally posted by [scoresby13](https://github.com/scoresby13) on 2026-11-25T05:48:01Z. --- ## Summary Lowers all six 64-bit scalar and vector shift instructions (`s_lshl_b64`, `s_lshr_b64`, `s_ashr_i64`, `v_lshlrev_b64`, `v_lshrrev_b64`, `v_ashrrev_i64`) in `victory-shader` using pure 32-bit DXIL operations on `(lo, hi)` dwords (`shift64` + `src64_dwords`), removing `flags::INT64` (`SFI0` bit `0x8000` / `Int64ShaderOps`) from shaders that use 64-bit shifts. ## Details - Masks shift counts with `sh = shift & 31`, `wide = (shift & 32) != 0`, and `inv = 31 - sh`, computing cross-dword carries via `(lo >> 1) >> inv` (`Shl`) and `(hi << 1) << inv` (`LShr`/`AShr`) so every 32-bit DXIL shift stays in `0..=31`. - Preserves 64-bit operand modifier checks, inline constant and `_i64` literal sign-extension, and scalar `SCC` updates. - Adds CPU-only `SFI0` validation (`shifts_64_bit_need_no_int64`) and GPU/WARP tests (`v_shift_64_matches_rdna2_without_int64`, `s_shift_64_matches_rdna2_without_int64`) covering 126 `(value, shift)` pairs per instruction plus inline `-1` and literal `-100` cases. ## Testing - `cargo clippy --workspace --all-targets --locked -- -D warnings` (passed) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (passed) - `cargo xtask policy` (`asset policy: 169 files ok`) - `cargo test -p victory-shader --locked shift -- --nocapture` (3 passed, 0 failed) No game data was used. AI-assisted.
futurepro62 commented 2026-11-25 07:06:30 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by futurepro62 on 2026-11-25T06:38:31Z.


Full-suite run on Windows, since this PR has no test report yet. Tested exact head b5dbeb6 (on its base 90b529f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (rust-toolchain.toml), DXC + dxil.dll 1.9.2602.17, debug.
  • cargo test --workspace --locked: 499 passed, 0 failed, 7 ignored (main 90b529f on this machine: 496 passed, 0 failed, 7 ignored).
  • cargo clippy --workspace --all-targets --locked -- -D warnings (the CI lint step): passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (the CI lint step): passed.
  • The new tests ran and passed: shifts_64_bit_need_no_int64, v_shift_64_matches_rdna2_without_int64, s_shift_64_matches_rdna2_without_int64.

Not tested

  • AMD (ztrx targets NVIDIA), a release build, the game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Zettrox/ztrx:comment:7155004754 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/45#issuecomment-7155004754). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T06:38:31Z. --- Full-suite run on Windows, since this PR has no test report yet. Tested exact head `b5dbeb6` (on its base `90b529f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (`rust-toolchain.toml`), DXC + dxil.dll 1.9.2602.17, debug. - `cargo test --workspace --locked`: **499 passed, 0 failed, 7 ignored** (main `90b529f` on this machine: 496 passed, 0 failed, 7 ignored). - `cargo clippy --workspace --all-targets --locked -- -D warnings` (the CI lint step): passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (the CI lint step): passed. - The new tests ran and passed: `shifts_64_bit_need_no_int64`, `v_shift_64_matches_rdna2_without_int64`, `s_shift_64_matches_rdna2_without_int64`. **Not tested** - AMD (ztrx targets NVIDIA), a release build, the game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/45:upstream-pr/45'
git switch 'upstream-pr/45'

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