fix(shader): apply f32 output modifiers on the exponent bits #638
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/638"
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-05T10:19:56Z.
What
agc_driver_f32_output_modifierfails on NVIDIA onmain(53dc19cf):FLT_MAX * 2.0overflows to +inf, anddiv:2of +inf is +inf. With every lane printed instead of the first, this is the only mismatch:v_add_f32 ... div:2andv_fma_f32 ... div:2on the same overflowing inputs are correct. The output modifier was emitted as a secondOpFMulby the constant 0.5 (or 2, 4); the NVIDIA driver behaves as if it folds it into the instruction's own multiply (no intermediate overflow), although both multiplies are decoratedNoContraction; I did not inspect the generated SASS. CI does not see this, since lavapipe does not fold it.The modifier now scales a normal result through its exponent field instead of a multiply:
mul:2,mul:4: add 1 or 2 to the exponent; signed infinity when it overflows.div:2: subtract 1 from the exponent; results below 2^-125 keep the existing signed-zero flush.An exhaustive CPU comparison of the old expression (IEEE multiply plus the existing selects) and the new one over all 2^32 inputs finds no difference for any of the three modifiers, so results change only where a driver folded the multiply. The shader disk cache key changes with the source hash.
Tested
Linux (Ubuntu 26.04, GCC 15.2.0), Release,
BUILD_TESTING=ON, fullcteston three Vulkan drivers selected withVK_DRIVER_FILES:mainagc_driver_f32_output_modifierfailsThe remaining failures also fail on
mainand are unrelated to this change: on NVIDIAagc_driver_lds_atomics64andagc_driver_scalar_sop1, on RADVagc_driver_pixel_helper_lanes,agc_driver_pixel_ldsandagc_driver_pixel_lds_lane_slots. I will report them separately.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)