@@ -1041,7 +1041,10 @@ TEST_FUNCTION_EXPORT VkResult get_settings_layers(const struct loader_instance*
10411041// Skip comparing to UNORDERED_LAYER_LOCATION
10421042// If layer_property is a regular layer, check if the lib_path is the same.
10431043// Make sure that the lib_name pointers are non-null before calling strcmp.
1044- bool check_if_layer_is_in_list (struct loader_layer_list * layer_list , struct loader_layer_properties * layer_property ) {
1044+ // consider_lib_path - true if comparison should include the library_path in distinguishing layers. Used to prevent duplicates
1045+ // between settings file provided layers and default found layers
1046+ bool check_if_layer_is_in_list (struct loader_layer_list * layer_list , struct loader_layer_properties * layer_property ,
1047+ bool consider_lib_path ) {
10451048 // If the layer is a meta layer, just check against the name
10461049 for (uint32_t i = 0 ; i < layer_list -> count ; i ++ ) {
10471050 if (0 == strncmp (layer_list -> list [i ].info .layerName , layer_property -> info .layerName , VK_MAX_EXTENSION_NAME_SIZE )) {
@@ -1051,6 +1054,9 @@ bool check_if_layer_is_in_list(struct loader_layer_list* layer_list, struct load
10511054 if (VK_LAYER_TYPE_FLAG_META_LAYER == (layer_property -> type_flags & VK_LAYER_TYPE_FLAG_META_LAYER )) {
10521055 return true;
10531056 }
1057+ if (!consider_lib_path ) {
1058+ return true;
1059+ }
10541060 if (layer_list -> list [i ].lib_name && layer_property -> lib_name ) {
10551061 return strcmp (layer_list -> list [i ].lib_name , layer_property -> lib_name ) == 0 ;
10561062 }
@@ -1099,7 +1105,7 @@ VkResult combine_settings_layers_with_regular_layers(const struct loader_instanc
10991105
11001106 // Insert the settings layers into output_layers up to unordered_layer_index
11011107 for (uint32_t i = 0 ; i < unordered_layer_location_index ; i ++ ) {
1102- if (!check_if_layer_is_in_list (output_layers , & settings_layers -> list [i ])) {
1108+ if (!check_if_layer_is_in_list (output_layers , & settings_layers -> list [i ], true )) {
11031109 res = loader_append_layer_property (inst , output_layers , & settings_layers -> list [i ]);
11041110 if (VK_SUCCESS != res ) {
11051111 goto out ;
@@ -1109,8 +1115,8 @@ VkResult combine_settings_layers_with_regular_layers(const struct loader_instanc
11091115
11101116 for (uint32_t i = 0 ; i < regular_layers -> count ; i ++ ) {
11111117 // Check if its already been put in the output_layers list as well as the remaining settings_layers
1112- bool regular_layer_is_ordered = check_if_layer_is_in_list (output_layers , & regular_layers -> list [i ]) ||
1113- check_if_layer_is_in_list (settings_layers , & regular_layers -> list [i ]);
1118+ bool regular_layer_is_ordered = check_if_layer_is_in_list (output_layers , & regular_layers -> list [i ], false ) ||
1119+ check_if_layer_is_in_list (settings_layers , & regular_layers -> list [i ], false );
11141120 // If it isn't found, add it
11151121 if (!regular_layer_is_ordered ) {
11161122 res = loader_append_layer_property (inst , output_layers , & regular_layers -> list [i ]);
@@ -1126,9 +1132,11 @@ VkResult combine_settings_layers_with_regular_layers(const struct loader_instanc
11261132 // Insert the rest of the settings layers into combined_layers from unordered_layer_index to the end
11271133 // start at one after the unordered_layer_index
11281134 for (uint32_t i = unordered_layer_location_index + 1 ; i < settings_layers -> count ; i ++ ) {
1129- res = loader_append_layer_property (inst , output_layers , & settings_layers -> list [i ]);
1130- if (VK_SUCCESS != res ) {
1131- goto out ;
1135+ if (!check_if_layer_is_in_list (output_layers , & settings_layers -> list [i ], true)) {
1136+ res = loader_append_layer_property (inst , output_layers , & settings_layers -> list [i ]);
1137+ if (VK_SUCCESS != res ) {
1138+ goto out ;
1139+ }
11321140 }
11331141 }
11341142
0 commit comments