Skip to content
Snippets Groups Projects
Commit 61df58fc authored by Vanessa Karolek's avatar Vanessa Karolek
Browse files

[#16][Fix] Fix queue creation

If you specify Compute and Transfer as QueueFlagBits in main.cpp, I get the error telling I create more queues than being available for this queue family. The error is caused by wrong indexing in line 111. My device holds 3 queue families and Compute and Transfer operations are only supported by queue family #0 and #2, but we indexed #1 since we push queue family candidates into a vector structure. Thus, queue family #1 is ignored and queue family #2 is not indexed. Therefore, the queue family candidates vector is unnecessary and just causing trouble.
parent 3cf26d26
No related branches found
No related tags found
4 merge requests!12Resolve "Swapchain Class",!7Resolve "Shader Program Class",!5Resolve "Pipeline State Object",!4Resolve "Renderpass Class"
Pipeline #24736 passed
......@@ -94,32 +94,29 @@ namespace vkcv
{
std::vector<vk::DeviceQueueCreateInfo> queueCreateInfos;
std::vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties();
std::vector<vk::QueueFamilyProperties> qFamilyCandidates;
// search for queue families which support the desired queue flag bits
for (auto& qFamily : qFamilyProperties) {
uint32_t create = queueCount;
for (int i = 0; i < qFamilyProperties.size(); i++) {
bool supported = true;
for (auto qFlag : queueFlags) {
supported = supported && (static_cast<uint32_t>(qFlag & qFamily.queueFlags) != 0);
supported = supported && (static_cast<uint32_t>(qFlag & qFamilyProperties[i].queueFlags) != 0);
}
if (supported) {
qFamilyCandidates.push_back(qFamily);
// if queue family supports all desired queue flag bits, create as many queues available for the actual queue family
// search for another queue family, if more queues should be created
if (supported && create > 0) {
const uint32_t maxCreatableQueues = std::min(create, qFamilyProperties[i].queueCount);
vk::DeviceQueueCreateInfo qCreateInfo(
vk::DeviceQueueCreateFlags(),
i,
maxCreatableQueues,
qPriorities.data()
);
queueCreateInfos.push_back(qCreateInfo);
create -= maxCreatableQueues;
}
}
uint32_t create = queueCount;
for (uint32_t i = 0; i < qFamilyCandidates.size() && create > 0; i++) {
const uint32_t maxCreatableQueues = std::min(create, qFamilyCandidates[i].queueCount);
vk::DeviceQueueCreateInfo qCreateInfo(
vk::DeviceQueueCreateFlags(),
i,
maxCreatableQueues,
qPriorities.data()
);
queueCreateInfos.push_back(qCreateInfo);
create -= maxCreatableQueues;
}
return queueCreateInfos;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment