Fix layers not being removed by meta-layer
authorCharles Giessen <charles@lunarg.com>
Wed, 12 Jan 2022 22:56:59 +0000 (16:56 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 13 Jan 2022 00:44:07 +0000 (17:44 -0700)
The code was faulty and would remove the layers that were supposed to be kept,
such as the meta layer itself. Bugs include taking a copy instead of a pointer
which led to an assignment being forgotten and using the wrong list when
looking through the list of layers.

loader/loader.c

index f3f3d5674505909e767534b1d38d2ed0bfc2c7c4..efe296aa4931a78c833b5cb37f5ebdd7494af464 100644 (file)
@@ -450,25 +450,23 @@ void loader_remove_layers_not_in_implicit_meta_layers(const struct loader_instan
     }
 
     for (i = 0; i < layer_count; i++) {
-        struct loader_layer_properties cur_layer_prop = layer_list->list[i];
+        struct loader_layer_properties *cur_layer_prop = &layer_list->list[i];
 
-        if (0 == (cur_layer_prop.type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER)) {
-            cur_layer_prop.keep = true;
-        } else {
+        if (0 == (cur_layer_prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER)) {
+            cur_layer_prop->keep = true;
             continue;
         }
+        for (j = 0; j < layer_count; j++) {
+            struct loader_layer_properties layer_to_check = layer_list->list[j];
 
-        if (cur_layer_prop.type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
-            for (j = 0; j < layer_count; j++) {
-                struct loader_layer_properties layer_to_check = layer_list->list[j];
-
-                if (i == j) {
-                    continue;
-                }
+            if (i == j) {
+                continue;
+            }
 
+            if (layer_to_check.type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
                 // For all layers found in this meta layer, we want to keep them as well.
-                if (loader_find_layer_name_in_meta_layer(inst, layer_to_check.info.layerName, layer_list, &cur_layer_prop)) {
-                    cur_layer_prop.keep = true;
+                if (loader_find_layer_name_in_meta_layer(inst, cur_layer_prop->info.layerName, layer_list, &layer_to_check)) {
+                    cur_layer_prop->keep = true;
                 }
             }
         }