Repository navigation
Conversation
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed head 26ee5818 line-by-line (CI green):
- Computing
mag = x & 0x7FFF_FFFFandnan = mag >u 0x7F80_0000matches all IEEE-754 f32 NaNs (+qNaN,-qNaN,+sNaN,-sNaN) while leaving±0.0, subnormals, finite values, and±Infuntouched. - Selecting the neutral element in both passes (
SMIN/UMAXforfmin,SMAX/UMINforfmax) turns NaN operands into no-ops on finite/infinite memory without affecting single-pass integer atomics (ops.len() == 1). - The new
global_atomic_fmin_and_fmax_ignore_nan_operandstest exercises all four NaN bit patterns against finite and±Infmemory cells as well as±Infand-0.0operands on both hardware and WARP.
Clean and sound.
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: the two-pass int-atomic lowering of fmin/fmax had a real NaN hole — NaN's bit pattern reads as a large positive int (or huge unsigned with the sign bit), so it could win the max pass and clobber a finite/infinite cell, breaking IEEE minNum/maxNum. The mag > 0x7F800000 check catches both signs, the neutral-element selection in both passes yields exactly 'NaN operands ignored' (and NaN+NaN stays NaN), while ±Inf and -0.0 still participate. Detection is built only for two-pass ops — right, integer atomics have no NaN semantics.
|
Independent Windows x64 verification of
Command: AI-assisted (Codex, gpt-6.2-sol). |
|
Automated triage for the maintainers. Merge candidate. In One point to confirm when reviewing: the test also asserts that a signalling NaN leaves memory unchanged. Under the IEEE 754-2008 CI: Generated by Claude Code |
|
Native RTX 4090 Laptop readback (driver 621.14): all 9 min/max output pairs match at With min/max cells initialized to +1/−1, the parent wrote the positive quiet or signaling NaN bits into the max cell ( I used the PR fixture on both production revisions, locally making it hardware-only, logging the adapter and every pair, and checking the mismatch count after the ninth readback. Coordination. |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
- Diff review: Detecting NaN operands via
(x & 0x7FFF_FFFF) > 0x7F80_0000and selecting the neutral element in both passes ofglobal_atomic_fmin/global_atomic_fmaxcleanly prevents NaN inputs from overwriting finite or infinite values in memory. cargo test -p victory-shader emit::memory_tests -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index(RTX 5090): 5 passed, 0 failed (includingglobal_atomic_fmin_and_fmax_ignore_nan_operands). (Skipped pre-existing #2571 on NVIDIA.)VICTORY_WARP=1 cargo test -p victory-shader emit::memory_tests -- --test-threads=1(WARP): 6 passed, 0 failed.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).
…min and global_atomic_fmax against NaN operands
…min and global_atomic_fmax against NaN operands
Problem
In
crates/victory-shader/src/emit/lower.rs(Lower::flat_write),global_atomic_fminandglobal_atomic_fmaxlower via two integer atomics split by sign bit (SLT(x, 0)) without checking forNaN:0x7FC0_0000/0x7F80_0001) hasnegative == false, soglobal_atomic_fmaxexecutesSMAX(mem, +NaN)and overwrites any finite or+Infvalue in memory with+NaN(since0x7FC0_0000 > 0x7F80_0000as signedi32).0xFFC0_0000/0xFF80_0001) hasnegative == true, soglobal_atomic_fminexecutesUMAX(mem, -NaN)and overwrites any finite or-Infvalue in memory with-NaN(since0xFFC0_0000 > 0xFF80_0000as unsignedu32).Per AMD RDNA2/GFX10.3
GLOBAL_ATOMIC_FMIN/GLOBAL_ATOMIC_FMAXIEEEminNum/maxNumsemantics, aNaNoperand must leave a non-NaN value in memory unchanged.Fix
When lowering float min/max atomics (
ops.len() > 1), computenan = (x & 0x7FFF_FFFF) >_u 0x7F80_0000(pred::IUGT) and select the pass'sneutralelement in both passes whennanis true. Disjoint from #1915 (which covers integer global atomics).Verification
emit::memory_tests::global_atomic_fmin_and_fmax_ignore_nan_operandstesting+qNaN,-qNaN,+sNaN, and-sNaNagainst both finite and±Infmemory cells, plus±Infand-0.0updates.windows-latestMSVC + WARP SM 6.6 +dxil.dllCI (cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features,xtask policy, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45762903919AI-assisted: T3 Code (Antigravity, gemini-4-neon)