vkr: Use vkGetDeviceQueue with queues that created with flags zero

This is a fix for segfault issue, because of usage of uninitialized
vkQueue handle.

Spec [1] states that vkGetDeviceQueue must only be used to get queues
that were created with the flags parameter of VkDeviceQueueCreateInfo
set to zero. To get queues that were created with a non-zero flags
parameter use vkGetDeviceQueue2.

The problem that in case queue was created with flags set to zero following
vkGetDeviceQueue2 call will fail. By failing I mean that pQueue set to NULL,
which later leads to segfault.

This problem was also reported by vulkan validation layer:

vkr: vkGetDeviceQueue2: value of pQueueInfo->flags must not be 0. The Vulkan
spec states: flags must not be 0
(https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkDeviceQueueInfo2-flags-requiredbitmask)

[1]: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceQueue.html

Signed-off-by: Andrii Pauk <Andrii.Pauk@opensynergy.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Andrii Pauk 3 years ago
parent 785cdaad3c
commit 634467acf3
  1. 9
      src/venus/vkr_device.c

@ -32,7 +32,14 @@ vkr_device_create_queues(struct vkr_context *ctx,
.queueIndex = j,
};
VkQueue handle = VK_NULL_HANDLE;
vkGetDeviceQueue2(dev->base.handle.device, &info, &handle);
/* There was a bug in spec which forbids usage of vkGetDeviceQueue2
* with flags set to zero. It was fixed in spec version 1.1.130.
* Work around drivers that are implementing this buggy behavior
*/
if (info.flags)
vkGetDeviceQueue2(dev->base.handle.device, &info, &handle);
else
vkGetDeviceQueue(dev->base.handle.device, info.queueFamilyIndex, info.queueIndex, &handle);
struct vkr_queue *queue = vkr_queue_create(
ctx, dev, info.flags, info.queueFamilyIndex, info.queueIndex, handle);

Loading…
Cancel
Save