loader: make sure createDevice uses ICDs physicalDevice
authorJon Ashburn <jon@lunarg.com>
Fri, 11 Mar 2016 21:43:57 +0000 (14:43 -0700)
committerJon Ashburn <jon@lunarg.com>
Fri, 11 Mar 2016 21:45:47 +0000 (14:45 -0700)
Trampoline CreateDevice was using the terminator's physicalDevice instead of
the ICDs.

Change-Id: Ifdc6497fe4130e1ac1440b225401e65600b2a999

loader/loader.c
loader/loader.h
loader/trampoline.c

index b67e1db0370a26bb48e2d6d5fa1b85af99cc91d5..104dc9e1181cdbbc081aaa722fa4c9d5fe517d17 100644 (file)
@@ -1181,6 +1181,8 @@ static void loader_icd_destroy(struct loader_instance *ptr_inst,
         dev = next_dev;
     }
 
+    if (icd->phys_devs != NULL)
+        loader_heap_free(ptr_inst, icd->phys_devs);
     loader_heap_free(ptr_inst, icd);
 }
 
@@ -3934,10 +3936,19 @@ terminator_EnumeratePhysicalDevices(VkInstance instance,
         return VK_ERROR_OUT_OF_HOST_MEMORY;
 
     for (i = 0; idx < copy_count && i < inst->total_icd_count; i++) {
+        icd = phys_devs[i].this_icd;
+        if (icd->phys_devs != NULL) {
+            loader_heap_free(inst, icd->phys_devs);
+        }
+        icd->phys_devs = loader_heap_alloc(inst,
+                              sizeof(VkPhysicalDevice) * phys_devs[i].count,
+                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+
         for (j = 0; j < phys_devs[i].count && idx < copy_count; j++) {
             loader_set_dispatch((void *)&inst->phys_devs_term[idx], inst->disp);
             inst->phys_devs_term[idx].this_icd = phys_devs[i].this_icd;
             inst->phys_devs_term[idx].phys_dev = phys_devs[i].phys_devs[j];
+            icd->phys_devs[j] = phys_devs[i].phys_devs[j];
             pPhysicalDevices[idx] =
                 (VkPhysicalDevice)&inst->phys_devs_term[idx];
             idx++;
index 89755eb830ea4c484bf0d30a5965b6804a64d8da..3560a9064a5243d8c8232b6d63f65ebee7707a7d 100644 (file)
@@ -200,7 +200,7 @@ struct loader_icd {
     // pointers to find other structs
     const struct loader_scanned_icds *this_icd_lib;
     const struct loader_instance *this_instance;
-
+    VkPhysicalDevice *phys_devs;  // physicalDevice object from icd
     struct loader_device *logical_device_list;
     VkInstance instance; // instance object from the icd
     PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
index f4370a5e62a9b0d2db038464aeb12ff6bd318347..a26d8c5a4d814983ef0f9fc5571d6779843b340a 100644 (file)
@@ -629,8 +629,9 @@ vkCreateDevice(VkPhysicalDevice physicalDevice,
         return VK_ERROR_OUT_OF_HOST_MEMORY;
     }
 
+    //TODO handle more than one phys dev per icd (icd->phys_devs[0])
     res = loader_add_device_extensions(
-        inst, icd, phys_dev->phys_dev,
+        inst, icd, icd->phys_devs[0],
         phys_dev->this_icd->this_icd_lib->lib_name, &icd_exts);
     if (res != VK_SUCCESS) {
         loader_platform_thread_unlock_mutex(&loader_lock);