Using Tracy GPU profiling
Tracy includes a feature that uses Vulkan timestamps to obtain timing information for commands executed on the GPU. If the Vulkan extension VK_EXT_calibrated_timestamps
is supported, the GPU timing data is synchronized to the same reference frame as the CPU timing. Let’s take a quick look at how to add Tracy GPU profiling to Vulkan within the VulkanContext
.
Getting ready
The corresponding C++ source code can be found in lvk/vulkan/VulkanClasses.cpp
.
How to do it...
Tracy GPU profiling can be integrated into existing Vulkan code as follows.
- First, include the
TracyVulkan.hpp
header and define a helper macro to use within our rendering functions.#if defined(LVK_WITH_TRACY_GPU) #include "tracy/TracyVulkan.hpp" #define LVK_PROFILER_GPU_ZONE(name, ctx, cmdBuffer, color) \ TracyVkZoneC(ctx->pimpl_->tracyVkCtx_, cmdBuffer, name, color); #else #define LVK_PROFILER_GPU_ZONE(name, ctx, cmdBuffer,...