perf(agc): probe the f32 denormal flush on KosmicKrisp for compute shaders #15859
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15859"
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 Gonic0 on 2026-11-04T20:07:16Z.
What
KosmicKrisp (Mesa's Vulkan on Metal) declares no f32 denormal flush, like MoltenVK and NVIDIA's proprietary driver, so every shader keeps the emulated flush. It now runs the startup probe (
ProbeFloat32FlushToZero) as those two do. On an Apple M5 Pro the probe matches (0 of 5472 results differ).When it matches, only compute shaders get the hardware flush.
Float32FlushControlgainscomputeOnly, set forVK_DRIVER_ID_MESA_KOSMICKRISP;VulkanDevice::Target()then leavesSpirvTarget::float32FlushToZerooff, andComputeTarget()sets it. Every graphics request is built fromTarget()and every compute request fromComputeTarget(), so graphics stages keep the emulated flush.Graphics stages are left out because, with the flush in them too, Metal's shader compiler service (
MTLCompilerService) drops its connection while KosmicKrisp builds one vertex/pixel pipeline of PPSA21564: pipeline creation returnsVK_ERROR_INVALID_SHADER_NVand the title stops about 30 s in, in every run. The same pair compiles with the emulated flush, and the title runs with the hardware flush on MoltenVK. This is recorded as debt;ARCHITECTURE.mdnames KosmicKrisp and the compute-only rule.The compute modules of PPSA21564 shrink by 17 to 23 % of their SPIR-V words, and their cold Metal compile time by 22 to 28 %.
Tested
macOS 27.2, Apple M5 Pro, Apple clang 21, x86-64 Release under Rosetta 2, KosmicKrisp built from Mesa
main(x86-64,MESA_KK_DISABLE_WORKAROUNDS=10).agc_float32_flush_control_testsgains two KosmicKrisp cases (computeOnlyset, with and without a declared flush). It passes on this branch, onmain9f35c937da. WithcomputeOnlyforced off, it fails on both new cases.VulkanDevice.cppcompiles on this branch.libkerneldoes not link on macOS on thismainwithout the open macOS port pull requests, so the GPU tests and the title ran on a tree with them (main04a9eb4fa2plus those pull requests, #7514, #10743 and #15583, and lab switches that stay off), built once without and once with this commit.ctest -R 'f32|f16|denorm|float32|mullit') on KosmicKrisp withANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1: every startup logsf32 denormal flush: hardware. 56 pass, 7 fail:agc_driver_div_scale_fixup_f32_denormal_modes,agc_driver_f16_fma_invalid_nan,agc_driver_f32_arithmetic_nan,agc_driver_f32_constant_factor_tininess,agc_driver_f32_denormal_flush,agc_driver_interpolation_f16andagc_driver_lds_add_f32. The same 7 fail with the same messages withAPS5_NO_HW_F32_FLUSH=1(emulated flush everywhere), e.g.f32 denormal flush: lane 8 no float mode v_fma_f32 v14, v4, v5, v6 is 0x00000000, expected 0x00800000in both, so they are KosmicKrisp's and unrelated to this change.APS5_PROFILE_DRAW=1, not the Performance report form), mean presents per 10 s and GPU busy per frame from 95 to 140 s. The first round compiled 29 pipelines cold in both runs and is left out; the other rounds compiled none:mainPerformance report form captures,
APS5_TRACE_FRAMES=1100:300(an earlier part of the level than the window above), noAPS5_PROFILE_*switch and no otherAPS5_TRACE_*switch thanAPS5_TRACE_DIR(the log goes to a file, as in #15583), alternating, same machine and session, no cold compiles:mainmainIn this window the frame times are about 2 % shorter and GPU busy per present is unchanged; the window above, later in the level, is where the compute work is heaviest.
Summary lines (pair 2):
Traces:
main: aps5-trace-9d57532f1be6-69802.json.gzmain: aps5-trace-9d57532f1be6-76377.json.gztools/trace_digest.pyfor pair 2:main(9d57532f1be6)frames 1100:300 from present 1100: 300 presents, frame p50 72.6 / p90 85.9 / p99 99.0 / max 121.2 ms, GPU busy 55.6 ms per present
Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 9d57532f1be6, dropped: yes
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 185.6, Driver.Packet.memory_wait 140.0, batch 55.7, Driver.Packet.prepare_memory 18.8, Graphics.Draw 18.0, Exp.FenceWait.idle 17.9, Driver.Packet.draw 13.8, Driver.Draw 13.8, Graphics.Draw.draw_and_resource_release 12.0, Driver.Packet.dispatch 7.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
this change (09e4d8069b2e)
frames 1100:300 from present 1100: 300 presents, frame p50 71.5 / p90 83.5 / p99 96.9 / max 116.1 ms, GPU busy 55.9 ms per present
Apple M5 Pro, KosmicKrisp Mesa 27.0.0-devel (git-b5b73e5964), Darwin 27.2.0, 3840x2160, commit 09e4d8069b2e, dropped: yes
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 182.1, Driver.Packet.memory_wait 137.9, batch 56.0, Driver.Packet.prepare_memory 18.4, Exp.FenceWait.idle 17.5, Graphics.Draw 17.2, Driver.Packet.draw 13.2, Driver.Draw 13.1, Graphics.Draw.draw_and_resource_release 11.7, Driver.Packet.dispatch 7.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Overlap
tools/pr_overlap.pyreports text conflicts only:ARCHITECTURE.mdparagraph (the probe programs' location).VulkanDevice's state (an f16 NaN probe for RDNA).None of them changes the f32 flush control.
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)main), macOS 27.2🤖 Generated with Claude Code