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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
|
/*
* Copyright (c) 2021-2023 The Khronos Group Inc.
* Copyright (c) 2021-2023 Valve Corporation
* Copyright (c) 2021-2023 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"
#include <array>
#include <fstream>
#include <utility>
#include "json_writer.h"
InstWrapper::InstWrapper(VulkanFunctions& functions, VkAllocationCallbacks* callbacks) noexcept
: functions(&functions), callbacks(callbacks) {}
InstWrapper::InstWrapper(VulkanFunctions& functions, VkInstance inst, VkAllocationCallbacks* callbacks) noexcept
: functions(&functions), inst(inst), callbacks(callbacks) {}
InstWrapper::~InstWrapper() noexcept {
if (inst != VK_NULL_HANDLE) functions->vkDestroyInstance(inst, callbacks);
}
InstWrapper::InstWrapper(InstWrapper&& other) noexcept {
functions = other.functions;
inst = other.inst;
callbacks = other.callbacks;
create_info = other.create_info;
other.inst = VK_NULL_HANDLE;
}
InstWrapper& InstWrapper::operator=(InstWrapper&& other) noexcept {
functions->vkDestroyInstance(inst, callbacks);
functions = other.functions;
inst = other.inst;
callbacks = other.callbacks;
create_info = other.create_info;
other.inst = VK_NULL_HANDLE;
return *this;
}
void InstWrapper::CheckCreate(VkResult result_to_check) {
handle_assert_null(inst);
ASSERT_EQ(result_to_check, functions->vkCreateInstance(create_info.get(), callbacks, &inst));
functions->load_instance_functions(inst);
}
void InstWrapper::CheckCreateWithInfo(InstanceCreateInfo& create_info, VkResult result_to_check) {
handle_assert_null(inst);
ASSERT_EQ(result_to_check, functions->vkCreateInstance(create_info.get(), callbacks, &inst));
functions->load_instance_functions(inst);
}
std::vector<VkPhysicalDevice> InstWrapper::GetPhysDevs(uint32_t phys_dev_count, VkResult result_to_check) {
uint32_t physical_count = phys_dev_count;
std::vector<VkPhysicalDevice> physical_devices;
physical_devices.resize(phys_dev_count);
VkResult res = functions->vkEnumeratePhysicalDevices(inst, &physical_count, physical_devices.data());
EXPECT_EQ(result_to_check, res);
return physical_devices;
}
std::vector<VkPhysicalDevice> InstWrapper::GetPhysDevs(VkResult result_to_check) {
uint32_t physical_count = 0;
VkResult res = functions->vkEnumeratePhysicalDevices(inst, &physical_count, nullptr);
EXPECT_EQ(result_to_check, res);
std::vector<VkPhysicalDevice> physical_devices;
physical_devices.resize(physical_count);
res = functions->vkEnumeratePhysicalDevices(inst, &physical_count, physical_devices.data());
EXPECT_EQ(result_to_check, res);
return physical_devices;
}
VkPhysicalDevice InstWrapper::GetPhysDev(VkResult result_to_check) {
uint32_t physical_count = 1;
VkPhysicalDevice physical_device = VK_NULL_HANDLE;
VkResult res = this->functions->vkEnumeratePhysicalDevices(inst, &physical_count, &physical_device);
EXPECT_EQ(result_to_check, res);
return physical_device;
}
std::vector<VkLayerProperties> InstWrapper::GetActiveLayers(VkPhysicalDevice phys_dev, uint32_t expected_count) {
uint32_t count = 0;
VkResult res = functions->vkEnumerateDeviceLayerProperties(phys_dev, &count, nullptr);
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
std::vector<VkLayerProperties> layer_props{count};
res = functions->vkEnumerateDeviceLayerProperties(phys_dev, &count, layer_props.data());
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
return layer_props;
}
std::vector<VkExtensionProperties> InstWrapper::EnumerateDeviceExtensions(VkPhysicalDevice physical_device,
uint32_t expected_count) {
uint32_t count = 0;
VkResult res = functions->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &count, nullptr);
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
std::vector<VkExtensionProperties> extensions{count};
res = functions->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &count, extensions.data());
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
return extensions;
}
std::vector<VkExtensionProperties> InstWrapper::EnumerateLayerDeviceExtensions(VkPhysicalDevice physical_device,
const char* layer_name, uint32_t expected_count) {
uint32_t count = 0;
VkResult res = functions->vkEnumerateDeviceExtensionProperties(physical_device, layer_name, &count, nullptr);
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
std::vector<VkExtensionProperties> extensions{count};
res = functions->vkEnumerateDeviceExtensionProperties(physical_device, layer_name, &count, extensions.data());
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
return extensions;
}
DeviceWrapper::DeviceWrapper(InstWrapper& inst_wrapper, VkAllocationCallbacks* callbacks) noexcept
: functions(inst_wrapper.functions), callbacks(callbacks){};
DeviceWrapper::DeviceWrapper(VulkanFunctions& functions, VkDevice device, VkAllocationCallbacks* callbacks) noexcept
: functions(&functions), dev(device), callbacks(callbacks){};
DeviceWrapper::~DeviceWrapper() noexcept { functions->vkDestroyDevice(dev, callbacks); }
DeviceWrapper::DeviceWrapper(DeviceWrapper&& other) noexcept {
functions = other.functions;
dev = other.dev;
callbacks = other.callbacks;
create_info = other.create_info;
other.dev = VK_NULL_HANDLE;
}
DeviceWrapper& DeviceWrapper::operator=(DeviceWrapper&& other) noexcept {
functions->vkDestroyDevice(dev, callbacks);
functions = other.functions;
dev = other.dev;
callbacks = other.callbacks;
create_info = other.create_info;
other.dev = VK_NULL_HANDLE;
return *this;
}
void DeviceWrapper::CheckCreate(VkPhysicalDevice phys_dev, VkResult result_to_check) {
handle_assert_null(dev);
ASSERT_EQ(result_to_check, functions->vkCreateDevice(phys_dev, create_info.get(), callbacks, &dev));
}
VkResult CreateDebugUtilsMessenger(DebugUtilsWrapper& debug_utils) {
handle_assert_null(debug_utils.messenger);
return debug_utils.local_vkCreateDebugUtilsMessengerEXT(debug_utils.inst, debug_utils.get(), debug_utils.callbacks,
&debug_utils.messenger);
}
void FillDebugUtilsCreateDetails(InstanceCreateInfo& create_info, DebugUtilsLogger& logger) {
create_info.add_extension("VK_EXT_debug_utils");
create_info.instance_info.pNext = logger.get();
}
void FillDebugUtilsCreateDetails(InstanceCreateInfo& create_info, DebugUtilsWrapper& wrapper) {
create_info.add_extension("VK_EXT_debug_utils");
create_info.instance_info.pNext = wrapper.get();
}
// Look through the event log. If you find a line containing the prefix we're interested in, look for the end of
// line character, and then see if the postfix occurs in it as well.
bool DebugUtilsLogger::find_prefix_then_postfix(const char* prefix, const char* postfix) const {
size_t new_start = 0;
size_t postfix_index = 0;
size_t next_eol = 0;
while ((new_start = returned_output.find(prefix, new_start)) != std::string::npos) {
next_eol = returned_output.find("\n", new_start);
if ((postfix_index = returned_output.find(postfix, new_start)) != std::string::npos) {
if (postfix_index < next_eol) {
return true;
}
}
new_start = next_eol + 1;
}
return false;
}
bool FindPrefixPostfixStringOnLine(DebugUtilsLogger const& env_log, const char* prefix, const char* postfix) {
return env_log.find_prefix_then_postfix(prefix, postfix);
}
PlatformShimWrapper::PlatformShimWrapper(fs::FileSystemManager& file_system_manager, const char* log_filter) noexcept
: loader_logging{"VK_LOADER_DEBUG"} {
#if defined(WIN32) || defined(__APPLE__)
shim_library = LibraryWrapper(SHIM_LIBRARY_NAME);
PFN_get_platform_shim get_platform_shim = shim_library.get_symbol(GET_PLATFORM_SHIM_STR);
assert(get_platform_shim != NULL && "Must be able to get \"platform_shim\"");
platform_shim = get_platform_shim();
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
platform_shim = get_platform_shim();
#endif
platform_shim->file_system_manager = &file_system_manager;
if (log_filter) {
loader_logging.set_new_value(log_filter);
}
}
TestICDHandle::TestICDHandle() noexcept {}
TestICDHandle::TestICDHandle(std::filesystem::path const& icd_path) noexcept : icd_library(icd_path) {
proc_addr_get_test_icd = icd_library.get_symbol(GET_TEST_ICD_FUNC_STR);
proc_addr_reset_icd = icd_library.get_symbol(RESET_ICD_FUNC_STR);
}
TestICD& TestICDHandle::get_test_icd() noexcept {
assert(proc_addr_get_test_icd != NULL && "symbol must be loaded before use");
return *proc_addr_get_test_icd();
}
TestICD& TestICDHandle::reset_icd() noexcept {
assert(proc_addr_reset_icd != NULL && "symbol must be loaded before use");
return *proc_addr_reset_icd();
}
std::filesystem::path TestICDHandle::get_icd_full_path() noexcept { return icd_library.get_path(); }
std::filesystem::path TestICDHandle::get_icd_manifest_path() noexcept { return manifest_path; }
std::filesystem::path TestICDHandle::get_shimmed_manifest_path() noexcept { return shimmed_manifest_path; }
TestLayerHandle::TestLayerHandle() noexcept {}
TestLayerHandle::TestLayerHandle(std::filesystem::path const& layer_path) noexcept : layer_library(layer_path) {
proc_addr_get_test_layer = layer_library.get_symbol(GET_TEST_LAYER_FUNC_STR);
proc_addr_reset_layer = layer_library.get_symbol(RESET_LAYER_FUNC_STR);
}
TestLayer& TestLayerHandle::get_test_layer() noexcept {
assert(proc_addr_get_test_layer != NULL && "symbol must be loaded before use");
return *proc_addr_get_test_layer();
}
TestLayer& TestLayerHandle::reset_layer() noexcept {
assert(proc_addr_reset_layer != NULL && "symbol must be loaded before use");
return *proc_addr_reset_layer();
}
std::filesystem::path TestLayerHandle::get_layer_full_path() noexcept { return layer_library.get_path(); }
std::filesystem::path TestLayerHandle::get_layer_manifest_path() noexcept { return manifest_path; }
std::filesystem::path TestLayerHandle::get_shimmed_manifest_path() noexcept { return shimmed_manifest_path; }
FrameworkEnvironment::FrameworkEnvironment() noexcept : FrameworkEnvironment(FrameworkSettings{}) {}
FrameworkEnvironment::FrameworkEnvironment(FrameworkSettings const& settings) noexcept
: settings(settings), platform_shim(file_system_manager, settings.log_filter) {
// Setup default path redirections
platform_shim->set_elevated_privilege(settings.run_as_if_with_elevated_privleges);
#if TESTING_COMMON_UNIX_PLATFORMS
if (!settings.home_env_var.empty()) env_var_home.set_new_value(settings.home_env_var);
#if !defined(__APPLE__)
if (!settings.xdg_config_home_env_var.empty()) env_var_xdg_config_home.set_new_value(settings.xdg_config_home_env_var);
if (!settings.xdg_config_dirs_env_var.empty()) env_var_xdg_config_dirs.set_new_value(settings.xdg_config_dirs_env_var);
if (!settings.xdg_data_home_env_var.empty()) env_var_xdg_data_home.set_new_value(settings.xdg_data_home_env_var);
if (!settings.xdg_data_dirs_env_var.empty()) env_var_xdg_data_dirs.set_new_value(settings.xdg_data_dirs_env_var);
#endif
#endif
const std::array<std::pair<const char*, ManifestLocation>, 4> secured_redirection_map = {
std::pair{"icd.d", ManifestLocation::driver},
std::pair{"implicit_layer.d", ManifestLocation::implicit_layer},
std::pair{"explicit_layer.d", ManifestLocation::explicit_layer},
std::pair{"loader_settings.d", ManifestLocation::settings_location},
};
const std::array<std::pair<const char*, ManifestLocation>, 4> unsecured_redirection_map = {
std::pair{"icd.d", ManifestLocation::unsecured_driver},
std::pair{"implicit_layer.d", ManifestLocation::unsecured_implicit_layer},
std::pair{"explicit_layer.d", ManifestLocation::unsecured_explicit_layer},
std::pair{"loader_settings.d", ManifestLocation::unsecured_settings},
};
#if TESTING_COMMON_UNIX_PLATFORMS && !defined(__APPLE__)
// Always are searching SYSCONFDIR on unix (but not apple, which is handled separately)
secure_manifest_base_location = SYSCONFDIR;
for (auto const& [redirect, location] : secured_redirection_map) {
file_system_manager.add_path_redirect(secure_manifest_base_location + "/vulkan/" + redirect, location);
}
// Determines which unsecure path should be used
if (!settings.run_as_if_with_elevated_privleges) {
if (!settings.xdg_config_home_env_var.empty()) {
auto env_var_list = split_env_var_as_list(settings.xdg_config_home_env_var);
unsecure_manifest_base_location = env_var_list.at(0);
if (!env_var_list.empty()) {
for (auto const& [redirect, location] : unsecured_redirection_map) {
file_system_manager.add_path_redirect(env_var_list.at(0) + "/vulkan/" + redirect, location);
}
}
} else if (!settings.xdg_data_home_env_var.empty()) {
auto env_var_list = split_env_var_as_list(settings.xdg_data_home_env_var);
if (!env_var_list.empty()) {
unsecure_manifest_base_location = env_var_list.at(0);
for (auto const& [redirect, location] : unsecured_redirection_map) {
file_system_manager.add_path_redirect(env_var_list.at(0) + "/vulkan/" + redirect, location);
}
}
} else {
std::string home = settings.home_env_var;
for (auto const& [redirect, location] : unsecured_redirection_map) {
unsecure_manifest_base_location = home + "/.config";
file_system_manager.add_path_redirect(home + "/.config/vulkan/" + redirect, location);
}
}
}
#endif
#if defined(__APPLE__)
// Since XDG env-var shouldn't ever be defined on apple, FALLBACK_DATA_DIRS takes over as the 'global' location to search, eg
// /usr/local/share
auto env_var_list = split_env_var_as_list(FALLBACK_DATA_DIRS);
assert(env_var_list.size() > 0 && "FALLBACK_DATA_DIRS was set to an empty path");
secure_manifest_base_location = env_var_list.at(0);
for (auto const& [redirect, location] : secured_redirection_map) {
file_system_manager.add_path_redirect(secure_manifest_base_location + "/vulkan/" + redirect, location);
}
std::string home = settings.home_env_var;
unsecure_manifest_base_location = home + "/.config";
for (auto const& [redirect, location] : unsecured_redirection_map) {
file_system_manager.add_path_redirect(home + "/.config/vulkan/" + redirect, location);
}
// Necessary since bundles look in sub folders for manifests, not the test framework folder itself
auto bundle_location = get_folder(ManifestLocation::macos_bundle).location();
file_system_manager.add_path_redirect(bundle_location / "vulkan/icd.d", ManifestLocation::macos_bundle);
file_system_manager.add_path_redirect(bundle_location / "vulkan/explicit_layer.d", ManifestLocation::macos_bundle);
file_system_manager.add_path_redirect(bundle_location / "vulkan/implicit_layer.d", ManifestLocation::macos_bundle);
#endif
platform_shim->is_finished_setup = true;
}
FrameworkEnvironment::~FrameworkEnvironment() {
// This is necessary to prevent the folder manager from using dead memory during destruction.
// What happens is that each folder manager tries to cleanup itself. Except, folders that were never called did not have
// their DirEntry array's filled out. So when that folder calls delete_folder, which calls readdir, the shim tries to order
// the files. Except, the list of files is in a object that is currently being destroyed.
platform_shim->is_during_destruction = true;
}
TestICD& FrameworkEnvironment::add_icd(TestICDDetails icd_details) noexcept {
size_t cur_icd_index = icds.size();
fs::Folder* fs_ptr = &get_folder(ManifestLocation::driver);
switch (icd_details.discovery_type) {
case (ManifestDiscoveryType::env_var):
case (ManifestDiscoveryType::add_env_var):
fs_ptr = &get_folder(ManifestLocation::driver_env_var);
break;
#if defined(WIN32)
case (ManifestDiscoveryType::windows_app_package):
fs_ptr = &get_folder(ManifestLocation::windows_app_package);
break;
#endif
case (ManifestDiscoveryType::override_folder):
fs_ptr = &get_folder(ManifestLocation::override_layer);
break;
#if defined(__APPLE__)
case (ManifestDiscoveryType::macos_bundle):
fs_ptr = &get_folder(ManifestLocation::macos_bundle);
break;
#endif
case (ManifestDiscoveryType::unsecured_generic):
fs_ptr = &get_folder(ManifestLocation::unsecured_driver);
break;
case (ManifestDiscoveryType::null_dir):
case (ManifestDiscoveryType::none):
fs_ptr = &get_folder(ManifestLocation::null);
break;
case (ManifestDiscoveryType::generic):
fs_ptr = &get_folder(ManifestLocation::driver);
break;
}
auto& folder = *fs_ptr;
if (!icd_details.is_fake) {
std::filesystem::path new_lib_name = icd_details.icd_manifest.lib_path.stem();
new_lib_name += "_";
new_lib_name += std::to_string(cur_icd_index);
new_lib_name += icd_details.icd_manifest.lib_path.extension();
auto new_driver_location = folder.copy_file(icd_details.icd_manifest.lib_path, new_lib_name);
#if TESTING_COMMON_UNIX_PLATFORMS
if (icd_details.library_path_type == LibraryPathType::default_search_paths) {
platform_shim->add_system_library(new_lib_name, new_driver_location);
}
#endif
#if defined(WIN32)
if (icd_details.library_path_type == LibraryPathType::default_search_paths) {
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS);
AddDllDirectory(new_driver_location.parent_path().native().c_str());
}
#endif
icds.push_back(TestICDHandle(new_driver_location));
icds.back().reset_icd();
if (icd_details.library_path_type == LibraryPathType::relative) {
icd_details.icd_manifest.lib_path = std::filesystem::path(".") / new_lib_name;
} else if (icd_details.library_path_type == LibraryPathType::default_search_paths) {
icd_details.icd_manifest.lib_path = new_lib_name;
} else {
icd_details.icd_manifest.lib_path = new_driver_location;
}
}
if (icd_details.discovery_type != ManifestDiscoveryType::none) {
std::filesystem::path new_manifest_path = icd_details.json_name.stem();
if (!icd_details.disable_icd_inc) {
new_manifest_path += "_";
new_manifest_path += std::to_string(cur_icd_index);
}
new_manifest_path += ".json";
icds.back().manifest_path = folder.write_manifest(new_manifest_path, icd_details.icd_manifest.get_manifest_str());
icds.back().shimmed_manifest_path = icds.back().manifest_path;
switch (icd_details.discovery_type) {
case (ManifestDiscoveryType::generic):
#if defined(WIN32)
platform_shim->add_manifest_to_registry(ManifestCategory::icd, icds.back().manifest_path);
#elif TESTING_COMMON_UNIX_PLATFORMS
icds.back().shimmed_manifest_path =
file_system_manager.get_path_redirect_by_manifest_location(ManifestLocation::driver) / new_manifest_path;
#endif
break;
case (ManifestDiscoveryType::unsecured_generic):
#if defined(WIN32)
platform_shim->add_unsecured_manifest_to_registry(ManifestCategory::icd, icds.back().manifest_path);
#elif TESTING_COMMON_UNIX_PLATFORMS
icds.back().shimmed_manifest_path =
file_system_manager.get_path_redirect_by_manifest_location(ManifestLocation::unsecured_driver) /
new_manifest_path;
#endif
break;
case (ManifestDiscoveryType::env_var):
if (icd_details.is_dir) {
env_var_vk_icd_filenames.add_to_list(folder.location());
} else {
env_var_vk_icd_filenames.add_to_list(folder.location() / new_manifest_path);
}
break;
case (ManifestDiscoveryType::add_env_var):
if (icd_details.is_dir) {
add_env_var_vk_icd_filenames.add_to_list(folder.location());
} else {
add_env_var_vk_icd_filenames.add_to_list(folder.location() / new_manifest_path);
}
break;
break;
#if defined(WIN32)
case (ManifestDiscoveryType::windows_app_package):
platform_shim->set_app_package_path(folder.location());
break;
#endif
#if defined(__APPLE__)
case (ManifestDiscoveryType::macos_bundle): // macos_bundle contents are always discoverable by the loader
#endif
case (ManifestDiscoveryType::override_folder): // should be found through override layer/settings file, not 'normal'
// search paths
case (ManifestDiscoveryType::null_dir):
case (ManifestDiscoveryType::none):
break;
}
}
return icds.back().get_test_icd();
}
void FrameworkEnvironment::add_implicit_layer(ManifestLayer layer_manifest, const std::string& json_name) noexcept {
add_layer_impl(TestLayerDetails{layer_manifest, json_name}, ManifestCategory::implicit_layer);
}
void FrameworkEnvironment::add_explicit_layer(ManifestLayer layer_manifest, const std::string& json_name) noexcept {
add_layer_impl(TestLayerDetails{layer_manifest, json_name}, ManifestCategory::explicit_layer);
}
void FrameworkEnvironment::add_fake_implicit_layer(ManifestLayer layer_manifest, const std::string& json_name) noexcept {
add_layer_impl(TestLayerDetails{layer_manifest, json_name}.set_is_fake(true), ManifestCategory::implicit_layer);
}
void FrameworkEnvironment::add_fake_explicit_layer(ManifestLayer layer_manifest, const std::string& json_name) noexcept {
add_layer_impl(TestLayerDetails{layer_manifest, json_name}.set_is_fake(true), ManifestCategory::explicit_layer);
}
void FrameworkEnvironment::add_implicit_layer(TestLayerDetails layer_details) noexcept {
add_layer_impl(layer_details, ManifestCategory::implicit_layer);
}
void FrameworkEnvironment::add_explicit_layer(TestLayerDetails layer_details) noexcept {
add_layer_impl(layer_details, ManifestCategory::explicit_layer);
}
void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, ManifestCategory category) {
fs::Folder* fs_ptr = &get_folder(ManifestLocation::explicit_layer);
EnvVarWrapper* env_var_to_use = nullptr;
switch (layer_details.discovery_type) {
case (ManifestDiscoveryType::generic):
if (category == ManifestCategory::implicit_layer) fs_ptr = &get_folder(ManifestLocation::implicit_layer);
break;
case (ManifestDiscoveryType::env_var):
if (category == ManifestCategory::explicit_layer) {
fs_ptr = &get_folder(ManifestLocation::explicit_layer_env_var);
env_var_to_use = &env_var_vk_layer_paths;
} else if (category == ManifestCategory::implicit_layer) {
fs_ptr = &get_folder(ManifestLocation::implicit_layer_env_var);
env_var_to_use = &env_var_vk_implicit_layer_paths;
}
if (layer_details.is_dir) {
env_var_to_use->add_to_list(fs_ptr->location());
} else {
env_var_to_use->add_to_list(fs_ptr->location() / layer_details.json_name);
}
break;
case (ManifestDiscoveryType::add_env_var):
if (category == ManifestCategory::explicit_layer) {
fs_ptr = &get_folder(ManifestLocation::explicit_layer_add_env_var);
env_var_to_use = &add_env_var_vk_layer_paths;
} else if (category == ManifestCategory::implicit_layer) {
fs_ptr = &get_folder(ManifestLocation::implicit_layer_add_env_var);
env_var_to_use = &add_env_var_vk_implicit_layer_paths;
}
if (layer_details.is_dir) {
env_var_to_use->add_to_list(fs_ptr->location());
} else {
env_var_to_use->add_to_list(fs_ptr->location() / layer_details.json_name);
}
break;
case (ManifestDiscoveryType::override_folder):
fs_ptr = &get_folder(ManifestLocation::override_layer);
break;
#if defined(__APPLE__)
case (ManifestDiscoveryType::macos_bundle):
fs_ptr = &(get_folder(ManifestLocation::macos_bundle));
break;
#endif
case (ManifestDiscoveryType::unsecured_generic):
fs_ptr = &(get_folder(category == ManifestCategory::implicit_layer ? ManifestLocation::unsecured_implicit_layer
: ManifestLocation::unsecured_explicit_layer));
break;
#if defined(WIN32)
case (ManifestDiscoveryType::windows_app_package):
fs_ptr = &(get_folder(ManifestLocation::windows_app_package));
break;
#endif
case (ManifestDiscoveryType::none):
case (ManifestDiscoveryType::null_dir):
fs_ptr = &(get_folder(ManifestLocation::null));
break;
}
auto& folder = *fs_ptr;
size_t new_layers_start = layers.size();
for (auto& layer : layer_details.layer_manifest.layers) {
if (!layer.lib_path.empty()) {
std::filesystem::path new_lib_path = layer.lib_path.stem();
new_lib_path += "_";
new_lib_path += std::to_string(layers.size());
new_lib_path += layer.lib_path.extension();
auto new_layer_location = folder.copy_file(layer.lib_path, new_lib_path);
#if TESTING_COMMON_UNIX_PLATFORMS
if (layer_details.library_path_type == LibraryPathType::default_search_paths) {
platform_shim->add_system_library(new_lib_path, new_layer_location);
}
#endif
#if defined(WIN32)
if (layer_details.library_path_type == LibraryPathType::default_search_paths) {
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS);
AddDllDirectory(new_layer_location.parent_path().native().c_str());
}
#endif
// Don't load the layer binary if using any of the wrap objects layers, since it doesn't export the same interface
// functions
if (!layer_details.is_fake &&
layer.lib_path.stem().string().find(std::filesystem::path(TEST_LAYER_WRAP_OBJECTS).stem().string()) ==
std::string::npos) {
layers.push_back(TestLayerHandle(new_layer_location));
layers.back().reset_layer();
}
if (layer_details.library_path_type == LibraryPathType::relative) {
layer.lib_path = std::filesystem::path(".") / new_lib_path;
} else if (layer_details.library_path_type == LibraryPathType::default_search_paths) {
layer.lib_path = new_lib_path;
} else {
layer.lib_path = new_layer_location;
}
}
}
if (layer_details.discovery_type != ManifestDiscoveryType::none) {
// Write a manifest file to a folder as long as the discovery type isn't none
auto layer_manifest_loc = folder.write_manifest(layer_details.json_name, layer_details.layer_manifest.get_manifest_str());
#if defined(WIN32)
// only add the manifest to the registry if its a generic location (as if it was installed) - both system and user local
if (layer_details.discovery_type == ManifestDiscoveryType::generic) {
platform_shim->add_manifest_to_registry(category, layer_manifest_loc);
}
if (layer_details.discovery_type == ManifestDiscoveryType::unsecured_generic) {
platform_shim->add_unsecured_manifest_to_registry(category, layer_manifest_loc);
}
if (layer_details.discovery_type == ManifestDiscoveryType::windows_app_package) {
platform_shim->set_app_package_path(folder.location());
}
#endif
for (size_t i = new_layers_start; i < layers.size(); i++) {
layers.at(i).manifest_path = layer_manifest_loc;
layers.at(i).shimmed_manifest_path = layer_manifest_loc;
#if TESTING_COMMON_UNIX_PLATFORMS
if (layer_details.discovery_type == ManifestDiscoveryType::generic) {
layers.at(i).shimmed_manifest_path =
((category == ManifestCategory::implicit_layer)
? file_system_manager.get_path_redirect_by_manifest_location(ManifestLocation::implicit_layer)
: file_system_manager.get_path_redirect_by_manifest_location(ManifestLocation::explicit_layer)) /
layer_details.json_name;
}
#endif
}
}
}
std::string get_loader_settings_file_contents(const LoaderSettings& loader_settings) noexcept {
JsonWriter writer;
writer.StartObject();
writer.AddKeyedString("file_format_version", loader_settings.file_format_version.get_version_str());
bool one_setting_file = true;
if (loader_settings.app_specific_settings.size() > 1) {
writer.StartKeyedArray("settings_array");
one_setting_file = false;
}
for (const auto& setting : loader_settings.app_specific_settings) {
if (one_setting_file) {
writer.StartKeyedObject("settings");
} else {
writer.StartObject();
}
if (!setting.app_keys.empty()) {
writer.StartKeyedArray("app_keys");
for (const auto& app_key : setting.app_keys) {
writer.AddString(app_key);
}
writer.EndArray();
}
if (!setting.layer_configurations.empty()) {
writer.StartKeyedArray("layers");
for (const auto& config : setting.layer_configurations) {
writer.StartObject();
writer.AddKeyedString("name", config.name);
writer.AddKeyedString("path", config.path.native());
writer.AddKeyedString("control", config.control);
writer.AddKeyedBool("treat_as_implicit_manifest", config.treat_as_implicit_manifest);
writer.EndObject();
}
writer.EndArray();
}
if (!setting.stderr_log.empty()) {
writer.StartKeyedArray("stderr_log");
for (const auto& filter : setting.stderr_log) {
writer.AddString(filter);
}
writer.EndArray();
}
if (!setting.log_configurations.empty()) {
writer.StartKeyedArray("log_locations");
for (const auto& config : setting.log_configurations) {
writer.StartObject();
writer.StartKeyedArray("destinations");
for (const auto& dest : config.destinations) {
writer.AddString(dest);
}
writer.EndArray();
writer.StartKeyedArray("filter");
for (const auto& filter : config.filters) {
writer.AddString(filter);
}
writer.EndArray();
writer.EndObject();
}
writer.EndArray();
}
if (!setting.driver_configurations.empty()) {
writer.AddKeyedBool("additional_drivers_use_exclusively", setting.additional_drivers_use_exclusively);
writer.StartKeyedArray("additional_drivers");
for (const auto& driver : setting.driver_configurations) {
writer.StartObject();
writer.AddKeyedString("path", driver.path);
writer.EndObject();
}
writer.EndArray();
}
if (!setting.device_configurations.empty()) {
writer.StartKeyedArray("device_configurations");
for (const auto& device : setting.device_configurations) {
writer.StartObject();
if (!device.deviceName.empty()) {
writer.AddKeyedString("deviceName", device.deviceName);
}
if (!device.driverName.empty()) {
writer.AddKeyedString("driverName", device.driverName);
}
writer.StartKeyedArray("deviceUUID");
for (const auto& u : device.deviceUUID) {
writer.AddInteger(u);
}
writer.EndArray();
writer.StartKeyedArray("driverUUID");
for (const auto& u : device.driverUUID) {
writer.AddInteger(u);
}
writer.EndArray();
writer.AddKeyedInteger("driverVersion", device.driverVersion);
writer.EndObject();
}
writer.EndArray();
}
writer.EndObject();
}
if (!one_setting_file) {
writer.EndArray();
}
writer.EndObject();
return writer.output;
}
void FrameworkEnvironment::write_settings_file(std::string const& file_contents, bool write_to_secure_location) {
auto location = write_to_secure_location ? ManifestLocation::settings_location : ManifestLocation::unsecured_settings;
auto out_path = get_folder(location).write_manifest("vk_loader_settings.json", file_contents);
#if defined(WIN32)
if (write_to_secure_location) {
platform_shim->hkey_local_machine_settings.clear();
platform_shim->add_manifest_to_registry(ManifestCategory::settings, out_path);
} else {
platform_shim->hkey_current_user_settings.clear();
platform_shim->add_unsecured_manifest_to_registry(ManifestCategory::settings, out_path);
}
#endif
}
void FrameworkEnvironment::update_loader_settings(const LoaderSettings& settings, bool write_to_secure_location) noexcept {
write_settings_file(get_loader_settings_file_contents(settings), write_to_secure_location);
}
void FrameworkEnvironment::remove_loader_settings() {
get_folder(ManifestLocation::settings_location).remove("vk_loader_settings.json");
}
void FrameworkEnvironment::write_file_from_string(std::string const& source_string, ManifestCategory category,
ManifestLocation location, std::string const& file_name) {
auto out_path = get_folder(location).write_manifest(file_name, source_string);
#if defined(WIN32)
// Only writes to the hkey_local_machine registries, doesn't support hkey_current_user registries
platform_shim->add_manifest_to_registry(category, out_path);
#endif
}
void FrameworkEnvironment::write_file_from_source(const char* source_file, ManifestCategory category, ManifestLocation location,
std::string const& file_name) {
std::fstream file{source_file, std::ios_base::in};
ASSERT_TRUE(file.is_open());
std::stringstream file_stream;
file_stream << file.rdbuf();
write_file_from_string(file_stream.str(), category, location, file_name);
}
TestICD& FrameworkEnvironment::get_test_icd(size_t index) noexcept { return icds[index].get_test_icd(); }
TestICD& FrameworkEnvironment::reset_icd(size_t index) noexcept { return icds[index].reset_icd(); }
std::filesystem::path FrameworkEnvironment::get_test_icd_path(size_t index) noexcept { return icds[index].get_icd_full_path(); }
std::filesystem::path FrameworkEnvironment::get_icd_manifest_path(size_t index) noexcept {
return icds[index].get_icd_manifest_path();
}
std::filesystem::path FrameworkEnvironment::get_shimmed_icd_manifest_path(size_t index) noexcept {
return icds[index].get_shimmed_manifest_path();
}
TestLayer& FrameworkEnvironment::get_test_layer(size_t index) noexcept { return layers[index].get_test_layer(); }
TestLayer& FrameworkEnvironment::reset_layer(size_t index) noexcept { return layers[index].reset_layer(); }
std::filesystem::path FrameworkEnvironment::get_test_layer_path(size_t index) noexcept {
return layers[index].get_layer_full_path();
}
std::filesystem::path FrameworkEnvironment::get_layer_manifest_path(size_t index) noexcept {
return layers[index].get_layer_manifest_path();
}
std::filesystem::path FrameworkEnvironment::get_shimmed_layer_manifest_path(size_t index) noexcept {
return layers[index].get_shimmed_manifest_path();
}
fs::Folder& FrameworkEnvironment::get_folder(ManifestLocation location) noexcept {
return file_system_manager.get_folder(location);
}
fs::Folder const& FrameworkEnvironment::get_folder(ManifestLocation location) const noexcept {
return file_system_manager.get_folder(location);
}
#if defined(__APPLE__)
void FrameworkEnvironment::setup_macos_bundle() noexcept {
platform_shim->bundle_contents = file_system_manager.get_folder(ManifestLocation::macos_bundle).location();
}
#endif
void FrameworkEnvironment::add_symlink(ManifestLocation location, std::filesystem::path const& target,
std::filesystem::path const& link_name) {
auto symlinked_path = get_folder(location).add_symlink(target, link_name);
file_system_manager.add_path_redirect(symlinked_path, location);
}
std::vector<VkExtensionProperties> FrameworkEnvironment::GetInstanceExtensions(uint32_t expected_count, const char* layer_name) {
uint32_t count = 0;
VkResult res = vulkan_functions.vkEnumerateInstanceExtensionProperties(layer_name, &count, nullptr);
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
std::vector<VkExtensionProperties> extension_props{count};
res = vulkan_functions.vkEnumerateInstanceExtensionProperties(layer_name, &count, extension_props.data());
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
return extension_props;
}
std::vector<VkLayerProperties> FrameworkEnvironment::GetLayerProperties(uint32_t expected_count) {
uint32_t count = 0;
VkResult res = vulkan_functions.vkEnumerateInstanceLayerProperties(&count, nullptr);
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
std::vector<VkLayerProperties> layer_props{count};
res = vulkan_functions.vkEnumerateInstanceLayerProperties(&count, layer_props.data());
EXPECT_EQ(VK_SUCCESS, res);
EXPECT_EQ(count, expected_count);
return layer_props;
}
template <typename CreationFunc, typename CreateInfo>
VkResult create_surface_helper(VulkanFunctions* functions, VkInstance inst, VkSurfaceKHR& surface, const char* load_func_name,
VkStructureType stype) {
CreationFunc pfn_CreateSurface = functions->load(inst, load_func_name);
if (!pfn_CreateSurface) return VK_ERROR_EXTENSION_NOT_PRESENT;
CreateInfo surf_create_info{stype};
return pfn_CreateSurface(inst, &surf_create_info, nullptr, &surface);
}
VkResult create_surface(VulkanFunctions* functions, VkInstance inst, VkSurfaceKHR& surface,
[[maybe_unused]] const char* api_selection) {
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
return create_surface_helper<PFN_vkCreateAndroidSurfaceKHR, VkAndroidSurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateAndroidSurfaceKHR", VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR);
#elif defined(VK_USE_PLATFORM_DIRECTFB_EXT)
return create_surface_helper<PFN_vkCreateDirectFBSurfaceEXT, VkDirectFBSurfaceCreateInfoEXT>(
functions, inst, surface, "vkCreateDirectFBSurfaceEXT", VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT);
#elif defined(VK_USE_PLATFORM_FUCHSIA)
return create_surface_helper<PFN_vkCreateImagePipeSurfaceFUCHSIA, VkImagePipeSurfaceCreateInfoFUCHSIA>(
functions, inst, surface, "vkCreateImagePipeSurfaceFUCHSIA", VK_STRUCTURE_TYPE_IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA);
#elif defined(VK_USE_PLATFORM_GGP)
return create_surface_helper<PFN__vkCreateStreamDescriptorSurfaceGGP, VkStreamDescriptorSurfaceCreateInfoGGP>(
functions, inst, surface, "vkCreateStreamDescriptorSurfaceGGP",
VK_STRUCTURE_TYPE_STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP);
#elif defined(VK_USE_PLATFORM_IOS_MVK)
return create_surface_helper<PFN_vkCreateIOSSurfaceMVK, VkIOSSurfaceCreateInfoMVK>(
functions, inst, surface, "vkCreateIOSSurfaceMVK", VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK);
#elif defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)
#if defined(VK_USE_PLATFORM_MACOS_MVK)
if (api_selection != nullptr && string_eq(api_selection, "VK_USE_PLATFORM_MACOS_MVK"))
return create_surface_helper<PFN_vkCreateMacOSSurfaceMVK, VkMacOSSurfaceCreateInfoMVK>(
functions, inst, surface, "vkCreateMacOSSurfaceMVK", VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK);
#endif
#if defined(VK_USE_PLATFORM_METAL_EXT)
if (api_selection == nullptr || (api_selection != nullptr && string_eq(api_selection, "VK_USE_PLATFORM_METAL_EXT")))
return create_surface_helper<PFN_vkCreateMetalSurfaceEXT, VkMetalSurfaceCreateInfoEXT>(
functions, inst, surface, "vkCreateMetalSurfaceEXT", VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT);
#endif
return VK_ERROR_NOT_PERMITTED_KHR;
#elif defined(VK_USE_PLATFORM_SCREEN_QNX)
return create_surface_helper<PFN_vkCreateScreenSurfaceQNX, VkScreenSurfaceCreateInfoQNX>(
functions, inst, surface, "vkCreateScreenSurfaceQNX", VK_STRUCTURE_TYPE_SCREEN_SURFACE_CREATE_INFO_QNX);
#elif defined(VK_USE_PLATFORM_VI_NN)
return create_surface_helper<PFN_vkCreateViSurfaceNN, VkViSurfaceCreateInfoNN>(functions, inst, surface, "vkCreateViSurfaceNN",
VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN);
#elif defined(VK_USE_PLATFORM_WIN32_KHR)
return create_surface_helper<PFN_vkCreateWin32SurfaceKHR, VkWin32SurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateWin32SurfaceKHR", VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR);
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WAYLAND_KHR)
#if defined(VK_USE_PLATFORM_XLIB_KHR)
if (string_eq(api_selection, "VK_USE_PLATFORM_XLIB_KHR"))
return create_surface_helper<PFN_vkCreateXlibSurfaceKHR, VkXlibSurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateXlibSurfaceKHR", VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR);
#endif
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
if (string_eq(api_selection, "VK_USE_PLATFORM_WAYLAND_KHR"))
return create_surface_helper<PFN_vkCreateWaylandSurfaceKHR, VkWaylandSurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateWaylandSurfaceKHR", VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR);
#endif
#if defined(VK_USE_PLATFORM_XCB_KHR)
if (api_selection == nullptr || string_eq(api_selection, "VK_USE_PLATFORM_XCB_KHR"))
return create_surface_helper<PFN_vkCreateXcbSurfaceKHR, VkXcbSurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateXcbSurfaceKHR", VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR);
#endif
return VK_ERROR_NOT_PERMITTED_KHR;
#else
return create_surface_helper<PFN_vkCreateDisplayPlaneSurfaceKHR, VkDisplaySurfaceCreateInfoKHR>(
functions, inst, surface, "vkCreateDisplayPlaneSurfaceKHR", VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR);
#endif
}
VkResult create_surface(InstWrapper& inst, VkSurfaceKHR& surface, const char* api_selection) {
return create_surface(inst.functions, inst.inst, surface, api_selection);
}
VkResult create_debug_callback(InstWrapper& inst, const VkDebugReportCallbackCreateInfoEXT& create_info,
VkDebugReportCallbackEXT& callback) {
return inst.functions->vkCreateDebugReportCallbackEXT(inst.inst, &create_info, nullptr, &callback);
}
extern "C" {
void __ubsan_on_report() { FAIL() << "Encountered an undefined behavior sanitizer error"; }
void __asan_on_error() { FAIL() << "Encountered an address sanitizer error"; }
void __tsan_on_report() { FAIL() << "Encountered a thread sanitizer error"; }
} // extern "C"
|