Repository navigation
Shaders: zero-extend unsigned 24-bit operands with one mask - #3632
Ingenioeren wants to merge 1 commit into
Conversation
|
I resolved the overlap between With #2926's test alone on The unsigned unclamped DXIL counts still match 19 for MUL, 23 for MUL_HI and 22 for MAD. The signed counts still match 21, 25 and 24. I got 36 VALU, 35 semantics and 34 lowerer tests passing, with one semantics test ignored. Strict all-feature shader Clippy passed. The branch preserves both PR commits. AI-assisted with Codex. |
|
WARP-only independent verification of #3632 (no GPU used) Claim: #1633 (comment) Revisions: PR head Setup: Windows 11, Base Control on base (PR test changes only, no
Merged
Diff review (all hunks in
AI-assisted: Claude Sonnet 5.5. No game files, dumps, install paths, shader names or retail hashes were used or are included. |
|
I updated the combined branch for your exact The same minimal fixtures now emit 21 unsigned and 23 signed MAD instructions, down from 22 and 24 in the earlier combined tree. Each multiply and high-multiply count stays at its previous budget. WARP with Agility 1.620.2 passed 34 lowerer, 36 VALU and 36 semantics tests, with one existing ignored test. The clamped regression and all 726 generated full-width addend cases per MAD opcode passed. Strict all-feature shader Clippy and the asset policy passed. @Ingenioeren, this branch is ready for merge coordination with #2926 and #3731. Please retain the original Git authors when rebasing or cherry-picking. If folding my changes into another commit, please add AI-assisted with OpenAI Codex. |
The unsigned 24-bit multiply forms zero-extend each operand with a left shift followed by a logical right shift. Masking with
0x00FF_FFFFdoes the same work in one instruction. Share the operand extension between the multiply, high-product and multiply-add arms; signed forms keep their arithmetic shifts, and the MAD addend remains a full dword.v_mul_u32_u24(VOP2 and VOP3)v_mul_hi_u32_u24(VOP2 and VOP3)v_mad_u32_u24These are emitted DXIL instruction counts for a shader with runtime inputs and a UAV result, including setup and terminators. The corresponding signed forms remain at 21, 25 and 24. GPU execution time was not benchmarked.
Validation on Windows, RX 6750 XT and WARP, based on
63bcca4:cargo test --locked --offline -p victory-shader unsigned_24_bit_operands_use_one_mask_each -- --nocapture: failed with tests alone on the old lowering (21/25/24 against 19/23/22 budgets); passes with the mask lowering.cargo test --locked --offline -p victory-shader multiplies_of_24_bits_ignore_the_upper_byte -- --nocapture: passes before and after. Ten synthetic signed/unsigned instruction encodings each run 4,580 inputs per adapter, with zero CPU-reference mismatches or hardware/WARP disagreements. Cases cover 24-bit sign boundaries, nonzero upper bytes, maximum products and full-width wrapping addends.cargo test --locked --offline -p victory-shader 24_bit -- --nocapture: 3 passed.cargo test --locked --offline -p victory-shader: baseline 300 passed / 2 failed / 3 ignored; final 302 passed / the same 2 failed / 3 ignored. Both failures (emit::rect::tests::rectangles_get_their_fourth_cornerandemit::tests::elements_sharing_a_row_keep_their_order) report the same localdxil.dllPipeline State Validation mismatch on both revisions.cargo test --locked --offline -p victory-shader --test resource_tracking: 3 passed / 1 ignored.cargo test --locked --offline -p victory-shader --doc: no doc tests, passed.cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings: passes before and after the production change.cargo fmt --check: fails on existing formatting differences on main; comparing the changed files with main found identical rustfmt deviations and none in the new test file.cargo run --locked --offline -p xtask -- policy --staged: passes, 4 files.lower.rsshrinks from 520,563 to 520,384 bytes.The test-only instruction counter matches #3600 exactly and is also shared by the other open instruction-count PRs. #3007 changes the high-product implementation; this change only shortens its operand extension, and the count budgets allow that further reduction. #2926 separately fixes clamping in the low-product/MAD arms; whichever lands second will need a small rebase in those arms. No duplicate optimization was found in the open/merged PR search.
No game files, game shaders or game run were used. Other GPUs and Linux/Wine were not tested.
AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.