7 #include "fml/trace_event.h"
15 enable_tracing && desc->HasExtension(
"GL_EXT_disjoint_timer_query");
20 if (!enabled_ || active_frame_.has_value() ||
21 std::this_thread::get_id() != raster_thread_) {
30 gl.GenQueriesEXT(1, &query);
35 active_frame_ = query;
36 gl.BeginQueryEXT(GL_TIME_ELAPSED_EXT, query);
40 raster_thread_ = std::this_thread::get_id();
47 while (!pending_traces_.empty()) {
48 auto query = pending_traces_.front();
54 GLuint available = GL_FALSE;
55 gl.GetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
57 if (available != GL_TRUE) {
63 uint64_t duration = 0;
64 gl.GetQueryObjectui64vEXT(query, GL_QUERY_RESULT_EXT, &duration);
65 auto gpu_ms = duration / 1000000.0;
67 FML_TRACE_COUNTER(
"flutter",
"GPUTracer",
68 reinterpret_cast<int64_t
>(
this),
69 "FrameTimeMS", gpu_ms);
70 gl.DeleteQueriesEXT(1, &query);
71 pending_traces_.pop_front();
76 if (!enabled_ || std::this_thread::get_id() != raster_thread_ ||
77 !active_frame_.has_value()) {
81 auto query = active_frame_.value();
82 gl.EndQueryEXT(GL_TIME_ELAPSED_EXT);
84 pending_traces_.push_back(query);
85 active_frame_ = std::nullopt;
void MarkFrameEnd(const ProcTableGLES &gl)
Record the end of a frame workload.
void MarkFrameStart(const ProcTableGLES &gl)
Record the start of a frame workload, if one hasn't already been started.
GPUTracerGLES(const ProcTableGLES &gl, bool enable_tracing)
void RecordRasterThread()
Record the thread id of the raster thread.
const DescriptionGLES * GetDescription() const