From dc8fdab71efdc3e516f2a8abdfdc2dec05fce448 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 18 Mar 2022 09:54:37 -0500 Subject: [PATCH] lavapipe: Use VK_OUTARRAY for GetPhysicalDeviceQueueFamilyProperties[2] This fixes bugs with lavapipe's hand-rolled pCount handling. The driver is supposed to set *pCount to the number of queues actually written in the case where it's initialized to a value that's too large. It's also supposed to handle *pCount being too small. Fixes: b38879f8c5f5 ("vallium: initial import of the vulkan frontend") Acked-by: Mike Blumenkrantz Part-of: --- src/gallium/frontends/lavapipe/lvp_device.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index ca75bde73da..dece67c2bc9 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1132,13 +1132,11 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceQueueFamilyProperties( uint32_t* pCount, VkQueueFamilyProperties* pQueueFamilyProperties) { - if (pQueueFamilyProperties == NULL) { - *pCount = 1; - return; - } + VK_OUTARRAY_MAKE(out, pQueueFamilyProperties, pCount); - assert(*pCount >= 1); - lvp_get_physical_device_queue_family_properties(pQueueFamilyProperties); + vk_outarray_append(&out, p) { + lvp_get_physical_device_queue_family_properties(p); + } } VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceQueueFamilyProperties2( @@ -1146,13 +1144,11 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceQueueFamilyProperties2( uint32_t* pCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) { - if (pQueueFamilyProperties == NULL) { - *pCount = 1; - return; - } + VK_OUTARRAY_MAKE(out, pQueueFamilyProperties, pCount); - assert(*pCount >= 1); - lvp_get_physical_device_queue_family_properties(&pQueueFamilyProperties->queueFamilyProperties); + vk_outarray_append(&out, p) { + lvp_get_physical_device_queue_family_properties(&p->queueFamilyProperties); + } } VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceMemoryProperties(