Shader tests: vector compares, carries, conversions and float arithmetic against the RDNA2 definitions #637
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!637
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-637"
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/compare-ops-isa→main· +574 −5 · 3 files · 1 commits · openSummary
Only
v_cmp_lgon a NaN andv_cmp_class_f16had a test that compares the lowered instruction with the definition in the RDNA2 instruction set document. The other float conditions (ordered and negated, with NaNs and signed zeros), the integer compares,v_cmp_class_f32, the carry-in/carry-out adds and subtracts and the float-to-integer conversions had none: a swapped ordered/unordered pair or a carry that is off by one would show only as a wrong picture. This adds a new test module that pins each of them to its definition, written out in Rust, over edge values. Every operation agrees with its definition, so there is no behaviour change; the PR is tests only.What is in it
crates/victory-shader/src/emit/isa_tests.rs(new, registered inemit/mod.rs), seven tests. Each instruction is one one-thread compute shader (the instruction, thenv_cndmask_b32where the result is a mask bit), run on the hardware adapter and WARP:float_compares_match_the_rdna2_conditions: the fourteen float conditions ofv_cmp_*_f32(lt eq le gt lg ge o u nge nlg ngt nle neq nlt) over all pairs of 16 operands: zeros of both signs, ±1, 0.5, 2, ±1e10, ±inf, a quiet, a negative quiet and a signalling NaN, the largest finite and the smallest normal.integer_compares_match_the_rdna2_conditions:lt eq le gt ne gefor i32 and u32 over all pairs of nine operands around the sign and wrap boundaries.class_f32_tests_the_ten_classes:v_cmp_class_f32on 15 operands covering every class (signalling and quiet NaN of both signs, ±inf, ±normal, ±denormal, ±0) against each single-class mask and some combined ones.carry_arithmetic_matches_the_rdna2_definitions:v_add_co_u32,v_sub_co_u32,v_subrev_co_u32and the three_ciforms with a carry in (the carry-in mask comes from av_cmp_ne_u32, because the translator only accepts carries it can track): the result and the carry or borrow out, over all pairs of nine operands and both carry-ins.conversions_and_rounding_match_the_rdna2_definitions:v_cvt_u32_f32,v_cvt_i32_f32,v_cvt_flr_i32_f32,v_cvt_rpi_i32_f32(NaN to 0, saturation at the 32-bit limits),v_trunc/ceil/rndne/floor_f32,v_cvt_f32_i32/u32(round to nearest even) andv_cvt_f32_ubyte0-3.float_arithmetic_with_nan_and_infinity_matches_the_rdna2_definitions:v_min_f32/v_max_f32(a NaN operand gives the other one) andv_add/sub/subrev/mul_f32over infinities and NaNs.packed_integer_operations_match_the_rdna2_definitions: the fourteen packed 16-bit integer operations (v_pk_mad/mul_lo/add/sub/min/maxin both signs, the three shifts) over 100 cases with different halves in every source, each with fourop_sel/op_sel_hicombinations (whole sources, swapped halves, low result from the high halves and the reverse).valu_tests.rsonly gainspub(super)on five helpers (vop3,sgpr,vgpr,build_valu_cs,run_cases) that the new module shares.Overlap to know about: #278 adds a hardware test of
v_cmp_class_f32(and integermin3/max3/med3);class_f32_tests_the_ten_classeshere covers the same instruction over every class and mask, in the same harness, so one of the two can be trimmed when both are ready.Left out on purpose:
v_cmp_f_f32andv_cmp_tru_f32, which lower as a real compare of the operands and remove the WARP device (#136, #152, #160);v_fma_f32(fused on AMD and not on WARP, #136); the order of-0and+0in min/max.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-shader219 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-shader215 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)returns).v_cmp_*_f16beyond the class test already there).AI use
Claude Code (Claude Sonnet 5.5) wrote the tests and ran the checks above on my machine. The reference functions follow the RDNA2 instruction set document's definitions; opcode numbers come from the repository's
gfx10/opcodes.rs. Nothing is taken from the game.🤖 Generated with Claude Code
🤖 Generated with Claude Code
@HAL9000RELOADED on GitHub · 2026-11-25 12:59 UTC · original
One AMD run of the new GPU tests of nine open shader PRs: this one and #635, #636, #638, #639, #658, #726, #741, #808. Until now those tests had run only on NVIDIA, on WARP or in CI without a GPU. The table is kept here, and each of the other eight links to it, rather than repeating it nine times.
Setup
maina253706+ #402 + the stack-headroom test fix from Marvisak/VIctory#742, then the whole workspace run withcargo test --workspace --no-fail-fast.int64_tests::multiply_add_of_32_by_32_plus_64_matches_the_definition,…shifts_of_64_bits_use_the_low_six_bits_of_the_countinteger_operations_match_the_rdna2_definitions,scalar_integer_operations_…,scalar_compares_set_scc_…,mbcnt_of_the_first_lane_counts_no_lane_below_itisa_tests(float and integer compares, carries, conversions, float arithmetic, class_f32, packed integer)lds_atomics_match_the_rdna2_definitions(hardware only)scalar_64_bit_operations_match_the_rdna2_definitionsv_cmp_f_and_t_64bit_match_rdna2v_shift_64_…,s_shift_64_matches_rdna2_without_int64,shifts_64_bit_need_no_int64mul_hi_matches_rdna2_without_int64,mul_hi_needs_no_int64packed_dot_products_and_clamps_execute_cleanly(13 integer dot-product values)Regressions: none in any of the nine. The only failures in these runs were:
depth_bounds_pipeline_loads_and_filters_draws, which is Windows 10's in-box runtime (#850, #692);warp_budget_saturates…(#849);victory-gpubinary (#875).All three are on
maintoo.Not covered: for #808, the two
v_dot2_f32_f16mismatches found in the emitted DXIL by an earlier review. Its test checks the integer dot products only.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.