Shaders: lower s_ff0_i32_b32 and s_ff0_i32_b64 in pure 32-bit DXIL #2061
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2063"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T04:19:31Z.
Summary
s_ff0_i32_b32(opcode0x11) ands_ff0_i32_b64(opcode0x12) incrates/victory-shader/src/emit/lower.rsusing pure 32-bit DXIL (FirstbitLoon inverted source dword(s)), matchings_ff1_i32_b32ands_ff1_i32_b64without enablingInt64/WIDE_OPS.SCCacross both instructions and applies the same numeric lane-mask guard in pixel/vertex shaders ass_ff1_i32_*(since a shorter host wave can change the lowest clear bit).crates/victory-shader/src/emit/valu_tests.rscovering all boundary inputs for 32-bit and 64-bit operands with bothSCC = 0andSCC = 1, verifyingInt64is not set.Verification
cargo xtask policy: passedcargo clippy -p victory-shader --tests -- -D warnings: passedcargo test -p victory-shader --lib scalar_ff0with Microsoftdxil.dll: 2/2 passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP)Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:31:13Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib scalar_ff0_— 2 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1(scalar_ff0_reads_the_source_width_and_writes_only_one_sgprandscalar_ff0_finds_the_lowest_clear_bit_and_preserves_scc)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean pure-32-bit DXIL lowering of
s_ff0_i32_b32ands_ff0_i32_b64preserving SCC, verified on hardware and WARP. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:33:50Z.
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_ff0_i32_b32/b64 lowered in pure 32-bit DXIL — ff0 find-first-zero for 32/64-bit.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:28:00Z.
Triage verdict — Keep the focused FF0 change and reconcile #148’s overlap (
d1d33ea)Evidence
main. Focused lowering · #148 patchChecks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T04:41:37Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
d1d33ea.victory-shader: 246 passed, 3 failed, 3 ignored; the newscalar_ff0_reads_the_source_width_and_writes_only_one_sgprandscalar_ff0_finds_the_lowest_clear_bit_and_preserves_sccpass. The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:24:43Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
d1d33eaaontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:25:34Z.
Automated triage for the maintainers.
Merge candidate.
This lowers
s_ff0_i32_b32ands_ff0_i32_b64(crates/victory-shader/src/emit/lower.rs,Lower::soparms) as first-bit-low of the complemented source dword(s). It reuses the existings_ff1_*paths, so the result is -1 when there is no clear bit, the b64 form adds 32 for a match in the high half, and no Int64 is needed. Checked against main:gfx10/opcodes.rsalready decodes 0x11 and 0x12, andgfx10/fields.rsreads the 64-bit source.Lower::inst, which is right because missing high lanes would read as clear bits. The added comment sits inside thatmatchwithout a matching name, which reads oddly. A rewording would help but is not a blocker.#148 and #1684 also lower s_ff0 among other instructions, but both conflict with main. This one merges cleanly. The retail-dump comparison above shows no program changes, so this adds a capability the current title does not use. Recommending a look, not approving.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:42:40Z.
Code review and RTX 5090 + WARP + DXIL verification at head
d1d33eaaf030merged cleanly ontomain(63bcca43c6a0;emit/lower.rs=521,062B,3,226B under the 512 KiB cap):crates/victory-shader/src/emit/lower.rs:3509-3511, 3737-3760, 3930-3941):s_ff0_i32_b32inverts viaXor u32::MAX+ DXILFirstbitLo(op 32), mapping0 -> 0andu32::MAX -> -1without touchingSCC.s_ff0_i32_b64splits into two 32-bitFirstbitLocalls (pure 32-bit DXIL, noInt64SFI0 flag), adding32when only the high word has a zero bit, andmask_okproperly excludess_ff0_i32_*fromMaskData::Host.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy(default +--features diagnostics): 0 warningsscalar_ff0(2/2),emit::lower::tests(33/33), andemit::semantics_tests(34/34 on both RTX 5090 and WARP, 1 ignored) all passed.LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.