From f8e5e7cd7d32393319d88fe2d93afc2036703001 Mon Sep 17 00:00:00 2001 From: spencer-lunarg Date: Thu, 6 Nov 2025 14:07:49 -0500 Subject: [PATCH] lavapipe: Fix crash when using zero queues When using VK_KHR_maintenance9 the user can pass a null pointer to VkDeviceQueueCreateInfo and we will create a dummy queue for them. Tested with new dEQP-VK.pipeline.no_queues.* https://gerrit.khronos.org/c/vk-gl-cts/+/18717 Signed-off-by: spencer-lunarg Reviewed-by: Konstantin Seurer Part-of: --- src/gallium/frontends/lavapipe/lvp_device.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 6c00c641812..c2ace3d1711 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1861,8 +1861,24 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice( if (pCreateInfo->queueCreateInfoCount) { assert(pCreateInfo->pQueueCreateInfos[0].queueFamilyIndex == 0); assert(pCreateInfo->pQueueCreateInfos[0].queueCount == 1); + result = lvp_queue_init(device, &device->queue, pCreateInfo->pQueueCreateInfos, 0); + } else { + /* VK_KHR_maintenance9 allows zero queues devices used to compile shaders only. + * Since we only ever create a single queue, and it has no hardward backing it, + * we can just create a dummy queue on the behalf of the user. + */ + const float fake_priority = 1.0f; + const VkDeviceQueueCreateInfo dummy_create_info = { + .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, + .pNext = NULL, + .flags = 0, + .queueFamilyIndex = 0, + .queueCount = 1, + .pQueuePriorities = &fake_priority + }; + result = lvp_queue_init(device, &device->queue, &dummy_create_info, 0); } - result = lvp_queue_init(device, &device->queue, pCreateInfo->pQueueCreateInfos, 0); + if (result != VK_SUCCESS) { vk_free(&device->vk.alloc, device); return result;