@@ -579,6 +579,9 @@ VkResult get_settings_layers(const struct loader_instance* inst, struct loader_l
579579 continue ;
580580 }
581581
582+ // Makes it possible to know if a new layer was added or not, since the only return value is VkResult
583+ size_t count_before_adding = settings_layers -> count ;
584+
582585 local_res =
583586 loader_add_layer_properties (inst , settings_layers , json , layer_config -> treat_as_implicit_manifest , layer_config -> path );
584587 loader_cJSON_Delete (json );
@@ -587,7 +590,11 @@ VkResult get_settings_layers(const struct loader_instance* inst, struct loader_l
587590 if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res ) {
588591 res = VK_ERROR_OUT_OF_HOST_MEMORY ;
589592 goto out ;
593+ } else if (local_res != VK_SUCCESS || count_before_adding == settings_layers -> count ) {
594+ // Indicates something was wrong with the layer, can't add it to the list
595+ continue ;
590596 }
597+
591598 struct loader_layer_properties * newly_added_layer = & settings_layers -> list [settings_layers -> count - 1 ];
592599 newly_added_layer -> settings_control_value = layer_config -> control ;
593600 // If the manifest file found has a name that differs from the one in the settings, remove this layer from consideration
@@ -618,16 +625,24 @@ VkResult get_settings_layers(const struct loader_instance* inst, struct loader_l
618625}
619626
620627// Check if layers has an element with the same name.
628+ // LAYER_CONTROL_OFF layers are missing some fields, just make sure the layerName is the same
629+ // If layer_property is a meta layer, just make sure the layerName is the same
630+ // Skip comparing to UNORDERED_LAYER_LOCATION
621631// If layer_property is a regular layer, check if the lib_path is the same.
622- // If layer_property is a meta layer, just use the layerName
632+ // Make sure that the lib_name pointers are non-null before calling strcmp.
623633bool check_if_layer_is_in_list (struct loader_layer_list * layer_list , struct loader_layer_properties * layer_property ) {
624634 // If the layer is a meta layer, just check against the name
625635 for (uint32_t i = 0 ; i < layer_list -> count ; i ++ ) {
626636 if (0 == strncmp (layer_list -> list [i ].info .layerName , layer_property -> info .layerName , VK_MAX_EXTENSION_NAME_SIZE )) {
627- if (0 == (layer_property -> type_flags & VK_LAYER_TYPE_FLAG_META_LAYER ) &&
628- strcmp (layer_list -> list [i ].lib_name , layer_property -> lib_name ) == 0 ) {
637+ if (layer_list -> list [i ].settings_control_value == LOADER_SETTINGS_LAYER_CONTROL_OFF ) {
629638 return true;
630639 }
640+ if (VK_LAYER_TYPE_FLAG_META_LAYER == (layer_property -> type_flags & VK_LAYER_TYPE_FLAG_META_LAYER )) {
641+ return true;
642+ }
643+ if (layer_list -> list [i ].lib_name && layer_property -> lib_name ) {
644+ return strcmp (layer_list -> list [i ].lib_name , layer_property -> lib_name ) == 0 ;
645+ }
631646 }
632647 }
633648 return false;
0 commit comments