@@ -81,6 +81,7 @@ struct activated_layer_info {
8181 char * manifest ;
8282 char * library ;
8383 bool is_implicit ;
84+ enum loader_layer_enabled_by_what enabled_by_what ;
8485 char * disable_env ;
8586 char * enable_name_env ;
8687 char * enable_value_env ;
@@ -142,6 +143,29 @@ bool loader_check_version_meets_required(loader_api_version required, loader_api
142143 (version .major == required .major && version .minor == required .minor && version .patch >= required .patch );
143144}
144145
146+ const char * get_enabled_by_what_str (enum loader_layer_enabled_by_what enabled_by_what ) {
147+ switch (enabled_by_what ) {
148+ default :
149+ assert (true && "Shouldn't reach this" );
150+ return "Unknown" ;
151+ case (ENABLED_BY_WHAT_UNSET ):
152+ assert (true && "Shouldn't reach this" );
153+ return "Unknown" ;
154+ case (ENABLED_BY_WHAT_LOADER_SETTINGS_FILE ):
155+ return "Loader Settings File (Vulkan Configurator)" ;
156+ case (ENABLED_BY_WHAT_IMPLICIT_LAYER ):
157+ return "Implicit Layer" ;
158+ case (ENABLED_BY_WHAT_VK_INSTANCE_LAYERS ):
159+ return "Environment Variable VK_INSTANCE_LAYERS" ;
160+ case (ENABLED_BY_WHAT_VK_LOADER_LAYERS_ENABLE ):
161+ return "Environment Variable VK_LOADER_LAYERS_ENABLE" ;
162+ case (ENABLED_BY_WHAT_IN_APPLICATION_API ):
163+ return "By the Application" ;
164+ case (ENABLED_BY_WHAT_META_LAYER ):
165+ return "Meta Layer (Vulkan Configurator)" ;
166+ }
167+ }
168+
145169// Wrapper around opendir so that the dirent_on_windows gets the instance it needs
146170// while linux opendir & readdir does not
147171DIR * loader_opendir (const struct loader_instance * instance , const char * name ) {
@@ -980,6 +1004,7 @@ VkResult loader_add_layer_names_to_list(const struct loader_instance *inst, cons
9801004
9811005 // If not a meta-layer, simply add it.
9821006 if (0 == (layer_prop -> type_flags & VK_LAYER_TYPE_FLAG_META_LAYER )) {
1007+ layer_prop -> enabled_by_what = ENABLED_BY_WHAT_IN_APPLICATION_API ;
9831008 err = loader_add_layer_properties_to_list (inst , output_list , layer_prop );
9841009 if (err == VK_ERROR_OUT_OF_HOST_MEMORY ) return err ;
9851010 err = loader_add_layer_properties_to_list (inst , expanded_output_list , layer_prop );
@@ -1090,7 +1115,7 @@ VkResult loader_add_implicit_layer(const struct loader_instance *inst, struct lo
10901115 if (loader_find_layer_name_in_list (& prop -> info .layerName [0 ], target_list )) {
10911116 return result ;
10921117 }
1093-
1118+ prop -> enabled_by_what = ENABLED_BY_WHAT_IMPLICIT_LAYER ;
10941119 result = loader_add_layer_properties_to_list (inst , target_list , prop );
10951120 if (result == VK_ERROR_OUT_OF_HOST_MEMORY ) return result ;
10961121 if (NULL != expanded_target_list ) {
@@ -1135,17 +1160,20 @@ VkResult loader_add_meta_layer(const struct loader_instance *inst, const struct
11351160 // If the component layer is itself an implicit layer, we need to do the implicit layer enable
11361161 // checks
11371162 if (0 == (search_prop -> type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER )) {
1163+ search_prop -> enabled_by_what = ENABLED_BY_WHAT_META_LAYER ;
11381164 result = loader_add_implicit_layer (inst , search_prop , filters , target_list , expanded_target_list , source_list );
11391165 if (result == VK_ERROR_OUT_OF_HOST_MEMORY ) return result ;
11401166 } else {
11411167 if (0 != (search_prop -> type_flags & VK_LAYER_TYPE_FLAG_META_LAYER )) {
11421168 bool found_layers_in_component_meta_layer = true;
1169+ search_prop -> enabled_by_what = ENABLED_BY_WHAT_META_LAYER ;
11431170 result = loader_add_meta_layer (inst , filters , search_prop , target_list , expanded_target_list , source_list ,
11441171 & found_layers_in_component_meta_layer );
11451172 if (result == VK_ERROR_OUT_OF_HOST_MEMORY ) return result ;
11461173 if (!found_layers_in_component_meta_layer ) found_all_component_layers = false;
11471174 } else if (!loader_find_layer_name_in_list (& search_prop -> info .layerName [0 ], target_list )) {
11481175 // Make sure the layer isn't already in the output_list, skip adding it if it is.
1176+ search_prop -> enabled_by_what = ENABLED_BY_WHAT_META_LAYER ;
11491177 result = loader_add_layer_properties_to_list (inst , target_list , search_prop );
11501178 if (result == VK_ERROR_OUT_OF_HOST_MEMORY ) return result ;
11511179 if (NULL != expanded_target_list ) {
@@ -1164,6 +1192,7 @@ VkResult loader_add_meta_layer(const struct loader_instance *inst, const struct
11641192
11651193 // Add this layer to the overall target list (not the expanded one)
11661194 if (found_all_component_layers ) {
1195+ prop -> enabled_by_what = ENABLED_BY_WHAT_META_LAYER ;
11671196 result = loader_add_layer_properties_to_list (inst , target_list , prop );
11681197 if (result == VK_ERROR_OUT_OF_HOST_MEMORY ) return result ;
11691198 // Write the result to out_found_all_component_layers in case this function is being recursed
@@ -4706,6 +4735,7 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c
47064735 activated_layers [num_activated_layers ].manifest = layer_prop -> manifest_file_name ;
47074736 activated_layers [num_activated_layers ].library = layer_prop -> lib_name ;
47084737 activated_layers [num_activated_layers ].is_implicit = !(layer_prop -> type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER );
4738+ activated_layers [num_activated_layers ].enabled_by_what = layer_prop -> enabled_by_what ;
47094739 if (activated_layers [num_activated_layers ].is_implicit ) {
47104740 activated_layers [num_activated_layers ].disable_env = layer_prop -> disable_env_var .name ;
47114741 activated_layers [num_activated_layers ].enable_name_env = layer_prop -> enable_env_var .name ;
@@ -4821,6 +4851,8 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c
48214851 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " %s" , activated_layers [index ].name );
48224852 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Type: %s" ,
48234853 activated_layers [index ].is_implicit ? "Implicit" : "Explicit" );
4854+ loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Enabled By: %s" ,
4855+ get_enabled_by_what_str (activated_layers [index ].enabled_by_what ));
48244856 if (activated_layers [index ].is_implicit ) {
48254857 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Disable Env Var: %s" ,
48264858 activated_layers [index ].disable_env );
@@ -5055,6 +5087,7 @@ VkResult loader_create_device_chain(const VkPhysicalDevice pd, const VkDeviceCre
50555087 activated_layers [num_activated_layers ].manifest = layer_prop -> manifest_file_name ;
50565088 activated_layers [num_activated_layers ].library = layer_prop -> lib_name ;
50575089 activated_layers [num_activated_layers ].is_implicit = !(layer_prop -> type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER );
5090+ activated_layers [num_activated_layers ].enabled_by_what = layer_prop -> enabled_by_what ;
50585091 if (activated_layers [num_activated_layers ].is_implicit ) {
50595092 activated_layers [num_activated_layers ].disable_env = layer_prop -> disable_env_var .name ;
50605093 }
@@ -5089,6 +5122,8 @@ VkResult loader_create_device_chain(const VkPhysicalDevice pd, const VkDeviceCre
50895122 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " %s" , activated_layers [index ].name );
50905123 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Type: %s" ,
50915124 activated_layers [index ].is_implicit ? "Implicit" : "Explicit" );
5125+ loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Enabled By: %s" ,
5126+ get_enabled_by_what_str (activated_layers [index ].enabled_by_what ));
50925127 if (activated_layers [index ].is_implicit ) {
50935128 loader_log (inst , VULKAN_LOADER_LAYER_BIT , 0 , " Disable Env Var: %s" ,
50945129 activated_layers [index ].disable_env );
0 commit comments