2023-10-19 12:38:31 +02:00
|
|
|
#include "unix_private.h"
|
|
|
|
|
2023-10-02 19:57:26 +02:00
|
|
|
#include <winternl.h>
|
2023-10-19 12:38:31 +02:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
2023-11-07 20:56:28 +01:00
|
|
|
#if 0
|
|
|
|
#pragma makedep unix
|
|
|
|
#endif
|
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
|
|
|
|
|
|
|
static void *(*p_HmdSystemFactory)( const char *name, int *return_code );
|
|
|
|
static void *(*p_VRClientCoreFactory)( const char *name, int *return_code );
|
|
|
|
|
2023-12-28 23:51:10 +01:00
|
|
|
VkDevice_T *(*p_get_native_VkDevice)( VkDevice_T * );
|
|
|
|
VkInstance_T *(*p_get_native_VkInstance)( VkInstance_T * );
|
|
|
|
VkPhysicalDevice_T *(*p_get_native_VkPhysicalDevice)( VkPhysicalDevice_T * );
|
|
|
|
VkPhysicalDevice_T *(*p_get_wrapped_VkPhysicalDevice)( VkInstance_T *, VkPhysicalDevice_T * );
|
|
|
|
VkQueue_T *(*p_get_native_VkQueue)( VkQueue_T * );
|
2023-10-02 19:57:26 +02:00
|
|
|
|
|
|
|
static void *get_winevulkan_unixlib( HMODULE winevulkan )
|
|
|
|
{
|
|
|
|
UINT64 unix_funcs;
|
|
|
|
NTSTATUS status;
|
|
|
|
Dl_info info;
|
|
|
|
|
|
|
|
status = NtQueryVirtualMemory( GetCurrentProcess(), winevulkan, (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 );
|
|
|
|
}
|
|
|
|
|
2023-12-28 23:54:02 +01:00
|
|
|
static BOOL load_vk_unwrappers( HMODULE winevulkan )
|
2023-10-02 19:57:26 +02:00
|
|
|
{
|
|
|
|
static HMODULE h = NULL;
|
|
|
|
void *unix_handle;
|
|
|
|
|
|
|
|
if (!(unix_handle = get_winevulkan_unixlib( winevulkan )))
|
|
|
|
{
|
|
|
|
ERR("Unable to open winevulkan.so.\n");
|
2023-12-28 23:54:02 +01:00
|
|
|
return FALSE;
|
2023-10-02 19:57:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_FUNC( name ) \
|
|
|
|
if (!(p_##name = (decltype(p_##name))dlsym( unix_handle, "__wine_" #name ))) \
|
|
|
|
{ \
|
|
|
|
ERR( "%s not found.\n", #name ); \
|
2023-12-28 23:54:02 +01:00
|
|
|
return FALSE; \
|
2023-10-02 19:57:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_FUNC( get_native_VkDevice )
|
|
|
|
LOAD_FUNC( get_native_VkInstance )
|
|
|
|
LOAD_FUNC( get_native_VkPhysicalDevice )
|
|
|
|
LOAD_FUNC( get_wrapped_VkPhysicalDevice )
|
|
|
|
LOAD_FUNC( get_native_VkQueue )
|
|
|
|
|
|
|
|
#undef LOAD_FUNC
|
|
|
|
|
|
|
|
dlclose(unix_handle);
|
2023-12-28 23:54:02 +01:00
|
|
|
return TRUE;
|
2023-10-02 19:57:26 +02:00
|
|
|
}
|
|
|
|
|
2024-02-10 01:20:52 +01:00
|
|
|
static void *vrclient;
|
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
NTSTATUS vrclient_init( void *args )
|
2023-10-19 12:38:31 +02:00
|
|
|
{
|
2023-09-30 14:15:53 +02:00
|
|
|
struct vrclient_init_params *params = (struct vrclient_init_params *)args;
|
2023-10-19 12:38:31 +02:00
|
|
|
|
2024-02-02 22:11:46 +01:00
|
|
|
params->_ret = false;
|
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
if (vrclient)
|
|
|
|
{
|
|
|
|
params->_ret = true;
|
|
|
|
return 0;
|
|
|
|
}
|
2023-10-19 12:38:31 +02:00
|
|
|
|
|
|
|
if (!(vrclient = dlopen( params->unix_path, RTLD_NOW )))
|
|
|
|
{
|
|
|
|
TRACE( "unable to load %s\n", params->unix_path );
|
2024-02-02 22:11:46 +01:00
|
|
|
return 0;
|
2023-10-19 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_FUNC( x ) \
|
|
|
|
if (!(p_##x = (decltype(p_##x))dlsym( vrclient, #x ))) \
|
|
|
|
{ \
|
|
|
|
ERR( "unable to load " #x "\n" ); \
|
2024-02-02 22:11:46 +01:00
|
|
|
return 0; \
|
2023-10-19 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_FUNC( HmdSystemFactory );
|
|
|
|
LOAD_FUNC( VRClientCoreFactory );
|
|
|
|
|
2023-10-02 19:57:26 +02:00
|
|
|
#undef LOAD_FUNC
|
|
|
|
|
2023-12-28 23:54:02 +01:00
|
|
|
if (!load_vk_unwrappers( params->winevulkan ))
|
2024-02-02 22:11:46 +01:00
|
|
|
return 0;
|
2023-12-28 23:54:02 +01:00
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
params->_ret = true;
|
|
|
|
return 0;
|
2024-02-10 01:20:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS vrclient_unload( void *args )
|
|
|
|
{
|
|
|
|
if (!vrclient) return 0;
|
|
|
|
dlclose( vrclient );
|
|
|
|
vrclient = NULL;
|
|
|
|
p_HmdSystemFactory = NULL;
|
|
|
|
p_VRClientCoreFactory = NULL;
|
|
|
|
return 0;
|
2023-10-19 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
NTSTATUS vrclient_HmdSystemFactory( void *args )
|
2023-10-19 12:38:31 +02:00
|
|
|
{
|
2023-09-30 14:15:53 +02:00
|
|
|
struct vrclient_HmdSystemFactory_params *params = (struct vrclient_HmdSystemFactory_params *)args;
|
|
|
|
params->_ret = p_HmdSystemFactory( params->name, params->return_code );
|
|
|
|
return 0;
|
2023-10-19 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
NTSTATUS vrclient_VRClientCoreFactory( void *args )
|
2023-10-19 12:38:31 +02:00
|
|
|
{
|
2023-09-30 14:15:53 +02:00
|
|
|
struct vrclient_VRClientCoreFactory_params *params = (struct vrclient_VRClientCoreFactory_params *)args;
|
|
|
|
params->_ret = p_VRClientCoreFactory( params->name, params->return_code );
|
|
|
|
return 0;
|
2023-10-19 12:38:31 +02:00
|
|
|
}
|
2023-10-05 14:28:29 +02:00
|
|
|
|
|
|
|
NTSTATUS IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame( void *args )
|
|
|
|
{
|
|
|
|
struct IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame_params *params = (struct IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame_params *)args;
|
|
|
|
struct u_IVRTrackedCamera_IVRTrackedCamera_001 *iface = (struct u_IVRTrackedCamera_IVRTrackedCamera_001 *)params->linux_side;
|
|
|
|
*(w_CameraVideoStreamFrame_t_0914 *)params->_ret = *iface->GetVideoStreamFrame( params->nDeviceIndex );
|
|
|
|
return 0;
|
|
|
|
}
|