Skip to content

Commit

Permalink
Fix VK_INSTANCE_LAYERS bug when using vk_loader_settings.json
Browse files Browse the repository at this point in the history
The issue was that copy of the VK_INSTANCE_LAYERS would be 'iterated' to
find the next path, but wouldn't be reset back to the beginning of the
stack allocation when going to the next iteration of the loop. By
creating a separate char* to hold the "current path" pointer, the start
of the allocation isn't lost.

Change-Id: Ic3f0b818bda2f0a017bc30cb1f315b245008e9f7
  • Loading branch information
charles-lunarg committed Nov 6, 2024
1 parent fd4f323 commit 5b00239
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions loader/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ VkResult enable_correct_layers_from_settings(const struct loader_instance* inst,
if (vk_instance_layers_env != NULL) {
vk_instance_layers_env_len = strlen(vk_instance_layers_env) + 1;
vk_instance_layers_env_copy = loader_stack_alloc(vk_instance_layers_env_len);
memset(vk_instance_layers_env_copy, 0, vk_instance_layers_env_len);

loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "env var \'%s\' defined and adding layers: %s",
ENABLED_LAYERS_ENV, vk_instance_layers_env);
Expand Down Expand Up @@ -761,13 +762,14 @@ VkResult enable_correct_layers_from_settings(const struct loader_instance* inst,
loader_strncpy(vk_instance_layers_env_copy, vk_instance_layers_env_len, vk_instance_layers_env,
vk_instance_layers_env_len);

while (vk_instance_layers_env_copy && *vk_instance_layers_env_copy) {
char* next = loader_get_next_path(vk_instance_layers_env_copy);
if (0 == strcmp(vk_instance_layers_env_copy, props->info.layerName)) {
char* instance_layers_env_iter = vk_instance_layers_env_copy;
while (instance_layers_env_iter && *instance_layers_env_iter) {
char* next = loader_get_next_path(instance_layers_env_iter);
if (0 == strcmp(instance_layers_env_iter, props->info.layerName)) {
enable_layer = true;
break;
}
vk_instance_layers_env_copy = next;
instance_layers_env_iter = next;
}
}

Expand Down

0 comments on commit 5b00239

Please sign in to comment.