zink: check for error when calling vkEnumeratePhysicalDevices
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Fri, 5 Feb 2021 11:48:37 +0000 (12:48 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 5 Feb 2021 16:45:43 +0000 (16:45 +0000)
It seems it's possible for Lavapipe to fail to enumerate the physical
devices, so let's handle that and fail all the way up here.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7881>

src/gallium/drivers/zink/zink_screen.c

index 56cd9b7..d1b37ae 100644 (file)
@@ -710,11 +710,15 @@ choose_pdev(const VkInstance instance)
 {
    uint32_t i, pdev_count;
    VkPhysicalDevice *pdevs, pdev = NULL;
-   vkEnumeratePhysicalDevices(instance, &pdev_count, NULL);
+   VkResult result = vkEnumeratePhysicalDevices(instance, &pdev_count, NULL);
+   if (result != VK_SUCCESS)
+      return VK_NULL_HANDLE;
+
    assert(pdev_count > 0);
 
    pdevs = malloc(sizeof(*pdevs) * pdev_count);
-   vkEnumeratePhysicalDevices(instance, &pdev_count, pdevs);
+   result = vkEnumeratePhysicalDevices(instance, &pdev_count, pdevs);
+   assert(result == VK_SUCCESS);
    assert(pdev_count > 0);
 
    for (i = 0; i < pdev_count; ++i) {