shader: lower packed dot products to DXIL dot4AddPacked and fmad #75
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/75"
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 Zettrox/ztrx. Originally posted by UnkwnDev on 2026-11-25T08:25:12Z.
Adds hardware-accelerated packed dot-product lowering to
victory-shader(crates/victory-shader/src/emit/dot.rs, hooked intolower.rs):v_dot4_i32_i8,v_dot4c_i32_i8, andv_dot4_u32_u8directly to SM 6.4@dx.op.dot4AddPacked.i32(opcodes 163 / 164), supportingop_sel/op_sel_hihalf-selection onv_dot4_i32_i8/v_dot4_u32_u8andv.clampsaturation. Improves SM 6.4 hardware DP4a utilization on NVIDIA RTX and Intel Arc GPUs.v_dot2_f32_f16andv_dot2c_f32_f16vialegacyF16ToF32and chained fused multiply-adds (fmad/tertiary.f32) matching RDNA2 rounding, honoring both VOP3P (opsel/opsel_hi/neg_hi) and VOP2 encodings plusv.clamp/v.omod.v_dot2_i32_i16,v_dot2_u32_u16(viapacked_srcwithopsel/opsel_hi), andv_dot8_u32_u4, with exact saturation whenv.clampis set.emit::valu_tests::packed_dot_products_and_clamps_execute_cleanlycovering all instructions, modifiers, and saturating clamps on both hardware GPU and WARP.Testing
cargo clippy -p victory-shader --all-targets --locked -- -D warnings: passedcargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: passedcargo test -p victory-shader --locked packed_dot_products_and_clamps_execute_cleanly -- --test-threads=1: 1 passed, 0 failedcargo test -p xtask --locked: 4 passed, 0 failed (repository_passes_policy)AI use
dot.rsand verifying hardware/WARP execution and CI checks.Imported from Zettrox/ztrx. Originally posted by IIKurumiII on 2026-11-25T09:04:01Z.
Tested commit
2c6ba52on an NVIDIA RTX 3060, driver621.24, Windows 11 Home build26300.9711.packed_dot_products_and_clamps_execute_cleanlypassed on both the GPU and WARP, with no device skips. This was a shader correctness test only. I didn’t measure in-game performance.Imported from Zettrox/ztrx. Originally posted by Aniseto on 2026-11-25T15:29:02Z.
Ran the packed dot-product test at
2c6ba52(clean PR head onmain90b529f):System
rust-toolchain.toml), MSVC 14.44.35207, DXIL validator 1.9.2609.5 (VICTORY_DXIL), debug buildResults
cargo test --locked -p victory-shader --lib packed_dot_products_and_clamps_execute_cleanly -- --nocapture: 1 passed, 0 failed, 0 ignored, 212 filtered out (exit 0), with no device skip under--nocapturecargo test --locked -p victory-shader --lib -- --test-threads=1: 211 passed, 0 failed, 2 ignored (exit 0)What this adds
The existing report in the thread is an RTX 3060 (Ampere). This adds a Blackwell wave32 part on driver 32.0.16.2124 with DXIL validator 1.9.2609.5; the packed-dot test, which executes on the host GPU and WARP, passes here.
Not tested
The title's shader pack, live pipeline creation, retail runs, a separate Intel Arc control lane, the console compiler's DXC, release profile, AMD GPUs.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from Zettrox/ztrx. Originally posted by UnkwnDev on 2026-11-25T15:40:07Z.
Updated in
db7f615with three fixes from downstream review and Intel Arc A770 hardware testing (thanks @IIKurumiII and @Aniseto for testing on RTX 3060 / 5070 Ti):v_dot2_f32_f16wherefsrcalready negatedsrc2whenv.neg[2]was set, restricting explicitv.neg >> 2negation tov_dot2c_f32_f16.Module::eval_u32andLower::dot4_packed/Lower::dot4_constso constant multiplicands inv_dot4_i32_i8,v_dot4_u32_u8, andv_dot4c_i32_i8expand in scalar arithmetic rather than passing constants todx.op.dot4AddPacked, avoiding Intel Arc IGC's 16-bit constant broadcast miscompilation.packed_dot_products_and_clamps_execute_cleanlyinvalu_tests.rsand added assertions for negatedv_dot2_f32_f16accumulators (2.0,-4.0), f16 denormals (0x0001,0x03FF), and constant dot4 multiplicands.Verified on Intel Arc A770 + WARP after the final edit:
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: exit 0cargo test -p victory-shader --lib -- --test-threads=1: 211 passed, 0 failed, 2 ignoredcargo test -p xtask --locked: 4 passed, 0 failedView 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.