macOS: Show MoltenVK submit, image acquire, and metal encode on Optick trace #871
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a macOS-only enhancement that shows MoltenVK's processing periods on the Optick trace. This information is quite interesting since it shows waiting periods for: a) Vulkan command buffer async submit, b) Vulkan/Metal image acquire (related to image present), and c) Vulkan to Metal encoding prior to execution on the GPU.
This also adds a new capability for Optick: the ability to add custom tags to Optick custom storage. This enhancement has already been submitted to the optik project at bombomby/optick#196.
This also fixes a minor HUD bug that would result in MoltenVK's encoding time showing 0 when Optick tracing is active.
UPDATE: Also fixes a new issue with cmake >= 3.29 where Apple
.xcframework
bundles are now supported. This causes issues withfind_package()
for libMoltenVK.dylib in recent Vulkan SDK versions (1.3.275 and later). Solution is toset(CMAKE_FIND_FRAMEWORK LAST)
which prioritizes dylibs over.framework
and.xcframework
bundles.This PR is compatible with current Vulkan SDK and MoltenVK releases, but to see the additional Optick traces you will need MoltenVK 1.2.9 (current dev stream) where additional performance statistics are available to the application (see merged PR KhronosGroup/MoltenVK#2183). This new Optick feature can be tested now using local builds of MoltenVK main, and will be generally available when using the next major release of the Vulkan SDK (i.e. the one after 1.3.280).
Here are some Optick traces that show the enhancement:
Vulkan command buffer submit scheduling wait (vsync off):
Vulkan/Metal image acquire wait (vsync on) - note relationship to Present timing:
Vulkan-to-Metal encoding time (vsync off) - note relationship to GPU execution:
The above traces are shown with
r_mvkSynchronousQueueSubmits
set to false (the default) for maximum fps. If you set this cvar to true, then latency is reduced but at the expense of performance. In some sense this is the macOS equivalent to setting the DX12 cvarr_maxFrameLatency = 1
in the proposed PR #784. Here is an example trace withr_mvkSynchronousQueueSubmits = true
, where queue submit to present time is minimized: