Flutter Engine
The Flutter Engine
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
Definition: QueueManager.h:58
void returnCommandBuffer(std::unique_ptr< CommandBuffer >)
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
void * GpuFinishedContext
Definition: GraphiteTypes.h:29
CallbackResult
Definition: GpuTypes.h:45
Definition: ref_ptr.h:256