| Flutter Impeller |

queue_vk.cc
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 #include "impeller/renderer/backend/vulkan/queue_vk.h"
6
7 #include "impeller/renderer/backend/vulkan/context_vk.h"
8
9 namespace impeller {
10
11 QueueVK::QueueVK(QueueIndexVK index, vk::Queue queue)
12 : index_(index), queue_(queue) {}
13
14 QueueVK::~QueueVK() = default;
15
16 const QueueIndexVK& QueueVK::GetIndex() const {
17 return index_;
18 }
19
20 vk::Result QueueVK::Submit(const vk::SubmitInfo& submit_info,
21 const vk::Fence& fence) const {
22 Lock lock(queue_mutex_);
23 return queue_.submit(submit_info, fence);
24 }
25
26 vk::Result QueueVK::Submit(const vk::Fence& fence) const {
27 Lock lock(queue_mutex_);
28 return queue_.submit({}, fence);
29 }
30
31 vk::Result QueueVK::Present(const vk::PresentInfoKHR& present_info) {
32 Lock lock(queue_mutex_);
33 return queue_.presentKHR(present_info);
34 }
35
36 void QueueVK::InsertDebugMarker(std::string_view label) const {
37 if (!HasValidationLayers()) {
38 return;
39 }
40 vk::DebugUtilsLabelEXT label_info;
41 label_info.pLabelName = label.data();
42 Lock lock(queue_mutex_);
43 queue_.insertDebugUtilsLabelEXT(label_info);
44 }
45
46 QueuesVK::QueuesVK() = default;
47
48 QueuesVK::QueuesVK(const vk::Device& device,
49 QueueIndexVK graphics,
50 QueueIndexVK compute,
51 QueueIndexVK transfer) {
52 auto vk_graphics = device.getQueue(graphics.family, graphics.index);
53 auto vk_compute = device.getQueue(compute.family, compute.index);
54 auto vk_transfer = device.getQueue(transfer.family, transfer.index);
55
56 // Always set up the graphics queue.
57 graphics_queue = std::make_shared<QueueVK>(graphics, vk_graphics);
58 ContextVK::SetDebugName(device, vk_graphics, "ImpellerGraphicsQ");
59
60 // Setup the compute queue if its different from the graphics queue.
61 if (compute == graphics) {
62 compute_queue = graphics_queue;
63 } else {
64 compute_queue = std::make_shared<QueueVK>(compute, vk_compute);
65 ContextVK::SetDebugName(device, vk_compute, "ImpellerComputeQ");
66 }
67
68 // Setup the transfer queue if its different from the graphics or compute
69 // queues.
70 if (transfer == graphics) {
71 transfer_queue = graphics_queue;
72 } else if (transfer == compute) {
73 transfer_queue = compute_queue;
74 } else {
75 transfer_queue = std::make_shared<QueueVK>(transfer, vk_transfer);
76 ContextVK::SetDebugName(device, vk_transfer, "ImpellerTransferQ");
77 }
78 }
79
80 bool QueuesVK::IsValid() const {
81 return graphics_queue && compute_queue && transfer_queue;
82 }
83
84 } // namespace impeller
impeller::QueueVK::GetIndex
const QueueIndexVK & GetIndex() const
Definition: queue_vk.cc:16
impeller::QueueIndexVK
Definition: queue_vk.h:15
impeller::QueueIndexVK::index
size_t index
Definition: queue_vk.h:17
impeller::Lock
Definition: thread.h:72
impeller::QueueVK::~QueueVK
~QueueVK()
impeller::QueuesVK::IsValid
bool IsValid() const
Definition: queue_vk.cc:80
impeller::QueuesVK::graphics_queue
std::shared_ptr< QueueVK > graphics_queue
Definition: queue_vk.h:64
queue_vk.h
impeller::QueueVK::Submit
vk::Result Submit(const vk::SubmitInfo &submit_info, const vk::Fence &fence) const
Definition: queue_vk.cc:20
impeller::QueuesVK::transfer_queue
std::shared_ptr< QueueVK > transfer_queue
Definition: queue_vk.h:66
impeller::QueuesVK::compute_queue
std::shared_ptr< QueueVK > compute_queue
Definition: queue_vk.h:65
impeller::ContextVK::SetDebugName
bool SetDebugName(T handle, std::string_view label) const
Definition: context_vk.h:109
impeller::QueueVK::Present
vk::Result Present(const vk::PresentInfoKHR &present_info)
Definition: queue_vk.cc:31
impeller::QueuesVK::QueuesVK
QueuesVK()
impeller::QueueVK::InsertDebugMarker
void InsertDebugMarker(std::string_view label) const
Definition: queue_vk.cc:36
impeller::QueueIndexVK::family
size_t family
Definition: queue_vk.h:16
context_vk.h
impeller::HasValidationLayers
bool HasValidationLayers()
Definition: context_vk.cc:46
impeller
Definition: allocation.cc:12
impeller::QueueVK::QueueVK
QueueVK(QueueIndexVK index, vk::Queue queue)
Definition: queue_vk.cc:11