Shaders: v_max_f16/v_min_f16/v_max3_f16/v_min3_f16 have no negative-zero ordering test #802
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#802
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@kss306 on GitHub · 2026-11-24 11:11 UTC · original
max_and_min_order_negative_zero_below_positive_zeroinvalu_tests.rschecks thatv_max_f32/v_min_f32/v_max3_f32/v_min3_f32order −0 below +0 as RDNA2 requires. The f16 equivalents (v_max_f16,v_min_f16,v_max3_f16,v_min3_f16) go through the samemax_min()helper (fixed by #448) but are never covered by any test.Affected instructions
v_max_f16v_max_f32(0x110) ✓v_min_f16v_min_f32(0x10F) ✓v_max3_f16v_max3_f32(0x154) ✓v_min3_f16v_min3_f32(0x151) ✓Implementation evidence
lower.rs,max_min()at line 1377, is the single helper for all float min/max variants. For f16 inputs the caller widens them from f16 to f32 viahalf_fsrc()before enteringmax_min(), so the helper operates on f32-widened values. RDNA2's f16 −0 (0x8000) widens to f32 −0 (0x8000_0000), so the magnitude AND with0x7FFF_FFFFcorrectly detects the two-zeros case in widened space.PR #448 explicitly states the fix covers "v_max_f32, v_min_f32, their three-operand and f16 forms". The implementation is correct; the f16 test was never added.
The f16 path in
valu16_op()(lower.rsaround line 4344):And the three-operand f16 forms (
lower.rsaround line 4377):Missing test
valu_tests.rsfn max_and_min_order_negative_zero_below_positive_zero()(line 311) covers only f32 opcodes (0x110,0x10F,0x154,0x151). The f16 opcodes0x111,0x10E,0x354,0x351do not appear in the test.The test helpers for f16 bit patterns are already present in the file (
f16_to_f32,is_f16_nan), and f16 −0 (0x8000) is already used inv_cmp_lg_is_false_for_nan. Adding the f16 cases requires only a secondopsarray.Suggested test addition
Extend
max_and_min_order_negative_zero_below_positive_zerowith an f16 block:No game data needed; the test skips when no SM 6.6 device is available and runs on WARP.
AI-assisted: found with Kiro (Claude) and independently confirmed by five separate analysis passes without cross-contamination; no hardware run, no game data.
@fuzeofficlal on GitHub · 2026-11-24 11:51 UTC · original
I added a synthetic regression test for all four f16 min/max forms. The two-source VOP3 encodings are
0x139forv_max_f16and0x13aforv_min_f16. The three-source encodings are0x354and0x351as reported. The test checks the decoded instruction names before comparing the low 16 bits of the readback.All eight sign combinations passed for each instruction on both the hardware D3D12 adapter and WARP. That includes the two cases where only the third operand's sign differs. The full VALU test group passed (14 tests), along with Clippy, formatting for the changed file, and the asset policy check.
The single test-only commit is available for review or cherry-pick.
53e1c74@towiice on GitHub · 2026-11-24 11:58 UTC · original
Implemented and verified on hardware. Note on opcode mapping: in GFX10 VOP3 encoding, VOP2 instructions map at base
0x100, sov_max_f16(VOP20x039) is0x139, andv_min_f16(VOP20x03A) is0x13A(whereas0x111/0x10Eare unknown/unmapped VOP3 opcodes).v_max3_f16(0x354) andv_min3_f16(0x351) are native VOP3.The extended test is implemented on:
https://github.com/towiice/VIctory/tree/test/valu-integer-min3-max3-med3 (commit
89fa58e)Hardware Test Results:
stable-x86_64-pc-windows-gnullvm.cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader --lib max_and_min -- --nocapture0x8000) below +0 (0x0000) on both hardware GPU and WARP.@geiyiliyabumo on GitHub · 2026-11-24 11:59 UTC · original
Added the requested synthetic hardware test
max_and_min_f16_order_negative_zero_below_positive_zerocoveringv_max_f16,v_min_f16,v_max3_f16, andv_min3_f16across all-0.0(0x8000) /+0.0(0x0000) orderings plus non-zero high-half garbage bits.(Note: in RDNA2 VOP3 encoding, the VOP2 forms
v_max_f16(0x039) andv_min_f16(0x03a) sit at0x139and0x13arather than0x111/0x10elisted in the OP table —0x111isv_min_i32and0x10edoes not decode. Verified againstvictory-shader's decoder and live hardware.)External PRs are currently
collaborators_only, so the verified commit (combined with #799 and #800 incrates/victory-shader/src/emit/valu_tests.rs, based onmainffe310e) is ready on my fork:github.com/geiyiliyabumo/VIctory@9a173fcVerification (Windows 11 Pro 26100, AMD Radeon RX 9060 XT driver
32.0.32029.2010+ WARP, Rust1.98.1):rustfmt --edition 2024 --check crates/victory-shader/src/emit/valu_tests.rs: PASScargo xtask policy: PASS (154 files ok)cargo clippy --workspace --all-targets --locked -- -D warnings(default +--features diagnostics): PASScargo test -p victory-shader --locked -- valu_tests: 16/16 PASS (verified on both RX 9060 XT and WARP viarun_cases)cargo test --workspace --locked: PASS (0 failed)AI-assisted; synthetic tests only, no game files.
@Altorru on GitHub · 2026-11-24 12:17 UTC · original
The f16 block is in max_and_min_order_negative_zero_below_positive_zero and covers v_max_f16, v_min_f16, v_max3_f16 and v_min3_f16. One correction to the issue text: the two-operand forms are VOP2 0x039/0x03a in this decoder, not VOP3 0x111/0x10E, so the test builds them as VOP2 and the three-operand forms as VOP3. Implemented in fork PR Altorru/VIctory#1 (upstream PR creation is collaborator-only), commit
bb3a37b. Windows CI passed: cargo test --workspace on https://github.com/Altorru/VIctory/actions/runs/45391712656, where the new test ran on WARP. No game data.