Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2022-10-26 21:24:24 +0300
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-11-05 02:07:38 +0300
commit8ff839bda370f2a46708f117b551ff0ea7954416 (patch)
tree21788aa695d7640901f8b24309d21bbe47c8e126
parent256a5e3b6d6fc31e711f912291498becd6a41330 (diff)
Fix vulkan.pc Libs.private for static builds
The Libs.private field shouldn't be present for shared library builds, so now the field wont be present in that case. For static library builds it should be present, but the fields should be deduplicated as well. Additionally, this adds a github actions run for testing the static build of the loader on MacOS. This requires making the test framework capable of using a statically built loader, which mainly took making VulkanFunctions capable of assigning the statically defined functions instead of loading them with dlsym. The static build option required changes to the unix_shim.cpp to not cause infinite loops.
-rw-r--r--.github/workflows/build.yml10
-rw-r--r--loader/CMakeLists.txt12
-rw-r--r--loader/vulkan.pc.in2
-rw-r--r--tests/framework/CMakeLists.txt4
-rw-r--r--tests/framework/shim/unix_shim.cpp41
-rw-r--r--tests/framework/test_environment.cpp138
-rw-r--r--tests/framework/test_environment.h141
-rw-r--r--tests/framework/test_util.cpp124
-rw-r--r--tests/framework/test_util.h139
9 files changed, 335 insertions, 276 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fabcdee3f..e2d0957fd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -139,11 +139,17 @@ jobs:
run: python scripts/generate_source.py --verify external/Vulkan-Headers/registry
mac:
- runs-on: macos-11
+ runs-on: ${{matrix.os}}
strategy:
matrix:
config: [ Debug, Release ]
+ os: [ macos-11 ]
+ static_build: [ ON, OFF ]
+ exclude:
+ - config: Debug
+ os: macos-11
+ static_build: ON
steps:
- uses: actions/checkout@v2
@@ -152,7 +158,7 @@ jobs:
python-version: '3.7'
- name: Generate build files
- run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -DBUILD_TESTS=On -DUPDATE_DEPS=ON -DTEST_USE_ADDRESS_SANITIZER=ON
+ run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -DBUILD_STATIC_LOADER=${{matrix.config}} -DBUILD_TESTS=On -DUPDATE_DEPS=ON
env:
# Specify the minimum version of macOS on which the target binaries are to be deployed.
# https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index c542c756d..e46a36725 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -383,9 +383,15 @@ endif()
include(FindPkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(VK_API_VERSION "${LOADER_GENERATED_HEADER_VERSION}")
- foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS})
- set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
- endforeach()
+ set(PRIVATE_LIBS "")
+ if (APPLE AND BUILD_STATIC_LOADER)
+ # Libs.private should only be present when building a static loader
+ foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
+ list(APPEND PRIVATE_LIBS "-l${LIB}")
+ endforeach()
+ list(REMOVE_DUPLICATES PRIVATE_LIBS)
+ set(PRIVATE_LIBS "Libs.private: ${PRIVATE_LIBS}")
+ endif()
if(WIN32)
if(MINGW)
set(VULKAN_LIB_SUFFIX "-1.dll")
diff --git a/loader/vulkan.pc.in b/loader/vulkan.pc.in
index 153815577..82e9f5edc 100644
--- a/loader/vulkan.pc.in
+++ b/loader/vulkan.pc.in
@@ -7,6 +7,6 @@ Name: @CMAKE_PROJECT_NAME@
Description: Vulkan Loader
Version: @VK_API_VERSION@
Libs: -L${libdir} -lvulkan@VULKAN_LIB_SUFFIX@
-Libs.private: @PRIVATE_LIBS@
+@PRIVATE_LIBS@
Cflags: -I${includedir}
diff --git a/tests/framework/CMakeLists.txt b/tests/framework/CMakeLists.txt
index 3aedff55a..b3d46f5bc 100644
--- a/tests/framework/CMakeLists.txt
+++ b/tests/framework/CMakeLists.txt
@@ -99,3 +99,7 @@ target_link_libraries(testing_dependencies
target_include_directories(testing_dependencies PUBLIC ${CMAKE_BINARY_DIR}/tests/framework)
target_compile_definitions(testing_dependencies PUBLIC "GTEST_LINKED_AS_SHARED_LIBRARY=1")
set_target_properties(testing_dependencies ${LOADER_STANDARD_CXX_PROPERTIES})
+if (APPLE AND BUILD_STATIC_LOADER)
+ target_compile_definitions(testing_dependencies PUBLIC "BUILD_STATIC_LOADER=1")
+ target_link_libraries(testing_dependencies PUBLIC vulkan)
+endif() \ No newline at end of file
diff --git a/tests/framework/shim/unix_shim.cpp b/tests/framework/shim/unix_shim.cpp
index c52bec7bc..e930293b8 100644
--- a/tests/framework/shim/unix_shim.cpp
+++ b/tests/framework/shim/unix_shim.cpp
@@ -83,6 +83,21 @@ using PFN_GETEGID = gid_t (*)(void);
using PFN_SEC_GETENV = char* (*)(const char* name);
#endif
+#if defined(__APPLE__)
+#define real_opendir opendir
+#define real_readdir readdir
+#define real_closedir closedir
+#define real_access access
+#define real_fopen fopen
+#define real_geteuid geteuid
+#define real_getegid getegid
+#if defined(HAVE_SECURE_GETENV)
+#define real_secure_getenv _secure_getenv
+#endif
+#if defined(HAVE___SECURE_GETENV)
+#define real__secure_getenv __secure_getenv
+#endif
+#else
static PFN_OPENDIR real_opendir = nullptr;
static PFN_READDIR real_readdir = nullptr;
static PFN_CLOSEDIR real_closedir = nullptr;
@@ -96,10 +111,12 @@ static PFN_SEC_GETENV real_secure_getenv = nullptr;
#if defined(HAVE___SECURE_GETENV)
static PFN_SEC_GETENV real__secure_getenv = nullptr;
#endif
+#endif
FRAMEWORK_EXPORT DIR* OPENDIR_FUNC_NAME(const char* path_name) {
+#if !defined(__APPLE__)
if (!real_opendir) real_opendir = (PFN_OPENDIR)dlsym(RTLD_NEXT, "opendir");
-
+#endif
DIR* dir;
if (platform_shim.is_fake_path(path_name)) {
auto fake_path_name = platform_shim.get_fake_path(fs::path(path_name));
@@ -113,7 +130,9 @@ FRAMEWORK_EXPORT DIR* OPENDIR_FUNC_NAME(const char* path_name) {
}
FRAMEWORK_EXPORT struct dirent* READDIR_FUNC_NAME(DIR* dir_stream) {
+#if !defined(__APPLE__)
if (!real_readdir) real_readdir = (PFN_READDIR)dlsym(RTLD_NEXT, "readdir");
+#endif
auto it = std::find_if(platform_shim.dir_entries.begin(), platform_shim.dir_entries.end(),
[dir_stream](DirEntry const& entry) { return entry.directory == dir_stream; });
@@ -151,8 +170,9 @@ FRAMEWORK_EXPORT struct dirent* READDIR_FUNC_NAME(DIR* dir_stream) {
}
FRAMEWORK_EXPORT int CLOSEDIR_FUNC_NAME(DIR* dir_stream) {
+#if !defined(__APPLE__)
if (!real_closedir) real_closedir = (PFN_CLOSEDIR)dlsym(RTLD_NEXT, "closedir");
-
+#endif
auto it = std::find_if(platform_shim.dir_entries.begin(), platform_shim.dir_entries.end(),
[dir_stream](DirEntry const& entry) { return entry.directory == dir_stream; });
@@ -164,8 +184,9 @@ FRAMEWORK_EXPORT int CLOSEDIR_FUNC_NAME(DIR* dir_stream) {
}
FRAMEWORK_EXPORT int ACCESS_FUNC_NAME(const char* in_pathname, int mode) {
+#if !defined(__APPLE__)
if (!real_access) real_access = (PFN_ACCESS)dlsym(RTLD_NEXT, "access");
-
+#endif
fs::path path{in_pathname};
if (!path.has_parent_path()) {
return real_access(in_pathname, mode);
@@ -180,8 +201,9 @@ FRAMEWORK_EXPORT int ACCESS_FUNC_NAME(const char* in_pathname, int mode) {
}
FRAMEWORK_EXPORT FILE* FOPEN_FUNC_NAME(const char* in_filename, const char* mode) {
+#if !defined(__APPLE__)
if (!real_fopen) real_fopen = (PFN_FOPEN)dlsym(RTLD_NEXT, "fopen");
-
+#endif
fs::path path{in_filename};
if (!path.has_parent_path()) {
return real_fopen(in_filename, mode);
@@ -199,8 +221,9 @@ FRAMEWORK_EXPORT FILE* FOPEN_FUNC_NAME(const char* in_filename, const char* mode
}
FRAMEWORK_EXPORT uid_t GETEUID_FUNC_NAME(void) {
+#if !defined(__APPLE__)
if (!real_geteuid) real_geteuid = (PFN_GETEUID)dlsym(RTLD_NEXT, "geteuid");
-
+#endif
if (platform_shim.use_fake_elevation) {
// Root on linux is 0, so force pretending like we're root
return 0;
@@ -210,8 +233,9 @@ FRAMEWORK_EXPORT uid_t GETEUID_FUNC_NAME(void) {
}
FRAMEWORK_EXPORT gid_t GETEGID_FUNC_NAME(void) {
+#if !defined(__APPLE__)
if (!real_getegid) real_getegid = (PFN_GETEGID)dlsym(RTLD_NEXT, "getegid");
-
+#endif
if (platform_shim.use_fake_elevation) {
// Root on linux is 0, so force pretending like we're root
return 0;
@@ -222,8 +246,9 @@ FRAMEWORK_EXPORT gid_t GETEGID_FUNC_NAME(void) {
#if defined(HAVE_SECURE_GETENV)
FRAMEWORK_EXPORT char* SECURE_GETENV_FUNC_NAME(const char* name) {
+#if !defined(__APPLE__)
if (!real_secure_getenv) real_secure_getenv = (PFN_SEC_GETENV)dlsym(RTLD_NEXT, "secure_getenv");
-
+#endif
if (platform_shim.use_fake_elevation) {
return NULL;
} else {
@@ -233,7 +258,9 @@ FRAMEWORK_EXPORT char* SECURE_GETENV_FUNC_NAME(const char* name) {
#endif
#if defined(HAVE___SECURE_GETENV)
FRAMEWORK_EXPORT char* __SECURE_GETENV_FUNC_NAME(const char* name) {
+#if !defined(__APPLE__)
if (!real__secure_getenv) real__secure_getenv = (PFN_SEC_GETENV)dlsym(RTLD_NEXT, "__secure_getenv");
+#endif
if (platform_shim.use_fake_elevation) {
return NULL;
diff --git a/tests/framework/test_environment.cpp b/tests/framework/test_environment.cpp
index 13ef8b832..4a99046ac 100644
--- a/tests/framework/test_environment.cpp
+++ b/tests/framework/test_environment.cpp
@@ -27,6 +27,144 @@
#include "test_environment.h"
+fs::path get_loader_path() {
+ auto loader_path = fs::path(FRAMEWORK_VULKAN_LIBRARY_PATH);
+ auto env_var_res = get_env_var("VK_LOADER_TEST_LOADER_PATH", false);
+ if (!env_var_res.empty()) {
+ loader_path = fs::path(env_var_res);
+ }
+ return loader_path;
+}
+
+void init_vulkan_functions(VulkanFunctions& funcs) {
+#if defined(BUILD_STATIC_LOADER)
+#define GPA(name) name
+#else
+#define GPA(name) funcs.loader.get_symbol(#name)
+#endif
+
+ // clang-format off
+ funcs.vkGetInstanceProcAddr = GPA(vkGetInstanceProcAddr);
+ funcs.vkEnumerateInstanceExtensionProperties = GPA(vkEnumerateInstanceExtensionProperties);
+ funcs.vkEnumerateInstanceLayerProperties = GPA(vkEnumerateInstanceLayerProperties);
+ funcs.vkEnumerateInstanceVersion = GPA(vkEnumerateInstanceVersion);
+ funcs.vkCreateInstance = GPA(vkCreateInstance);
+ funcs.vkDestroyInstance = GPA(vkDestroyInstance);
+ funcs.vkEnumeratePhysicalDevices = GPA(vkEnumeratePhysicalDevices);
+ funcs.vkEnumeratePhysicalDeviceGroups = GPA(vkEnumeratePhysicalDeviceGroups);
+ funcs.vkGetPhysicalDeviceFeatures = GPA(vkGetPhysicalDeviceFeatures);
+ funcs.vkGetPhysicalDeviceFeatures2 = GPA(vkGetPhysicalDeviceFeatures2);
+ funcs.vkGetPhysicalDeviceFormatProperties = GPA(vkGetPhysicalDeviceFormatProperties);
+ funcs.vkGetPhysicalDeviceFormatProperties2 = GPA(vkGetPhysicalDeviceFormatProperties2);
+ funcs.vkGetPhysicalDeviceImageFormatProperties = GPA(vkGetPhysicalDeviceImageFormatProperties);
+ funcs.vkGetPhysicalDeviceImageFormatProperties2 = GPA(vkGetPhysicalDeviceImageFormatProperties2);
+ funcs.vkGetPhysicalDeviceSparseImageFormatProperties = GPA(vkGetPhysicalDeviceSparseImageFormatProperties);
+ funcs.vkGetPhysicalDeviceSparseImageFormatProperties2 = GPA(vkGetPhysicalDeviceSparseImageFormatProperties2);
+ funcs.vkGetPhysicalDeviceProperties = GPA(vkGetPhysicalDeviceProperties);
+ funcs.vkGetPhysicalDeviceProperties2 = GPA(vkGetPhysicalDeviceProperties2);
+ funcs.vkGetPhysicalDeviceQueueFamilyProperties = GPA(vkGetPhysicalDeviceQueueFamilyProperties);
+ funcs.vkGetPhysicalDeviceQueueFamilyProperties2 = GPA(vkGetPhysicalDeviceQueueFamilyProperties2);
+ funcs.vkGetPhysicalDeviceMemoryProperties = GPA(vkGetPhysicalDeviceMemoryProperties);
+ funcs.vkGetPhysicalDeviceMemoryProperties2 = GPA(vkGetPhysicalDeviceMemoryProperties2);
+ funcs.vkGetPhysicalDeviceSurfaceSupportKHR = GPA(vkGetPhysicalDeviceSurfaceSupportKHR);
+ funcs.vkGetPhysicalDeviceSurfaceFormatsKHR = GPA(vkGetPhysicalDeviceSurfaceFormatsKHR);
+ funcs.vkGetPhysicalDeviceSurfacePresentModesKHR = GPA(vkGetPhysicalDeviceSurfacePresentModesKHR);
+ funcs.vkGetPhysicalDeviceSurfaceCapabilitiesKHR = GPA(vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
+ funcs.vkEnumerateDeviceExtensionProperties = GPA(vkEnumerateDeviceExtensionProperties);
+ funcs.vkEnumerateDeviceLayerProperties = GPA(vkEnumerateDeviceLayerProperties);
+ funcs.vkGetPhysicalDeviceExternalBufferProperties = GPA(vkGetPhysicalDeviceExternalBufferProperties);
+ funcs.vkGetPhysicalDeviceExternalFenceProperties = GPA(vkGetPhysicalDeviceExternalFenceProperties);
+ funcs.vkGetPhysicalDeviceExternalSemaphoreProperties = GPA(vkGetPhysicalDeviceExternalSemaphoreProperties);
+
+ funcs.vkDestroySurfaceKHR = GPA(vkDestroySurfaceKHR);
+ funcs.vkGetDeviceProcAddr = GPA(vkGetDeviceProcAddr);
+ funcs.vkCreateDevice = GPA(vkCreateDevice);
+
+ funcs.vkCreateHeadlessSurfaceEXT = GPA(vkCreateHeadlessSurfaceEXT);
+ funcs.vkCreateDisplayPlaneSurfaceKHR = GPA(vkCreateDisplayPlaneSurfaceKHR);
+ funcs.vkGetPhysicalDeviceDisplayPropertiesKHR = GPA(vkGetPhysicalDeviceDisplayPropertiesKHR);
+ funcs.vkGetPhysicalDeviceDisplayPlanePropertiesKHR = GPA(vkGetPhysicalDeviceDisplayPlanePropertiesKHR);
+ funcs.vkGetDisplayPlaneSupportedDisplaysKHR = GPA(vkGetDisplayPlaneSupportedDisplaysKHR);
+ funcs.vkGetDisplayModePropertiesKHR = GPA(vkGetDisplayModePropertiesKHR);
+ funcs.vkCreateDisplayModeKHR = GPA(vkCreateDisplayModeKHR);
+ funcs.vkGetDisplayPlaneCapabilitiesKHR = GPA(vkGetDisplayPlaneCapabilitiesKHR);
+ funcs.vkGetPhysicalDevicePresentRectanglesKHR = GPA(vkGetPhysicalDevicePresentRectanglesKHR);
+ funcs.vkGetPhysicalDeviceDisplayProperties2KHR = GPA(vkGetPhysicalDeviceDisplayProperties2KHR);
+ funcs.vkGetPhysicalDeviceDisplayPlaneProperties2KHR = GPA(vkGetPhysicalDeviceDisplayPlaneProperties2KHR);
+ funcs.vkGetDisplayModeProperties2KHR = GPA(vkGetDisplayModeProperties2KHR);
+ funcs.vkGetDisplayPlaneCapabilities2KHR = GPA(vkGetDisplayPlaneCapabilities2KHR);
+ funcs.vkGetPhysicalDeviceSurfaceCapabilities2KHR = GPA(vkGetPhysicalDeviceSurfaceCapabilities2KHR);
+ funcs.vkGetPhysicalDeviceSurfaceFormats2KHR = GPA(vkGetPhysicalDeviceSurfaceFormats2KHR);
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ funcs.vkCreateAndroidSurfaceKHR = GPA(vkCreateAndroidSurfaceKHR);
+#endif // VK_USE_PLATFORM_ANDROID_KHR
+#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
+ funcs.vkCreateDirectFBSurfaceEXT = GPA(vkCreateDirectFBSurfaceEXT);
+ funcs.vkGetPhysicalDeviceDirectFBPresentationSupportEXT = GPA(vkGetPhysicalDeviceDirectFBPresentationSupportEXT);
+#endif // VK_USE_PLATFORM_DIRECTFB_EXT
+#ifdef VK_USE_PLATFORM_FUCHSIA
+ funcs.vkCreateImagePipeSurfaceFUCHSIA = GPA(vkCreateImagePipeSurfaceFUCHSIA);
+#endif // VK_USE_PLATFORM_FUCHSIA
+#ifdef VK_USE_PLATFORM_GGP
+ funcs.vkCreateStreamDescriptorSurfaceGGP = GPA(vkCreateStreamDescriptorSurfaceGGP);
+#endif // VK_USE_PLATFORM_GGP
+#ifdef VK_USE_PLATFORM_IOS_MVK
+ funcs.vkCreateIOSSurfaceMVK = GPA(vkCreateIOSSurfaceMVK);
+#endif // VK_USE_PLATFORM_IOS_MVK
+#ifdef VK_USE_PLATFORM_MACOS_MVK
+ funcs.vkCreateMacOSSurfaceMVK = GPA(vkCreateMacOSSurfaceMVK);
+#endif // VK_USE_PLATFORM_MACOS_MVK
+#ifdef VK_USE_PLATFORM_METAL_EXT
+ funcs.vkCreateMetalSurfaceEXT = GPA(vkCreateMetalSurfaceEXT);
+#endif // VK_USE_PLATFORM_METAL_EXT
+#ifdef VK_USE_PLATFORM_SCREEN_QNX
+ funcs.vkCreateScreenSurfaceQNX = GPA(vkCreateScreenSurfaceQNX);
+ funcs.vkGetPhysicalDeviceScreenPresentationSupportQNX = GPA(vkGetPhysicalDeviceScreenPresentationSupportQNX);
+#endif // VK_USE_PLATFORM_SCREEN_QNX
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ funcs.vkCreateWaylandSurfaceKHR = GPA(vkCreateWaylandSurfaceKHR);
+ funcs.vkGetPhysicalDeviceWaylandPresentationSupportKHR = GPA(vkGetPhysicalDeviceWaylandPresentationSupportKHR);
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ funcs.vkCreateXcbSurfaceKHR = GPA(vkCreateXcbSurfaceKHR);
+ funcs.vkGetPhysicalDeviceXcbPresentationSupportKHR = GPA(vkGetPhysicalDeviceXcbPresentationSupportKHR);
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ funcs.vkCreateXlibSurfaceKHR = GPA(vkCreateXlibSurfaceKHR);
+ funcs.vkGetPhysicalDeviceXlibPresentationSupportKHR = GPA(vkGetPhysicalDeviceXlibPresentationSupportKHR);
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+ funcs.vkCreateWin32SurfaceKHR = GPA(vkCreateWin32SurfaceKHR);
+ funcs.vkGetPhysicalDeviceWin32PresentationSupportKHR = GPA(vkGetPhysicalDeviceWin32PresentationSupportKHR);
+#endif // VK_USE_PLATFORM_WIN32_KHR
+
+ funcs.vkDestroyDevice = GPA(vkDestroyDevice);
+ funcs.vkGetDeviceQueue = GPA(vkGetDeviceQueue);
+#undef GPA
+ // clang-format on
+}
+
+#if defined(BUILD_STATIC_LOADER)
+VulkanFunctions::VulkanFunctions() {
+#else
+VulkanFunctions::VulkanFunctions() : loader(get_loader_path()) {
+#endif
+ init_vulkan_functions(*this);
+}
+
+DeviceFunctions::DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device) {
+ vkGetDeviceProcAddr = vulkan_functions.vkGetDeviceProcAddr;
+ vkDestroyDevice = load(device, "vkDestroyDevice");
+ vkGetDeviceQueue = load(device, "vkGetDeviceQueue");
+ vkCreateCommandPool = load(device, "vkCreateCommandPool");
+ vkAllocateCommandBuffers = load(device, "vkAllocateCommandBuffers");
+ vkDestroyCommandPool = load(device, "vkDestroyCommandPool");
+ vkCreateSwapchainKHR = load(device, "vkCreateSwapchainKHR");
+ vkGetSwapchainImagesKHR = load(device, "vkGetSwapchainImagesKHR");
+ vkDestroySwapchainKHR = load(device, "vkDestroySwapchainKHR");
+}
+
InstWrapper::InstWrapper(VulkanFunctions& functions, VkAllocationCallbacks* callbacks) noexcept
: functions(&functions), callbacks(callbacks) {}
InstWrapper::InstWrapper(VulkanFunctions& functions, VkInstance inst, VkAllocationCallbacks* callbacks) noexcept
diff --git a/tests/framework/test_environment.h b/tests/framework/test_environment.h
index 95af7d4ea..fcdd681db 100644
--- a/tests/framework/test_environment.h
+++ b/tests/framework/test_environment.h
@@ -117,6 +117,147 @@ void handle_assert_equal(size_t count, T left[], T right[]) {
}
}
+// VulkanFunctions - loads vulkan functions for tests to use
+
+struct VulkanFunctions {
+#if !defined(BUILD_STATIC_LOADER)
+ LibraryWrapper loader;
+#endif
+ // Pre-Instance
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = nullptr;
+ PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties = nullptr;
+ PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties = nullptr;
+ PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = nullptr;
+ PFN_vkCreateInstance vkCreateInstance = nullptr;
+
+ // Instance
+ PFN_vkDestroyInstance vkDestroyInstance = nullptr;
+ PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = nullptr;
+ PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups = nullptr;
+ PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures = nullptr;
+ PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2 = nullptr;
+ PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = nullptr;
+ PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties = nullptr;
+ PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties = nullptr;
+ PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = nullptr;
+ PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = nullptr;
+ PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = nullptr;
+ PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2 = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR = nullptr;
+ PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties = nullptr;
+ PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties = nullptr;
+ PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties = nullptr;
+ PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties = nullptr;
+ PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties = nullptr;
+
+ PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr = nullptr;
+ PFN_vkCreateDevice vkCreateDevice = nullptr;
+ PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = nullptr;
+ PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = nullptr;
+
+ // WSI
+ PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT = nullptr;
+ PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR = nullptr;
+ PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR = nullptr;
+ PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR = nullptr;
+ PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR = nullptr;
+ PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR = nullptr;
+ PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR = nullptr;
+ PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR = nullptr;
+ PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR = nullptr;
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = nullptr;
+#endif // VK_USE_PLATFORM_ANDROID_KHR
+#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
+ PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT = nullptr;
+ PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT = nullptr;
+#endif // VK_USE_PLATFORM_DIRECTFB_EXT
+#ifdef VK_USE_PLATFORM_FUCHSIA
+ PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA = nullptr;
+#endif // VK_USE_PLATFORM_FUCHSIA
+#ifdef VK_USE_PLATFORM_GGP
+ PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP = nullptr;
+#endif // VK_USE_PLATFORM_GGP
+#ifdef VK_USE_PLATFORM_IOS_MVK
+ PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK = nullptr;
+#endif // VK_USE_PLATFORM_IOS_MVK
+#ifdef VK_USE_PLATFORM_MACOS_MVK
+ PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK = nullptr;
+#endif // VK_USE_PLATFORM_MACOS_MVK
+#ifdef VK_USE_PLATFORM_METAL_EXT
+ PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = nullptr;
+#endif // VK_USE_PLATFORM_METAL_EXT
+#ifdef VK_USE_PLATFORM_SCREEN_QNX
+ PFN_vkCreateScreenSurfaceQNX vkCreateScreenSurfaceQNX = nullptr;
+ PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX vkGetPhysicalDeviceScreenPresentationSupportQNX = nullptr;
+#endif // VK_USE_PLATFORM_SCREEN_QNX
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR = nullptr;
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR = nullptr;
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR = nullptr;
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+ PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR = nullptr;
+#endif // VK_USE_PLATFORM_WIN32_KHR
+ PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR = nullptr;
+
+ // device functions
+ PFN_vkDestroyDevice vkDestroyDevice = nullptr;
+ PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
+
+ VulkanFunctions();
+
+ FromVoidStarFunc load(VkInstance inst, const char* func_name) const {
+ return FromVoidStarFunc(vkGetInstanceProcAddr(inst, func_name));
+ }
+
+ FromVoidStarFunc load(VkDevice device, const char* func_name) const {
+ return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
+ }
+};
+
+struct DeviceFunctions {
+ PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr = nullptr;
+ PFN_vkDestroyDevice vkDestroyDevice = nullptr;
+ PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
+ PFN_vkCreateCommandPool vkCreateCommandPool = nullptr;
+ PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = nullptr;
+ PFN_vkDestroyCommandPool vkDestroyCommandPool = nullptr;
+ PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = nullptr;
+ PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR = nullptr;
+ PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR = nullptr;
+
+ DeviceFunctions() = default;
+ DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device);
+
+ FromVoidStarFunc load(VkDevice device, const char* func_name) const {
+ return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
+ }
+};
+
// InstWrapper & DeviceWrapper - used to make creating instances & devices easier test writing
struct InstWrapper {
InstWrapper(VulkanFunctions& functions, VkAllocationCallbacks* callbacks = nullptr) noexcept;
diff --git a/tests/framework/test_util.cpp b/tests/framework/test_util.cpp
index d14775a6c..4b67dba77 100644
--- a/tests/framework/test_util.cpp
+++ b/tests/framework/test_util.cpp
@@ -517,130 +517,6 @@ path FolderManager::copy_file(path const& file, std::string const& new_name) {
bool string_eq(const char* a, const char* b) noexcept { return a && b && strcmp(a, b) == 0; }
bool string_eq(const char* a, const char* b, size_t len) noexcept { return a && b && strncmp(a, b, len) == 0; }
-fs::path get_loader_path() {
- auto loader_path = fs::path(FRAMEWORK_VULKAN_LIBRARY_PATH);
- auto env_var_res = get_env_var("VK_LOADER_TEST_LOADER_PATH", false);
- if (!env_var_res.empty()) {
- loader_path = fs::path(env_var_res);
- }
- return loader_path;
-}
-
-VulkanFunctions::VulkanFunctions() : loader(get_loader_path()) {
- // clang-format off
- vkGetInstanceProcAddr = loader.get_symbol("vkGetInstanceProcAddr");
- vkEnumerateInstanceExtensionProperties = loader.get_symbol("vkEnumerateInstanceExtensionProperties");
- vkEnumerateInstanceLayerProperties = loader.get_symbol("vkEnumerateInstanceLayerProperties");
- vkEnumerateInstanceVersion = loader.get_symbol("vkEnumerateInstanceVersion");
- vkCreateInstance = loader.get_symbol("vkCreateInstance");
- vkDestroyInstance = loader.get_symbol("vkDestroyInstance");
- vkEnumeratePhysicalDevices = loader.get_symbol("vkEnumeratePhysicalDevices");
- vkEnumeratePhysicalDeviceGroups = loader.get_symbol("vkEnumeratePhysicalDeviceGroups");
- vkGetPhysicalDeviceFeatures = loader.get_symbol("vkGetPhysicalDeviceFeatures");
- vkGetPhysicalDeviceFeatures2 = loader.get_symbol("vkGetPhysicalDeviceFeatures2");
- vkGetPhysicalDeviceFormatProperties = loader.get_symbol("vkGetPhysicalDeviceFormatProperties");
- vkGetPhysicalDeviceFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceFormatProperties2");
- vkGetPhysicalDeviceImageFormatProperties = loader.get_symbol("vkGetPhysicalDeviceImageFormatProperties");
- vkGetPhysicalDeviceImageFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceImageFormatProperties2");
- vkGetPhysicalDeviceSparseImageFormatProperties = loader.get_symbol("vkGetPhysicalDeviceSparseImageFormatProperties");
- vkGetPhysicalDeviceSparseImageFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceSparseImageFormatProperties2");
- vkGetPhysicalDeviceProperties = loader.get_symbol("vkGetPhysicalDeviceProperties");
- vkGetPhysicalDeviceProperties2 = loader.get_symbol("vkGetPhysicalDeviceProperties2");
- vkGetPhysicalDeviceQueueFamilyProperties = loader.get_symbol("vkGetPhysicalDeviceQueueFamilyProperties");
- vkGetPhysicalDeviceQueueFamilyProperties2 = loader.get_symbol("vkGetPhysicalDeviceQueueFamilyProperties2");
- vkGetPhysicalDeviceMemoryProperties = loader.get_symbol("vkGetPhysicalDeviceMemoryProperties");
- vkGetPhysicalDeviceMemoryProperties2 = loader.get_symbol("vkGetPhysicalDeviceMemoryProperties2");
- vkGetPhysicalDeviceSurfaceSupportKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceSupportKHR");
- vkGetPhysicalDeviceSurfaceFormatsKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceFormatsKHR");
- vkGetPhysicalDeviceSurfacePresentModesKHR = loader.get_symbol("vkGetPhysicalDeviceSurfacePresentModesKHR");
- vkGetPhysicalDeviceSurfaceCapabilitiesKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
- vkEnumerateDeviceExtensionProperties = loader.get_symbol("vkEnumerateDeviceExtensionProperties");
- vkEnumerateDeviceLayerProperties = loader.get_symbol("vkEnumerateDeviceLayerProperties");
- vkGetPhysicalDeviceExternalBufferProperties = loader.get_symbol("vkGetPhysicalDeviceExternalBufferProperties");
- vkGetPhysicalDeviceExternalFenceProperties = loader.get_symbol("vkGetPhysicalDeviceExternalFenceProperties");
- vkGetPhysicalDeviceExternalSemaphoreProperties = loader.get_symbol("vkGetPhysicalDeviceExternalSemaphoreProperties");
-
- vkDestroySurfaceKHR = loader.get_symbol("vkDestroySurfaceKHR");
- vkGetDeviceProcAddr = loader.get_symbol("vkGetDeviceProcAddr");
- vkCreateDevice = loader.get_symbol("vkCreateDevice");
-
- vkCreateHeadlessSurfaceEXT = loader.get_symbol("vkCreateHeadlessSurfaceEXT");
- vkCreateDisplayPlaneSurfaceKHR = loader.get_symbol("vkCreateDisplayPlaneSurfaceKHR");
- vkGetPhysicalDeviceDisplayPropertiesKHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPropertiesKHR");
- vkGetPhysicalDeviceDisplayPlanePropertiesKHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
- vkGetDisplayPlaneSupportedDisplaysKHR = loader.get_symbol("vkGetDisplayPlaneSupportedDisplaysKHR");
- vkGetDisplayModePropertiesKHR = loader.get_symbol("vkGetDisplayModePropertiesKHR");
- vkCreateDisplayModeKHR = loader.get_symbol("vkCreateDisplayModeKHR");
- vkGetDisplayPlaneCapabilitiesKHR = loader.get_symbol("vkGetDisplayPlaneCapabilitiesKHR");
- vkGetPhysicalDevicePresentRectanglesKHR = loader.get_symbol("vkGetPhysicalDevicePresentRectanglesKHR");
- vkGetPhysicalDeviceDisplayProperties2KHR = loader.get_symbol("vkGetPhysicalDeviceDisplayProperties2KHR");
- vkGetPhysicalDeviceDisplayPlaneProperties2KHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPlaneProperties2KHR");
- vkGetDisplayModeProperties2KHR = loader.get_symbol("vkGetDisplayModeProperties2KHR");
- vkGetDisplayPlaneCapabilities2KHR = loader.get_symbol("vkGetDisplayPlaneCapabilities2KHR");
- vkGetPhysicalDeviceSurfaceCapabilities2KHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceCapabilities2KHR");
- vkGetPhysicalDeviceSurfaceFormats2KHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceFormats2KHR");
-
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
- vkCreateAndroidSurfaceKHR = loader.get_symbol("vkCreateAndroidSurfaceKHR");
-#endif // VK_USE_PLATFORM_ANDROID_KHR
-#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
- vkCreateDirectFBSurfaceEXT = loader.get_symbol("vkCreateDirectFBSurfaceEXT");
- vkGetPhysicalDeviceDirectFBPresentationSupportEXT = loader.get_symbol("vkGetPhysicalDeviceDirectFBPresentationSupportEXT");
-#endif // VK_USE_PLATFORM_DIRECTFB_EXT
-#ifdef VK_USE_PLATFORM_FUCHSIA
- vkCreateImagePipeSurfaceFUCHSIA = loader.get_symbol("vkCreateImagePipeSurfaceFUCHSIA");
-#endif // VK_USE_PLATFORM_FUCHSIA
-#ifdef VK_USE_PLATFORM_GGP
- vkCreateStreamDescriptorSurfaceGGP = loader.get_symbol("vkCreateStreamDescriptorSurfaceGGP");
-#endif // VK_USE_PLATFORM_GGP
-#ifdef VK_USE_PLATFORM_IOS_MVK
- vkCreateIOSSurfaceMVK = loader.get_symbol("vkCreateIOSSurfaceMVK");
-#endif // VK_USE_PLATFORM_IOS_MVK
-#ifdef VK_USE_PLATFORM_MACOS_MVK
- vkCreateMacOSSurfaceMVK = loader.get_symbol("vkCreateMacOSSurfaceMVK");
-#endif // VK_USE_PLATFORM_MACOS_MVK
-#ifdef VK_USE_PLATFORM_METAL_EXT
- vkCreateMetalSurfaceEXT = loader.get_symbol("vkCreateMetalSurfaceEXT");
-#endif // VK_USE_PLATFORM_METAL_EXT
-#ifdef VK_USE_PLATFORM_SCREEN_QNX
- vkCreateScreenSurfaceQNX = loader.get_symbol("vkCreateScreenSurfaceQNX");
- vkGetPhysicalDeviceScreenPresentationSupportQNX = loader.get_symbol("vkGetPhysicalDeviceScreenPresentationSupportQNX");
-#endif // VK_USE_PLATFORM_SCREEN_QNX
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- vkCreateWaylandSurfaceKHR = loader.get_symbol("vkCreateWaylandSurfaceKHR");
- vkGetPhysicalDeviceWaylandPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceWaylandPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WAYLAND_KHR
-#ifdef VK_USE_PLATFORM_XCB_KHR
- vkCreateXcbSurfaceKHR = loader.get_symbol("vkCreateXcbSurfaceKHR");
- vkGetPhysicalDeviceXcbPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceXcbPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XCB_KHR
-#ifdef VK_USE_PLATFORM_XLIB_KHR
- vkCreateXlibSurfaceKHR = loader.get_symbol("vkCreateXlibSurfaceKHR");
- vkGetPhysicalDeviceXlibPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceXlibPresentationSupportKHR");
-#endif // VK_USE_PLATFORM_XLIB_KHR
-#ifdef VK_USE_PLATFORM_WIN32_KHR
- vkCreateWin32SurfaceKHR = loader.get_symbol("vkCreateWin32SurfaceKHR");
- vkGetPhysicalDeviceWin32PresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceWin32PresentationSupportKHR");
-#endif // VK_USE_PLATFORM_WIN32_KHR
-
- vkDestroyDevice = loader.get_symbol("vkDestroyDevice");
- vkGetDeviceQueue = loader.get_symbol("vkGetDeviceQueue");
-
- // clang-format on
-}
-
-DeviceFunctions::DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device) {
- vkGetDeviceProcAddr = vulkan_functions.vkGetDeviceProcAddr;
- vkDestroyDevice = load(device, "vkDestroyDevice");
- vkGetDeviceQueue = load(device, "vkGetDeviceQueue");
- vkCreateCommandPool = load(device, "vkCreateCommandPool");
- vkAllocateCommandBuffers = load(device, "vkAllocateCommandBuffers");
- vkDestroyCommandPool = load(device, "vkDestroyCommandPool");
- vkCreateSwapchainKHR = load(device, "vkCreateSwapchainKHR");
- vkGetSwapchainImagesKHR = load(device, "vkGetSwapchainImagesKHR");
- vkDestroySwapchainKHR = load(device, "vkDestroySwapchainKHR");
-}
-
InstanceCreateInfo::InstanceCreateInfo() {
instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
diff --git a/tests/framework/test_util.h b/tests/framework/test_util.h
index e958c1139..719b8e632 100644
--- a/tests/framework/test_util.h
+++ b/tests/framework/test_util.h
@@ -37,7 +37,6 @@
* LibraryWrapper - RAII wrapper for a library
* DispatchableHandle - RAII wrapper for vulkan dispatchable handle objects
* ostream overload for VkResult - prettifies googletest output
- * VulkanFunctions - loads vulkan functions for tests to use
* Instance & Device create info helpers
* operator == overloads for many vulkan structs - more concise tests
*/
@@ -642,144 +641,6 @@ struct MockQueueFamilyProperties {
VkQueueFamilyProperties get() const noexcept { return properties; }
};
-struct VulkanFunctions {
- LibraryWrapper loader;
-
- // Pre-Instance
- PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = nullptr;
- PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties = nullptr;
- PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties = nullptr;
- PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = nullptr;
- PFN_vkCreateInstance vkCreateInstance = nullptr;
-
- // Instance
- PFN_vkDestroyInstance vkDestroyInstance = nullptr;
- PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = nullptr;
- PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups = nullptr;
- PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures = nullptr;
- PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2 = nullptr;
- PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties = nullptr;
- PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties = nullptr;
- PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties = nullptr;
- PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = nullptr;
- PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = nullptr;
- PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties = nullptr;
- PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2 = nullptr;
- PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR = nullptr;
- PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR = nullptr;
- PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR = nullptr;
- PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR = nullptr;
- PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties = nullptr;
- PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties = nullptr;
- PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties = nullptr;
- PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties = nullptr;
- PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties = nullptr;
-
- PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr = nullptr;
- PFN_vkCreateDevice vkCreateDevice = nullptr;
- PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = nullptr;
- PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = nullptr;
-
- // WSI
- PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT = nullptr;
- PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR = nullptr;
- PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR = nullptr;
- PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR = nullptr;
- PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR = nullptr;
- PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR = nullptr;
- PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR = nullptr;
- PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR = nullptr;
- PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR = nullptr;
- PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR = nullptr;
- PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR = nullptr;
- PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR = nullptr;
- PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR = nullptr;
- PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR = nullptr;
- PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR = nullptr;
-
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
- PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = nullptr;
-#endif // VK_USE_PLATFORM_ANDROID_KHR
-#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
- PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT = nullptr;
- PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT = nullptr;
-#endif // VK_USE_PLATFORM_DIRECTFB_EXT
-#ifdef VK_USE_PLATFORM_FUCHSIA
- PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA = nullptr;
-#endif // VK_USE_PLATFORM_FUCHSIA
-#ifdef VK_USE_PLATFORM_GGP
- PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP = nullptr;
-#endif // VK_USE_PLATFORM_GGP
-#ifdef VK_USE_PLATFORM_IOS_MVK
- PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK = nullptr;
-#endif // VK_USE_PLATFORM_IOS_MVK
-#ifdef VK_USE_PLATFORM_MACOS_MVK
- PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK = nullptr;
-#endif // VK_USE_PLATFORM_MACOS_MVK
-#ifdef VK_USE_PLATFORM_METAL_EXT
- PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = nullptr;
-#endif // VK_USE_PLATFORM_METAL_EXT
-#ifdef VK_USE_PLATFORM_SCREEN_QNX
- PFN_vkCreateScreenSurfaceQNX vkCreateScreenSurfaceQNX = nullptr;
- PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX vkGetPhysicalDeviceScreenPresentationSupportQNX = nullptr;
-#endif // VK_USE_PLATFORM_SCREEN_QNX
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR = nullptr;
- PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR = nullptr;
-#endif // VK_USE_PLATFORM_WAYLAND_KHR
-#ifdef VK_USE_PLATFORM_XCB_KHR
- PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR = nullptr;
- PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR = nullptr;
-#endif // VK_USE_PLATFORM_XCB_KHR
-#ifdef VK_USE_PLATFORM_XLIB_KHR
- PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = nullptr;
- PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR = nullptr;
-#endif // VK_USE_PLATFORM_XLIB_KHR
-#ifdef VK_USE_PLATFORM_WIN32_KHR
- PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = nullptr;
- PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR = nullptr;
-#endif // VK_USE_PLATFORM_WIN32_KHR
- PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR = nullptr;
-
- // device functions
- PFN_vkDestroyDevice vkDestroyDevice = nullptr;
- PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
-
- VulkanFunctions();
-
- FromVoidStarFunc load(VkInstance inst, const char* func_name) const {
- return FromVoidStarFunc(vkGetInstanceProcAddr(inst, func_name));
- }
-
- FromVoidStarFunc load(VkDevice device, const char* func_name) const {
- return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
- }
-};
-
-struct DeviceFunctions {
- PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr = nullptr;
- PFN_vkDestroyDevice vkDestroyDevice = nullptr;
- PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
- PFN_vkCreateCommandPool vkCreateCommandPool = nullptr;
- PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = nullptr;
- PFN_vkDestroyCommandPool vkDestroyCommandPool = nullptr;
- PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = nullptr;
- PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR = nullptr;
- PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR = nullptr;
-
- DeviceFunctions() = default;
- DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device);
-
- FromVoidStarFunc load(VkDevice device, const char* func_name) const {
- return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
- }
-};
-
struct InstanceCreateInfo {
BUILDER_VALUE(InstanceCreateInfo, VkInstanceCreateInfo, instance_info, {})
BUILDER_VALUE(InstanceCreateInfo, VkApplicationInfo, application_info, {})