Flutter Engine
The Flutter Engine
gpu_tracer_mtl.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_GPU_TRACER_MTL_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_GPU_TRACER_MTL_H_
7
8#include <Metal/Metal.h>
9
10#include <memory>
11#include <optional>
15
16namespace impeller {
17
18class ContextMTL;
19
20/// @brief Approximate the GPU frame time by computing a difference between the
21/// smallest GPUStartTime and largest GPUEndTime for all command buffers
22/// submitted in a frame workload.
23class GPUTracerMTL : public std::enable_shared_from_this<GPUTracerMTL> {
24 public:
25 GPUTracerMTL() = default;
26
27 ~GPUTracerMTL() = default;
28
29 /// @brief Record that the current frame has ended. Any additional cmd buffers
30 /// will be attributed to the "next" frame.
31 void MarkFrameEnd();
32
33 /// @brief Record the current cmd buffer GPU execution timestamps into an
34 /// aggregate frame workload metric.
35 void RecordCmdBuffer(id<MTLCommandBuffer> buffer);
36
37 private:
38 struct GPUTraceState {
39 Scalar smallest_timestamp = std::numeric_limits<float>::max();
40 Scalar largest_timestamp = 0;
41 size_t pending_buffers = 0;
42 };
43
44 mutable Mutex trace_state_mutex_;
45 GPUTraceState trace_states_[16] IPLR_GUARDED_BY(trace_state_mutex_);
46 size_t current_state_ IPLR_GUARDED_BY(trace_state_mutex_) = 0u;
47};
48
49} // namespace impeller
50
51#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_GPU_TRACER_MTL_H_
Approximate the GPU frame time by computing a difference between the smallest GPUStartTime and larges...
void RecordCmdBuffer(id< MTLCommandBuffer > buffer)
Record the current cmd buffer GPU execution timestamps into an aggregate frame workload metric.
void MarkFrameEnd()
Record that the current frame has ended. Any additional cmd buffers will be attributed to the "next" ...
size_t current_state_ IPLR_GUARDED_BY(trace_state_mutex_)=0u
static float max(float r, float g, float b)
Definition: hsl.cpp:49
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