5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_GPU_TRACER_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_GPU_TRACER_VK_H_
13#include "vulkan/vulkan_handles.hpp"
26class GPUTracerVK :
public std::enable_shared_from_this<GPUTracerVK> {
28 GPUTracerVK(std::weak_ptr<ContextVK> context,
bool enable_gpu_tracing);
54 static const constexpr size_t kTraceStatesSize = 16u;
59 void OnFenceComplete(
size_t frame);
63 void RecordCmdBufferStart(
const vk::CommandBuffer&
buffer,
GPUProbe& probe);
67 void RecordCmdBufferEnd(
const vk::CommandBuffer&
buffer,
GPUProbe& probe);
69 std::weak_ptr<ContextVK> context_;
71 struct GPUTraceState {
72 size_t current_index = 0;
73 size_t pending_buffers = 0;
74 vk::UniqueQueryPool query_pool;
77 mutable Mutex trace_state_mutex_;
81 std::vector<size_t>
IPLR_GUARDED_BY(trace_state_mutex_) states_to_reset_ = {};
84 float timestamp_period_ = 1;
93 bool in_frame_ =
false;
97 std::thread::id raster_thread_id_;
98 bool enabled_ =
false;
103 explicit GPUProbe(
const std::weak_ptr<GPUTracerVK>& tracer);
121 std::weak_ptr<GPUTracerVK> tracer_;
122 std::optional<size_t> index_ = std::nullopt;
void RecordCmdBufferStart(const vk::CommandBuffer &buffer)
Record a timestamp query into the provided cmd buffer to record start time.
GPUProbe(GPUProbe &&)=delete
GPUProbe & operator=(GPUProbe &&)=delete
void RecordCmdBufferEnd(const vk::CommandBuffer &buffer)
Record a timestamp query into the provided cmd buffer to record end time.
A class that uses timestamp queries to record the approximate GPU execution time.
void MarkFrameStart()
Signal the start of a frame workload.
void MarkFrameEnd()
Signal the end of a frame workload.
size_t current_state_ IPLR_GUARDED_BY(trace_state_mutex_)=0u
std::unique_ptr< GPUProbe > CreateGPUProbe()
Create a GPUProbe to trace the execution of a command buffer on the GPU.
void InitializeQueryPool(const ContextVK &context)
Initialize the set of query pools.
static const uint8_t buffer[]
#define IPLR_GUARDED_BY(x)