loader: Trampoline vkEnumeratePhysDev should use layer-returned physDev count
authorPiers Daniell <pdaniell@nvidia.com>
Thu, 31 Mar 2016 21:00:59 +0000 (15:00 -0600)
committerJon Ashburn <jon@lunarg.com>
Fri, 1 Apr 2016 17:23:38 +0000 (11:23 -0600)
Modify the trampoline vkEnumeratePhysicalDevices() implementation to
enumerate the number of physical devices based on what the top-most
layer reports and not what the terminator_EnumeratePhysicalDevices
counted. This allows intermediate layers to modify the physical device
count.

Change-Id: Ifd5c3c8c4db53cf97b976feefe18de7cfef47e35

loader/trampoline.c

index dd01579..0622dce 100644 (file)
@@ -511,7 +511,8 @@ vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
     }
     if (inst->phys_devs)
         loader_heap_free(inst, inst->phys_devs);
-    count = inst->total_gpu_count;
+    count = min(inst->total_gpu_count, *pPhysicalDeviceCount);
+    *pPhysicalDevices = count;
     inst->phys_devs = (struct loader_physical_device_tramp *)loader_heap_alloc(
         inst, count * sizeof(struct loader_physical_device_tramp),
         VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);