Dont return an error for 0 physical device extensions
authorCharles Giessen <charles@lunarg.com>
Thu, 10 Feb 2022 18:34:50 +0000 (11:34 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 10 Feb 2022 23:38:15 +0000 (16:38 -0700)
Previously the logic of loader_add_device_extensions could return an error from
enumerating device extensions. This was because the code would return immediately
if either an error was returned from the driver or the count was zero. Now the
logic will return an error only if the driver returned an error. Zero device
extensions won't be treated as an error and will simply return VK_SUCCESS.

loader/loader.c

index 0bb5fc6ed1f083ca152cd78e6b4f14900b2a414a..8e55193f2a4faf659f618ae706e5511d67c973cb 100644 (file)
@@ -582,11 +582,17 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst,
     VkExtensionProperties *ext_props = NULL;
 
     res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, NULL);
-    if (res == VK_SUCCESS && count > 0) {
+    if (res != VK_SUCCESS) {
+        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
+                   "loader_add_device_extensions: Error getting physical device extension info count from library %s", lib_name);
+        return res;
+    }
+    if (count > 0) {
         ext_props = loader_stack_alloc(count * sizeof(VkExtensionProperties));
         if (!ext_props) {
             loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
-                       "loader_add_device_extensions: Failed to allocate space for device extension properties.");
+                       "loader_add_device_extensions: Failed to allocate space for device extension properties from library %s.",
+                       lib_name);
             return VK_ERROR_OUT_OF_HOST_MEMORY;
         }
         res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, ext_props);
@@ -599,10 +605,6 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst,
                 return res;
             }
         }
-    } else {
-        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
-                   "loader_add_device_extensions: Error getting physical device extension info count from library %s", lib_name);
-        return res;
     }
 
     return VK_SUCCESS;