hello-tool: don't create redundant queues
vulkan prohibits queues with identical ids
This commit is contained in:
parent
1238ae4914
commit
c7302ab423
@ -143,16 +143,24 @@ main (void)
|
|||||||
|
|
||||||
auto queues = pdevice.queue_families ();
|
auto queues = pdevice.queue_families ();
|
||||||
int graphics_queue_id = -1, present_queue_id = -1;
|
int graphics_queue_id = -1, present_queue_id = -1;
|
||||||
for (int i = 0; unsigned (i) != queues.size (); ++i) {
|
|
||||||
if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
|
||||||
graphics_queue_id = i;
|
|
||||||
|
|
||||||
VkBool32 present_support = false;
|
for (int i = 0, last = queues.size (); i != last; ++i)
|
||||||
cruft::vk::error::try_func (
|
if (queues[i].queueCount > 0 && queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
||||||
&vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.id (), i, surface.id (), &present_support
|
graphics_queue_id = i;
|
||||||
);
|
break;
|
||||||
if (present_support)
|
}
|
||||||
|
|
||||||
|
for (int i = 0, last = queues.size (); i != last; ++i) {
|
||||||
|
if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR,
|
||||||
|
pdevice.id (), i, surface.id ())) {
|
||||||
present_queue_id = i;
|
present_queue_id = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (graphics_queue_id == -1 || present_queue_id == -1) {
|
||||||
|
std::cerr << "unable to find useful queues\n";
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
float priority = 1.f;
|
float priority = 1.f;
|
||||||
@ -185,7 +193,7 @@ main (void)
|
|||||||
VkDeviceCreateInfo device_info {};
|
VkDeviceCreateInfo device_info {};
|
||||||
device_info.sType = cruft::vk::structure_type_v<VkDeviceCreateInfo>;
|
device_info.sType = cruft::vk::structure_type_v<VkDeviceCreateInfo>;
|
||||||
device_info.pQueueCreateInfos = std::data (device_queues);
|
device_info.pQueueCreateInfos = std::data (device_queues);
|
||||||
device_info.queueCreateInfoCount = std::size (device_queues);
|
device_info.queueCreateInfoCount = graphics_queue_id == present_queue_id ? 1 : 2;
|
||||||
device_info.pEnabledFeatures = &device_features;
|
device_info.pEnabledFeatures = &device_features;
|
||||||
device_info.enabledLayerCount = std::size (layers);
|
device_info.enabledLayerCount = std::size (layers);
|
||||||
device_info.ppEnabledLayerNames = layers;
|
device_info.ppEnabledLayerNames = layers;
|
||||||
|
Loading…
Reference in New Issue
Block a user