Skip to content

Commit 6c0e5ef

Browse files
Use VK_LOADER_DEBUG if settings stderr_log is empty
If a loader settings file was present, the logging settings of the file were used irregardless of whether the settings file actually specified. The loader will now check to see if the settings stderr_log value is at least non-zero before deciding to skip a message, allowing for the VK_LOADER_DEBUG filter to be applied in case if it is zero.
1 parent 2ae1a82 commit 6c0e5ef

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

loader/log.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t ms
143143

144144
// Always log to stderr if this is a fatal error
145145
if (0 == (msg_type & VULKAN_LOADER_FATAL_ERROR_BIT)) {
146-
// Exit early if the current instance settings do not ask for logging to stderr
147-
if (inst && inst->settings.settings_active && 0 == (msg_type & inst->settings.debug_level)) {
148-
return;
146+
if (inst && inst->settings.settings_active && inst->settings.debug_level > 0) {
147+
// Exit early if the current instance settings have some debugging options but do match the current msg_type
148+
if (0 == (msg_type & inst->settings.debug_level)) {
149+
return;
150+
}
149151
// Check the global settings and if that doesn't say to skip, check the environment variable
150152
} else if (0 == (msg_type & g_loader_debug)) {
151153
return;

tests/loader_settings_tests.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,61 @@ TEST(SettingsFile, StderrLog_NoOutput) {
22432243
}
22442244
}
22452245

2246+
// Settings can say which filters to use - make sure the lack of this filter works correctly with VK_LOADER_DEBUG
2247+
TEST(SettingsFile, NoStderr_log_but_VK_LOADER_DEBUG) {
2248+
FrameworkEnvironment env{FrameworkSettings{}.set_log_filter("all")};
2249+
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({});
2250+
2251+
const char* explicit_layer_name = "Regular_TestLayer1";
2252+
2253+
env.add_explicit_layer(TestLayerDetails{
2254+
ManifestLayer{}.add_layer(
2255+
ManifestLayer::LayerDescription{}.set_name(explicit_layer_name).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)),
2256+
"explicit_test_layer1.json"});
2257+
2258+
env.update_loader_settings(env.loader_settings.set_file_format_version({1, 0, 0}).add_app_specific_setting(
2259+
AppSpecificSettings{}
2260+
.add_layer_configuration(LoaderSettingsLayerConfiguration{}
2261+
.set_name(explicit_layer_name)
2262+
.set_path(env.get_shimmed_layer_manifest_path())
2263+
.set_control("auto"))
2264+
.add_layer_configuration(
2265+
LoaderSettingsLayerConfiguration{}.set_name("VK_LAYER_missing").set_path("/road/to/nowhere").set_control("auto"))));
2266+
env.loader_settings.app_specific_settings.at(0).stderr_log = {};
2267+
env.update_loader_settings(env.loader_settings);
2268+
2269+
std::string expected_output_verbose;
2270+
expected_output_verbose += "DEBUG: Layer Configurations count = 2\n";
2271+
expected_output_verbose += "DEBUG: ---- Layer Configuration [0] ----\n";
2272+
expected_output_verbose += std::string("DEBUG: Name: ") + explicit_layer_name + "\n";
2273+
expected_output_verbose += "DEBUG: Path: " + env.get_shimmed_layer_manifest_path().string() + "\n";
2274+
expected_output_verbose += "DEBUG: Control: auto\n";
2275+
expected_output_verbose += "DEBUG: ---- Layer Configuration [1] ----\n";
2276+
expected_output_verbose += "DEBUG: Name: VK_LAYER_missing\n";
2277+
expected_output_verbose += "DEBUG: Path: /road/to/nowhere\n";
2278+
expected_output_verbose += "DEBUG: Control: auto\n";
2279+
expected_output_verbose += "DEBUG: ---------------------------------\n";
2280+
2281+
std::string expected_output_info = std::string("INFO: ") + get_settings_location_log_message(env) + "\n";
2282+
2283+
std::string expected_output_warning =
2284+
"WARNING: Layer name Regular_TestLayer1 does not conform to naming standard (Policy #LLP_LAYER_3)\n";
2285+
2286+
std::string expected_output_error = "ERROR: loader_get_json: Failed to open JSON file /road/to/nowhere\n";
2287+
2288+
env.platform_shim->clear_logs();
2289+
{
2290+
InstWrapper inst{env.vulkan_functions};
2291+
inst.CheckCreate();
2292+
EXPECT_TRUE(env.platform_shim->find_in_log(expected_output_verbose));
2293+
EXPECT_TRUE(env.platform_shim->find_in_log(expected_output_info));
2294+
EXPECT_TRUE(env.platform_shim->find_in_log(expected_output_warning));
2295+
EXPECT_TRUE(env.platform_shim->find_in_log(expected_output_error));
2296+
2297+
auto active_layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 0);
2298+
EXPECT_TRUE(active_layer_props.size() == 0);
2299+
}
2300+
}
22462301
TEST(SettingsFile, ManyLayersEnabledInManyWays) {
22472302
FrameworkEnvironment env{};
22482303
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({});

0 commit comments

Comments
 (0)