Shaders: lower 64-bit shifts without INT64 #726

Open
scoresby13 wants to merge 1 commit from upstream-pr/726 into main
scoresby13 commented 2026-11-25 05:47:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by scoresby13 on 2026-11-25T05:47:32Z.


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 -p victory-shader --all-targets --locked -- -D warnings (passed)
  • cargo clippy -p victory-shader --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:fxceless/victory-fork:issue:6598121866 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/726). Originally posted by [scoresby13](https://github.com/scoresby13) on 2026-11-25T05:47:32Z. --- ## 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 -p victory-shader --all-targets --locked -- -D warnings` (passed) - `cargo clippy -p victory-shader --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.
HAL9000RELOADED commented 2026-11-25 13:06:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T13:00:20Z.


An AMD run of this PR's new tests. v_shift_64_matches_rdna2_without_int64 and s_shift_64_matches_rdna2_without_int64 pass, and so does the CPU-side shifts_64_bit_need_no_int64 on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with the Agility SDK runtime from #402. They ran on the hardware device; WARP skips on this machine. Nothing else in the workspace regresses.

The setup, and the same run for eight related shader PRs, are in one table on #637: https://github.com/fxceless/victory-fork/pull/637#issuecomment-7163143604

<!-- greyfinch-sync:fxceless/victory-fork:comment:7163156358 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/726#issuecomment-7163156358). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T13:00:20Z. --- An AMD run of this PR's new tests. `v_shift_64_matches_rdna2_without_int64` and `s_shift_64_matches_rdna2_without_int64` pass, and so does the CPU-side `shifts_64_bit_need_no_int64` on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with the Agility SDK runtime from #402. They ran on the hardware device; WARP skips on this machine. Nothing else in the workspace regresses. The setup, and the same run for eight related shader PRs, are in one table on #637: https://github.com/fxceless/victory-fork/pull/637#issuecomment-7163143604
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/726:upstream-pr/726'
git switch 'upstream-pr/726'

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