tests: Load libvulkan dynamically in shader_runner_vulkan.c.

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@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-04-18 20:28:45 -05:00 committed by Alexandre Julliard
parent bcad6d6997
commit beffe5f367
2 changed files with 12 additions and 1 deletions

View File

@ -309,7 +309,7 @@ TESTS = $(vkd3d_tests) $(vkd3d_cross_tests) $(vkd3d_shader_tests)
tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@ tests_d3d12_LDADD = $(LDADD) @PTHREAD_LIBS@ @VULKAN_LIBS@
tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@ tests_d3d12_invalid_usage_LDADD = $(LDADD) @VULKAN_LIBS@
tests_hlsl_d3d12_LDADD = $(LDADD) @VULKAN_LIBS@ tests_hlsl_d3d12_LDADD = $(LDADD) @VULKAN_LIBS@
tests_shader_runner_LDADD = $(LDADD) @VULKAN_LIBS@ tests_shader_runner_LDADD = $(LDADD) @VULKAN_LIBS@ @DL_LIBS@
tests_shader_runner_SOURCES = \ tests_shader_runner_SOURCES = \
tests/shader_runner.c \ tests/shader_runner.c \
tests/shader_runner_d3d12.c \ tests/shader_runner_d3d12.c \

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#define VK_NO_PROTOTYPES
#include "config.h" #include "config.h"
#include "vulkan/vulkan.h" #include "vulkan/vulkan.h"
#include "vkd3d_shader.h" #include "vkd3d_shader.h"
@ -45,6 +46,8 @@ static struct vulkan_resource *vulkan_resource(struct resource *r)
#define DECLARE_VK_PFN(name) PFN_##name name; #define DECLARE_VK_PFN(name) PFN_##name name;
DECLARE_VK_PFN(vkGetInstanceProcAddr)
struct vulkan_shader_runner struct vulkan_shader_runner
{ {
struct shader_runner r; struct shader_runner r;
@ -984,8 +987,16 @@ static bool init_vulkan_runner(struct vulkan_shader_runner *runner)
VkFormatProperties format_props; VkFormatProperties format_props;
uint32_t count, graphics_index; uint32_t count, graphics_index;
VkDevice device; VkDevice device;
void *libvulkan;
VkResult vr; VkResult vr;
if (!(libvulkan = vkd3d_dlopen(SONAME_LIBVULKAN)))
{
skip("Failed to load %s: %s.\n", SONAME_LIBVULKAN, vkd3d_dlerror());
return false;
}
vkGetInstanceProcAddr = vkd3d_dlsym(libvulkan, "vkGetInstanceProcAddr");
runner->vkCreateInstance = (void *)vkGetInstanceProcAddr(NULL, "vkCreateInstance"); runner->vkCreateInstance = (void *)vkGetInstanceProcAddr(NULL, "vkCreateInstance");
if ((vr = VK_CALL(vkCreateInstance(&instance_desc, NULL, &runner->instance))) < 0) if ((vr = VK_CALL(vkCreateInstance(&instance_desc, NULL, &runner->instance))) < 0)