@@ -305,6 +305,17 @@ void log_settings(const struct loader_instance* inst, loader_settings* settings)
305305 loader_log (inst , VULKAN_LOADER_DEBUG_BIT , 0 , "---------------------------------" );
306306}
307307
308+ void log_global_settings () {
309+ loader_platform_thread_lock_mutex (& global_loader_settings_lock );
310+ if (global_loader_settings .settings_active ) {
311+ log_settings (NULL , & global_loader_settings );
312+ } else {
313+ loader_log (NULL , VULKAN_LOADER_INFO_BIT , 0 ,
314+ "No valid vk_loader_settings.json file found, no loader settings will be active" );
315+ }
316+ loader_platform_thread_unlock_mutex (& global_loader_settings_lock );
317+ }
318+
308319// Loads the vk_loader_settings.json file
309320// Returns VK_SUCCESS if it was found & was successfully parsed. Otherwise, it returns VK_ERROR_INITIALIZATION_FAILED if it
310321// wasn't found or failed to parse, and returns VK_ERROR_OUT_OF_HOST_MEMORY if it was unable to allocate enough memory.
@@ -316,16 +327,12 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
316327#if defined(WIN32 )
317328 res = windows_get_loader_settings_file_path (inst , & settings_file_path );
318329 if (res != VK_SUCCESS ) {
319- loader_log (inst , VULKAN_LOADER_INFO_BIT , 0 ,
320- "No valid vk_loader_settings.json file found, no loader settings will be active" );
321330 goto out ;
322331 }
323332
324333#elif COMMON_UNIX_PLATFORMS
325334 res = get_unix_settings_path (inst , & settings_file_path );
326335 if (res != VK_SUCCESS ) {
327- loader_log (inst , VULKAN_LOADER_INFO_BIT , 0 ,
328- "No valid vk_loader_settings.json file found, no loader settings will be active" );
329336 goto out ;
330337 }
331338#else
@@ -489,12 +496,16 @@ TEST_FUNCTION_EXPORT VkResult update_global_loader_settings(void) {
489496 loader_settings settings = {0 };
490497 VkResult res = get_loader_settings (NULL , & settings );
491498 loader_platform_thread_lock_mutex (& global_loader_settings_lock );
492-
493- free_loader_settings (NULL , & global_loader_settings );
494- if (res == VK_SUCCESS ) {
495- if (!check_if_settings_are_equal (& settings , & global_loader_settings )) {
496- log_settings (NULL , & settings );
497- }
499+ if (res != VK_SUCCESS ) {
500+ // If we failed to get the global loader settings file, unset the current loader settings
501+ free_loader_settings (NULL , & global_loader_settings );
502+ memset (& global_loader_settings , 0 , sizeof (loader_settings ));
503+ } else if (check_if_settings_are_equal (& settings , & global_loader_settings )) {
504+ // If we successfully got the new global loader settings, but is identical to old settings, return after cleaning up
505+ free_loader_settings (NULL , & settings );
506+ } else {
507+ // Replace the current global loader settings with the new ones, setting the debug level if there are any debug filters set
508+ free_loader_settings (NULL , & global_loader_settings );
498509
499510 memcpy (& global_loader_settings , & settings , sizeof (loader_settings ));
500511 if (global_loader_settings .settings_active && global_loader_settings .debug_level > 0 ) {
0 commit comments