loader: gh901 Fix loader w multiple ICDs
authorMark Young <marky@lunarg.com>
Tue, 6 Sep 2016 15:53:45 +0000 (09:53 -0600)
committerMark Young <marky@lunarg.com>
Tue, 6 Sep 2016 16:36:22 +0000 (10:36 -0600)
When an ICD failed during CreateInstance time, the loader needs
to remove the ICD from the list of available ICDs.

Change-Id: Id27a971e401ec9475b9488bdd95298e0f509f6b7

loader/loader.c

index 825d2b0..98b9686 100644 (file)
@@ -4121,7 +4121,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(
             // If out of memory, bail immediately.
             goto out;
         } else if (VK_SUCCESS != res) {
-            // Keep trying if there was some other error.
+            // Something bad happened with this ICD, so free it and try the
+            // next.
+            ptr_instance->icds = icd->next;
+            loader_icd_destroy(ptr_instance, icd, pAllocator);
             continue;
         }
 
@@ -4133,7 +4136,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(
             // If out of memory, bail immediately.
             goto out;
         } else if (VK_SUCCESS != res) {
-            // Keep trying if there was some other error.
+            // Something bad happened with this ICD, so free it and try the
+            // next.
+            ptr_instance->icds = icd->next;
+            loader_icd_destroy(ptr_instance, icd, pAllocator);
             continue;
         }
 
@@ -4157,9 +4163,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(
             // If out of memory, bail immediately.
             goto out;
         } else if (VK_SUCCESS != res) {
-            // Keep trying if there was some other error.
             loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
                        "ICD ignored: failed to CreateInstance in ICD %d", i);
+            ptr_instance->icds = icd->next;
+            loader_icd_destroy(ptr_instance, icd, pAllocator);
             continue;
         }