@@ -4768,6 +4768,93 @@ TEST(TestLayers, EnvironVkInstanceLayersAndDisableFilters) {
4768
4768
ASSERT_TRUE (env.debug_log .find_prefix_then_postfix (explicit_layer_name_2, " disabled because name matches filter of env var" ));
4769
4769
}
4770
4770
4771
+ // Verify that layers enabled through VK_INSTANCE_LAYERS which were not found get the proper error message
4772
+ TEST (TestLayers, NonExistantLayerInVK_INSTANCE_LAYERS) {
4773
+ FrameworkEnvironment env;
4774
+ env.add_icd (TestICDDetails (TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA));
4775
+ env.get_test_icd ().add_physical_device ({});
4776
+
4777
+ const char * layer_name = " VK_LAYER_test_layer" ;
4778
+ env.add_explicit_layer (
4779
+ ManifestLayer{}.add_layer (
4780
+ ManifestLayer::LayerDescription{}.set_name (layer_name).set_lib_path (TEST_LAYER_PATH_EXPORT_VERSION_2)),
4781
+ " test_layer.json" );
4782
+
4783
+ EnvVarWrapper layers_enable_env_var{" VK_INSTANCE_LAYERS" , " VK_LAYER_I_dont_exist" };
4784
+ {
4785
+ InstWrapper inst{env.vulkan_functions };
4786
+ FillDebugUtilsCreateDetails (inst.create_info , env.debug_log );
4787
+ inst.CheckCreate ();
4788
+
4789
+ ASSERT_TRUE (
4790
+ env.debug_log .find (" Layer \" VK_LAYER_I_dont_exist\" was not found but was requested by env var VK_INSTANCE_LAYERS!" ));
4791
+ auto phys_dev = inst.GetPhysDev ();
4792
+ uint32_t count = 1 ;
4793
+ ASSERT_EQ (VK_SUCCESS, env.vulkan_functions .vkEnumerateDeviceLayerProperties (phys_dev, &count, nullptr ));
4794
+ ASSERT_EQ (0U , count);
4795
+ }
4796
+ // Make sure layers that do exist are loaded
4797
+ env.debug_log .clear ();
4798
+ layers_enable_env_var.add_to_list (layer_name);
4799
+ {
4800
+ InstWrapper inst{env.vulkan_functions };
4801
+ FillDebugUtilsCreateDetails (inst.create_info , env.debug_log );
4802
+ inst.CheckCreate ();
4803
+ ASSERT_TRUE (
4804
+ env.debug_log .find (" Layer \" VK_LAYER_I_dont_exist\" was not found but was requested by env var VK_INSTANCE_LAYERS!" ));
4805
+ auto phys_dev = inst.GetPhysDev ();
4806
+ uint32_t count = 1 ;
4807
+ VkLayerProperties enabled_layer_prop{};
4808
+ ASSERT_EQ (VK_SUCCESS, env.vulkan_functions .vkEnumerateDeviceLayerProperties (phys_dev, &count, &enabled_layer_prop));
4809
+ ASSERT_EQ (1U , count);
4810
+ ASSERT_TRUE (string_eq (enabled_layer_prop.layerName , layer_name));
4811
+ }
4812
+ // Make sure that if the layer appears twice in the env-var nothing bad happens
4813
+ env.debug_log .clear ();
4814
+ layers_enable_env_var.add_to_list (" VK_LAYER_I_dont_exist" );
4815
+ {
4816
+ InstWrapper inst{env.vulkan_functions };
4817
+ FillDebugUtilsCreateDetails (inst.create_info , env.debug_log );
4818
+ inst.CheckCreate ();
4819
+ ASSERT_TRUE (
4820
+ env.debug_log .find (" Layer \" VK_LAYER_I_dont_exist\" was not found but was requested by env var VK_INSTANCE_LAYERS!" ));
4821
+ auto phys_dev = inst.GetPhysDev ();
4822
+ uint32_t count = 1 ;
4823
+ VkLayerProperties enabled_layer_prop{};
4824
+ ASSERT_EQ (VK_SUCCESS, env.vulkan_functions .vkEnumerateDeviceLayerProperties (phys_dev, &count, &enabled_layer_prop));
4825
+ ASSERT_EQ (1U , count);
4826
+ ASSERT_TRUE (string_eq (enabled_layer_prop.layerName , layer_name));
4827
+ }
4828
+ }
4829
+
4830
+ // Verify that if the same layer appears twice in VK_INSTANCE_LAYERS nothing bad happens
4831
+ TEST (TestLayers, DuplicatesInEnvironVK_INSTANCE_LAYERS) {
4832
+ FrameworkEnvironment env;
4833
+ env.add_icd (TestICDDetails (TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA));
4834
+ env.get_test_icd ().add_physical_device ({});
4835
+
4836
+ const char * layer_name = " VK_LAYER_test_layer" ;
4837
+ env.add_explicit_layer (
4838
+ ManifestLayer{}.add_layer (
4839
+ ManifestLayer::LayerDescription{}.set_name (layer_name).set_lib_path (TEST_LAYER_PATH_EXPORT_VERSION_2)),
4840
+ " test_layer.json" );
4841
+
4842
+ EnvVarWrapper layers_enable_env_var{" VK_INSTANCE_LAYERS" };
4843
+
4844
+ layers_enable_env_var.add_to_list (layer_name);
4845
+ layers_enable_env_var.add_to_list (layer_name);
4846
+
4847
+ InstWrapper inst{env.vulkan_functions };
4848
+ FillDebugUtilsCreateDetails (inst.create_info , env.debug_log );
4849
+ inst.CheckCreate ();
4850
+ auto phys_dev = inst.GetPhysDev ();
4851
+ uint32_t count = 1 ;
4852
+ VkLayerProperties enabled_layer_prop{};
4853
+ ASSERT_EQ (VK_SUCCESS, env.vulkan_functions .vkEnumerateDeviceLayerProperties (phys_dev, &count, &enabled_layer_prop));
4854
+ ASSERT_EQ (1U , count);
4855
+ ASSERT_TRUE (string_eq (enabled_layer_prop.layerName , layer_name));
4856
+ }
4857
+
4771
4858
TEST (TestLayers, AppEnabledExplicitLayerFails) {
4772
4859
FrameworkEnvironment env;
4773
4860
env.add_icd (TestICDDetails (TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA, VK_MAKE_API_VERSION (0 , 1 , 2 , 0 )));
0 commit comments