forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgpu_tracer_vk.h
More file actions
40 lines (29 loc) · 1.06 KB
/
gpu_tracer_vk.h
File metadata and controls
40 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "impeller/renderer/backend/vulkan/context_vk.h"
namespace impeller {
/// @brief A class that uses timestamp queries to record the approximate GPU
/// execution time.
class GPUTracerVK {
public:
explicit GPUTracerVK(const std::weak_ptr<ContextVK>& context);
~GPUTracerVK() = default;
/// @brief Record the approximate start time of the GPU workload for the
/// current frame.
void RecordStartFrameTime();
/// @brief Record the approximate end time of the GPU workload for the current
/// frame.
void RecordEndFrameTime();
private:
void ResetQueryPool(size_t pool);
const std::weak_ptr<ContextVK> context_;
vk::UniqueQueryPool query_pool_ = {};
size_t current_index_ = 0u;
// The number of nanoseconds for each timestamp unit.
float timestamp_period_ = 1;
bool started_frame_ = false;
bool valid_ = false;
};
} // namespace impeller