fix(shader): emit unordered f32 relations as negated ordered ones #3357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3357"
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 boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T08:47:39Z.
What
On NVIDIA (RTX 4070 Laptop GPU, Windows driver 616.92),
agc_driver_f32_compare_constant, added in #2408, aborts with exit code 3 before it checks anything. The abort is inside NVIDIA's shader compiler (nvgpucomp64.dll, undervkCreateComputePipelines). The test passes on the AMD Radeon 780M here and on RADV (#2408).Narrowed with the test's own shader:
+inf(0x7f800000) triggers it.v_cmp_ngt_f32andv_cmp_nlt_f32do.These compile to
OpFUnordLessThanEqual/OpFUnordGreaterThanEqualagainst+inf, which are always true for non-NaN input. The abort also happens withCompareInstructions.cppfrom before #2408, so it isn't #2408's folding: any shader doing an unordered relational compare against+infhits it on this driver.The four unordered relational emitters now emit the negated inverse ordered relation, for example
OpFUnordLessThanEqual(a, b)becomesOpLogicalNot(OpFOrdGreaterThan(a, b)). That is the same predicate for every input, NaN and signed zeros included:unord(a <= b) = isnan(a) || isnan(b) || a <= b = !ord(a > b).OpFUnordEqual/OpFUnordNotEqualand the ordered forms are unchanged.SpirvSpecializationalready treatsOpLogicalNotand the ordered forms as foldable, like the unordered ones.The existing
agc_driver_f32_compare_constantcovers it: all twelve predicates, both operand orders, NaN, ±inf, ±0 and denormal rows.Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, with
VK_LOADER_DRIVERS_DISABLE=*dzn*(#3255), onmain04ab4a86:main,agc_driver_f32_compare_constantaborts (exit 3) every run. With only the+infconstant andngtornltkept, it still aborts; with any other constant or predicate it passes.ctest -R "^agc_|video_out|^shader|recompiler"passes 372/372.ANYPS5_GPU=AMD): the same set gives 368/372 both with and without this change. The four failures (vopc_compare_table,sdwa_integer_clamp,sdwa_integer_selectors,interpolation_f16) fail the same way withmain's emitter, so they are existing AMD-on-Windows issues, not this change.check_conventions.pypasses, andpr_overlap.pyreports no overlap.Not run on Linux; the change is in the SPIR-V emitter shared by all hosts, and RADV already passed the test.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:52:32Z.
Checked the four rewrites against the identity
unord(a op b) = !ord(inverse op)(NaN and signed zeros included);Eq/NotEqualand the ordered forms are untouched, andSpirvSpecializationalready foldsOpLogicalNotand the ordered relations. Built on current main:agc_driver_f32_compare_constant,agc_driver_f32_denormal_flushandagc_driver_vopc_compare_*pass on RADV, plus the scoped AGC ctest (392/394; the two "Not Run" are unrelated to this change). The NVIDIA abort itself can't be reproduced here, so that part rests on your RTX 4070 run. Merging once CI is green.