-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueFamily.cpp
More file actions
53 lines (39 loc) · 1.32 KB
/
Copy pathQueueFamily.cpp
File metadata and controls
53 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "QueueFamily.hpp"
#include <set>
using Indices = QueueFamily::Indices;
bool Indices::isComplete() const {
return graphicsFamily.has_value() && presentFamily.has_value();
}
Indices::QueueCreateInfos QueueFamily::Indices::getQueueCreateInfos() const {
std::set<uint32_t> uniqueFamilies = {
graphicsFamily.value(), presentFamily.value()};
float queuePriority = 1.0f;
QueueCreateInfos queueCreateInfos;
for (uint32_t queueFamilyIndex : uniqueFamilies) {
const auto queueCreateInfo =
vk::DeviceQueueCreateInfo()
.setQueueFamilyIndex(queueFamilyIndex)
.setQueueCount(1)
.setPQueuePriorities(&queuePriority);
queueCreateInfos.emplace_back(queueCreateInfo);
}
return queueCreateInfos;
}
Indices QueueFamily::findIndices(
const vk::PhysicalDevice& device, const vk::SurfaceKHR& surface
) {
Indices indices;
const auto families = device.getQueueFamilyProperties();
for (uint32_t familyIndex = 0; familyIndex < families.size(); ++familyIndex) {
if (families[familyIndex].queueFlags & vk::QueueFlagBits::eGraphics) {
indices.graphicsFamily = familyIndex;
}
if (device.getSurfaceSupportKHR(familyIndex, surface)) {
indices.presentFamily = familyIndex;
}
if (indices.isComplete()) {
break;
}
}
return indices;
}