perf(shader): keep the device's f32 NaN result behind an operand guard when a startup probe matches #20187
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20187"
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 Ketz7 on 2026-11-14T19:52:51Z.
What
IEEE_MODE, the emitter rebuilds RDNA's NaN result for everyv_add_f32,v_sub_f32,v_subrev_f32andv_mul_f32(nanResultF32/propagatedNanResultF32). That sequence dominates the SPIR-V of large compute programs and the time the driver spends compiling them, which is what trips the title watchdogs in #6118 and #12089 (see also #11183). #17227 already drops the selects whose payload nothing observes; this change covers the ones that remain.v_mul_f32keeps its tiny-product flush.ProbeFloat32SingleNans,Execution/src/Float32NanProbe.cpp), in the style ofFloatFlushProbe, runs the four instructions over every ordered pair of four buffer-loaded registers. It covers 32 lanes and 8 rounds of quiet and signalling NaNs with different payloads and signs, infinities, zeros, normals and denormals, with no float mode and with denormals flushed. It compiles each mode once with the emulated NaN and once with the guard, and compares 24,576 results bit for bit. It takes about 10 ms.SpirvTarget::float32SingleNansis set only when every result matches. It is part of the cache key and of the serialized request (version 58; older requests read asfalse).APS5_FAST_F32,IEEE_MODE, a directed f32 rounding mode and the fused forms keep their current paths.APS5_NO_NATIVE_F32_NANSskips the probe.agc_shader_replay --f32-single-nansreplays a request with the flag.tests/execution/Float32NanProbe.cpp. It checks that the guarded module is smaller than the emulated one, thatIEEE_MODEoutput is unchanged by the flag, that the probe compares all 24,576 results, and that a device with the flag set reports no mismatch.RequestSerializerTestscovers version 58: round trip, truncation, a version 57 request and the future-version check.ARCHITECTURE.mdsection,ENVIRONMENT.mdrow, and a debt entry indocs/dev/debt/libSceAgcDriver.md. The debt entry records what the probe cannot see: a different compiler choice on larger programs, other stages and wave64.Tested
Windows 11 Pro 26H2 (build 26300.9974), AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (LLPC) 32.0.32015.7029, Ryzen 9 7900X, 32 GB.
Probe at startup:
operand guard (0 of 24576 probe results differ, 10 ms).Pipeline creation for a synthetic compute program of random f32 add, sub and mul.
mainalready includes #17227. Each pair ran on the same build with and withoutAPS5_NO_NATIVE_F32_NANS:main→ PR5979e000both5979e000both5979e000both5979e000bothd979e000bothNaN-heavy program: 10,053 → 9,121 words, checksum
5dbf7838on both.Focused AGC and shader tests: 18/18 pass.
agc_shader_memoryandagc_shader_memory_coherent_atomic_loadspass after the version 58 update.Validation run with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, Vulkan SDK layer 1.4.368:main: 16/16 pass.VUID-errors.tools/check_conventions.pypasses.ProsperoLight (PPSA99002 01.000.110) at 3840x2160 on
mainand on this PR:performance_comparereports no configuration differences.1a4faa376f. The head commit differs from it only intests/ShaderMemory.cpp, which now expects serialization version 58.main:seconds 20:10 from present 1197: 600 presents, frame p50 16.7 / p90 16.9 / p99 17.0 / max 17.0 ms, GPU busy 6.2 ms per present
AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
2db3a6bf65, dropped: noThis PR:
seconds 20:10 from present 1197: 600 presents, frame p50 16.7 / p90 16.9 / p99 17.0 / max 17.1 ms, GPU busy 6.0 ms per present
AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit 1a4faa376fd1, dropped: no
Traces and digests attached.
Overlap:
floatBinary.ProbeFloat32SingleNansbelongs inside its RDNA section.Checklist
main; no other open PR implements the same functionsNotImplemented_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 MarcZX10 on 2026-11-14T21:00:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and compatibility paths support merging.
What I ran
Reviewed head
90065c79251514aca64aee41663aff17e282bbcfusingrepo_read.pyto inspect the prepared diff and targeted source ranges. No tests or builds were run. The author-reported test results are not results from this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or build were run. Hardware behavior beyond the reported RX 7900 XT test was not verified. The prepared bundle excluded full file text for
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; their changed regions were read through the pinned reader. All changed files listed in the review manifest were reviewed; no changed files were excluded by rule.To get this to a good state
Nothing is required.
Pull request closed