Skip to content

Commit dc252cd

Browse files
Add more logging when the settings file has invalid members
Logs cases which cause the vk_loader_settings.json to fail to parse.
1 parent 63dcb0a commit dc252cd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

loader/settings.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
339339

340340
res = loader_parse_json_string(json, "file_format_version", &file_format_version_string);
341341
if (res != VK_SUCCESS) {
342+
if (res != VK_ERROR_OUT_OF_HOST_MEMORY) {
343+
loader_log(
344+
inst, VULKAN_LOADER_DEBUG_BIT, 0,
345+
"Loader settings file from %s missing required field file_format_version - no loader settings will be active",
346+
settings_file_path);
347+
}
342348
goto out;
343349
}
344350
uint32_t settings_array_count = 0;
@@ -350,6 +356,13 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
350356
settings_array_count = loader_cJSON_GetArraySize(settings_array);
351357
} else if (NULL != single_settings_object) {
352358
settings_array_count = 1;
359+
} else if (settings_array == NULL && single_settings_object) {
360+
loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
361+
"Loader settings file from %s missing required settings objects: Either one of the \"settings\" or "
362+
"\"settings_array\" objects must be present - no loader settings will be active",
363+
settings_file_path);
364+
res = VK_ERROR_INITIALIZATION_FAILED;
365+
goto out;
353366
}
354367

355368
// Corresponds to the settings object that has no app keys
@@ -399,6 +412,10 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
399412
// No app specific settings match - either use global settings or exit
400413
if (index_to_use == -1) {
401414
if (global_settings_index == -1) {
415+
loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
416+
"Loader settings file from %s missing global settings and none of the app specific settings matched the "
417+
"current application - no loader settings will be active",
418+
settings_file_path, settings_file_path);
402419
goto out; // No global settings were found - exit
403420
} else {
404421
index_to_use = global_settings_index; // Global settings are present - use it
@@ -410,6 +427,10 @@ VkResult get_loader_settings(const struct loader_instance* inst, loader_settings
410427
if (has_multi_setting_file) {
411428
single_settings_object = loader_cJSON_GetArrayItem(settings_array, index_to_use);
412429
if (NULL == single_settings_object) {
430+
loader_log(
431+
inst, VULKAN_LOADER_DEBUG_BIT, 0,
432+
"Loader settings file from %s failed to get the settings object at index %d - no loader settings will be active ",
433+
settings_file_path, index_to_use);
413434
res = VK_ERROR_INITIALIZATION_FAILED;
414435
goto out;
415436
}

0 commit comments

Comments
 (0)