Shaders: lower six integer operations; test the integer vector and scalar ops and the scalar compares against their definitions #636
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!636
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-636"
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?
@Gruzzberry on GitHub · 2026-11-25 03:40 UTC · original
Gruzzberry:gz/salu-integer-ops→main· +549 −0 · 2 files · 1 commits · openSummary
The integer vector and scalar operations had no test that compares them with what the RDNA2 instruction set document defines, so a wrong shift mask, a swapped operand or a missing operation would only show up as a wrong picture. This adds three table-driven tests that run each operation as a one-thread compute shader over edge values and compare the result with the definition written out in Rust. Everything that was lowered agreed with its definition; six operations were not lowered at all, so a program using one was refused as
Unsupportedand its pipelines dropped. They are lowered here, since a table row for each is what the tests need.What is in it
One commit.
lower.rs:v_mul_hi_u32_u24andv_mul_hi_i32_i24(bits 47:32 of the product of the operands' low 24 bits, sign-extended from bit 23 for the signed one) through the existingmul_hion the widened operands;s_absdiff_i32(an SCC writer already inir.rs) ands_pack_ll_b32_b16,s_pack_lh_b32_b16,s_pack_hh_b32_b16.valu_tests.rs:integer_operations_match_the_rdna2_definitions: 38 vector operations (bfi, bfm, bcnt, bfrev, not, xnor, xor3, or3, and_or, xad, add3, lshl_add, add_lshl, lshl_or, the three reversed shifts, mul_lo, mul_hi in 32 and 24 bits, mul_u32_u24/i32_i24, mad_u32_u24/i32_i24, min3/max3/med3 signed and unsigned, v_perm_b32 with every selector class, alignbit, alignbyte, ffbl, ffbh unsigned and signed) over 128 cases built from edges (shifts around 0, 31 and 32, the 24-bit and sign boundaries, runs of ones).mbcnt_of_the_first_lane_counts_no_lane_below_itcoversv_mbcnt_lo/hi_u32_b32on lane 0; it needs a 32-lane wave, so it runs on the hardware adapter only (and skips underVICTORY_WARP=1).scalar_integer_operations_match_the_rdna2_definitions: 40 SOP1/SOP2 operations over 96 cases.scalar_compares_set_scc_as_the_rdna2_document_defines:s_cmp_{eq,lg,gt,ge,lt,le}_{i32,u32}ands_bitcmp0/1_b32over 121 pairs, ands_cmpk_*against five immediates (sign-extended for the signed forms, zero-extended for the unsigned ones), SCC read back throughs_cselect_b32.Before the lowering, the vector test stops at
Unsupported { what: "v_mul_hi_u32_u24" }and the scalar one ats_absdiff_i32. With it every operation in the tables agrees with its definition.Does the title use them?
No.
victory translateover the whole shader pack (26,148 programs, base2119b0e) translates all of them, and none of the programs the later stages refuse is refused for one of these operations. So the lowering changes are coverage, not a fix for something the title hits; the tests are the point of the PR. If you would rather have only the tests, drop thelower.rshunks and the table rows for the six operations.Overlap to know about:
s_sext_i32_i8/i16(#182),s_bcnt0_i32_b32(#171) ands_ff0_i32_b32(#233) are left out on purpose, since open PRs lower them. #278 adds hardware tests for integermin3/max3/med3ands_bfe_u32, which this table also covers (together with every other operation in it).Tested
c96b4f2, one commit.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean. Without--all-featuresit fails onc96b4f2itself (placed_filler_twinsinvictory-gpu/src/resource.rsis never used); this change adds no warning.cargo xtask policy: 169 files ok.cargo test --workspace --lockedon the RTX 4070 (default adapter, run directly):victory-shader216 passed, 2 failed (emit::rect::tests::the_rectangle_stage_is_a_geometry_shaderandrectangles_are_drawn_whole, the PSV0 validator issue of #61); every other crate passes.c96b4f2without this change: 212 passed, the same 2 failed.VICTORY_WARP=1 cargo test --workspace --locked(every GPU test on WARP):victory-shader212 passed, 6 failed. The same 6 fail onc96b4f2(208 passed): the twoemit::rectones, andds_min_max_f32_order_floats_and_return_the_old_value,v_permlane16_and_x16_read_the_lanes_their_selectors_pick,whole_wave_f64_sum_and_cvt_f32_f64anda_lane_mask_joined_with_a_number_is_read_as_the_number_it_is, which need a 32-lane device thatVICTORY_WARP=1takes away. No new failure.Not tested
Host::new(false)gives and WARP, so they run there too, but I did not.s_*_b64,v_*_i64).AI use
Claude Code (Claude Sonnet 5.5) read the code, wrote the tests and the lowering changes, and ran the checks above on my machine. The reference functions follow the RDNA2 instruction set document's definitions; the opcode numbers come from the repository's own
gfx10/opcodes.rs. Nothing is taken from the game.🤖 Generated with Claude Code
🤖 Generated with Claude Code
@HAL9000RELOADED on GitHub · 2026-11-25 13:00 UTC · original
An AMD run of this PR's new tests.
integer_operations_match_the_rdna2_definitions,scalar_integer_operations_match_the_rdna2_definitions,scalar_compares_set_scc_as_the_rdna2_document_definesandmbcnt_of_the_first_lane_counts_no_lane_below_itpass on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with the Agility SDK runtime from #402. They ran on the hardware device; WARP skips on this machine. Nothing else in the workspace regresses.The setup, and the same run for eight related shader PRs, are in one table on #637: #637
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.