From 317c252ae16c07a283bbf61e3ac30bd6ff01a33a Mon Sep 17 00:00:00 2001 From: PanGao-h <109496735+PanGao-h@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:35:31 +0800 Subject: [PATCH] Fix validation error given no async compute queue On an old integrated graphic card, the sample crashes when switching scenes. There's a validation error and perhaps some resource handling inside driver that cannot transfer resources properly when src/dst queue family are the same. > Validation Error: [ VUID-VkDeviceCreateInfo-queueFamilyIndex-02802 ] Object 0: handle = 0x1275c88d200, type = VK_OBJECT_TYPE_PHYSICAL_DEVICE; | MessageID = 0x29498778 | CreateDevice(): pCreateInfo->pQueueCreateInfos[1].queueFamilyIndex (=0) is not unique and was also used in pCreateInfo->pQueueCreateInfos[0]. The Vulkan spec states: The queueFamilyIndex member of each element of pQueueCreateInfos must be unique within pQueueCreateInfos, except that two members can share the same queueFamilyIndex if one describes protected-capable queues and one describes queues that are not protected-capable (https://vulkan.lunarg.com/doc/view/1.3.216.0/windows/1.3-extensions/vkspec.html#VUID-VkDeviceCreateInfo-queueFamilyIndex-02802) --- src/VK/base/Device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VK/base/Device.cpp b/src/VK/base/Device.cpp index 80c0ce7..d9ed2d9 100644 --- a/src/VK/base/Device.cpp +++ b/src/VK/base/Device.cpp @@ -237,7 +237,7 @@ namespace CAULDRON_VK VkDeviceCreateInfo device_info = {}; device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; device_info.pNext = &physicalDeviceFeatures2; - device_info.queueCreateInfoCount = 2; + device_info.queueCreateInfoCount = (graphics_queue_family_index == compute_queue_family_index) ? 1 : 2; device_info.pQueueCreateInfos = queue_info; device_info.enabledExtensionCount = (uint32_t)extension_names.size(); device_info.ppEnabledExtensionNames = device_info.enabledExtensionCount ? extension_names.data() : NULL;