mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Do not require dlfcn.
For Windows builds. Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
143f25b12e
commit
4cdbcbd85f
@ -54,7 +54,8 @@ VKD3D_CHECK_MINGW32_PROG([CROSSCC32], [CROSSTARGET32], [no])
|
||||
VKD3D_CHECK_MINGW64_PROG([CROSSCC64], [CROSSTARGET64], [no])
|
||||
|
||||
dnl Check for headers
|
||||
AC_CHECK_HEADERS([pthread.h vulkan/vulkan.h \
|
||||
AC_CHECK_HEADERS([dlfcn.h pthread.h \
|
||||
vulkan/vulkan.h \
|
||||
vulkan/spirv.h vulkan/GLSL.std.450.h \
|
||||
spirv/unified1/spirv.h spirv/unified1/GLSL.std.450.h])
|
||||
AS_IF([test "x$ac_cv_header_pthread_h" != "xyes"], [AC_MSG_ERROR([pthread.h not found.])])
|
||||
@ -76,7 +77,7 @@ AC_CHECK_LIB([m], [ceilf])
|
||||
AC_ARG_VAR([DL_LIBS], [linker flags for dl])
|
||||
AC_CHECK_LIB([dl], [dlopen],
|
||||
[AC_SUBST([DL_LIBS], ["-ldl"])],
|
||||
[AC_MSG_ERROR([libdl not found.])])
|
||||
[AS_IF([test "$ac_cv_header_dlfnc_h" = "xyes"], [AC_MSG_ERROR([libdl not found.])])])
|
||||
|
||||
AC_ARG_VAR([PTHREAD_LIBS], [linker flags for pthreads])
|
||||
AC_CHECK_LIB([pthread], [pthread_create],
|
||||
|
@ -18,8 +18,51 @@
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void *vkd3d_dlopen(const char *name)
|
||||
{
|
||||
return dlopen(name, RTLD_NOW);
|
||||
}
|
||||
|
||||
static void *vkd3d_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return dlsym(handle, symbol);
|
||||
}
|
||||
|
||||
static int vkd3d_dlclose(void *handle)
|
||||
{
|
||||
return dlclose(handle);
|
||||
}
|
||||
|
||||
static const char *vkd3d_dlerror(void)
|
||||
{
|
||||
return dlerror();
|
||||
}
|
||||
#else
|
||||
static void *vkd3d_dlopen(const char *name)
|
||||
{
|
||||
FIXME("Not implemented for this platform.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *vkd3d_dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int vkd3d_dlclose(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *vkd3d_dlerror(void)
|
||||
{
|
||||
return "Not implemented for this platform.\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
struct vkd3d_struct
|
||||
{
|
||||
enum vkd3d_structure_type type;
|
||||
@ -321,16 +364,16 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance,
|
||||
|
||||
if (!vkGetInstanceProcAddr)
|
||||
{
|
||||
if (!(instance->libvulkan = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
|
||||
if (!(instance->libvulkan = vkd3d_dlopen(SONAME_LIBVULKAN)))
|
||||
{
|
||||
ERR("Failed to load libvulkan: %s.\n", dlerror());
|
||||
ERR("Failed to load libvulkan: %s.\n", vkd3d_dlerror());
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (!(vkGetInstanceProcAddr = dlsym(instance->libvulkan, "vkGetInstanceProcAddr")))
|
||||
if (!(vkGetInstanceProcAddr = vkd3d_dlsym(instance->libvulkan, "vkGetInstanceProcAddr")))
|
||||
{
|
||||
ERR("Could not load function pointer for vkGetInstanceProcAddr().\n");
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
instance->libvulkan = NULL;
|
||||
return E_FAIL;
|
||||
}
|
||||
@ -343,7 +386,7 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance,
|
||||
if (FAILED(hr = vkd3d_load_vk_global_procs(&instance->vk_global_procs, vkGetInstanceProcAddr)))
|
||||
{
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
instance->libvulkan = NULL;
|
||||
return hr;
|
||||
}
|
||||
@ -428,7 +471,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
|
||||
&extension_count, &user_extension_supported)))
|
||||
{
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -443,7 +486,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
|
||||
if (!(extensions = vkd3d_calloc(extension_count, sizeof(*extensions))))
|
||||
{
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
vkd3d_free(user_extension_supported);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
@ -471,7 +514,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
|
||||
{
|
||||
ERR("Failed to create Vulkan instance, vr %d.\n", vr);
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
return hresult_from_vk_result(vr);
|
||||
}
|
||||
|
||||
@ -481,7 +524,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
|
||||
if (instance->vk_procs.vkDestroyInstance)
|
||||
instance->vk_procs.vkDestroyInstance(vk_instance, NULL);
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -541,7 +584,7 @@ static void vkd3d_destroy_instance(struct vkd3d_instance *instance)
|
||||
VK_CALL(vkDestroyInstance(vk_instance, NULL));
|
||||
|
||||
if (instance->libvulkan)
|
||||
dlclose(instance->libvulkan);
|
||||
vkd3d_dlclose(instance->libvulkan);
|
||||
|
||||
vkd3d_free(instance);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user