fix(shader): apply f32 abs and neg source modifiers on the sign bit #765
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/765"
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 khasinski on 2026-10-05T22:04:35Z.
What
Found while testing #663 on NVIDIA: its new
agc_driver_division_output_modifierstest fails there withvDivFixupF32works on integer bits and returnsdenominator | 0x400000for a NaN denominator. ButreadOperandappliedabsandnegon F32 operands asFPAbs32/FPNeg32(FAbs/OpFNegatein SPIR-V), and on NVIDIAFAbsof0x7ff00000returns the driver's canonical NaN0x7fffffff. The payload is gone before the fixup runs. RADV and lavapipe keep the payload, so CI passes.F32 operands now clear or flip the sign bit, the code path
readOperandalready uses for U32 operands. The F32 branch only bitcasts the result. IEEE 754 definesabsandnegateas sign-bit operations that never change a NaN payload, so the bit form is exact for every input. The shader disk cache key changes with the source hash.The f16 source modifiers in
SubwordPacking.cppuse the sameFPAbs32/FPNeg32pattern and may lose f16 NaN payloads on NVIDIA in the same way. This PR does not change them, and I did not test them.Tested
Linux (Ubuntu 26.04, GCC 15.2.0), Release,
BUILD_TESTING=ON. Vulkan drivers selected withVK_DRIVER_FILES:ctestonmain(bc24783e) with this change: NVIDIA 315/318, RADV (Ryzen 9 9950X3D iGPU, RDNA2) 315/318, lavapipe 318/318. The failing tests are the same as onmainwithout this change: on NVIDIAagc_driver_f32_output_modifier(#638),agc_driver_lds_atomics64andagc_driver_scalar_sop1, on RADVagc_driver_pixel_helper_lanes,agc_driver_pixel_ldsandagc_driver_pixel_lds_lane_slots.No new test: #663's
agc_driver_division_output_modifierscovers this on NVIDIA. No current test onmainpasses a NaN with a payload through anabs/negoperand on a path that keeps the bits.No title tested.
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)