Shaders: apply v_mov_b32 and v_cndmask_b32 abs/neg modifiers bitwise #1275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1275"
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 Sakura-Byte on 2026-11-24T17:01:17Z.
Fixes #883.
Summary
raw_src/src_bits(crates/victory-shader/src/emit/lower.rs): Reads source operand raw bits (preserving DPP cross-lane inputs and SDWA selection) and appliesabs(& 0x7FFF_FFFF) andneg(^ 0x8000_0000) bitwise, while keepingsrc()rejecting modifiers on integer ALU instructions.v_mov_b32andv_cndmask_b32: Usessrc_bitsonv_cndmask_b32and onv_mov_b32whenclampandomodare unset, preserving exact bit patterns across denormals,+-0.0, infinities, andsNaN/qNaNpayloads instead of quieting or flushing via float operations.v_mov_b32withclamporomodcontinues to take the float output modifier path.crates/victory-shader/src/emit/valu_tests.rs): Addedv_mov_b32_bitwise_abs_and_neg,v_mov_b32_sdwa_and_dpp_apply_bitwise_abs_and_neg, andv_cndmask_b32_applies_abs_and_neg_bitwiseacross 16 floating-point bit patterns, SDWA byte sign-extension + neg, VOP3 clamp/omod, and DPP bitwise lowering inspection (Module::func_names/Module::inst_linesandLowered::op_names/Lowered::insts).Verification
Ran cleanly on clean
origin/main(ffe310e):cargo xtask policy:asset policy: 154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)VICTORY_D3D12_WARP=1 VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:123 passed; 0 failed; 1 ignored(including all16 passed; 0 failedinemit::valu_tests, with only the existing release-only benchmarkemit::bitcode::tests::bench_writeignored;dxil.dllvalidation ran;v_mov_b32_dppvalidates DXIL and checks bitwisebin:Xor/bin:Andwithoutdx.op.unary.f32, executing when aWaveSize(32)compute PSO is supported).AI-assisted; synthetic tests only, zero game assets.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:06:55Z.
Review: APPROVED
v_mov_b32/v_cndmask_b32 abs/neg modifiers now apply bitwise (And 0x7FFFFFFF / Xor 0x80000000) instead of routing through the float path or erroring — matches the ISA (integer modifiers, denormal/NaN payload preserving). src() keeps rejecting modifiers for integer ops; src_bits is used only where the ISA defines them. SDWA/DPP raw-source preservation is kept via raw_src. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed; the three new tests are valu_tests (Windows-gated), so execution semantics need a Windows run — the bitwise construction itself is straightforward.Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T19:12:54Z.
On an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
2d44b99,cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 122 passed, 1 failed:The values are fine: in each
run_casesthe hardware leg runs first, and it passed every case. The failure comes from the test's gate.dpp_neg) declaresWaveSize(32)(waveReadLaneAt/waveGetLaneIndexin the dump).can_run_dpponly asks whether the hardware adapter can make that pipeline, andrun_casesthen runs it on hardware and WARP.CreateComputePipelineStatereturnsE_INVALIDARG.The fix is a per-host wave-size check like
run_cases_with_wave_sizein #1412/#1416, or checkingcompute_pipelinefor each host inside the loop instead of once for the hardware.Imported from Marvisak/VIctory. Originally posted by Sakura-Byte on 2026-11-24T19:48:32Z.
Thank you @marquezinii for catching that and pinning down the exact cause! You were right: the old
can_run_dpppre-check only probed the hardware adapter and then ranrun_casesunconditionally across both hardware and 4-lane WARP, hittingE_INVALIDARGon WARP'sCreateComputePipelineStatefor theWaveSize(32)DPP shader.Fixed in commit
cdbe178(cdbe1789185578baa7130eae642f4fec58287687) incrates/victory-shader/src/emit/valu_tests.rs:run_casesintorun_cases_withand addedrun_cases_if_supported, which checkshost.compute_pipeline(shader)per host inside the("hardware", false)/("warp", true)loop and skips only hosts whose wave size refuses to build the pipeline (instead of panicking on WARP while still asserting that at least one SM 6.6 device was found).v_mov_b32_dppexecution check inv_mov_b32_sdwa_and_dpp_apply_bitwise_abs_and_negtorun_cases_if_supported.Re-verified on
cdbe178(Windows 11, NVIDIA GeForce RTX 5090 D + WARP):cargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings(default and--all-features):0warningscargo test -p victory-shader --locked --lib -- --test-threads=1(with hardware + WARP): 123 passed, 0 failed, 1 ignored (v_mov_b32_sdwa_and_dpp_apply_bitwise_abs_and_negexecuted and passed all 16 cases on RTX 5090 D while cleanly skipping 4-lane WARP)VICTORY_WARP=1 VICTORY_D3D12_WARP=1 cargo test -p victory-shader --locked --lib -- --test-threads=1 v_mov_b32_sdwa_and_dpp_apply_bitwise_abs_and_neg: 1 passed, 0 failedAI-assisted; synthetic tests only, zero game assets.
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T19:55:53Z.
Confirmed at
cdbe178on the same RTX 5070 (driver 621.40, Windows 11 26300, Rust 1.98.1).cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 123 passed, 0 failed, 1 ignored. Inv_mov_b32_sdwa_and_dpp_apply_bitwise_abs_and_negthe DPP check runs on the hardware adapter and passes, and WARP now printscompute_pipeline unsupported ...; skippedinstead of failing.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:20:51Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
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.