shader: lower and verify RDNA2 binary32 floating-point vector comparisons #849
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/855"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-23T13:50:59Z.
## Change
Lowers and verifies all 16 RDNA2 binary32 floating-point vector comparison predicates (
v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32) across VOPC (_e32), VOP3 (_e64), and whole-dword SDWA forms intools/pixel_aot.py:tests/pixel_aot_check.py): Addsf32_compares()andf32_compares_reference()covering all 16 predicates across_e32(vcc_lo),_e64(s52/s53/vcc_lo), input modifiers (-s44,|s45|,s53,-|s44|), scalar literals, and whole-dword SDWA selections across ordered values, equal values, signed zeroes (+0.0vs-0.0), quiet/signaling NaNs, infinities, and extreme exponents.tests/pixel_aot_check.py,tests/rdna2_tools_check.py): Rejects SGPR destinations on explicit_e32("VOPC e32 destination must be vcc"), unsupported modifiers (clamp,op_sel), sub-dword SDWA selections (src0_sel:WORD_0,src1_sel:BYTE_2), untracked registers, and exec-writing neighbours (v_cmpx_lt_f32_e32,v_cmpx_lt_f32_e64).tests/form_coverage_check.py,tests/rdna2_tools_check.py,docs/experiments.md): Expands tracked comparison coverage from 122 to 156 forms acrossgfx1013.tsvandrdna2.tsv(adding 17 VOPC and 17 VOP3 binary32 forms) while assertingv_cmpx_lt_f32remains excluded.Verification
On Windows x64 (
D:\XboxToWin repo\.venv\Scripts\python.exe -B):python -B tests/form_coverage_check.py: passed (156 comparison forms validated acrossgfx1013.tsvandrdna2.tsv).python -B tests/rdna2_tools_check.py: passed (75 tests passed).python -B tests/pso_readiness_check.py: passed.python -B tests/docs_links_check.py(13 files, 171 links) andpython -B tests/bidi_controls_check.py(695 files): 0 errors.git -c core.whitespace=cr-at-eol diff --check upstream/main: 23/23 passed, 0 errors.windows.ymlCI.Evidence and follow-up
Uses 100% synthetic RDNA2 shader fixtures and an independent Python IEEE-754 reference oracle. No commercial binaries, game files, or copyrighted dumps are included.
Assisted by AI.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T14:17:15Z.
I reproduced the comparison failures on WARP and pushed a focused fix. The reference now reinterprets integer immediates as binary32 bits (so 1 is not 1.0). With that corrected, the ordered -abs(NaN) <= 2.0 comparison still incorrectly set channel 1 bit 17 on WARP. The lowerer now classifies the source bits explicitly before accepting an ordered result. I also switched both instruction mutations to inputs that distinguish the changed predicate or modifier.
The full comparison draw passed on WARP and RTX 4060 Laptop, including a signaling NaN input, and the LLVM 15 binary/negative tests passed. The updated head is waiting for GitHub CI.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T16:11:24Z.
pixel_aot_comparisons_hardwareis red on RDNA4 at041ca68; the cause is denormal flushing, not the comparator.Environment: Windows 11 25H2 (build 26200.9711), MSVC 19.44 + DXC from VS 2022 BuildTools, adapter AMD Radeon RX 9070 XT (vendor
1002, device7550), driver32.0.32029.2010,debug_layer=unavailable, commit041ca68(ancestor ofmaina2da089).Command and result:
93/94 passed in 295 s. The failure:
pixel_aot_comparisons_warppasses on the same commit and the same build (6.05 s).The case
Second case file of the batch (
f32-cmp-1.case), the "equal values and signed zeros" set (+0.0, -0.0, -1.0, 1.0), channel 0 only:0x0008cccc ^ 0x000ccccc = 0x00040000— only bit 18 differs. Every other bit, and every other channel, matches.Bit 18 is the integer-literal case,
v_cmp_eq_f32_e32 vcc_lo, 1, v16, lowered to:(
tools/pixel_aot.py;cmp99in the generated source).asfloat(1u)is the subnormal1.401298e-45;alu24is the runtime rhs, here-0.0.So the flag turns on whether
1.4e-45 == -0.0. The Python reference (word_to_float(1), with the comment "Integer immediates are interpreted as binary32 bits, not converted") says no, and WARP agrees. On this RDNA4 part, FP32 flushes subnormals to+0, and+0.0 == -0.0is true, so the GPU sets the bit. The disagreement is FTZ, not the predicate, the encoding or the mask accumulation.Two consequences
0x3f800000at bit 21 for exactly that), or the flush can be made explicit in the lowering with the reference updated to match.asfloat(1u) == xis probably not what the console computes either. I have not verified that on Scarlett silicon — it is an inference from this GPU and the shared FP32 mode — but if it holds, the fix belongs in the translator rather than in the fixture, and this test would have to encode the flushed behaviour.The
-bad-controls are fine: each one reports its injected channel, so they still isolate what they are meant to isolate.Why CI does not see it
_hardwaretests return 77 without a physical GPU, so a main that reads green can still be red on every RDNA machine. This is the first entry in that category I have found.Reproduce with:
Happy to re-run this on the same adapter once the case is fixed, and to check the flushed reading against the rest of the comparison sets.
AI-assisted; the run and the HLSL inspection were executed locally on the adapter above. The FTZ reading and the line references come from a separate review pass and were reproduced here at
041ca68.