Repository navigation
Shaders: lower six integer operations; test the integer vector and scalar ops and the scalar compares against their definitions - #636
Open
Gruzzberry wants to merge 1 commit into
Conversation
…alar ops and the scalar compares against their definitions The integer vector and scalar operations had no test that compares them with the RDNA2 instruction set document. Three tests run each operation as a one-thread compute shader over edge values and compare the result with the definition written out in Rust, on the hardware adapter and WARP: - 38 integer vector operations (bit fields, funnel shifts, 24-bit and high multiplies, three-input adds and logic, min3/max3/med3, v_perm_b32 with every selector class, find-first-bit) over 128 cases, and v_mbcnt of lane 0 on the hardware adapter alone; - 40 scalar SOP1/SOP2 operations over 96 cases; - the scalar compares: s_cmp_* i32/u32, s_bitcmp0/1 and the s_cmpk_* forms against five immediates, with SCC read back through s_cselect_b32. Everything that was lowered agreed with its definition. Six operations were not lowered at all, so a program using one was refused as "unsupported" and its pipelines dropped; they are lowered here: v_mul_hi_u32_u24 and v_mul_hi_i32_i24 (through the 64-bit product of the widened operands), s_absdiff_i32 and s_pack_ll/lh/hh_b32_b16. The title's shader pack has no program using them (a translate run over all 26148 programs refuses none for these), so the lowerings are coverage. The sign extensions and the zero-bit counts are left to the open PRs that lower them. Assisted-by: Claude Code (Claude Sonnet 5.5)
oceansde012
pushed a commit
to oceansde012/victory-gta6
that referenced
this pull request
Nov 25, 2026
HLE: implement the RPC runtime's GUID calls (cherry picked from commit ff15f98)
|
An AMD run of this PR's new tests. The setup, and the same run for eight related shader PRs, are in one table on #637: #637 (comment) |
PiloteCode
pushed a commit
to PiloteCode/victory-fork
that referenced
this pull request
Nov 25, 2026
HLE: implement the RPC runtime's GUID calls
HAL9000RELOADED
added a commit
to HAL9000RELOADED/victory-fork
that referenced
this pull request
Nov 26, 2026
…est the integer vector and sca) head 69505cd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #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