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_;
78 GPUTraceState trace_states_[kTraceStatesSize] IPLR_GUARDED_BY(
81 std::vector<size_t> IPLR_GUARDED_BY(trace_state_mutex_) states_to_reset_ = {};
84 float timestamp_period_ = 1;
93 bool in_frame_ =
false;
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(const std::weak_ptr< GPUTracerVK > &tracer)
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.
GPUTracerVK(std::weak_ptr< ContextVK > context, bool enable_gpu_tracing)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer