perf(shader): let APS5_FAST_F32 compile f32 arithmetic with host float rules #10720
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10720"
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 meh7an on 2026-10-24T19:33:43Z.
What
APS5_FAST_F32(set to anything but0) compiles f32 arithmetic with the host GPU's float rules instead of emulating RDNA's.nanResultF32returns the instruction's host result. Onmainit picks RDNA's NaN: the first NaN source, quieted in IEEE mode; else0xffc00000when the result is NaN.f32DenormalFlushForasks for no software flush. Onmainit emulates RDNA's denormal flush in software wherever the device's own flush (ProbeFloat32FlushToZero) does not cover the instruction.SourceVersiondiffers).Results differ from RDNA's only when a result is a NaN (its sign and payload bits) or a denormal (the host's rules decide whether it is flushed). The switch is off by default, so nothing changes unless it is set.
A question for the maintainers. On the page measured below, the exact rules cost about a quarter of the GPU time. Would you take host rules as the default, with an exact opt-in, the way
v_rcp_f32uses the driver's division unlessAPS5_EXACT_RCPis set? I kept it opt-in here so that is your call. If you'd rather have it as the default, I'll flip it in this PR and rename the switch.Test.
agc_driver_f32_arithmetic_nan_fast(new) runs the f32 NaN program ofagc_driver_f32_arithmetic_nanwithAPS5_FAST_F32=1. Every non-NaN result must match RDNA as before; a result that RDNA gives as a NaN only has to be a NaN. Without that allowance it fails at lane 0'sv_add_f32, which returns0x7fffffff(NVIDIA's NaN) where RDNA returns0x7f812345. The default test is unchanged.Related. Both of these stay exact; this switch is for users who accept host NaN payloads and denormals:
tools/pr_overlap.pylists one conflict: #4287 rewrites the body ofnanResultF32, where this PR adds an early return as the first line. The proposed order is #4287 first (comment). Once it merges, this PR rebases onto it and keeps that line as the function's first statement. It found no other overlap. Of the PRs it could not compare, #5925, #6858 and #6924 only callShaderDiskCache::SourceVersion(), which returns each mode's own version.Tested
Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 2080 Ti, driver 617.14, i9-9900K, on
main29f539a5f3.Sonic Origins Plus (PPSA05324), Sonic 2 page of the main menu,
main's defaults otherwise. One build, two arms: the default (exact) andAPS5_FAST_F32=1. Each arm got one warm-up boot (each mode has its own shader cache version), then one traced round (APS5_TRACE_SECONDS=200:15). The build is 991731d42276, which differs from this PR's head only in the test and its registration.Driver.Packet(ms/frame)APS5_FAST_F32=1ctest(2159 tests) onmainplus this PR: everything passes exceptagc_driver_depth_plane_partial_store("repeated lookups of the first layer of an unchanged array proved no refresh"), which fails the same way on plainmain29f539a5f3on this machine.ctest --test-dir build -R "f32|f16|nan|denormal|rcp|float|fma" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 88/88 onmain, 89/89 on this PR (the extra one isagc_driver_f32_arithmetic_nan_fast). Neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line.The two summaries and their digests (both traces are attached):
fast-f32-s2-traces.zip
default (exact)
seconds 200:15 from present 3536: 179 presents, frame p50 82.9 / p90 91.5 / p99 99.3 / max 100.9 ms, GPU busy 68.7 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 991731d42276, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 68.6, Graphics.Draw 30.9, Driver.Present 27.2, VideoOut.Flip 27.2, VideoOut.Flip.present 27.0, Driver.Present.render_fence_wait 26.6, Vulkan.Retire 26.6, Vulkan.Retire.wait 26.6, Graphics.Draw.draw_and_resource_release 25.1, Driver.Packet 16.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
APS5_FAST_F32=1
seconds 200:15 from present 3652: 177 presents, frame p50 82.5 / p90 94.9 / p99 110.9 / max 115.6 ms, GPU busy 50.5 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 991731d42276, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 50.4, Graphics.Draw 32.1, Graphics.Draw.draw_and_resource_release 26.4, Driver.Present 17.7, VideoOut.Flip 17.7, VideoOut.Flip.present 17.6, Driver.Present.render_fence_wait 17.2, Vulkan.Retire 17.2, Vulkan.Retire.wait 17.2, Driver.Packet 17.0
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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-10-24T19:36:48Z.
Review: CHANGES_REQUESTED
Reviewed exact head
7d6cc57fdf7fb9b6ad5e683807329d4a8a24d50a. The opt-in switch is applied consistently to NaN-result selection, denormal handling, and shader-cache versioning; the PR reports paired focused Vulkan tests and performance traces. Local diff-check and conventions pass; I could not run the GPU tests in this environment. One integration blocker remains: open #4287 changes the body ofnanResultF32, where this PR adds its early return. The description says whichever lands second should preserve the line, but the checklist saysDepends on: noneand does not record an agreed order. CONTRIBUTING requires coordinating overlapping changes and recording the dependency/order. Please confirm the plan with the other author and update the checklist.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:20:58Z.
Review: COMMENTED
The implementation is opt-in, changes the shader cache key, and the author reports paired focused Vulkan runs with validation enabled and no VUIDs, so the change itself is well scoped. I would keep the default decision with maintainers as the PR does. One evidence caveat for the performance data: both trace captures say
trace_dropped: true, with hundreds of thousands of lost events on the queue worker and draw committer. GPU-busy-per-present is still reported by the trace tool, but please clarify whether that aggregate remains complete when event buffers fill, and attach/comparetools/trace_digest.pysummaries as the repository performance rule requires. The current PR text has detailed summaries but no visible trace-digest output in the body; I cannot validate the 26% GPU-busy claim from the pasted excerpts alone. I am leaving this as a non-blocking comment pending that clarification.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:24:09Z.
Review: APPROVED
Re-reviewed exact head
7d6cc57fdf7fb9b6ad5e683807329d4a8a24d50a. The checklist now recordsDepends on: #4287, matching the stated merge order. The attached archive and body include thetrace_digest.pysummaries for both arms, with dropped-event counts and the higher p90/p99 for the fast arm disclosed. I checked the current trace implementation:gpu_busy_ms_per_presentis derived from the Vulkan present counters, which accumulate completed GPU timestamp batch durations; it does not use the bounded per-thread event buffers that dropped queue-worker and draw-committer slices in these traces. The JSON also does not report the GPU range snapshot as dropped. That supports the reported aggregate GPU-busy metric while limiting the dropped traces’ completeness for CPU slice attribution. The PR reports paired main/change validation runs and no VUIDs on the RTX 2080 Ti; I did not rerun the Vulkan tests locally. Product jobs are skipped by hosted PR policy. The opt-in remains off by default as described. No remaining review blocker found.