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