Skip to content

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

Open
geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:feat/shader-s-bitreplicate
Open

geiyiliyabumo wants to merge 1 commit into
Marvisak:mainfrom
geiyiliyabumo:feat/shader-s-bitreplicate

Conversation

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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

Evidence

Checks and limits

Next step

This verification was AI-assisted.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

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

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants