BUILDER_VALUE(TestLayer, bool, intercept_vkEnumerateInstanceExtensionProperties, false)
BUILDER_VALUE(TestLayer, bool, intercept_vkEnumerateInstanceLayerProperties, false)
- struct LayerCallback {
- FP_layer_callback callback = nullptr;
- void* data = nullptr;
- };
// Called in vkCreateInstance after calling down the chain & returning
- BUILDER_VALUE(TestLayer, LayerCallback, create_instance_callback, {})
+ BUILDER_VALUE(TestLayer, std::function<VkResult(TestLayer& layer)>, create_instance_callback, {})
// Called in vkCreateDevice after calling down the chain & returning
- BUILDER_VALUE(TestLayer, LayerCallback, create_device_callback, {})
+ BUILDER_VALUE(TestLayer, std::function<VkResult(TestLayer& layer)>, create_device_callback, {})
PFN_vkGetInstanceProcAddr next_vkGetInstanceProcAddr = VK_NULL_HANDLE;
PFN_vkGetDeviceProcAddr next_vkGetDeviceProcAddr = VK_NULL_HANDLE;
"regular_test_layer.json");
auto& layer = env->get_test_layer(0);
- layer.set_create_instance_callback(TestLayer::LayerCallback{
- [](TestLayer& layer, void* data) -> VkResult {
- uint32_t phys_dev_count = 0;
- VkResult res = layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, nullptr);
- if (res != VK_SUCCESS || phys_dev_count > 1) {
- return VK_ERROR_INITIALIZATION_FAILED; // expecting only a single physical device.
- }
- VkPhysicalDevice phys_dev{};
- res = layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, &phys_dev);
- if (res != VK_SUCCESS) {
- return VK_ERROR_INITIALIZATION_FAILED;
- }
- VkPhysicalDeviceProperties2 props2{};
- props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
- layer.instance_dispatch_table.GetPhysicalDeviceProperties2(phys_dev, &props2);
-
- VkPhysicalDeviceFeatures2 features2{};
- features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
- layer.instance_dispatch_table.GetPhysicalDeviceFeatures2(phys_dev, &features2);
- return VK_SUCCESS;
- },
- nullptr});
+ layer.set_create_instance_callback([](TestLayer& layer) -> VkResult {
+ uint32_t phys_dev_count = 0;
+ VkResult res = layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, nullptr);
+ if (res != VK_SUCCESS || phys_dev_count > 1) {
+ return VK_ERROR_INITIALIZATION_FAILED; // expecting only a single physical device.
+ }
+ VkPhysicalDevice phys_dev{};
+ res = layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, &phys_dev);
+ if (res != VK_SUCCESS) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+ VkPhysicalDeviceProperties2 props2{};
+ props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
+ layer.instance_dispatch_table.GetPhysicalDeviceProperties2(phys_dev, &props2);
+
+ VkPhysicalDeviceFeatures2 features2{};
+ features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+ layer.instance_dispatch_table.GetPhysicalDeviceFeatures2(phys_dev, &features2);
+ return VK_SUCCESS;
+ });
InstWrapper inst{env->vulkan_functions};
inst.create_info.add_layer(regular_layer_name).set_api_version(1, 1, 0);
"regular_test_layer.json");
auto& layer = env->get_test_layer(0);
- layer.set_create_instance_callback(TestLayer::LayerCallback{
- [](TestLayer& layer, void* data) -> VkResult {
- uint32_t phys_dev_count = 1;
- VkPhysicalDevice phys_dev{};
- layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, &phys_dev);
-
- VkPhysicalDeviceProperties2KHR props2{};
- props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
- layer.instance_dispatch_table.GetPhysicalDeviceProperties2KHR(phys_dev, &props2);
-
- VkPhysicalDeviceFeatures2KHR features2{};
- features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
- layer.instance_dispatch_table.GetPhysicalDeviceFeatures2KHR(phys_dev, &features2);
- return VK_SUCCESS;
- },
- nullptr});
+ layer.set_create_instance_callback([](TestLayer& layer) -> VkResult {
+ uint32_t phys_dev_count = 1;
+ VkPhysicalDevice phys_dev{};
+ layer.instance_dispatch_table.EnumeratePhysicalDevices(layer.instance_handle, &phys_dev_count, &phys_dev);
+
+ VkPhysicalDeviceProperties2KHR props2{};
+ props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
+ layer.instance_dispatch_table.GetPhysicalDeviceProperties2KHR(phys_dev, &props2);
+
+ VkPhysicalDeviceFeatures2KHR features2{};
+ features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
+ layer.instance_dispatch_table.GetPhysicalDeviceFeatures2KHR(phys_dev, &features2);
+ return VK_SUCCESS;
+ });
InstWrapper inst{env->vulkan_functions};
inst.create_info.add_layer(regular_layer_name).add_extension("VK_KHR_get_physical_device_properties2");
#if defined(__linux__) || defined(__FreeBSD__)
// Make sure the loader reports the correct message based on if USE_UNSAFE_FILE_SEARCH is set or not
TEST(EnvironmentVariables, NonSecureEnvVarLookup) {
- SingleICDShim env(TestICDDetails(TEST_ICD_PATH_VERSION_6));
+ FrameworkEnvironment env{};
+ env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6));
env.get_test_icd().physical_devices.emplace_back("physical_device_0");
DebugUtilsLogger log{VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT};
set_env_var("XDG_DATA_DIRS", "::::/tmp/goober3:/tmp/goober4/with spaces:::");
set_env_var("XDG_DATA_HOME", "::::/tmp/goober3:/tmp/goober4/with spaces:::");
- SingleICDShim env{TestICDDetails{TEST_ICD_PATH_VERSION_6}};
+ FrameworkEnvironment env{};
+ env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6));
env.get_test_icd().physical_devices.push_back({});
InstWrapper inst{env.vulkan_functions};
vk_layer_path += (HOME / "/ with spaces/:::::/tandy:").str();
set_env_var("VK_LAYER_PATH", vk_layer_path);
- SingleICDShim env{TestICDDetails{TEST_ICD_PATH_VERSION_6}};
+ FrameworkEnvironment env{};
+ env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6));
env.get_test_icd().physical_devices.push_back({});
env.platform_shim->redirect_path("/tmp/carol", env.explicit_layer_folder.location());
const char* layer_name = "TestLayer";
- env->add_explicit_layer(
+ env.add_explicit_layer(
ManifestLayer{}.add_layer(
ManifestLayer::LayerDescription{}.set_name(layer_name).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)),
"test_layer.json");