Shaders: lower 64-bit shifts without INT64 #2133

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

@⁠scoresby13 on GitHub · 2026-11-25 05:46 UTC · original
scoresby13:shader/shift64-no-int64 → main · +325 −21 · 2 files · 1 commits · closed without merging

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.

Claimed on #1633.

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: 182 files ok)
  • cargo test -p victory-shader --locked shift -- --nocapture (4 passed, 0 failed)
  • cargo test -p victory-shader --locked signed_64_bit_operands_sign_extend_their_literal -- --nocapture (1 passed, 0 failed)

No game data was used. AI-assisted.

**@⁠scoresby13** on GitHub · 2026-11-25 05:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2133) `scoresby13:shader/shift64-no-int64` → `main` · +325 −21 · 2 files · 1 commits · closed without merging ## 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. Claimed on #1633. ## 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: 182 files ok`) - `cargo test -p victory-shader --locked shift -- --nocapture` (4 passed, 0 failed) - `cargo test -p victory-shader --locked signed_64_bit_operands_sign_extend_their_literal -- --nocapture` (1 passed, 0 failed) No game data was used. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:41 +00:00
github-bot closed this pull request 2026-11-26 04:55:41 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 08:24 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 670c441f onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 08:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2133#issuecomment-7156995717) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 670c441f onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:49 UTC · original

Automated triage for the maintainers.

Merge candidate. This lowers s_lshl/lshr/ashr_b64 and v_lshlrev/lshrrev/ashrrev_b64 on 32-bit dword pairs (Lower::shift64, src64_dwords), so these shaders no longer need Int64ShaderOps. That follows the earlier v_perm_b32 and v_sad changes in main. I checked the arithmetic:

  • Every 32-bit shift amount stays in 0..=31.
  • The carry (lo >> 1) >> (31 - sh) / (hi << 1) << (31 - sh) is 0 at sh == 0.
  • When bit 5 is set the result selects the other dword, with sign fill for ashr.
  • The operands are sign-extended the same way as src64.

CI passes, and the offline count on the retail shaders is unchanged. One optional cleanup: src64 could build on src64_dwords so the operand rules live in one place.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2133#issuecomment-7160215239) <!-- victory-triage v1 head=670c441fc9e96b56ea4734f2b2ec9ae9cf97235a verdict=merge-candidate at=2026-11-25T10:48:53Z --> Automated triage for the maintainers. Merge candidate. This lowers `s_lshl/lshr/ashr_b64` and `v_lshlrev/lshrrev/ashrrev_b64` on 32-bit dword pairs (`Lower::shift64`, `src64_dwords`), so these shaders no longer need `Int64ShaderOps`. That follows the earlier v_perm_b32 and v_sad changes in main. I checked the arithmetic: - Every 32-bit shift amount stays in 0..=31. - The carry `(lo >> 1) >> (31 - sh)` / `(hi << 1) << (31 - sh)` is 0 at `sh == 0`. - When bit 5 is set the result selects the other dword, with sign fill for `ashr`. - The operands are sign-extended the same way as `src64`. CI passes, and the offline count on the retail shaders is unchanged. One optional cleanup: `src64` could build on `src64_dwords` so the operand rules live in one place. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:05 UTC · original

Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because it adds no capability the project needs. The arithmetic is right and the tests pass on hardware and WARP. But the title needs Int64 on the host anyway (64-bit compares, 64-bit image atomics, and flags::INT64 is set in four other places), and every SM 6.6 host has it. Merging would retranslate about 9,800 title sites, turning each native 64-bit shift into about ten 32-bit operations, and add a near-copy of src64. If the project ever decides that emitted DXIL must avoid Int64, this is a correct starting point.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 22:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2133#issuecomment-7175931851) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because it adds no capability the project needs. The arithmetic is right and the tests pass on hardware and WARP. But the title needs Int64 on the host anyway (64-bit compares, 64-bit image atomics, and `flags::INT64` is set in four other places), and every SM 6.6 host has it. Merging would retranslate about 9,800 title sites, turning each native 64-bit shift into about ten 32-bit operations, and add a near-copy of `src64`. If the project ever decides that emitted DXIL must avoid Int64, this is a correct starting point. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

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