Repository navigation
Conversation
What was wrong: the `neg` source modifier was lowered as `-0.0 - x`. IEEE 754 leaves the sign of a NaN out of a subtraction to the host, and WARP keeps it: a negated NaN reached the instruction with the sign it had. The console's modifier flips bit 31 alone, NaN or not. The floor conversions show it, as they saturate a NaN by its sign: `v_cvt_rpi_i32_f32 -v1` and `v_cvt_flr_i32_f32 -v1` of 0x7fc00000 gave 0x7fffffff on WARP, 0x80000000 on an RX 7900 XTX (RDNA3) and the model. Found by the VALU fuzzer of Marvisak#1614 with VICTORY_FUZZ_MODS=1 (20 and 9 of 200 inputs differed, all NaNs). `neg` is now an integer XOR of the sign bit (`fneg`), the same on every host, for f32 sources, v_fma_mix sources, f16 sources read as f32 and packed f16 sources. The 16-bit and select paths already flipped the bit. New test: source_modifiers_set_the_sign_of_a_nan checks both floor conversions with abs, neg and -|x| against the model on the hardware adapter and WARP; without the fix it fails on WARP only. Checked on Windows 11, RX 7900 XTX (driver 32.0.32029.2010) and WARP: cargo test --workspace --locked passes (780), both CI clippy runs are clean, and the fuzzer with modifiers on the four float-to-integer conversions shows 0 of 400 inputs differing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Local verification on Windows / rustc 1.100.0 / MSVC, synthetic inputs only, no game data; GPU tests allowed here (hardware + WARP), no clippy/rustup.
AI-assisted (Hy4 flash). |
|
Verified
|
kotekompotek
left a comment
There was a problem hiding this comment.
Correct: 0.0 - x goes through the host's subtraction semantics which don't guarantee the NaN sign flip the NEG input modifier performs on hardware — bit-level xor of 0x80000000 is the right lowering (matches the ISA's sign-bit flip for any input incl. NaN/-0). All four neg sites converted consistently. LGTM.
…neg-NaN - Marvisak#2909: reject empty query heaps at creation (count == 0) - Marvisak#2789: ds_wrap_rtn_b32 reads both of its data operands - Marvisak#2771: a global or scratch load into LDS has no result register - Marvisak#2765: scratch with neither address names no register (GFX10.3 ST mode) - Marvisak#2812: a comparison sampler replaces the reduction instead of OR-ing in - Marvisak#2823: neg input modifier flips bit 31 by XOR (a NaN's sign too) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Automated triage for the maintainers. The CI: passing. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::semantics_tests::source_modifiers_set_the_sign_of_a_nan: 1 passed, 0 failed (0 mismatches on both RTX 5090 hardware and WARP, 0 hardware/WARP differences).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
I checked whether this fix also covers
The optional test-only commit |
…s a NaN's sign too
…s a NaN's sign too
The
negsource modifier was lowered as-0.0 - x. IEEE 754 leaves the sign of a NaN produced by a subtraction to the host, and WARP keeps it, so a negated NaN reached the instruction with its original sign. On the console the modifier flips bit 31 alone, NaN or not (RDNA2 ISA).The floor conversions make it visible, because they saturate a NaN by its sign:
v_cvt_rpi_i32_f32 v5, -v1, v1 =0x7fc00000to_i32_floorof-NaN)0x800000000x800000000x7fffffffHow it was found
#1614's VALU fuzzer, merged onto
main(13f91ca), withVICTORY_FUZZ_MODS=1and 200 inputs per opcode on the RX 7900 XTX against WARP. Only two results were new beyond the 17 known disagreements, and neither appears without modifiers:v_cvt_rpi_i32_f32, neg src0: 20 of 200 inputs differ;v_cvt_flr_i32_f32, neg src0: 9 of 200 inputs differ.All of the differing inputs are NaNs. This is separate from the Intel UHD finding reported on #1614 (NaN gives 0 there, without modifiers).
Change
Lower::fnegnegates by XOR-ing the sign bit on the integer bits, which gives the same result on every host.neginput modifier was a subtraction:fsrc);v_fma_mix*sources;Related, no overlap: #2548 makes
v_mov_b32's modifiers bitwise on the integer path.Test
semantics_tests::source_modifiers_set_the_sign_of_a_nanruns both floor conversions withabs,negand-|x|onF32_EDGES. It compares against the existingto_i32_floormodel on the hardware adapter and on WARP.Checks
Windows 11, AMD Radeon RX 7900 XTX (driver 32.0.32029.2010), and WARP:
cargo test --workspace --locked: 780 passed, 0 failed.--all-targets, with and without--all-features,-D warnings): clean.cargo xtask policy: ok.cargo fmt --checkreports nothing in the two changed files.VICTORY_FUZZ_MODS=1, 400 inputs, onv_cvt_{flr,rpi}_i32_f32andv_cvt_{i32,u32}_f32: 0 differ.Not tested: NVIDIA and Intel adapters. I also did not rerun the full 23-minute fuzzer with the fix. Per the floor-conversion test's own note, the title uses neither conversion, so the gain is hosts agreeing, including CI's WARP, rather than a visible change in the game.
🤖 Generated with Claude Code