Flutter Impeller
impeller::GPUTracerGLES Class Reference

Trace GPU execution times using GL_EXT_disjoint_timer_query on GLES. More...

#include <gpu_tracer_gles.h>

Public Member Functions

 GPUTracerGLES (const ProcTableGLES &gl, bool enable_tracing)
 
 ~GPUTracerGLES ()=default
 
void RecordRasterThread ()
 Record the thread id of the raster thread. More...
 
void MarkFrameStart (const ProcTableGLES &gl)
 Record the start of a frame workload, if one hasn't already been started. More...
 
void MarkFrameEnd (const ProcTableGLES &gl)
 Record the end of a frame workload. More...
 

Detailed Description

Trace GPU execution times using GL_EXT_disjoint_timer_query on GLES.

Note: there are a substantial number of GPUs where usage of the this API is known to cause crashes. As a result, this functionality is disabled by default and can only be enabled in debug/profile mode via a specific opt-in flag that is exposed in the Android manifest.

To enable, add the following metadata to the application's Android manifest: <meta-data android:name="io.flutter.embedding.android.EnableOpenGLGPUTracing" android:value="false" />

Definition at line 27 of file gpu_tracer_gles.h.

Constructor & Destructor Documentation

◆ GPUTracerGLES()

impeller::GPUTracerGLES::GPUTracerGLES ( const ProcTableGLES gl,
bool  enable_tracing 
)

Definition at line 11 of file gpu_tracer_gles.cc.

11  {
12 #ifdef IMPELLER_DEBUG
13  auto desc = gl.GetDescription();
14  enabled_ =
15  enable_tracing && desc->HasExtension("GL_EXT_disjoint_timer_query");
16 #endif // IMPELLER_DEBUG
17 }

References impeller::ProcTableGLES::GetDescription().

◆ ~GPUTracerGLES()

impeller::GPUTracerGLES::~GPUTracerGLES ( )
default

Member Function Documentation

◆ MarkFrameEnd()

void impeller::GPUTracerGLES::MarkFrameEnd ( const ProcTableGLES gl)

Record the end of a frame workload.

Definition at line 75 of file gpu_tracer_gles.cc.

75  {
76  if (!enabled_ || std::this_thread::get_id() != raster_thread_ ||
77  !active_frame_.has_value()) {
78  return;
79  }
80 
81  auto query = active_frame_.value();
82  gl.EndQueryEXT(GL_TIME_ELAPSED_EXT);
83 
84  pending_traces_.push_back(query);
85  active_frame_ = std::nullopt;
86 }

◆ MarkFrameStart()

void impeller::GPUTracerGLES::MarkFrameStart ( const ProcTableGLES gl)

Record the start of a frame workload, if one hasn't already been started.

Definition at line 19 of file gpu_tracer_gles.cc.

19  {
20  if (!enabled_ || active_frame_.has_value() ||
21  std::this_thread::get_id() != raster_thread_) {
22  return;
23  }
24 
25  // At the beginning of a frame, check the status of all pending
26  // previous queries.
27  ProcessQueries(gl);
28 
29  uint32_t query = 0;
30  gl.GenQueriesEXT(1, &query);
31  if (query == 0) {
32  return;
33  }
34 
35  active_frame_ = query;
36  gl.BeginQueryEXT(GL_TIME_ELAPSED_EXT, query);
37 }

◆ RecordRasterThread()

void impeller::GPUTracerGLES::RecordRasterThread ( )

Record the thread id of the raster thread.

Definition at line 39 of file gpu_tracer_gles.cc.

39  {
40  raster_thread_ = std::this_thread::get_id();
41 }

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