Flutter Engine
Loading...
Searching...
No Matches
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
5
#include "
impeller/renderer/backend/vulkan/queue_vk.h
"
6
7
#include <utility>
8
9
#include "
impeller/renderer/backend/vulkan/context_vk.h
"
10
11
namespace
impeller
{
12
13
QueueVK::QueueVK
(
QueueIndexVK
index, vk::Queue
queue
)
14
: index_(index), queue_(
queue
) {}
15
16
QueueVK::~QueueVK
() =
default
;
17
18
const
QueueIndexVK
&
QueueVK::GetIndex
()
const
{
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
58
QueuesVK
QueuesVK::FromEmbedderQueue
(vk::Queue
queue
,
59
uint32_t
queue_family_index
) {
60
auto
graphics_queue
= std::make_shared<QueueVK>(
61
QueueIndexVK
{.
family
=
queue_family_index
, .index = 0},
queue
);
62
63
return
QueuesVK
(
graphics_queue
,
graphics_queue
,
graphics_queue
);
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) {
82
compute_queue
=
graphics_queue
;
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) {
92
transfer_queue
=
graphics_queue
;
93
}
else
if
(transfer == compute) {
94
transfer_queue
=
compute_queue
;
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
{
105
return
graphics_queue
&&
compute_queue
&&
transfer_queue
;
106
}
107
108
}
// namespace impeller
impeller::ContextVK::SetDebugName
bool SetDebugName(T handle, std::string_view label) const
Definition
context_vk.h:151
impeller::Lock
Definition
thread.h:72
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
device
VkDevice device
Definition
main.cc:69
queue
VkQueue queue
Definition
main.cc:71
queue_family_index
uint32_t queue_family_index
Definition
main.cc:70
impeller
Definition
texture.h:16
impeller::HasValidationLayers
bool HasValidationLayers()
Definition
context_vk.cc:53
std
Definition
ref_ptr.h:261
queue_vk.h
context_vk.h
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::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()
impeller
renderer
backend
vulkan
queue_vk.cc
Generated on Thu Nov 6 2025 16:11:23 for Flutter Engine by
1.9.8