| Flutter Impeller |

Classes | Public Member Functions | Friends | List of all members
impeller::GPUTracerVK Class Referenceabstract

A class that uses timestamp queries to record the approximate GPU execution time. More...

`#include <gpu_tracer_vk.h>`

Inheritance diagram for impeller::GPUTracerVK:

## Public Member Functions
| GPUTracerVK (const std::shared_ptr< DeviceHolder > &device_holder)
| ~GPUTracerVK ()=default
std::unique_ptr< GPUProbe > | CreateGPUProbe ()
| Create a GPUProbe to trace the execution of a command buffer on the GPU. More...
void | MarkFrameStart ()
| Signal the start of a frame workload. More...
void | MarkFrameEnd ()
| Signal the end of a frame workload. More...
bool | IsEnabled () const

## Friends
class | GPUProbe

## Detailed Description

A class that uses timestamp queries to record the approximate GPU execution time.

Definition at line 18 of file gpu_tracer_vk.h.

## Constructor & Destructor Documentation

## ◆ GPUTracerVK()

impeller::GPUTracerVK::GPUTracerVK | ( | const std::shared_ptr< DeviceHolder > & | device_holder | ) |
| explicit

Definition at line 21 of file gpu_tracer_vk.cc.

22 : device_holder_(device_holder) {
23 timestamp_period_ = device_holder_->GetPhysicalDevice()
24 .getProperties()
25 .limits.timestampPeriod;
26 if (timestamp_period_ <= 0) {
27 // The device does not support timestamp queries.
28 return;
29 }
30 // Disable tracing in release mode.
31 #ifdef IMPELLER_DEBUG
32 enabled_ = true;
33 #endif
34 }

## ◆ ~GPUTracerVK()

impeller::GPUTracerVK::~GPUTracerVK | ( |  | ) |
| default

## Member Function Documentation

## ◆ CreateGPUProbe()

std::unique_ptr< GPUProbe > impeller::GPUTracerVK::CreateGPUProbe | ( |  | ) |

Create a GPUProbe to trace the execution of a command buffer on the GPU.

Definition at line 67 of file gpu_tracer_vk.cc.

67 {
68 return std::make_unique<GPUProbe>(weak_from_this());
69 }

## ◆ IsEnabled()

bool impeller::GPUTracerVK::IsEnabled | ( |  | ) | const

Definition at line 36 of file gpu_tracer_vk.cc.

36 {
37 return enabled_;
38 }

## ◆ MarkFrameEnd()

void impeller::GPUTracerVK::MarkFrameEnd | ( |  | ) |

Signal the end of a frame workload.

Definition at line 46 of file gpu_tracer_vk.cc.

46 {
47 if (!enabled_) {
48 return;
49 }
50
51 Lock lock(trace_state_mutex_);
52 current_state_ = (current_state_ + 1) % kTraceStatesSize;
53
54 auto& state = trace_states_[current_state_];
55 // If there are still pending buffers on the trace state we're switching to,
56 // that means that a cmd buffer we were relying on to signal this likely
57 // never finished. This shouldn't happen unless there is a bug in the
58 // encoder logic. We set it to zero anyway to prevent a validation error
59 // from becoming a memory leak.
60 FML_DCHECK(state.pending_buffers == 0u);
61
62 state.pending_buffers = 0;
63 state.current_index = 0;
64 in_frame_ = false;
65 }

## ◆ MarkFrameStart()

void impeller::GPUTracerVK::MarkFrameStart | ( |  | ) |

Signal the start of a frame workload.

       Any cmd buffers that are created after this call and before
       [MarkFrameEnd] will be attributed to the current frame.

Definition at line 40 of file gpu_tracer_vk.cc.

40 {
41 FML_DCHECK(!in_frame_);
42 in_frame_ = true;
43 raster_thread_id_ = std::this_thread::get_id();
44 }

## Friends And Related Function Documentation

## ◆ GPUProbe

friend class GPUProbe
| friend

Definition at line 41 of file gpu_tracer_vk.h.

The documentation for this class was generated from the following files:

- impeller/renderer/backend/vulkan/gpu_tracer_vk.h
- impeller/renderer/backend/vulkan/gpu_tracer_vk.cc