Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GpuWorkSubmission.cpp
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
9
13
14namespace skgpu::graphite {
15
16GpuWorkSubmission::GpuWorkSubmission(std::unique_ptr<CommandBuffer> cmdBuffer,
17 QueueManager* queueManager)
18 : fCommandBuffer(std::move(cmdBuffer))
19 , fQueueManager(queueManager) {
20 SkSpan<const sk_sp<Buffer>> buffers = fCommandBuffer->buffersToAsyncMapOnSubmit();
21 if (!buffers.empty()) {
22 fOutstandingAsyncMapCounter = sk_make_sp<SkRefCnt>();
23 for (auto& buffer : fCommandBuffer->buffersToAsyncMapOnSubmit()) {
24 SkASSERT(!buffer->isUnmappable());
25 fOutstandingAsyncMapCounter->ref();
27 static_cast<SkRefCnt*>(c)->unref();
28 },
29 fOutstandingAsyncMapCounter.get());
30 }
31 }
32}
33
35 fCommandBuffer->callFinishedProcs(/*success=*/true);
36 fCommandBuffer->resetCommandBuffer();
37 fQueueManager->returnCommandBuffer(std::move(fCommandBuffer));
38}
39
40bool GpuWorkSubmission::isFinished(const SharedContext* sharedContext) {
41 return this->onIsFinished(sharedContext) &&
42 (!fOutstandingAsyncMapCounter || fOutstandingAsyncMapCounter->unique());
43}
44
46 this->onWaitUntilFinished(sharedContext);
47 if (fOutstandingAsyncMapCounter) {
48 while (!fOutstandingAsyncMapCounter->unique()) {
49 fQueueManager->tick();
50 }
51 }
52}
53
54} // namespace skgpu::graphite
55
#define SkASSERT(cond)
Definition SkAssert.h:116
void ref() const
Definition SkRefCnt.h:62
bool unique() const
Definition SkRefCnt.h:50
constexpr bool empty() const
Definition SkSpan_impl.h:96
T * get() const
Definition SkRefCnt.h:303
void waitUntilFinished(const SharedContext *sharedContext)
virtual void onWaitUntilFinished(const SharedContext *sharedContext)=0
virtual bool onIsFinished(const SharedContext *sharedContext)=0
GpuWorkSubmission(std::unique_ptr< CommandBuffer > cmdBuffer, QueueManager *queueManager)
bool isFinished(const SharedContext *sharedContext)
virtual void tick() const
void returnCommandBuffer(std::unique_ptr< CommandBuffer >)
static const uint8_t buffer[]
void * GpuFinishedContext
CallbackResult
Definition GpuTypes.h:45
Definition ref_ptr.h:256