Flutter Engine
The Flutter Engine
QueueManager.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_QueueManager_DEFINED
9#define skgpu_graphite_QueueManager_DEFINED
10
15#include "src/core/SkTHash.h"
16
17#include <memory>
18#include <vector>
19
20namespace skgpu::graphite {
21
22class Buffer;
23class CommandBuffer;
24class Context;
25class GpuWorkSubmission;
26struct InsertRecordingInfo;
28class SharedContext;
29class Task;
30class UploadBufferManager;
31
33public:
34 virtual ~QueueManager();
35
36 // Adds the commands from the passed in Recording to the current CommandBuffer
37 [[nodiscard]] bool addRecording(const InsertRecordingInfo&, Context*);
38
39 // Adds the commands from the passed in Task to the current CommandBuffer
40 [[nodiscard]] bool addTask(Task*, Context*);
41
42 // Adds a proc that will be called when the current CommandBuffer is submitted and finishes
43 [[nodiscard]] bool addFinishInfo(const InsertFinishInfo&,
45 SkSpan<const sk_sp<Buffer>> buffersToAsyncMap = {});
46
47 [[nodiscard]] bool submitToGpu();
48 [[nodiscard]] bool hasUnfinishedGpuWork();
50
51#if defined(GRAPHITE_TEST_UTILS)
52 virtual void startCapture() {}
53 virtual void stopCapture() {}
54#endif
55
56 void returnCommandBuffer(std::unique_ptr<CommandBuffer>);
57
58 virtual void tick() const {}
59
61
62protected:
63 QueueManager(const SharedContext* sharedContext);
64
65 using OutstandingSubmission = std::unique_ptr<GpuWorkSubmission>;
66
68 std::unique_ptr<CommandBuffer> fCurrentCommandBuffer;
69
70private:
71 virtual std::unique_ptr<CommandBuffer> getNewCommandBuffer(ResourceProvider*) = 0;
73
74 bool setupCommandBuffer(ResourceProvider*);
75
76 SkDeque fOutstandingSubmissions;
77
78 std::vector<std::unique_ptr<CommandBuffer>> fAvailableCommandBuffers;
79
80 skia_private::THashMap<uint32_t, uint32_t> fLastAddedRecordingIDs;
81};
82
83} // namespace skgpu::graphite
84
85#endif // skgpu_graphite_QueueManager_DEFINED
void addUploadBufferManagerRefs(UploadBufferManager *)
const SharedContext * fSharedContext
Definition: QueueManager.h:67
void checkForFinishedWork(SyncToCpu)
bool addRecording(const InsertRecordingInfo &, Context *)
std::unique_ptr< GpuWorkSubmission > OutstandingSubmission
Definition: QueueManager.h:65
virtual OutstandingSubmission onSubmitToGpu()=0
bool addFinishInfo(const InsertFinishInfo &, ResourceProvider *, SkSpan< const sk_sp< Buffer > > buffersToAsyncMap={})
bool addTask(Task *, Context *)
std::unique_ptr< CommandBuffer > fCurrentCommandBuffer
Definition: QueueManager.h:68
QueueManager(const SharedContext *sharedContext)
virtual void tick() const
Definition: QueueManager.h:58
void returnCommandBuffer(std::unique_ptr< CommandBuffer >)
virtual std::unique_ptr< CommandBuffer > getNewCommandBuffer(ResourceProvider *)=0
Definition: DM.cpp:1161