Shaders: lower s_bitreplicate_b64_b32 in pure 32-bit DXIL #2081

Open
geiyiliyabumo wants to merge 1 commit from upstream-pr/2083 into main
geiyiliyabumo commented 2026-11-25 04:30:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T04:30:22Z.


Summary

  • Lowers GFX10 SOP1 instruction s_bitreplicate_b64_b32 (opcode 0x3b) in crates/victory-shader/src/emit/lower.rs using pure 32-bit DXIL (4-step 16-to-32 bit interleave + even | (even << 1) for low and high halves), writing the 2-dword scalar destination without enabling Int64 / WIDE_OPS and while preserving SCC.
  • Adds synthetic IR, DXIL-validation, and GPU execution tests in crates/victory-shader/src/emit/valu_tests.rs covering 8 bit patterns across both halves with both SCC = 0 and SCC = 1, verifying destination width and that Int64 is not set.

Verification

  • cargo xtask policy: passed
  • cargo clippy -p victory-shader --tests -- -D warnings: passed
  • cargo test -p victory-shader --lib s_bitreplicate with Microsoft dxil.dll: 2/2 passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)
  • Zero game files or game-derived data used (synthetic tests only).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597239017 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T04:30:22Z. --- ## Summary - Lowers GFX10 SOP1 instruction `s_bitreplicate_b64_b32` (opcode `0x3b`) in `crates/victory-shader/src/emit/lower.rs` using pure 32-bit DXIL (4-step 16-to-32 bit interleave + `even | (even << 1)` for low and high halves), writing the 2-dword scalar destination without enabling `Int64` / `WIDE_OPS` and while preserving `SCC`. - Adds synthetic IR, DXIL-validation, and GPU execution tests in `crates/victory-shader/src/emit/valu_tests.rs` covering 8 bit patterns across both halves with both `SCC = 0` and `SCC = 1`, verifying destination width and that `Int64` is not set. ## Verification - `cargo xtask policy`: passed - `cargo clippy -p victory-shader --tests -- -D warnings`: passed - `cargo test -p victory-shader --lib s_bitreplicate` with Microsoft `dxil.dll`: 2/2 passed on **AMD Radeon RX 9060 XT (RDNA4)** and **Microsoft Basic Render Driver (WARP)** - Zero game files or game-derived data used (synthetic tests only).
DenRakEiw commented 2026-11-25 05:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:36:22Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib s_bitreplicate_b64_b32_ — 2 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (s_bitreplicate_b64_b32_ir_and_dxil and s_bitreplicate_b64_b32_replicates_both_halves_and_preserves_scc)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean pure-32-bit DXIL lowering of s_bitreplicate_b64_b32 replicating both halves and preserving SCC, verified on RTX 5090 + WARP. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051919008 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#pullrequestreview-6051919008). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:36:22Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib s_bitreplicate_b64_b32_` — **2 passed, 0 failed** on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (`s_bitreplicate_b64_b32_ir_and_dxil` and `s_bitreplicate_b64_b32_replicates_both_halves_and_preserves_scc`) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean pure-32-bit DXIL lowering of `s_bitreplicate_b64_b32` replicating both halves and preserving SCC, verified on RTX 5090 + WARP. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:39:54Z.


Triage verdict — Confirmed duplicate of the bit-replicate change in #166 (fd1f5fa)

Evidence

  • @geiyiliyabumo and @n-romanovich split the same input into two halfwords and use the same four spreading masks and final OR to duplicate each input bit. Both write two SGPRs without changing SCC or requiring Int64. #166 is clean against current main and also adds three independent bit-set and reversal instructions. This lowering · #166 lowering

Checks and limits

  • Compared both exact-head implementations and fixtures. The existing #2083 review reports both focused tests passing with hardware, WARP, and DXIL validation. #166 has separate contributor readback evidence, including a native RDNA2 check of all four instruction rules. #2083 verification · #166 RDNA2 evidence

Next step

  • Maintainers could retain #166 and close this focused duplicate after carrying over the expanded input patterns, explicit SCC controls, and no-Int64 assertion. Preserve credit for both implementations and the earlier test work.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153051393 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#issuecomment-7153051393). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:39:54Z. --- **Triage verdict — Confirmed duplicate of the bit-replicate change in #166** (`fd1f5fa`) **Evidence** - @geiyiliyabumo and @n-romanovich split the same input into two halfwords and use the same four spreading masks and final OR to duplicate each input bit. Both write two SGPRs without changing SCC or requiring Int64. #166 is clean against current `main` and also adds three independent bit-set and reversal instructions. [This lowering](https://github.com/Marvisak/VIctory/pull/2083/files) · [#166 lowering](https://github.com/Marvisak/VIctory/pull/166/files) **Checks and limits** - Compared both exact-head implementations and fixtures. The existing #2083 review reports both focused tests passing with hardware, WARP, and DXIL validation. #166 has separate contributor readback evidence, including a native RDNA2 check of all four instruction rules. [#2083 verification](https://github.com/Marvisak/VIctory/pull/2083#pullrequestreview-6051919008) · [#166 RDNA2 evidence](https://github.com/Marvisak/VIctory/pull/166#issuecomment-7123513553) **Next step** - Maintainers could retain #166 and close this focused duplicate after carrying over the expanded input patterns, explicit SCC controls, and no-Int64 assertion. Preserve credit for both implementations and the earlier test work. This verification was AI-assisted.
upipibi commented 2026-11-25 05:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T04:41:35Z.


Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at fd1f5fa. victory-shader: 246 passed, 3 failed, 3 ignored; the new s_bitreplicate_b64_b32_ir_and_dxil and s_bitreplicate_b64_b32_replicates_both_halves_and_preserves_scc pass. The 3 failures are #1744's NVIDIA failures on main. Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153077639 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#issuecomment-7153077639). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T04:41:35Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `fd1f5fa`. `victory-shader`: 246 passed, 3 failed, 3 ignored; the new `s_bitreplicate_b64_b32_ir_and_dxil` and `s_bitreplicate_b64_b32_replicates_both_halves_and_preserves_scc` pass. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. Not run: a title. AI-assisted (Claude Code).
catminou4 commented 2026-11-25 06:02:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:09:19Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. s_bitreplicate_b64_b32 lowered in pure 32-bit DXIL — bit-replicate without i64.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052154393 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#pullrequestreview-6052154393). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:09:19Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. s_bitreplicate_b64_b32 lowered in pure 32-bit DXIL — bit-replicate without i64.
sinan-cmyk commented 2026-11-25 09:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:04:31Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head fd1f5fa2 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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157840295 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#issuecomment-7157840295). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:04:31Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head fd1f5fa2 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).
Marvisak commented 2026-11-25 11:05:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:31:54Z.


Automated triage for the maintainers.

This lowering of s_bitreplicate_b64_b32 in Lower (emit/lower.rs, the wide SOP1 arm) duplicates #166, which is still open. #166 makes the same change to the wide test, uses the same four-mask 16-bit spread with the final x | x << 1 for each half, and writes both SGPRs without touching SCC or needing Int64. It also lowers s_bitset0/1_b64 and s_brev_b64. I compared the two lowering hunks, and they match. The extra input patterns and the explicit SCC/no-Int64 assertions here would be welcome as test additions on #166. Reason for closing: duplicate of the broader open PR #166. the PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159823313 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2083#issuecomment-7159823313). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:31:54Z. --- <!-- victory-triage v1 head=fd1f5fa295c2a598e79574ed228f0c08770e2985 verdict=proposed-close at=2026-11-25T10:31:41Z --> Automated triage for the maintainers. This lowering of `s_bitreplicate_b64_b32` in `Lower` (`emit/lower.rs`, the wide SOP1 arm) duplicates #166, which is still open. #166 makes the same change to the `wide` test, uses the same four-mask 16-bit spread with the final `x | x << 1` for each half, and writes both SGPRs without touching SCC or needing Int64. It also lowers `s_bitset0/1_b64` and `s_brev_b64`. I compared the two lowering hunks, and they match. The extra input patterns and the explicit SCC/no-Int64 assertions here would be welcome as test additions on #166. Reason for closing: duplicate of the broader open PR #166. the PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. CI: passing. --- _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/2083:upstream-pr/2083'
git switch 'upstream-pr/2083'

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