Check for version 1.3 in GetP.D.ToolProperties
authorCharles Giessen <charles@lunarg.com>
Wed, 1 Dec 2021 21:02:52 +0000 (14:02 -0700)
committerMike Schuchardt <mikes@lunarg.com>
Tue, 25 Jan 2022 18:54:13 +0000 (10:54 -0800)
To ensure that no crashes occur due to calling into the driver's
vkGetPhysicalDeviceToolProperties. This prevents cases where the function is
exported but the physical device doesn't actually support the function (such
as mesa with its function dispatcher shared between drivers).

loader/terminator.c

index 69cad212ee1a3ddee706e0ed4218a720c0531f1a..ec3e11230eb2eaf14facd1c40405587a42d40da2 100644 (file)
@@ -626,8 +626,13 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceToolProperties(VkPhys
     struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice;
     struct loader_icd_term *icd_term = phys_dev_term->this_icd_term;
 
-    if (icd_term->dispatch.GetPhysicalDeviceToolProperties) {
-        return icd_term->dispatch.GetPhysicalDeviceToolProperties(phys_dev_term->phys_dev, pToolCount, pToolProperties);
+    VkPhysicalDeviceProperties properties;
+    if (icd_term->dispatch.GetPhysicalDeviceProperties) {
+        icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, &properties);
+
+        if (VK_VERSION_MINOR(properties.apiVersion) >= 3 && icd_term->dispatch.GetPhysicalDeviceToolProperties) {
+            return icd_term->dispatch.GetPhysicalDeviceToolProperties(phys_dev_term->phys_dev, pToolCount, pToolProperties);
+        }
     }
 
     // In the case the driver didn't support the extension, make sure that the first layer doesn't find the count uninitialized