From: Charles Giessen Date: Fri, 11 Feb 2022 16:52:00 +0000 (-0700) Subject: Clarify behavior of override_paths + VK_LAYER_PATH X-Git-Tag: upstream/v1.3.207~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a7407b1512cc7a5473348f01bafbd91fb7b5802;p=platform%2Fupstream%2FVulkan-Loader.git Clarify behavior of override_paths + VK_LAYER_PATH If a meta layer which contains `override_paths` is active, all of the paths in VK_LAYER_PATH are ignored when searchign for explicit layers. This may be changed changed in the future but for now is better tested and documented. --- diff --git a/docs/LoaderLayerInterface.md b/docs/LoaderLayerInterface.md index 95a1ccd8..2f2a4097 100644 --- a/docs/LoaderLayerInterface.md +++ b/docs/LoaderLayerInterface.md @@ -1038,7 +1038,7 @@ override layer global and applies it to every application upon startup. If the override layer contains `override_paths`, then it uses this list of paths exclusively for component layers. Thus, it ignores both the default explicit and implicit layer layer search -locations. +locations as well as paths set by environment variables like `VK_LAYER_PATH`. If any component layer is not present in the provided override paths, the meta layer is disabled. @@ -1379,6 +1379,12 @@ layer is not applied. So if an override meta layer wants to mix default and custom layer locations, the override paths must contain both custom and default layer locations. +* If the override layer is both present and contains `override_paths`, the +paths from the environment variable `VK_LAYER_PATH` are ignored when searching +for explicit layers. +For example, when both the meta layer override paths and `VK_LAYER_PATH` are +present, none of the layers in `VK_LAYER_PATH` are discoverable, and the +loader will not find them. ## Layer Manifest File Format The Khronos loader uses manifest files to discover available layer libraries diff --git a/tests/framework/test_environment.cpp b/tests/framework/test_environment.cpp index 9c91a1bc..f60948f1 100644 --- a/tests/framework/test_environment.cpp +++ b/tests/framework/test_environment.cpp @@ -221,10 +221,14 @@ void FrameworkEnvironment::add_fake_explicit_layer(ManifestLayer layer_manifest, add_layer_impl(fake_details, explicit_layer_folder, ManifestCategory::explicit_layer); } void FrameworkEnvironment::add_implicit_layer(TestLayerDetails layer_details) noexcept { - add_layer_impl(layer_details, implicit_layer_folder, ManifestCategory::implicit_layer); + add_layer_impl(layer_details, + layer_details.destination_folder == nullptr ? implicit_layer_folder : *layer_details.destination_folder, + ManifestCategory::implicit_layer); } void FrameworkEnvironment::add_explicit_layer(TestLayerDetails layer_details) noexcept { - add_layer_impl(layer_details, explicit_layer_folder, ManifestCategory::explicit_layer); + add_layer_impl(layer_details, + layer_details.destination_folder == nullptr ? explicit_layer_folder : *layer_details.destination_folder, + ManifestCategory::explicit_layer); } void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, fs::FolderManager& folder_manager, diff --git a/tests/framework/test_environment.h b/tests/framework/test_environment.h index 3a80af61..5e70b53d 100644 --- a/tests/framework/test_environment.h +++ b/tests/framework/test_environment.h @@ -304,6 +304,7 @@ struct TestLayerDetails { : layer_manifest(layer_manifest), json_name(json_name) {} BUILDER_VALUE(TestLayerDetails, ManifestLayer, layer_manifest, {}); BUILDER_VALUE(TestLayerDetails, std::string, json_name, "test_layer"); + BUILDER_VALUE(TestLayerDetails, fs::FolderManager*, destination_folder, nullptr); BUILDER_VALUE(TestLayerDetails, bool, add_to_regular_search_paths, true); BUILDER_VALUE(TestLayerDetails, bool, is_fake, false); }; diff --git a/tests/loader_layer_tests.cpp b/tests/loader_layer_tests.cpp index 1e508a05..dfa7a58f 100644 --- a/tests/loader_layer_tests.cpp +++ b/tests/loader_layer_tests.cpp @@ -842,10 +842,58 @@ TEST_F(OverrideMetaLayer, BasicOverridePathsIgnoreOtherLayers) { InstWrapper inst{env->vulkan_functions}; inst.create_info.set_api_version(1, 1, 0); inst.create_info.add_layer(regular_layer_name); + FillDebugUtilsCreateDetails(inst.create_info, env->debug_log); inst.CheckCreate(VK_ERROR_LAYER_NOT_PRESENT); ASSERT_FALSE(env->debug_log.find(std::string("Insert instance layer ") + regular_layer_name)); } +TEST_F(OverrideMetaLayer, OverridePathsInteractionWithVK_LAYER_PATH) { + env->get_test_icd().add_physical_device({}); + + fs::FolderManager vk_layer_path_folder{FRAMEWORK_BUILD_DIRECTORY, "vk_layer_folder"}; + set_env_var("VK_LAYER_PATH", vk_layer_path_folder.location().str()); + fs::FolderManager override_path_folder{FRAMEWORK_BUILD_DIRECTORY, "override_path_folder"}; + + // add explicit layer to VK_LAYER_PATH folder + const char* env_var_layer_name = "VK_LAYER_env_var_set_path"; + env->add_explicit_layer(TestLayerDetails{ManifestLayer{} + .set_file_format_version(ManifestVersion(1, 2, 0)) + .add_layer(ManifestLayer::LayerDescription{} + .set_name(env_var_layer_name) + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2) + .set_api_version(VK_MAKE_API_VERSION(0, 1, 0, 0))), + "regular_test_layer.json"} + .set_destination_folder(&vk_layer_path_folder)); + + // add layer to regular explicit layer folder + const char* regular_layer_name = "VK_LAYER_regular_layer_path"; + env->add_explicit_layer(TestLayerDetails{ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{} + .set_name(regular_layer_name) + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2) + .set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0))), + "regular_test_layer.json"} + .set_destination_folder(&override_path_folder)); + + env->add_implicit_layer(ManifestLayer{} + .set_file_format_version(ManifestVersion(1, 2, 0)) + .add_layer(ManifestLayer::LayerDescription{} + .set_name(lunarg_meta_layer_name) + .set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0)) + .add_component_layer(regular_layer_name) + .set_disable_environment("DisableMeIfYouCan") + .add_override_path(override_path_folder.location().str())), + "meta_test_layer.json"); + + InstWrapper inst{env->vulkan_functions}; + inst.create_info.set_api_version(1, 1, 0); + inst.create_info.add_layer(env_var_layer_name); + FillDebugUtilsCreateDetails(inst.create_info, env->debug_log); + inst.CheckCreate(VK_ERROR_LAYER_NOT_PRESENT); + ASSERT_FALSE(env->debug_log.find(std::string("Insert instance layer ") + env_var_layer_name)); + + remove_env_var("VK_LAYER_PATH"); +} + // Make sure that implicit layers not in the override paths aren't found by mistake TEST_F(OverrideMetaLayer, OverridePathsEnableImplicitLayerInDefaultPaths) { env->get_test_icd().add_physical_device({}); diff --git a/tests/loader_regression_tests.cpp b/tests/loader_regression_tests.cpp index 1b943891..4ce8263c 100644 --- a/tests/loader_regression_tests.cpp +++ b/tests/loader_regression_tests.cpp @@ -1115,6 +1115,8 @@ TEST(EnvironmentVariables, VK_LAYER_PATH) { EXPECT_TRUE(env.debug_log.find("/tmp/carol")); EXPECT_TRUE(env.debug_log.find("/tandy")); EXPECT_TRUE(env.debug_log.find((HOME / "/ with spaces/").str())); + + remove_env_var("VK_LAYER_PATH"); } #endif