Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Private Member Functions | List of all members
impeller::GPUTracerMTL Class Referenceabstract

Approximate the GPU frame time by computing a difference between the smallest GPUStartTime and largest GPUEndTime for all command buffers submitted in a frame workload. More...

#include <gpu_tracer_mtl.h>

Inheritance diagram for impeller::GPUTracerMTL:

Public Member Functions

 GPUTracerMTL ()=default
 
 ~GPUTracerMTL ()=default
 
void MarkFrameEnd ()
 Record that the current frame has ended. Any additional cmd buffers will be attributed to the "next" frame. More...
 
void RecordCmdBuffer (id< MTLCommandBuffer > buffer)
 Record the current cmd buffer GPU execution timestamps into an aggregate frame workload metric. More...
 

Private Member Functions

size_t current_state_ IPLR_GUARDED_BY (trace_state_mutex_)=0u
 

Detailed Description

Approximate the GPU frame time by computing a difference between the smallest GPUStartTime and largest GPUEndTime for all command buffers submitted in a frame workload.

Definition at line 23 of file gpu_tracer_mtl.h.

Constructor & Destructor Documentation

◆ GPUTracerMTL()

impeller::GPUTracerMTL::GPUTracerMTL ( )
default

◆ ~GPUTracerMTL()

impeller::GPUTracerMTL::~GPUTracerMTL ( )
default

Member Function Documentation

◆ IPLR_GUARDED_BY()

size_t current_state_ impeller::GPUTracerMTL::IPLR_GUARDED_BY ( trace_state_mutex_  )
privatepure virtual

◆ MarkFrameEnd()

void impeller::GPUTracerMTL::MarkFrameEnd ( )

Record that the current frame has ended. Any additional cmd buffers will be attributed to the "next" frame.

Definition at line 16 of file gpu_tracer_mtl.mm.

16 {
17 if (@available(ios 10.3, tvos 10.2, macos 10.15, macCatalyst 13.0, *)) {
18 Lock lock(trace_state_mutex_);
19 current_state_ = (current_state_ + 1) % 16;
20 }
21}
SK_API sk_sp< SkSurface > ios(9.0)
SK_API sk_sp< SkSurface > tvos(9.0))

◆ RecordCmdBuffer()

void impeller::GPUTracerMTL::RecordCmdBuffer ( id< MTLCommandBuffer >  buffer)

Record the current cmd buffer GPU execution timestamps into an aggregate frame workload metric.

Definition at line 23 of file gpu_tracer_mtl.mm.

23 {
24 if (@available(ios 10.3, tvos 10.2, macos 10.15, macCatalyst 13.0, *)) {
25 Lock lock(trace_state_mutex_);
26 auto current_state = current_state_;
27 trace_states_[current_state].pending_buffers += 1;
28
29 auto weak_self = weak_from_this();
30 [buffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
31 auto self = weak_self.lock();
32 if (!self) {
33 return;
34 }
35 Lock lock(self->trace_state_mutex_);
36 auto& state = self->trace_states_[current_state];
37 state.pending_buffers--;
38 state.smallest_timestamp = std::min(
39 state.smallest_timestamp, static_cast<Scalar>(buffer.GPUStartTime));
40 state.largest_timestamp = std::max(
41 state.largest_timestamp, static_cast<Scalar>(buffer.GPUEndTime));
42
43 if (state.pending_buffers == 0) {
44 auto gpu_ms =
45 (state.largest_timestamp - state.smallest_timestamp) * 1000;
46 state.smallest_timestamp = std::numeric_limits<float>::max();
47 state.largest_timestamp = 0;
48 FML_TRACE_COUNTER("flutter", "GPUTracer",
49 reinterpret_cast<int64_t>(this), // Trace Counter ID
50 "FrameTimeMS", gpu_ms);
51 }
52 }];
53 }
54}
AtkStateType state
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
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
Definition: switches.h:126
float Scalar
Definition: scalar.h:18
#define FML_TRACE_COUNTER(category_group, name, counter_id, arg1,...)
Definition: trace_event.h:85

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