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 
6 
7 #include <utility>
8 
10 
11 namespace impeller {
12 
13 QueueVK::QueueVK(QueueIndexVK index, vk::Queue queue)
14  : index_(index), queue_(queue) {}
15 
16 QueueVK::~QueueVK() = default;
17 
19  return index_;
20 }
21 
22 vk::Result QueueVK::Submit(const vk::SubmitInfo& submit_info,
23  const vk::Fence& fence) const {
24  Lock lock(queue_mutex_);
25  return queue_.submit(submit_info, fence);
26 }
27 
28 vk::Result QueueVK::Submit(const vk::Fence& fence) const {
29  Lock lock(queue_mutex_);
30  return queue_.submit({}, fence);
31 }
32 
33 vk::Result QueueVK::Present(const vk::PresentInfoKHR& present_info) {
34  Lock lock(queue_mutex_);
35  return queue_.presentKHR(present_info);
36 }
37 
38 void QueueVK::InsertDebugMarker(std::string_view label) const {
39  if (!HasValidationLayers()) {
40  return;
41  }
42  vk::DebugUtilsLabelEXT label_info;
43  label_info.pLabelName = label.data();
44  Lock lock(queue_mutex_);
45  queue_.insertDebugUtilsLabelEXT(label_info);
46 }
47 
48 QueuesVK::QueuesVK() = default;
49 
50 QueuesVK::QueuesVK(std::shared_ptr<QueueVK> graphics_queue,
51  std::shared_ptr<QueueVK> compute_queue,
52  std::shared_ptr<QueueVK> transfer_queue)
53  : graphics_queue(std::move(graphics_queue)),
54  compute_queue(std::move(compute_queue)),
55  transfer_queue(std::move(transfer_queue)) {}
56 
57 // static
59  uint32_t queue_family_index) {
60  auto graphics_queue = std::make_shared<QueueVK>(
61  QueueIndexVK{.family = queue_family_index, .index = 0}, queue);
62 
64 }
65 
66 // static
67 QueuesVK QueuesVK::FromQueueIndices(const vk::Device& device,
68  QueueIndexVK graphics,
69  QueueIndexVK compute,
70  QueueIndexVK transfer) {
71  auto vk_graphics = device.getQueue(graphics.family, graphics.index);
72  auto vk_compute = device.getQueue(compute.family, compute.index);
73  auto vk_transfer = device.getQueue(transfer.family, transfer.index);
74 
75  // Always set up the graphics queue.
76  auto graphics_queue = std::make_shared<QueueVK>(graphics, vk_graphics);
77  ContextVK::SetDebugName(device, vk_graphics, "ImpellerGraphicsQ");
78 
79  // Setup the compute queue if its different from the graphics queue.
80  std::shared_ptr<QueueVK> compute_queue;
81  if (compute == graphics) {
83  } else {
84  compute_queue = std::make_shared<QueueVK>(compute, vk_compute);
85  ContextVK::SetDebugName(device, vk_compute, "ImpellerComputeQ");
86  }
87 
88  // Setup the transfer queue if its different from the graphics or compute
89  // queues.
90  std::shared_ptr<QueueVK> transfer_queue;
91  if (transfer == graphics) {
93  } else if (transfer == compute) {
95  } else {
96  transfer_queue = std::make_shared<QueueVK>(transfer, vk_transfer);
97  ContextVK::SetDebugName(device, vk_transfer, "ImpellerTransferQ");
98  }
99 
100  return QueuesVK(std::move(graphics_queue), std::move(compute_queue),
101  std::move(transfer_queue));
102 }
103 
104 bool QueuesVK::IsValid() const {
106 }
107 
108 } // namespace impeller
bool SetDebugName(T handle, std::string_view label) const
Definition: context_vk.h:151
QueueVK(QueueIndexVK index, vk::Queue queue)
Definition: queue_vk.cc:13
const QueueIndexVK & GetIndex() const
Definition: queue_vk.cc:18
void InsertDebugMarker(std::string_view label) const
Definition: queue_vk.cc:38
vk::Result Present(const vk::PresentInfoKHR &present_info)
Definition: queue_vk.cc:33
vk::Result Submit(const vk::SubmitInfo &submit_info, const vk::Fence &fence) const
Definition: queue_vk.cc:22
bool HasValidationLayers()
Definition: context_vk.cc:53
Definition: comparable.h:95
The collection of queues used by the context. The queues may all be the same.
Definition: queue_vk.h:63
static QueuesVK FromEmbedderQueue(vk::Queue queue, uint32_t queue_family_index)
Definition: queue_vk.cc:58
static QueuesVK FromQueueIndices(const vk::Device &device, QueueIndexVK graphics, QueueIndexVK compute, QueueIndexVK transfer)
Definition: queue_vk.cc:67
std::shared_ptr< QueueVK > compute_queue
Definition: queue_vk.h:65
std::shared_ptr< QueueVK > transfer_queue
Definition: queue_vk.h:66
std::shared_ptr< QueueVK > graphics_queue
Definition: queue_vk.h:64
bool IsValid() const
Definition: queue_vk.cc:104