From: Mark Young Date: Wed, 2 Feb 2022 22:19:26 +0000 (-0700) Subject: Add a few tests to verify the vkGet***ProcAddr commands X-Git-Tag: upstream/v1.3.207~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdebcc4ee08a8e18521cb0486db7201b8793bd4b;p=platform%2Fupstream%2FVulkan-Loader.git Add a few tests to verify the vkGet***ProcAddr commands Verify that the loader exported version matches the ones you receive from vkGet****ProcAddr. --- diff --git a/tests/loader_get_proc_addr_tests.cpp b/tests/loader_get_proc_addr_tests.cpp index dc2ce16b..e965a8ac 100644 --- a/tests/loader_get_proc_addr_tests.cpp +++ b/tests/loader_get_proc_addr_tests.cpp @@ -27,6 +27,50 @@ #include "test_environment.h" +// Verify that the various ways to get vkGetInstanceProcAddr return the same value +TEST(GetProcAddr, VerifyGetInstanceProcAddr) { + FrameworkEnvironment env{}; + env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6)); + env.get_test_icd().physical_devices.emplace_back("physical_device_0"); + + InstWrapper inst{env.vulkan_functions}; + inst.create_info.set_api_version(VK_API_VERSION_1_1); + inst.CheckCreate(); + + // NOTE: The vulkan_functions are queried using the platform get proc addr from the loader. So we'll compare + // that to what is returned by asking it what the various Vulkan get proc addr functions are. + PFN_vkGetInstanceProcAddr gipa_loader = env.vulkan_functions.vkGetInstanceProcAddr; + PFN_vkGetInstanceProcAddr gipa_queried = + reinterpret_cast(env.vulkan_functions.vkGetInstanceProcAddr(inst.inst, "vkGetInstanceProcAddr")); + ASSERT_EQ(gipa_loader, gipa_queried); +} + +// Verify that the various ways to get vkGetDeviceProcAddr return the same value +TEST(GetProcAddr, VerifyGetDeviceProcAddr) { + FrameworkEnvironment env{}; + env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6)); + env.get_test_icd().physical_devices.emplace_back("physical_device_0"); + + InstWrapper inst{env.vulkan_functions}; + inst.create_info.set_api_version(VK_API_VERSION_1_1); + inst.CheckCreate(); + VkPhysicalDevice phys_dev = inst.GetPhysDev(); + + // NOTE: The vulkan_functions are queried using the platform get proc addr from the loader. So we'll compare + // that to what is returned by asking it what the various Vulkan get proc addr functions are. + PFN_vkGetDeviceProcAddr gdpa_loader = env.vulkan_functions.vkGetDeviceProcAddr; + PFN_vkGetDeviceProcAddr gdpa_inst_queried = + reinterpret_cast(env.vulkan_functions.vkGetInstanceProcAddr(inst.inst, "vkGetDeviceProcAddr")); + ASSERT_EQ(gdpa_loader, gdpa_inst_queried); + + DeviceWrapper dev{inst}; + dev.create_info.add_device_queue(DeviceQueueCreateInfo{}.add_priority(0.0f)); + dev.CheckCreate(phys_dev); + + PFN_vkGetDeviceProcAddr gdpa_dev_queried = + reinterpret_cast(env.vulkan_functions.vkGetDeviceProcAddr(dev.dev, "vkGetDeviceProcAddr")); + ASSERT_EQ(gdpa_loader, gdpa_dev_queried); +} // Load the global function pointers with and without a NULL vkInstance handle. // Call the function to make sure it is callable, don't care about what is returned. TEST(GetProcAddr, GlobalFunctions) {