Skip to content

Commit

Permalink
Correctly check if settings file exists on windows
Browse files Browse the repository at this point in the history
While there was logic to check if the vk_loader_settings.json file existed,
it was not being run at an appropriate time and with another expression that
caused the check to never happen.

This commit also logs that the loader fails to find the loader settings file, and
if it finds a registry entry, if the file doesn't exist.
  • Loading branch information
charles-lunarg committed Nov 21, 2024
1 parent 684dcee commit 639f392
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions loader/loader_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,12 +1194,15 @@ VkResult get_settings_path_if_exists_in_registry_key(const struct loader_instanc
}
}

// Make sure the path exists first
if (*out_path && !loader_platform_file_exists(name)) {
return VK_ERROR_INITIALIZATION_FAILED;
}

if (strcmp(VK_LOADER_SETTINGS_FILENAME, &(name[start_of_path_filename])) == 0) {
// Make sure the path exists first
if (!loader_platform_file_exists(name)) {
loader_log(
inst, VULKAN_LOADER_DEBUG_BIT, 0,
"Registry contained entry to vk_loader_settings.json but the corresponding file does not exist, ignoring");
return VK_ERROR_INITIALIZATION_FAILED;
}

*out_path = loader_instance_heap_calloc(inst, name_size + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (*out_path == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
Expand Down
4 changes: 4 additions & 0 deletions loader/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,16 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
#if defined(WIN32)
res = windows_get_loader_settings_file_path(inst, &settings_file_path);
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
"No valid vk_loader_settings.json file found, no loader settings will be active");
goto out;
}

#elif COMMON_UNIX_PLATFORMS
res = get_unix_settings_path(inst, &settings_file_path);
if (res != VK_SUCCESS) {
loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
"No valid vk_loader_settings.json file found, no loader settings will be active");
goto out;
}
#else
Expand Down

0 comments on commit 639f392

Please sign in to comment.