Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
gpu_submission_tracker.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_CORE_GPU_SUBMISSION_TRACKER_H_
6#define FLUTTER_IMPELLER_CORE_GPU_SUBMISSION_TRACKER_H_
7
8#include <cstdint>
9#include <vector>
10
12
13namespace impeller {
14
15/// @brief Tracks GPU completion of submitted command buffers as a monotonic
16/// watermark.
17///
18/// Backends record an id for each submitted command buffer and mark it from
19/// the command buffer's completion callback. Consumers compare ids against
20/// [CompletedThrough] to find out whether the GPU is done with all work
21/// submitted up to a point in time, regardless of the order in which
22/// individual command buffers complete.
23///
24/// All methods are thread safe.
26 public:
27 /// Records a command buffer submission and returns its id.
28 uint64_t RecordSubmission();
29
30 /// Marks a previously recorded submission as completed by the GPU.
31 void RecordCompletion(uint64_t id);
32
33 /// Returns the highest id such that all submissions with ids up to and
34 /// including it have completed.
35 uint64_t CompletedThrough() const;
36
37 /// Returns the id of the most recent submission.
38 uint64_t LatestSubmission() const;
39
40 private:
41 mutable Mutex mutex_;
42 uint64_t last_id_ IPLR_GUARDED_BY(mutex_) = 0;
43 // Sorted, since ids are recorded in increasing order. The pending count
44 // tracks GPU queue depth and stays small, so erasure is cheap and steady
45 // state performs no heap allocation.
46 std::vector<uint64_t> pending_ IPLR_GUARDED_BY(mutex_);
47};
48
49} // namespace impeller
50
51#endif // FLUTTER_IMPELLER_CORE_GPU_SUBMISSION_TRACKER_H_
Tracks GPU completion of submitted command buffers as a monotonic watermark.
uint64_t LatestSubmission() const
Returns the id of the most recent submission.
void RecordCompletion(uint64_t id)
Marks a previously recorded submission as completed by the GPU.
uint64_t RecordSubmission()
Records a command buffer submission and returns its id.
#define IPLR_GUARDED_BY(x)