perf(agc): probe the f32 denormal flush on MoltenVK #8578
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8578"
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 imellag on 2026-10-20T17:16:57Z.
What
The startup probe that switches shaders from the emulated f32 denormal flush to the device's own flush (
FloatFlushProbe, which compares 5472 results against the emulation and switches only when none differ) runs only on devices that declareshaderDenormFlushToZeroFloat32with independent denormal behavior. MoltenVK declares neither, so on macOS every shader keeps the emulated flush around every f32 add, multiply, fma, min, max and comparison.Float32FlushControlFor(new, Execution/include/Float32FlushControl.hpp) now decides two things from the driver ID and the float controls: whether to probe (as before, plusVK_DRIVER_ID_MOLTENVK) and whether the device declares the flush.VulkanDevicekeeps the driver ID from the driver properties query and addsCapabilityDenormFlushToZeroonly when it is declared;SpirvModuleSetupemits theDenormFlushToZeroexecution mode only when that capability is supported. On MoltenVK a module compiled for the hardware flush therefore declares no execution mode and relies on the native behavior the probe measured; if any probe result differs, shaders keep the emulation as before. For every other driver the decision is the old condition, so nothing changes there.agc_float32_flush_controlcovers the decision;agc_driver_f32_denormal_flushalso checks the natively flushed module (no execution mode, fewer words than the emulated one).#8014 also stores the driver ID in
VulkanDevice; whichever of the two merges second can use the other's field.Tested
Apple M4 Pro, macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), Apple clang 21.0.0.
main83751168d: the libraries do not build on macOS, so the changed files (VulkanDevice.cpp, SpirvModuleSetup.cpp, F32DenormalFlush.cpp) were compiled on their own andagc_float32_flush_controlwas run: passes.ci/macos-series-253db0badb (plus #7937's code commits, needed to build libkernel, and #8477), AGC and shader suites on MoltenVK: 761/807 without this change, 762/808 with it, the same 46 failures. All 10 probe lines in that run read[float-controls] f32 denormal flush: hardware (0 of 5472 probe results differ from the emulated flush).agc_driver_f32_denormal_flushfails in both runs at the same case (v_mul_f32 v25, |v4|, -v5gives0x00000000, expected0x80000000): a signed zero lost by SPIRV-Cross's helper for NoContraction multiplies, unrelated to the flush.APS5_TRACE_SECONDS=140:5only, base and change alternated twice in one session. The base is the macOS integration head7cf8c610c(former #7332) and notmain, because titles do not run frommainon macOS. The presenter waits about 4 ms less per frame for the GPU (GPU busy per present is noisier), and the frame rate rises by about 10%:7cf8c610c7cf8c610cSummary lines
In the two captures of the change the queue worker's trace buffer filled 4.8 and 4.9 s into the 5 s window (
trace_dropped). The four traces are attached in a comment below. Linux and Windows were not run; for drivers other than MoltenVK the probe decision is unchanged, as the unit test checks.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 imellag on 2026-10-20T17:17:54Z.
Traces of the four captures in the table above, in the same order (each file name matches the
tracefield of its summary line):1-base-1-aps5-trace-7cf8c610c6a7-63071.json.gz
2-change-1-aps5-trace-bb294211065d-64633.json.gz
3-base-2-aps5-trace-7cf8c610c6a7-66252.json.gz
4-change-2-aps5-trace-bb294211065d-67934.json.gz
They open in ui.perfetto.dev;
python3 tools/trace_digest.py <trace>gives the per-thread table the presenter wait comes from.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T17:26:56Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL1326-1328Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T21:27:44Z.
Checked the decision table (
agc_float32_flush_control), that drivers other than MoltenVK keep the old condition, that theDenormFlushToZeromode is emitted only with the device capability, and that the probe still gates the switch (any differing result keeps the emulation). Re-checked against current main: clean merge, no semantic overlap. The measured presenter-wait and frame-time gain on MoltenVK is consistent with the change; merged.Imported from boykopovar/AnyPS5. Originally posted by Mauro42K on 2026-10-21T00:19:35Z.
Tested the M1 probe on a MacBook Pro (Apple M1, macOS 27.0.1) with LunarG Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2. The filtered
^(agc|shader)CTest suite was run with-j2, using the same reference profile at both revisions.2bfbc2fcffc97ddbf9fd00ac2a5f4ba77b6e6f66: 807 tests, 683 passed, 73 skipped, 51 failed/aborted.a4a16a6f860afcdc5c2fbbd3d48c3701c33fbc27: 808 tests, 687 passed, 73 skipped, 48 failed/aborted.[float-controls]probe reportedhardware (0 of 5472 probe results differ from the emulated flush)in all 614 occurrences recorded at the #8578 revision. The baseline does not contain this probe output.Three tests that failed at baseline passed at the #8578 revision:
agc_driver_sgpr_pattern_fill_keys,agc_driver_storage_read_during_idle_store, andagc_driver_vertex_target_range_imported. No new failing tests appeared in the selected suite. This is one run per revision; it does not establish causality or repeatability for those changes.The reference-profile failure lists are included below. “Failed/aborted” follows CTest’s summary;
agc_driver_rect_list_indirect,agc_driver_vertex_clip_cull_draw, andagc_driver_vertex_clip_cull_draw_no_keywere subprocess aborts at both revisions.Baseline failures — 2bfbc2fcf (51)
agc_driver_compute_fs_table_callsagc_driver_dpp16_operandsagc_driver_f16_conversion_float_modeagc_driver_f16_fma_denormal_modesagc_driver_f32_constant_factor_tininessagc_driver_f32_denormal_flushagc_driver_f32_output_modifieragc_driver_f64_add_mul_denormal_modesagc_driver_f64_rounding_denormal_modesagc_driver_float16_fma_roundingagc_driver_float16_miscagc_driver_float16_modifiersagc_driver_float16_roundingagc_driver_guest_memory_lifetimeagc_driver_guest_memory_lifetime_copyagc_driver_guest_memory_lifetime_directagc_driver_guest_memory_lifetime_heapagc_driver_guest_memory_lifetime_heap_uncachedagc_driver_guest_memory_lifetime_lockedagc_driver_image_cache_bitsagc_driver_image_plane_bias_on_single_level_volumeagc_driver_image_srgb_sample_copyagc_driver_image_srgb_sample_copy_forcedagc_driver_image_table_reuseagc_driver_image_texel_statusagc_driver_indirect_arguments_pending_produceragc_driver_ldexp_f16_inline_constantsagc_driver_multisample_retirementagc_driver_packed_aluagc_driver_packed_f16_denormal_modesagc_driver_pass_input_hazardagc_driver_pixel_interlockagc_driver_pixel_sample_coverageagc_driver_pixel_sample_iterationagc_driver_rect_list_indirectagc_driver_sample_mask_multisampleagc_driver_sdwa_float_selectorsagc_driver_sdwa_ldexp_f16agc_driver_sgpr_pattern_fill_keysagc_driver_stencil_ref_export_unusedagc_driver_storage_read_during_idle_storeagc_driver_tessellationagc_driver_uint8x4_color_targetagc_driver_vertex_clip_cull_distancesagc_driver_vertex_clip_cull_drawagc_driver_vertex_clip_cull_draw_no_keyagc_driver_vertex_target_range_importedagc_driver_vertex_user_data_tailagc_driver_vop2_modifier_formsagc_performance_overlay_statisticsagc_write_trackingWith #8578 — a4a16a6f8 (48)
agc_driver_compute_fs_table_callsagc_driver_dpp16_operandsagc_driver_f16_conversion_float_modeagc_driver_f16_fma_denormal_modesagc_driver_f32_constant_factor_tininessagc_driver_f32_denormal_flushagc_driver_f32_output_modifieragc_driver_f64_add_mul_denormal_modesagc_driver_f64_rounding_denormal_modesagc_driver_float16_fma_roundingagc_driver_float16_miscagc_driver_float16_modifiersagc_driver_float16_roundingagc_driver_guest_memory_lifetimeagc_driver_guest_memory_lifetime_copyagc_driver_guest_memory_lifetime_directagc_driver_guest_memory_lifetime_heapagc_driver_guest_memory_lifetime_heap_uncachedagc_driver_guest_memory_lifetime_lockedagc_driver_image_cache_bitsagc_driver_image_plane_bias_on_single_level_volumeagc_driver_image_srgb_sample_copyagc_driver_image_srgb_sample_copy_forcedagc_driver_image_table_reuseagc_driver_image_texel_statusagc_driver_indirect_arguments_pending_produceragc_driver_ldexp_f16_inline_constantsagc_driver_multisample_retirementagc_driver_packed_aluagc_driver_packed_f16_denormal_modesagc_driver_pass_input_hazardagc_driver_pixel_interlockagc_driver_pixel_sample_coverageagc_driver_pixel_sample_iterationagc_driver_rect_list_indirectagc_driver_sample_mask_multisampleagc_driver_sdwa_float_selectorsagc_driver_sdwa_ldexp_f16agc_driver_stencil_ref_export_unusedagc_driver_tessellationagc_driver_uint8x4_color_targetagc_driver_vertex_clip_cull_distancesagc_driver_vertex_clip_cull_drawagc_driver_vertex_clip_cull_draw_no_keyagc_driver_vertex_user_data_tailagc_driver_vop2_modifier_formsagc_performance_overlay_statisticsagc_write_trackingTests were run with assistance from OpenAI Codex; the figures and test lists were checked against the captured local logs. No game-performance claim is inferred from these tests.