Repository navigation
fix(shader): clamp f32 results to +0 for NaN and -0 - #500
Merged
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
9 tasks done
9 tasks done
Collaborator
|
Thanks, checked the bit rule ( |
9 tasks done
Collaborator
|
Gated on PPSA21564 with #508 on top: no visual or FPS change. |
9 tasks done
oneandonlydean
added a commit
to oneandonlydean/AnyPS5
that referenced
this pull request
Oct 5, 2026
Takes upstream's merged versions of our boykopovar#586 boykopovar#611 boykopovar#612 boykopovar#505 boykopovar#490 boykopovar#619 boykopovar#503 boykopovar#627 boykopovar#628 boykopovar#618 and drops astrobot's local copies, plus gate-batch-3 (boykopovar#469 boykopovar#500 boykopovar#504 boykopovar#509 boykopovar#510 boykopovar#514 boykopovar#525 boykopovar#526 boykopovar#528), round o/p (boykopovar#617 boykopovar#620 boykopovar#621 boykopovar#622 boykopovar#623 boykopovar#624 boykopovar#501 boykopovar#508 boykopovar#629 boykopovar#630 boykopovar#631). Conflicts: - SpirvAnalysis.hpp/.cpp, SpirvBufferAccess.cpp: upstream's boykopovar#586/boykopovar#612. The 64-bit LDS atomics keep the full array (f27d6e5 no longer needed). - SpirvMemoryInstructions.cpp: upstream's constant slot plus offset; astrobot's split-wave append/consume kept. - GuestTextureResource.cpp, TextureTiling.cpp and their tests: upstream's boykopovar#490/boykopovar#503 (astrobot had no other change there). - MaskedSelect.cpp test, ShaderMemory.cpp LDS test: upstream's. - State.cpp: upstream's boykopovar#505 export count and boykopovar#469 null pixel program; astrobot's depth export rejection and depth target model kept. - Pipeline.cpp: upstream's pipeline key; astrobot's depth attachment and blend check (a trailing unused attachment stays valid, as colorGapPipelineTests expects). - Draw.cpp, Recorder.cpp, ShaderResources.cpp: astrobot's (renderPassKey with depth, moved sample functions, residency maintenance), which already hold the merged boykopovar#505/boykopovar#628/boykopovar#490 changes. - ShaderInputState.cpp: both register sets. - State.hpp: the duplicate exportIndex member from the auto-merge removed. - CMakeLists.txt: astrobot's test list (a superset of upstream's). - tests/Graphics.cpp: upstream's CompactedExportTests replaces astrobot's inline copy; tests/Recorder.cpp: upstream's viewPastLastMipTests added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The VOP3/SDWA
clampbit on f32 results (FPSaturate32) was emitted as GLSLFClamp(x, 0, 1). In SPIR-V that leaves NaN and −0 open: on RADV a NaN result stays NaN (0xffc00000) and lavapipe gives1.0, but the hardware gives+0for both. It is now done on the bits (1 <= bits <= 0x7f800000 ? umin(bits, 0x3f800000) : 0), so every driver gives the same result.FPSaturate64already works this way.Behaviour measured on HW (RDNA2, gfx1035, IEEE mode 0/1, f32 denormals on/off: all the same)
+0; −0 →+0; negatives and −inf →+0; > 1 and +inf →1.0.Tested
New execution test
agc_driver_f32_result_clamp_tests: 16 ops withclamp(add, sub, mul, mul with negated source, fma, fmac, min, max, med3, max3, floor, fract, trunc, ceil, rndne, cvt_f32_i32) over 32 rows covering each pre-clamp class (NaN, ±0, ±inf, negative, (0,1), 1, > 1). Expected values come from the hardware, and the Python model matches them in all 503 checked cells. Denormal rows and min/max rows with sNaN (where the result depends on IEEE mode) are left out. No row depends on whether the driver fusesfma.Passes on RADV, local lavapipe and CI's lavapipe (Mesa 25.2.8). The test fails without the fix on both drivers (going back to
FClamp, dropping the lower bound, or keeping NaN bits all fail). Full Release ctest is green exceptagc_driver_pixel_helper_lanes, which also fails onmainon local RADV.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)