loader: Fix EnumPhysDev bug
authorMark Young <marky@lunarg.com>
Tue, 24 Jan 2017 22:54:29 +0000 (15:54 -0700)
committerMark Young <marky@lunarg.com>
Wed, 25 Jan 2017 07:16:36 +0000 (00:16 -0700)
Fix a bug found by Piers with regards to vkEnumeratePhysicalDevices.
Basically, if the application called the function without first
calling it with NULL pPhysicalDevices, the count would be wrong.

Change-Id: If3a4ba60b17c64df2133d31d3692ee6da21c6a01

loader/trampoline.c

index 4d14f58..207a747 100644 (file)
@@ -549,7 +549,7 @@ vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
         goto out;
     }
 
-    if (pPhysicalDevices == NULL) {
+    if (NULL == pPhysicalDevices || 0 == inst->total_gpu_count) {
         // Call down.  At the lower levels, this will setup the terminator
         // structures in the loader.
         res = disp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount,
@@ -559,7 +559,9 @@ vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
                         "vkEnumeratePhysicalDevices: Failed in dispatch call"
                         " used to determine number of available GPUs");
         }
+    }
 
+    if (NULL == pPhysicalDevices) {
         // Goto out, even on success since we don't need to fill in the rest.
         goto out;
     }