Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
12
13namespace impeller {
14
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///
31class QueueVK {
32 public:
33 QueueVK(QueueIndexVK index, vk::Queue queue);
34
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 Present(const vk::PresentInfoKHR& present_info);
43
44 void InsertDebugMarker(std::string_view label) const;
45
46 private:
47 mutable Mutex queue_mutex_;
48
49 const QueueIndexVK index_;
50 const vk::Queue queue_ IPLR_GUARDED_BY(queue_mutex_);
51
52 QueueVK(const QueueVK&) = delete;
53
54 QueueVK& operator=(const QueueVK&) = delete;
55};
56
57//------------------------------------------------------------------------------
58/// @brief The collection of queues used by the context. The queues may all
59/// be the same.
60///
61struct QueuesVK {
62 std::shared_ptr<QueueVK> graphics_queue;
63 std::shared_ptr<QueueVK> compute_queue;
64 std::shared_ptr<QueueVK> transfer_queue;
65
67
68 QueuesVK(const vk::Device& device,
69 QueueIndexVK graphics,
70 QueueIndexVK compute,
71 QueueIndexVK transfer);
72
73 bool IsValid() const;
74};
75
76} // namespace impeller
77
78#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_QUEUE_VK_H_
A thread safe object that can be used to access device queues. If multiple objects are created with t...
Definition queue_vk.h:31
const QueueIndexVK & GetIndex() const
Definition queue_vk.cc:16
void InsertDebugMarker(std::string_view label) const
Definition queue_vk.cc:31
vk::Result Present(const vk::PresentInfoKHR &present_info)
Definition queue_vk.cc:26
vk::Result Submit(const vk::SubmitInfo &submit_info, const vk::Fence &fence) const
Definition queue_vk.cc:20
VkDevice device
Definition main.cc:53
VkQueue queue
Definition main.cc:55
constexpr bool operator==(const QueueIndexVK &other) const
Definition queue_vk.h:19
The collection of queues used by the context. The queues may all be the same.
Definition queue_vk.h:61
std::shared_ptr< QueueVK > compute_queue
Definition queue_vk.h:63
std::shared_ptr< QueueVK > transfer_queue
Definition queue_vk.h:64
std::shared_ptr< QueueVK > graphics_queue
Definition queue_vk.h:62
bool IsValid() const
Definition queue_vk.cc:75
#define IPLR_GUARDED_BY(x)