lavapipe: Fix crash when using zero queues
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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 <spencer@lunarg.com>
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38288>
This commit is contained in:
spencer-lunarg 2025-11-06 14:07:49 -05:00 committed by Marge Bot
parent 179e744f75
commit f8e5e7cd7d

View file

@ -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;