lavapipe: Use VK_OUTARRAY for GetPhysicalDeviceQueueFamilyProperties[2]
authorJason Ekstrand <jason.ekstrand@collabora.com>
Fri, 18 Mar 2022 14:54:37 +0000 (09:54 -0500)
committerJason Ekstrand <jason.ekstrand@collabora.com>
Fri, 18 Mar 2022 16:19:15 +0000 (11:19 -0500)
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 <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15459>

src/gallium/frontends/lavapipe/lvp_device.c

index ca75bde..dece67c 100644 (file)
@@ -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(