[PATCH vkd3d 6/8] tests: Load libvulkan dynamically in d3d12_crosstest.h.

Zebediah Figura zfigura at codeweavers.com
Mon Apr 18 20:28:46 CDT 2022


We would like to allow overriding the soname of libvulkan, in which case the
tests and demos should respect that override.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 Makefile.am             |  8 ++++----
 tests/d3d12_crosstest.h | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f7566d4b9..2da441c6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -306,10 +306,10 @@ TEST_EXTENSIONS = .shader_test
 if BUILD_TESTS
 check_PROGRAMS = $(vkd3d_tests) $(vkd3d_cross_tests) tests/shader_runner
 TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_tests)
-tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@
-tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@
-tests_hlsl_d3d12_LDADD = $(LDADD) @VULKAN_LIBS@
-tests_shader_runner_LDADD = $(LDADD) @VULKAN_LIBS@ @DL_LIBS@
+tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @DL_LIBS@
+tests_d3d12_invalid_usage_LDADD = $(LDADD) @DL_LIBS@
+tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@
+tests_shader_runner_LDADD = $(LDADD) @DL_LIBS@
 tests_shader_runner_SOURCES = \
 	tests/shader_runner.c \
 	tests/shader_runner_d3d12.c \
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h
index fc761809a..e6dc7a6c9 100644
--- a/tests/d3d12_crosstest.h
+++ b/tests/d3d12_crosstest.h
@@ -39,6 +39,7 @@
 typedef int HRESULT;
 #endif
 
+#define VK_NO_PROTOTYPES
 #define COBJMACROS
 #define CONST_VTABLE
 #define INITGUID
@@ -419,6 +420,11 @@ static inline bool is_depth_clip_enable_supported(ID3D12Device *device)
 
 #else
 
+#define DECLARE_VK_PFN(name) static PFN_##name name;
+DECLARE_VK_PFN(vkGetInstanceProcAddr)
+#define VK_INSTANCE_PFN   DECLARE_VK_PFN
+#include "vulkan_procs.h"
+
 static bool check_device_extension(VkPhysicalDevice vk_physical_device, const char *name)
 {
     VkExtensionProperties *properties;
@@ -585,8 +591,20 @@ static void init_adapter_info(void)
     VkPhysicalDeviceDriverPropertiesKHR driver_properties;
     struct vkd3d_instance *instance;
     ID3D12Device *device;
+    void *libvulkan;
     HRESULT hr;
 
+    if (!(libvulkan = vkd3d_dlopen(SONAME_LIBVULKAN)))
+    {
+        skip("Failed to load %s: %s.\n", SONAME_LIBVULKAN, vkd3d_dlerror());
+        return;
+    }
+
+#define LOAD_VK_PFN(name) name = vkd3d_dlsym(libvulkan, #name);
+LOAD_VK_PFN(vkGetInstanceProcAddr)
+#define VK_INSTANCE_PFN LOAD_VK_PFN
+#include "vulkan_procs.h"
+
     if (FAILED(hr = create_vkd3d_instance(&instance)))
         return;
 
-- 
2.35.1




More information about the wine-devel mailing list