Flutter Engine
The Flutter Engine
VulkanQueueManager.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
14
15namespace skgpu::graphite {
16
18 : QueueManager(sharedContext)
19 , fQueue(queue) {
20}
21
22const VulkanSharedContext* VulkanQueueManager::vkSharedContext() const {
23 return static_cast<const VulkanSharedContext*>(fSharedContext);
24}
25
26std::unique_ptr<CommandBuffer> VulkanQueueManager::getNewCommandBuffer(
27 ResourceProvider* resourceProvider) {
28 VulkanResourceProvider* vkResourceProvider =
29 static_cast<VulkanResourceProvider*>(resourceProvider);
30
31 auto cmdBuffer = VulkanCommandBuffer::Make(this->vkSharedContext(), vkResourceProvider);
32 return cmdBuffer;
33}
34
36public:
37 VulkanWorkSubmission(std::unique_ptr<CommandBuffer> cmdBuffer, QueueManager* queueManager)
38 : GpuWorkSubmission(std::move(cmdBuffer), queueManager) {}
40
41private:
42 bool onIsFinished(const SharedContext*) override {
43 return static_cast<VulkanCommandBuffer*>(this->commandBuffer())->isFinished();
44 }
45 void onWaitUntilFinished(const SharedContext*) override {
46 return static_cast<VulkanCommandBuffer*>(this->commandBuffer())->waitUntilFinished();
47 }
48};
49
50QueueManager::OutstandingSubmission VulkanQueueManager::onSubmitToGpu() {
52 VulkanCommandBuffer* vkCmdBuffer =
53 static_cast<VulkanCommandBuffer*>(fCurrentCommandBuffer.get());
54 if (!vkCmdBuffer->submit(fQueue)) {
55 fCurrentCommandBuffer->callFinishedProcs(/*success=*/false);
56 return nullptr;
57 }
58
59 std::unique_ptr<GpuWorkSubmission> submission(
60 new VulkanWorkSubmission(std::move(fCurrentCommandBuffer), this));
61 return submission;
62}
63
64} // namespace skgpu::graphite
#define SkASSERT(cond)
Definition: SkAssert.h:116
void waitUntilFinished(const SharedContext *sharedContext)
bool isFinished(const SharedContext *sharedContext)
const SharedContext * fSharedContext
Definition: QueueManager.h:67
std::unique_ptr< GpuWorkSubmission > OutstandingSubmission
Definition: QueueManager.h:65
std::unique_ptr< CommandBuffer > fCurrentCommandBuffer
Definition: QueueManager.h:68
static std::unique_ptr< VulkanCommandBuffer > Make(const VulkanSharedContext *, VulkanResourceProvider *)
VulkanQueueManager(VkQueue queue, const SharedContext *)
VulkanWorkSubmission(std::unique_ptr< CommandBuffer > cmdBuffer, QueueManager *queueManager)
VkQueue queue
Definition: main.cc:55
Definition: ref_ptr.h:256