perf(shader): skip impossible NaN repair for normal multipliers #14892
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14892"
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 Filip722 on 2026-11-01T23:13:43Z.
What
nanResultF32builds a canonical-NaN result fallback even for an exact FP32 multiply with a known normal, finite, nonzero factor. That factor excludes the invalid zero-times-infinity case, so any NaN already comes from an input and is handled by the existing input-payload selections.FPMul32caller and inspect the effective operands after input modifiers and denormal handling.This branch now merges pinned
main66e1f7f993c9intoed98df2caf76, retaining the same four-file change. The six-pair ordinary gameplay comparison below remains the original5bae1a4bc2cf/f2fae88ef0a3result. It is not a gameplay timing report for the refreshed head.Ready for review: the implementation, matched focused validation and separately scoped gameplay/native evidence are complete. Shared-helper merge ordering is still unresolved and must be settled before merging; questions are posted on #4287, #11490 and #12548. Those proposals do not implement this normal-constant proof. This standalone branch includes none of them, so no dependency or ordering agreement is claimed. The remaining ordering decision is part of review; any subsequent reconciliation will be validated before merge.
Tested
The original
5bae1a4bc2cf/f2fae88ef0a3hardware comparison passed for arithmetic NaNs (exact and fast), add/multiply denormal modes, denormal flush, constant-factor tininess and output modifiers. Both arms used the same synthetic fixture,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validation; all six checks loaded the actual Khronos layer, with no VUID errors, missing-layer reports or skips.For the refreshed integration,
66e1f7f993c9plus the identical synthetic fixture anded98df2caf76each passed all six focused Vulkan checks listed above under the same required Vulkan/cache-bypass validation settings; each individual test loaded the actual Khronos instance and device layer, with zero VUID errors, missing layers, skips or truncated validation output. The staged libraries came from a newly built current-main snapshot, with 399 libraries per arm, 398 byte-identical current-main libraries (including the shared66e1f7f993VideoOut binary), and only the graphics driver differing.The separate refreshed actual GPL+LTO native check found 27 targeted result repairs reduced to zero and fragment native code reduced from 13,148 to 12,760 bytes; both retained 32 VGPR, 108 SGPR, wave64 and zero scratch, joined to actual bound draws at 2560×1440 guest/render/physical Vulkan targets with single-sample images (1920×1080 presentation). This verifies the refreshed shader-work result; no new ordinary gameplay timing was run for the merged head.
Ordinary Sons of Sparta camp comparison on AMD Radeon 760M, private RADV Mesa 26.2.6 / libdrm 2.4.133, Debian 13: 12 valid runs in six matched pairs, zero retries, all six pairs faster. Actual rendering was 2560×1440 with 1920×1080 presentation, normal GPL+LTO and journal OFF. Mean frame time changed from 21.96919873535 ms on
5bae1a4bc2cfto 21.07197233492 ms onf2fae88ef0a3. The paired reduction was 0.8972264 ms, 95% Student-t interval [0.831245, 0.963208] ms, or 4.083505% [3.793507, 4.373503]%. The six run pairs are the repetitions used for that interval.Timing evidence bundle: All twelve original timing traces, summaries, digests and paired analysis
Original upstream summary lines from the first prospective pair (all twelve lines and
tools/trace_digest.pyoutputs are in the bundle):For the original
5bae1a4bc2cf/f2fae88ef0a3comparison, the associated actual optimized GPL+LTO fragment native code shrank from 13,148 to 12,760 bytes and the 27 targeted result repairs disappeared. Allocation stayed at 32 VGPR, 108 SGPR, wave64 and zero scratch. The ordinary paired runs above establish the reported gameplay result.Checklist
main; no other open PR implements the same functions — integrated pinned main66e1f7f993c9ined98df2caf76; exact-head manual review found no duplicate normal-constant domain fold. Shared-helper merge-order coordination remains pending as described above.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T05:01:07Z.
Review: APPROVED
The change is sound by reading. For
FPMul32with an effective constant factor whose exponent is neither 0 nor 0xff, only0 × ∞could make a NaN from non-NaN inputs, and a finite nonzero normal factor rules that out. NaN inputs still go through the existing input-payload selections, and every other opcode and unproved factor keeps the canonical-NaN fallback.Windows 11, AMD RX 9070 XT, WinLibs GCC 15.2.0,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, merged onto currentmainf6232fcfda(clean merge):agc_driver_f32_arithmetic_nanand_fastpass, including the new literal 2, 0.5, zero and infinity cases. With main'sTranslationContext.hpp,FloatInstructions.cppandOperandAccess.cpprestored they pass too, as expected: results shouldn't change, only the emitted fallback.Non-blocking: both summary lines in the description carry
"dirty":true, and you note the timing is from the earlier5bae1a4bc2cf/f2fae88ef0a3pair, not the refreshed head.