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 #pragma once
6 
7 #include <memory>
8 
9 #include "flutter/fml/macros.h"
10 #include "impeller/base/thread.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  void InsertDebugMarker(const char* label) const;
43 
44  private:
45  mutable Mutex queue_mutex_;
46 
47  const QueueIndexVK index_;
48  const vk::Queue queue_ IPLR_GUARDED_BY(queue_mutex_);
49 
50  FML_DISALLOW_COPY_AND_ASSIGN(QueueVK);
51 };
52 
53 //------------------------------------------------------------------------------
54 /// @brief The collection of queues used by the context. The queues may all
55 /// be the same.
56 ///
57 struct QueuesVK {
58  std::shared_ptr<QueueVK> graphics_queue;
59  std::shared_ptr<QueueVK> compute_queue;
60  std::shared_ptr<QueueVK> transfer_queue;
61 
62  QueuesVK();
63 
64  QueuesVK(const vk::Device& device,
65  QueueIndexVK graphics,
66  QueueIndexVK compute,
67  QueueIndexVK transfer);
68 
69  bool IsValid() const;
70 };
71 
72 } // 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::QueueVK::~QueueVK
~QueueVK()
impeller::QueueIndexVK::operator==
constexpr bool operator==(const QueueIndexVK &other) const
Definition: queue_vk.h:19
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:58
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:60
impeller::QueuesVK::compute_queue
std::shared_ptr< QueueVK > compute_queue
Definition: queue_vk.h:59
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:57
impeller::QueueIndexVK::family
size_t family
Definition: queue_vk.h:16
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:31
impeller::QueueVK::QueueVK
QueueVK(QueueIndexVK index, vk::Queue queue)
Definition: queue_vk.cc:11