1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
|
/*
* Copyright (c) 2021-2022 The Khronos Group Inc.
* Copyright (c) 2021-2022 Valve Corporation
* Copyright (c) 2021-2022 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and/or associated documentation files (the "Materials"), to
* deal in the Materials without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Materials, and to permit persons to whom the Materials are
* furnished to do so, subject to the following conditions:
*
* The above copyright notice(s) and this permission notice shall be included in
* all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
* USE OR OTHER DEALINGS IN THE MATERIALS.
*
* Author: Charles Giessen <charles@lunarg.com>
*/
#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_2_EXPORT_ICD_GPDPA)).add_physical_device("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<PFN_vkGetInstanceProcAddr>(
env.vulkan_functions.vkGetInstanceProcAddr(inst.inst, "vkGetInstanceProcAddr"));
ASSERT_EQ(gipa_loader, gipa_queried);
}
{
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(VK_API_VERSION_1_3);
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<PFN_vkGetInstanceProcAddr>(
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_2_EXPORT_ICD_GPDPA)).add_physical_device("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 = inst.load("vkGetDeviceProcAddr");
ASSERT_EQ(gdpa_loader, gdpa_inst_queried);
DeviceWrapper dev{inst};
dev.CheckCreate(phys_dev);
PFN_vkGetDeviceProcAddr gdpa_dev_queried = dev.load("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) {
FrameworkEnvironment env{};
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
auto& gipa = env.vulkan_functions.vkGetInstanceProcAddr;
// global entry points with NULL instance handle
{
auto EnumerateInstanceExtensionProperties =
reinterpret_cast<PFN_vkEnumerateInstanceExtensionProperties>(gipa(NULL, "vkEnumerateInstanceExtensionProperties"));
handle_assert_has_value(EnumerateInstanceExtensionProperties);
uint32_t ext_count = 0;
ASSERT_EQ(VK_SUCCESS, EnumerateInstanceExtensionProperties("", &ext_count, nullptr));
auto EnumerateInstanceLayerProperties =
reinterpret_cast<PFN_vkEnumerateInstanceLayerProperties>(gipa(NULL, "vkEnumerateInstanceLayerProperties"));
handle_assert_has_value(EnumerateInstanceLayerProperties);
uint32_t layer_count = 0;
ASSERT_EQ(VK_SUCCESS, EnumerateInstanceLayerProperties(&layer_count, nullptr));
auto EnumerateInstanceVersion = reinterpret_cast<PFN_vkEnumerateInstanceVersion>(gipa(NULL, "vkEnumerateInstanceVersion"));
handle_assert_has_value(EnumerateInstanceVersion);
uint32_t api_version = 0;
EnumerateInstanceVersion(&api_version);
auto GetInstanceProcAddr = reinterpret_cast<PFN_vkGetInstanceProcAddr>(gipa(NULL, "vkGetInstanceProcAddr"));
ASSERT_EQ(GetInstanceProcAddr,
reinterpret_cast<PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr(NULL, "vkGetInstanceProcAddr")));
auto CreateInstance = reinterpret_cast<PFN_vkCreateInstance>(gipa(NULL, "vkCreateInstance"));
handle_assert_has_value(CreateInstance);
}
// Now create an instance and query the functions again - should work because the instance version is less than 1.2
for (int i = 0; i <= 2; i++) {
InstWrapper inst{env.vulkan_functions};
inst.create_info.api_version = VK_MAKE_API_VERSION(0, 1, i, 0);
inst.CheckCreate();
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties =
inst.load("vkEnumerateInstanceExtensionProperties");
handle_assert_has_value(EnumerateInstanceExtensionProperties);
uint32_t ext_count = 0;
ASSERT_EQ(VK_SUCCESS, EnumerateInstanceExtensionProperties("", &ext_count, nullptr));
PFN_vkEnumerateInstanceLayerProperties EnumerateInstanceLayerProperties = inst.load("vkEnumerateInstanceLayerProperties");
handle_assert_has_value(EnumerateInstanceLayerProperties);
uint32_t layer_count = 0;
ASSERT_EQ(VK_SUCCESS, EnumerateInstanceLayerProperties(&layer_count, nullptr));
PFN_vkEnumerateInstanceVersion EnumerateInstanceVersion = inst.load("vkEnumerateInstanceVersion");
handle_assert_has_value(EnumerateInstanceVersion);
uint32_t api_version = 0;
EnumerateInstanceVersion(&api_version);
PFN_vkGetInstanceProcAddr GetInstanceProcAddr = inst.load("vkGetInstanceProcAddr");
handle_assert_has_value(GetInstanceProcAddr);
ASSERT_EQ(GetInstanceProcAddr,
reinterpret_cast<PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr(inst, "vkGetInstanceProcAddr")));
PFN_vkCreateInstance CreateInstance = inst.load("vkCreateInstance");
handle_assert_has_value(CreateInstance);
}
{
// Create a 1.3 instance - now everything should return NULL
InstWrapper inst{env.vulkan_functions};
inst.create_info.api_version = VK_MAKE_API_VERSION(0, 1, 3, 0);
inst.CheckCreate();
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties =
inst.load("vkEnumerateInstanceExtensionProperties");
handle_assert_null(EnumerateInstanceExtensionProperties);
PFN_vkEnumerateInstanceLayerProperties EnumerateInstanceLayerProperties = inst.load("vkEnumerateInstanceLayerProperties");
handle_assert_null(EnumerateInstanceLayerProperties);
PFN_vkEnumerateInstanceVersion EnumerateInstanceVersion = inst.load("vkEnumerateInstanceVersion");
handle_assert_null(EnumerateInstanceVersion);
PFN_vkCreateInstance CreateInstance = inst.load("vkCreateInstance");
handle_assert_null(CreateInstance);
PFN_vkGetInstanceProcAddr GetInstanceProcAddr = inst.load("vkGetInstanceProcAddr");
handle_assert_equal(env.vulkan_functions.vkGetInstanceProcAddr, GetInstanceProcAddr);
ASSERT_EQ(GetInstanceProcAddr,
reinterpret_cast<PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr(inst, "vkGetInstanceProcAddr")));
ASSERT_EQ(GetInstanceProcAddr,
reinterpret_cast<PFN_vkGetInstanceProcAddr>(GetInstanceProcAddr(NULL, "vkGetInstanceProcAddr")));
// get a non pre-instance function pointer
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices = inst.load("vkEnumeratePhysicalDevices");
handle_assert_has_value(EnumeratePhysicalDevices);
EnumeratePhysicalDevices = reinterpret_cast<PFN_vkEnumeratePhysicalDevices>(gipa(NULL, "vkEnumeratePhysicalDevices"));
handle_assert_null(EnumeratePhysicalDevices);
}
}
TEST(GetProcAddr, Verify10FunctionsFailToLoadWithSingleDriver) {
FrameworkEnvironment env{};
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({}).set_can_query_GetPhysicalDeviceFuncs(false);
InstWrapper inst{env.vulkan_functions};
inst.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
}
TEST(GetProcAddr, Verify10FunctionsLoadWithMultipleDrivers) {
FrameworkEnvironment env{};
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({});
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({}).set_can_query_GetPhysicalDeviceFuncs(false);
InstWrapper inst{env.vulkan_functions};
inst.CheckCreate();
inst.GetPhysDevs(1);
}
// Swapchain functions which require a terminator in all cases have situations where the driver may have a
// NULL function pointer but the loader shouldn't abort() if that is the case. Rather, it should log a message
// and return VK_SUCCESS to maintain previous behavior.
TEST(GetDeviceProcAddr, SwapchainFuncsWithTerminator) {
FrameworkEnvironment env{};
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).setup_WSI().add_physical_device("physical_device_0");
InstWrapper inst(env.vulkan_functions);
inst.create_info.add_extension("VK_EXT_debug_utils");
inst.create_info.setup_WSI();
ASSERT_NO_FATAL_FAILURE(inst.CheckCreate());
VkSurfaceKHR surface{};
ASSERT_EQ(VK_SUCCESS, create_surface(inst, surface));
VkSurfaceKHR surface2{};
ASSERT_EQ(VK_SUCCESS, create_surface(inst, surface2));
DebugUtilsWrapper log{inst};
ASSERT_EQ(VK_SUCCESS, CreateDebugUtilsMessenger(log));
auto phys_dev = inst.GetPhysDev();
{
DeviceWrapper dev{inst};
ASSERT_NO_FATAL_FAILURE(dev.CheckCreate(phys_dev));
DeviceFunctions dev_funcs{env.vulkan_functions, dev};
PFN_vkCreateSwapchainKHR CreateSwapchainKHR = dev.load("vkCreateSwapchainKHR");
PFN_vkCreateSwapchainKHR inst_CreateSwapchainKHR = inst.load("vkCreateSwapchainKHR");
PFN_vkGetDeviceGroupSurfacePresentModesKHR GetDeviceGroupSurfacePresentModesKHR =
dev.load("vkGetDeviceGroupSurfacePresentModesKHR");
PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR = dev.load("vkCreateSharedSwapchainsKHR");
ASSERT_FALSE(CreateSwapchainKHR);
ASSERT_TRUE(inst_CreateSwapchainKHR);
ASSERT_FALSE(GetDeviceGroupSurfacePresentModesKHR);
ASSERT_FALSE(CreateSharedSwapchainsKHR);
VkSwapchainCreateInfoKHR info{};
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
info.surface = surface;
VkSwapchainKHR swapchain{};
log.logger.clear();
ASSERT_FALSE(dev_funcs.vkDestroySwapchainKHR);
// try to call the vkCreateSwapchainKHR acquired from the instance - this *should* abort due to not enabling the extension
ASSERT_DEATH(inst_CreateSwapchainKHR(dev.dev, &info, nullptr, &swapchain),
"vkCreateSwapchainKHR: Driver's function pointer was NULL, returning VK_SUCCESS. Was the VK_KHR_swapchain "
"extension enabled?");
log.logger.clear();
ASSERT_FALSE(dev_funcs.vkDestroySwapchainKHR);
}
driver.physical_devices.at(0).add_extensions({"VK_KHR_swapchain", "VK_KHR_display_swapchain", "VK_EXT_debug_marker"});
{
DeviceWrapper dev{inst};
dev.create_info.add_extensions({"VK_KHR_swapchain", "VK_KHR_display_swapchain", "VK_EXT_debug_marker"});
ASSERT_NO_FATAL_FAILURE(dev.CheckCreate(phys_dev));
DeviceFunctions dev_funcs{env.vulkan_functions, dev};
PFN_vkCreateSwapchainKHR CreateSwapchainKHR = dev.load("vkCreateSwapchainKHR");
PFN_vkCreateSwapchainKHR inst_CreateSwapchainKHR = inst.load("vkCreateSwapchainKHR");
PFN_vkGetDeviceGroupSurfacePresentModesKHR GetDeviceGroupSurfacePresentModesKHR =
dev.load("vkGetDeviceGroupSurfacePresentModesKHR");
PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR = dev.load("vkCreateSharedSwapchainsKHR");
ASSERT_TRUE(CreateSwapchainKHR);
ASSERT_TRUE(inst_CreateSwapchainKHR);
ASSERT_TRUE(GetDeviceGroupSurfacePresentModesKHR);
ASSERT_TRUE(CreateSharedSwapchainsKHR);
ASSERT_TRUE(dev_funcs.vkDestroySwapchainKHR);
VkSwapchainCreateInfoKHR info{};
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
info.surface = surface;
VkSwapchainKHR swapchain{};
CreateSwapchainKHR(dev.dev, &info, nullptr, &swapchain);
ASSERT_FALSE(
log.find("vkCreateSwapchainKHR: Driver's function pointer was NULL, returning VK_SUCCESS. Was the VK_KHR_swapchain "
"extension enabled?"));
log.logger.clear();
dev_funcs.vkDestroySwapchainKHR(dev.dev, swapchain, nullptr);
inst_CreateSwapchainKHR(dev.dev, &info, nullptr, &swapchain);
ASSERT_FALSE(
log.find("vkCreateSwapchainKHR: Driver's function pointer was NULL, returning VK_SUCCESS. Was the VK_KHR_swapchain "
"extension enabled?"));
log.logger.clear();
dev_funcs.vkDestroySwapchainKHR(dev.dev, swapchain, nullptr);
VkDeviceGroupPresentModeFlagsKHR modes{};
GetDeviceGroupSurfacePresentModesKHR(dev.dev, surface, &modes);
std::array<VkSwapchainCreateInfoKHR, 2> infos{};
infos[0] = info;
infos[1].sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
infos[1].surface = surface2;
ASSERT_EQ(VK_SUCCESS, CreateSharedSwapchainsKHR(dev.dev, 2, infos.data(), nullptr, &swapchain));
}
env.vulkan_functions.vkDestroySurfaceKHR(inst.inst, surface, nullptr);
env.vulkan_functions.vkDestroySurfaceKHR(inst.inst, surface2, nullptr);
}
// Verify that the various ways to get vkGetDeviceProcAddr return the same value
TEST(GetProcAddr, PreserveLayerGettingVkCreateDeviceWithNullInstance) {
FrameworkEnvironment env{};
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
env.add_implicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name("VK_LAYER_technically_buggy_layer")
.set_description("actually_layer_1")
.set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
.set_disable_environment("if_you_can")),
"buggy_layer_1.json"));
env.get_test_layer().set_buggy_query_of_vkCreateDevice(true);
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(VK_API_VERSION_1_1);
inst.CheckCreate();
VkPhysicalDevice phys_dev = inst.GetPhysDev();
DeviceWrapper dev{inst};
dev.CheckCreate(phys_dev);
}
// The following tests - AppQueries11FunctionsWhileOnlyEnabling10, AppQueries12FunctionsWhileOnlyEnabling11, and
// AppQueries13FunctionsWhileOnlyEnabling12 - check that vkGetDeviceProcAddr only returning functions from core versions up to
// the apiVersion declared in VkApplicationInfo. Function querying should succeed if VK_KHR_maintenance_5 is not enabled, and they
// should return zero when that extension is enabled.
TEST(GetDeviceProcAddr, AppQueries11FunctionsWhileOnlyEnabling10) {
FrameworkEnvironment env{};
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_1))
.set_icd_api_version(VK_API_VERSION_1_1)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_1).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());
std::vector<const char*> functions = {"vkGetDeviceQueue2", "vkCmdDispatchBase", "vkCreateDescriptorUpdateTemplate"};
for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{ // doesn't enable the feature or extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // doesn't enable the feature
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // enables the feature and extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
inst.CheckCreate();
VkPhysicalDeviceMaintenance5FeaturesKHR features{};
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR;
features.maintenance5 = VK_TRUE;
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.create_info.dev.pNext = &features;
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}
TEST(GetDeviceProcAddr, AppQueries12FunctionsWhileOnlyEnabling11) {
FrameworkEnvironment env{};
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_2))
.set_icd_api_version(VK_API_VERSION_1_2)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_2).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());
std::vector<const char*> functions = {"vkCmdDrawIndirectCount", "vkCmdNextSubpass2", "vkGetBufferDeviceAddress",
"vkGetDeviceMemoryOpaqueCaptureAddress"};
for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{ // doesn't enable the feature or extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // doesn't enable the feature
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // enables the feature and extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();
VkPhysicalDeviceMaintenance5FeaturesKHR features{};
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR;
features.maintenance5 = VK_TRUE;
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.create_info.dev.pNext = &features;
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}
TEST(GetDeviceProcAddr, AppQueries13FunctionsWhileOnlyEnabling12) {
FrameworkEnvironment env{};
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_3))
.set_icd_api_version(VK_API_VERSION_1_3)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_3).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());
std::vector<const char*> functions = {"vkCreatePrivateDataSlot", "vkGetDeviceBufferMemoryRequirements", "vkCmdWaitEvents2",
"vkGetDeviceImageSparseMemoryRequirements"};
for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{ // doesn't enable the feature or extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // doesn't enable the feature
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
inst.CheckCreate();
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_NE(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
{ // enables the feature and extension
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
inst.CheckCreate();
VkPhysicalDeviceMaintenance5FeaturesKHR features{};
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR;
features.maintenance5 = VK_TRUE;
DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.create_info.dev.pNext = &features;
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}
|