Add test for implicit layer with 0.1 API version

The loader disables implicit layers if their API version isn't the same or
greater than the application. Make sure this still works even with pre 1.0
versions.
This commit is contained in:
Charles Giessen 2022-01-26 13:14:22 -07:00 committed by Charles Giessen
parent 8aad559a09
commit 8d192539c5
4 changed files with 107 additions and 8 deletions

View File

@ -228,7 +228,6 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, fs::Fo
// Don't load the layer binary if using any of the wrap objects layers, since it doesn't export the same interface
// functions
std::cout << "stem: " << layer.lib_path.stem().str() << "\n";
if (layer.lib_path.stem().str().find(fs::path(TEST_LAYER_WRAP_OBJECTS).stem().str()) == std::string::npos) {
layers.push_back(TestLayerHandle(new_layer_location));
layers.back().reset_layer();

View File

@ -600,12 +600,14 @@ InstanceCreateInfo::InstanceCreateInfo() {
}
VkInstanceCreateInfo* InstanceCreateInfo::get() noexcept {
application_info.pApplicationName = app_name.c_str();
application_info.pEngineName = engine_name.c_str();
application_info.applicationVersion = app_version;
application_info.engineVersion = engine_version;
application_info.apiVersion = api_version;
instance_info.pApplicationInfo = &application_info;
if (fill_in_application_info) {
application_info.pApplicationName = app_name.c_str();
application_info.pEngineName = engine_name.c_str();
application_info.applicationVersion = app_version;
application_info.engineVersion = engine_version;
application_info.apiVersion = api_version;
instance_info.pApplicationInfo = &application_info;
}
instance_info.enabledLayerCount = static_cast<uint32_t>(enabled_layers.size());
instance_info.ppEnabledLayerNames = enabled_layers.data();
instance_info.enabledExtensionCount = static_cast<uint32_t>(enabled_extensions.size());

View File

@ -723,10 +723,13 @@ struct InstanceCreateInfo {
BUILDER_VALUE(InstanceCreateInfo, uint32_t, api_version, VK_MAKE_VERSION(1, 0, 0))
BUILDER_VECTOR(InstanceCreateInfo, const char*, enabled_layers, layer)
BUILDER_VECTOR(InstanceCreateInfo, const char*, enabled_extensions, extension)
// tell the get() function to not provide `application_info`
BUILDER_VALUE(InstanceCreateInfo, bool, fill_in_application_info, true)
InstanceCreateInfo();
VkInstanceCreateInfo* get() noexcept;
InstanceCreateInfo& set_api_version(uint32_t major, uint32_t minor, uint32_t patch);
};

View File

@ -2169,7 +2169,7 @@ TEST(TestLayers, NewerInstanceVersionThanImplicitLayer) {
EXPECT_EQ(layer_count, 1);
EXPECT_TRUE(string_eq(layer_props[0].layerName, regular_layer_name));
{ // 1.1 instance -- instance layer should be found
{ // 1.1 instance - should find the implicit layer
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();
@ -2202,3 +2202,98 @@ TEST(TestLayers, NewerInstanceVersionThanImplicitLayer) {
ASSERT_EQ(0, count);
}
}
TEST(TestLayers, ImplicitLayerPre10APIVersion) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6, VK_MAKE_API_VERSION(0, 1, 2, 0)));
env.get_test_icd().icd_api_version = VK_MAKE_API_VERSION(0, 1, 2, 0);
VkPhysicalDeviceProperties properties{};
properties.apiVersion = VK_MAKE_API_VERSION(0, 1, 2, 0);
env.get_test_icd().add_physical_device({});
env.get_test_icd().physical_devices.back().set_properties(properties);
const char* regular_layer_name = "VK_LAYER_TestLayer1";
env.add_implicit_layer(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, 0, 1, 0))
.set_disable_environment("DisableMeIfYouCan")),
"regular_test_layer.json");
uint32_t layer_count = 0;
EXPECT_EQ(VK_SUCCESS, env.vulkan_functions.vkEnumerateInstanceLayerProperties(&layer_count, nullptr));
EXPECT_EQ(layer_count, 1);
std::array<VkLayerProperties, 1> layer_props;
EXPECT_EQ(VK_SUCCESS, env.vulkan_functions.vkEnumerateInstanceLayerProperties(&layer_count, layer_props.data()));
EXPECT_EQ(layer_count, 1);
EXPECT_TRUE(string_eq(layer_props[0].layerName, regular_layer_name));
{ // 1.0 instance -- instance layer should be found
DebugUtilsLogger log;
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
FillDebugUtilsCreateDetails(inst.create_info, log);
inst.CheckCreate();
ASSERT_TRUE(log.find(std::string("loader_add_implicit_layer: Disabling implicit layer ") + regular_layer_name +
" for using an old API version 0.1 versus application requested 1.0"));
VkPhysicalDevice phys_dev = inst.GetPhysDev();
uint32_t count = 0;
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, nullptr);
ASSERT_EQ(0, count);
VkLayerProperties layer_props{};
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, &layer_props);
ASSERT_EQ(0, count);
}
{ // 1.1 instance -- instance layer should be found
DebugUtilsLogger log;
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
FillDebugUtilsCreateDetails(inst.create_info, log);
inst.CheckCreate();
ASSERT_TRUE(log.find(std::string("loader_add_implicit_layer: Disabling implicit layer ") + regular_layer_name +
" for using an old API version 0.1 versus application requested 1.1"));
VkPhysicalDevice phys_dev = inst.GetPhysDev();
uint32_t count = 0;
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, nullptr);
ASSERT_EQ(0, count);
VkLayerProperties layer_props{};
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, &layer_props);
ASSERT_EQ(0, count);
}
{ // 1.2 instance -- instance layer shouldn't be found
DebugUtilsLogger log;
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
FillDebugUtilsCreateDetails(inst.create_info, log);
inst.CheckCreate();
VkPhysicalDevice phys_dev = inst.GetPhysDev();
ASSERT_TRUE(log.find(std::string("loader_add_implicit_layer: Disabling implicit layer ") + regular_layer_name +
" for using an old API version 0.1 versus application requested 1.2"));
uint32_t count = 0;
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, nullptr);
ASSERT_EQ(0, count);
VkLayerProperties layer_props{};
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, &layer_props);
ASSERT_EQ(0, count);
}
{ // application doesn't state its API version
DebugUtilsLogger log;
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_fill_in_application_info(false);
FillDebugUtilsCreateDetails(inst.create_info, log);
inst.CheckCreate();
EXPECT_TRUE(log.find(std::string("loader_add_implicit_layer: Disabling implicit layer ") + regular_layer_name +
" for using an old API version 0.1 versus application requested 1.0"));
VkPhysicalDevice phys_dev = inst.GetPhysDev();
uint32_t count = 0;
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, nullptr);
ASSERT_EQ(0, count);
VkLayerProperties layer_props{};
env.vulkan_functions.vkEnumerateDeviceLayerProperties(phys_dev, &count, &layer_props);
ASSERT_EQ(0, count);
}
}