Repository navigation
Shader tests: vector compares, carries, conversions and float arithmetic against the RDNA2 definitions - #637
Open
Gruzzberry wants to merge 1 commit into
Open
Gruzzberry wants to merge 1 commit into
Gruzzberry wants to merge 1 commit into
Conversation
…tic against the RDNA2 definitions The f32 compare conditions had one direct test (v_cmp_lg on NaN) and v_cmp_class_f16 had its own; the other conditions, the integer compares, v_cmp_class_f32, the carry forms and the float-to-integer conversions had none. These tests pin them to the instruction set document's definitions: one one-thread compute shader per instruction over every pair (or each) of a set of edge values, on the hardware adapter and WARP. - the fourteen float conditions of v_cmp_*_f32 (lt, eq, le, gt, lg, ge, o, u and the negated forms) over 16 operands: zeros of both signs, +-1, +-inf, a quiet, a negative quiet and a signalling NaN, the finite and normal limits; - the signed and unsigned integer conditions over nine operands around the sign and wrap boundaries; - v_cmp_class_f32 on every operand class (signalling and quiet NaN, +-inf, +-normal, +-denormal, +-0) against single-class and combined masks; - v_add_co_u32, v_sub_co_u32, v_subrev_co_u32 and the three _ci forms with a carry in: the result and the carry or borrow out; - 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) and v_cvt_f32_ubyte0-3; - v_min_f32, v_max_f32 (a NaN gives the other operand), v_add/sub/subrev/ mul_f32 over infinities and NaNs; - the fourteen packed 16-bit integer operations (v_pk_add/sub/mul_lo/mad/ min/max in both signs, the three shifts) with four op_sel/op_sel_hi selector combinations, so both halves of every source are used in both result halves. All agree with the definitions; no behaviour changes. v_cmp_f_f32 and v_cmp_tru_f32 are left out on purpose (they remove the WARP device, see fxceless#136). valu_tests.rs only gains pub(super) on the helpers the new module shares. Assisted-by: Claude Code (Claude Sonnet 5.5)
|
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
Regressions: none in any of the nine. The only failures in these runs were:
All three are on Not covered: for #808, the two |
This was referenced Nov 25, 2026
HAL9000RELOADED
added a commit
to HAL9000RELOADED/victory-fork
that referenced
this pull request
Nov 26, 2026
…conversions and float arithmet) head 5709ce8
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
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 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-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