| Flutter Impeller |

queue_vk.h
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 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_QUEUE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_QUEUE_VK_H_
7
8 #include <memory>
9
10 #include "impeller/base/thread.h"
11 #include "impeller/renderer/backend/vulkan/vk.h"
12
13 namespace impeller {
14
15 struct QueueIndexVK {
16 size_t family = 0;
17 size_t index = 0;
18
19 constexpr bool operator==(const QueueIndexVK& other) const {
20 return family == other.family && index == other.index;
21 }
22 };
23
24 //------------------------------------------------------------------------------
25 /// @brief A thread safe object that can be used to access device queues.
26 /// If multiple objects are created with the same underlying queue,
27 /// then the external synchronization guarantees of Vulkan queues
28 /// cannot be met. So care must be taken the same device queue
29 /// doesn't form the basis of multiple `QueueVK`s.
30 ///
31 class QueueVK {
32 public:
33 QueueVK(QueueIndexVK index, vk::Queue queue);
34
35 ~QueueVK();
36
37 const QueueIndexVK& GetIndex() const;
38
39 vk::Result Submit(const vk::SubmitInfo& submit_info,
40 const vk::Fence& fence) const;
41
42 vk::Result Submit(const vk::Fence& fence) const;
43
44 vk::Result Present(const vk::PresentInfoKHR& present_info);
45
46 void InsertDebugMarker(std::string_view label) const;
47
48 private:
49 mutable Mutex queue_mutex_;
50
51 const QueueIndexVK index_;
52 const vk::Queue queue_ IPLR_GUARDED_BY(queue_mutex_);
53
54 QueueVK(const QueueVK&) = delete;
55
56 QueueVK& operator=(const QueueVK&) = delete;
57 };
58
59 //------------------------------------------------------------------------------
60 /// @brief The collection of queues used by the context. The queues may all
61 /// be the same.
62 ///
63 struct QueuesVK {
64 std::shared_ptr<QueueVK> graphics_queue;
65 std::shared_ptr<QueueVK> compute_queue;
66 std::shared_ptr<QueueVK> transfer_queue;
67
68 QueuesVK();
69
70 QueuesVK(std::shared_ptr<QueueVK> graphics_queue,
71 std::shared_ptr<QueueVK> compute_queue,
72 std::shared_ptr<QueueVK> transfer_queue);
73
74 static QueuesVK FromEmbedderQueue(vk::Queue queue,
75 uint32_t queue_family_index);
76
77 static QueuesVK FromQueueIndices(const vk::Device& device,
78 QueueIndexVK graphics,
79 QueueIndexVK compute,
80 QueueIndexVK transfer);
81
82 bool IsValid() const;
83 };
84
85 } // namespace impeller
86
87 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_QUEUE_VK_H_
impeller::QueueVK
A thread safe object that can be used to access device queues. If multiple objects are created with t...
Definition: queue_vk.h:31
impeller::QueueVK::QueueVK
QueueVK(QueueIndexVK index, vk::Queue queue)
Definition: queue_vk.cc:13
impeller::QueueVK::GetIndex
const QueueIndexVK & GetIndex() const
Definition: queue_vk.cc:18
impeller::QueueVK::InsertDebugMarker
void InsertDebugMarker(std::string_view label) const
Definition: queue_vk.cc:38
impeller::QueueVK::Present
vk::Result Present(const vk::PresentInfoKHR &present_info)
Definition: queue_vk.cc:33
impeller::QueueVK::~QueueVK
~QueueVK()
impeller::QueueVK::Submit
vk::Result Submit(const vk::SubmitInfo &submit_info, const vk::Fence &fence) const
Definition: queue_vk.cc:22
impeller
Definition: allocation.cc:12
impeller::QueueIndexVK
Definition: queue_vk.h:15
impeller::QueueIndexVK::family
size_t family
Definition: queue_vk.h:16
impeller::QueueIndexVK::index
size_t index
Definition: queue_vk.h:17
impeller::QueueIndexVK::operator==
constexpr bool operator==(const QueueIndexVK &other) const
Definition: queue_vk.h:19
impeller::QueuesVK
The collection of queues used by the context. The queues may all be the same.
Definition: queue_vk.h:63
impeller::QueuesVK::FromEmbedderQueue
static QueuesVK FromEmbedderQueue(vk::Queue queue, uint32_t queue_family_index)
Definition: queue_vk.cc:58
impeller::QueuesVK::FromQueueIndices
static QueuesVK FromQueueIndices(const vk::Device &device, QueueIndexVK graphics, QueueIndexVK compute, QueueIndexVK transfer)
Definition: queue_vk.cc:67
impeller::QueuesVK::compute_queue
std::shared_ptr< QueueVK > compute_queue
Definition: queue_vk.h:65
impeller::QueuesVK::transfer_queue
std::shared_ptr< QueueVK > transfer_queue
Definition: queue_vk.h:66
impeller::QueuesVK::graphics_queue
std::shared_ptr< QueueVK > graphics_queue
Definition: queue_vk.h:64
impeller::QueuesVK::IsValid
bool IsValid() const
Definition: queue_vk.cc:104
impeller::QueuesVK::QueuesVK
QueuesVK()
thread.h
vk.h