vrclient: Load unwrappers from winevulkan.so.
This commit is contained in:
parent
1489a6a8d5
commit
74ae018197
1 changed files with 49 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define __USE_GNU
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winnls.h"
|
#include "winnls.h"
|
||||||
|
#include "winternl.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
#include "vrclient_defs.h"
|
#include "vrclient_defs.h"
|
||||||
|
@ -41,6 +43,8 @@ typedef struct winRenderModel_t_1168 winRenderModel_t_1168;
|
||||||
typedef struct winRenderModel_TextureMap_t_1168 winRenderModel_TextureMap_t_1168;
|
typedef struct winRenderModel_TextureMap_t_1168 winRenderModel_TextureMap_t_1168;
|
||||||
#include "cppIVRRenderModels_IVRRenderModels_006.h"
|
#include "cppIVRRenderModels_IVRRenderModels_006.h"
|
||||||
|
|
||||||
|
#include "wine/unixlib.h"
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
||||||
|
@ -370,9 +374,32 @@ static VkPhysicalDevice_T *(WINAPI *get_native_VkPhysicalDevice)(VkPhysicalDevic
|
||||||
static VkPhysicalDevice_T *(WINAPI *get_wrapped_VkPhysicalDevice)(VkInstance_T *, VkPhysicalDevice_T *);
|
static VkPhysicalDevice_T *(WINAPI *get_wrapped_VkPhysicalDevice)(VkInstance_T *, VkPhysicalDevice_T *);
|
||||||
static VkQueue_T *(WINAPI *get_native_VkQueue)(VkQueue_T *);
|
static VkQueue_T *(WINAPI *get_native_VkQueue)(VkQueue_T *);
|
||||||
|
|
||||||
|
static void *get_winevulkan_unix_lib_handle(HMODULE hvulkan)
|
||||||
|
{
|
||||||
|
unixlib_handle_t unix_funcs;
|
||||||
|
NTSTATUS status;
|
||||||
|
Dl_info info;
|
||||||
|
|
||||||
|
status = NtQueryVirtualMemory(GetCurrentProcess(), hvulkan, (MEMORY_INFORMATION_CLASS)1000 /*MemoryWineUnixFuncs*/,
|
||||||
|
&unix_funcs, sizeof(unix_funcs), NULL);
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
WINE_ERR("NtQueryVirtualMemory status %#x.\n", (int)status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!dladdr((void *)(ULONG_PTR)unix_funcs, &info))
|
||||||
|
{
|
||||||
|
WINE_ERR("dladdr failed.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
WINE_TRACE("path %s.\n", info.dli_fname);
|
||||||
|
return dlopen(info.dli_fname, RTLD_NOW);
|
||||||
|
}
|
||||||
|
|
||||||
static void load_vk_unwrappers(void)
|
static void load_vk_unwrappers(void)
|
||||||
{
|
{
|
||||||
static HMODULE h = NULL;
|
static HMODULE h = NULL;
|
||||||
|
void *unix_handle;
|
||||||
|
|
||||||
if(h)
|
if(h)
|
||||||
/* already loaded */
|
/* already loaded */
|
||||||
|
@ -384,11 +411,28 @@ static void load_vk_unwrappers(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_native_VkDevice = (void*)GetProcAddress(h, "__wine_get_native_VkDevice");
|
if (!(unix_handle = get_winevulkan_unix_lib_handle(h)))
|
||||||
get_native_VkInstance = (void*)GetProcAddress(h, "__wine_get_native_VkInstance");
|
{
|
||||||
get_native_VkPhysicalDevice = (void*)GetProcAddress(h, "__wine_get_native_VkPhysicalDevice");
|
ERR("Unable to open winevulkan.so.\n");
|
||||||
get_wrapped_VkPhysicalDevice = (void*)GetProcAddress(h, "__wine_get_wrapped_VkPhysicalDevice");
|
return;
|
||||||
get_native_VkQueue = (void*)GetProcAddress(h, "__wine_get_native_VkQueue");
|
}
|
||||||
|
|
||||||
|
#define L(name) \
|
||||||
|
if (!(name = dlsym(unix_handle, "__wine_"#name))) \
|
||||||
|
{\
|
||||||
|
ERR("%s not found.\n", #name);\
|
||||||
|
dlclose(unix_handle);\
|
||||||
|
return;\
|
||||||
|
}
|
||||||
|
|
||||||
|
L(get_native_VkDevice);
|
||||||
|
L(get_native_VkInstance);
|
||||||
|
L(get_native_VkPhysicalDevice);
|
||||||
|
L(get_wrapped_VkPhysicalDevice);
|
||||||
|
L(get_native_VkQueue);
|
||||||
|
#undef L
|
||||||
|
|
||||||
|
dlclose(unix_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_hmd_present_reg(void)
|
static bool is_hmd_present_reg(void)
|
||||||
|
|
Loading…
Reference in a new issue