Shaders: lower v_mad_i64_i32; test the 64-bit integer vector operations against their definitions #635
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!635
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-635"
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/int64-valu-isa→main· +136 −5 · 4 files · 1 commits · openSummary
v_mad_u64_u32is lowered; its signed siblingv_mad_i64_i32(a signed 32 x 32 multiply plus a 64-bit addend, into a 64-bit result) is not, so a program using it is refused asUnsupported { what: "v_mad_i64_i32" }and its pipelines are dropped. This lowers it as the same operation on sign-extended factors, and adds a test of the 64-bit integer vector operations (the three 64-bit shifts and both multiply-adds) against the definitions in the RDNA2 instruction set document.What is in it
crates/victory-shader/src/emit/lower.rs: a"v_mad_i64_i32"arm next to"v_mad_u64_u32": sign-extend both factors to 64 bits, multiply, add the 64-bit addend, write the two result dwords. The carry out is not modelled: the lane-mask value of the instruction's carry destination isVal::Missing("the carry of a signed multiply-add"), so a program that reads it is refused as for any lane mask read as data, and one that ignores it (the usual address computation) translates.crates/victory-shader/src/emit/int64_tests.rs(new, registered inemit/mod.rs): two tests, one-thread compute shaders run twice (low dword of the result, then the high one) on the hardware adapter and WARP:shifts_of_64_bits_use_the_low_six_bits_of_the_count:v_lshlrev_b64,v_lshrrev_b64,v_ashrrev_i64with counts 0, 1, 31, 32, 33, 63, 64, 65 and0xffffffc1over 64 values built from the halves' sign and carry edges.multiply_add_of_32_by_32_plus_64_matches_the_definition:v_mad_u64_u32andv_mad_i64_i32over eight values for each factor and four addends (0, 2^32-1, -1, and 2^63+1).valu_tests.rsonly gainspub(super)on five helpers the new module shares.Before the lowering,
multiply_add_of_32_by_32_plus_64_matches_the_definitionstops atlower: Unsupported { offset: 36, what: "v_mad_i64_i32" }. With it, both operations and the three shifts agree with the definitions on WARP.Does the title use it?
No:
victory translateover the whole shader pack (26,148 programs, base2119b0e) translates all of them and refuses none for this instruction. The change is coverage; the test is the main point. If you would rather have the test alone, drop thelower.rshunk and the signed multiply-add half of the second test.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: 170 files ok.cargo test --workspace --lockedon the RTX 4070 (default adapter, run directly):victory-shader214 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-shader210 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
v_mad_i64_i32(not modelled; the RDNA2 document's wording for the signed form is not what I rely on).v_add_co_u32chains, f64).AI use
Claude Code (Claude Sonnet 5.5) wrote the lowering and the tests and ran the checks above on my machine. The reference functions follow the RDNA2 instruction set document. 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.
multiply_add_of_32_by_32_plus_64_matches_the_definitionandshifts_of_64_bits_use_the_low_six_bits_of_the_countpass 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
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.