Module: Mesa
Branch: staging/21.0
Commit: 58874f63dad93ec12a1786895a7cd5705892f0a0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=58874f63dad93ec12a1786895a7cd5705892f0a0

Author: Georg Lehmann <[email protected]>
Date:   Mon Mar  8 17:39:09 2021 +0100

vulkan/device_select: Only call vkGetPhysicalDeviceProperties2 if the device 
supports it.

vkGetPhysicalDeviceProperties2 is not allowed to be used with a 1.0 device
because it's  a vulkan 1.1 function.

Closes: #4396
Fixes: 38ce8d4d ("vulkan/device_select: Stop using device properties 2.")
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9462>
(cherry picked from commit fb1100d718fbee07dc294e1ede20a084cda423b9)

---

 .pick_status.json                                    |  2 +-
 src/vulkan/device-select-layer/device_select_layer.c | 17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e2fdf1318c3..064ff336d76 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -571,7 +571,7 @@
         "description": "vulkan/device_select: Only call 
vkGetPhysicalDeviceProperties2 if the device supports it.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "38ce8d4d00c2b0e567b6dd36876cf171acb1dbc7"
     },
diff --git a/src/vulkan/device-select-layer/device_select_layer.c 
b/src/vulkan/device-select-layer/device_select_layer.c
index 134a3bd22dd..2485d66ac94 100644
--- a/src/vulkan/device-select-layer/device_select_layer.c
+++ b/src/vulkan/device-select-layer/device_select_layer.c
@@ -193,6 +193,13 @@ static void device_select_DestroyInstance(VkInstance 
instance, const VkAllocatio
    free(info);
 }
 
+static void get_device_properties(const struct instance_info *info, 
VkPhysicalDevice device, VkPhysicalDeviceProperties2 *properties)
+{
+    info->GetPhysicalDeviceProperties(device, &properties->properties);
+
+    if (info->GetPhysicalDeviceProperties2 && 
properties->properties.apiVersion >= VK_API_VERSION_1_1)
+        info->GetPhysicalDeviceProperties2(device, properties);
+}
 
 static void print_gpu(const struct instance_info *info, unsigned index, 
VkPhysicalDevice device)
 {
@@ -205,10 +212,7 @@ static void print_gpu(const struct instance_info *info, 
unsigned index, VkPhysic
    };
    if (info->has_vulkan11 && info->has_pci_bus)
       properties.pNext = &ext_pci_properties;
-   if (info->GetPhysicalDeviceProperties2)
-      info->GetPhysicalDeviceProperties2(device, &properties);
-   else
-      info->GetPhysicalDeviceProperties(device, &properties.properties);
+   get_device_properties(info, device, &properties);
 
    switch(properties.properties.deviceType) {
    case VK_PHYSICAL_DEVICE_TYPE_OTHER:
@@ -251,10 +255,7 @@ static bool fill_drm_device_info(const struct 
instance_info *info,
 
    if (info->has_vulkan11 && info->has_pci_bus)
       properties.pNext = &ext_pci_properties;
-   if (info->GetPhysicalDeviceProperties2)
-     info->GetPhysicalDeviceProperties2(device, &properties);
-   else
-     info->GetPhysicalDeviceProperties(device, &properties.properties);
+   get_device_properties(info, device, &properties);
 
    drm_device->cpu_device = properties.properties.deviceType == 
VK_PHYSICAL_DEVICE_TYPE_CPU;
    drm_device->dev_info.vendor_id = properties.properties.vendorID;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to