vrclient: Use unixlib interface for C API functions.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-09-30 14:15:53 +02:00 committed by Arkadiusz Hiler
parent cf89fdf018
commit fd5711e93b
7 changed files with 61 additions and 15 deletions

View file

@ -214,6 +214,12 @@ all_versions = {}
unique_structs = []
UNIX_FUNCS = [
'vrclient_init',
'vrclient_HmdSystemFactory',
'vrclient_VRClientCoreFactory',
]
MANUAL_METHODS = {
"IVRClientCore_BIsHmdPresent": lambda ver, abi: abi == 'w',
"IVRClientCore_Init": lambda ver, abi: True,
@ -1583,6 +1589,8 @@ with open(u"vrclient_x64/unixlib_generated.h", "w") as file:
out(u'enum unix_funcs\n')
out(u'{\n')
for func in UNIX_FUNCS:
out(f' unix_{func},\n')
for klass, method in all_methods:
sdkver = klass._sdkver
if type(method) is Destructor:
@ -1604,6 +1612,8 @@ with open('vrclient_x64/unixlib_generated.cpp', 'w') as file:
out(u'extern "C" const unixlib_entry_t __wine_unix_call_funcs[] =\n')
out(u'{\n')
for func in UNIX_FUNCS:
out(f' {func},\n')
for klass, method in all_methods:
sdkver = klass._sdkver
if type(method) is Destructor:

View file

@ -25,6 +25,10 @@ extern VkQueue_T *(WINAPI *p_get_native_VkQueue)( VkQueue_T * );
extern char *json_convert_startup_info(const char *startup_info);
extern char *json_convert_paths(const char *input);
extern NTSTATUS vrclient_init( void *args );
extern NTSTATUS vrclient_HmdSystemFactory( void *args );
extern NTSTATUS vrclient_VRClientCoreFactory( void *args );
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

View file

@ -67,23 +67,28 @@ static void load_vk_unwrappers( HMODULE winevulkan )
dlclose(unix_handle);
}
bool unix_vrclient_init( struct vrclient_init_params *params )
NTSTATUS vrclient_init( void *args )
{
struct vrclient_init_params *params = (struct vrclient_init_params *)args;
static void *vrclient;
if (vrclient) return true;
if (vrclient)
{
params->_ret = true;
return 0;
}
if (!(vrclient = dlopen( params->unix_path, RTLD_NOW )))
{
TRACE( "unable to load %s\n", params->unix_path );
return false;
return -1;
}
#define LOAD_FUNC( x ) \
if (!(p_##x = (decltype(p_##x))dlsym( vrclient, #x ))) \
{ \
ERR( "unable to load " #x "\n" ); \
return false; \
return -1; \
}
LOAD_FUNC( HmdSystemFactory );
@ -92,15 +97,20 @@ bool unix_vrclient_init( struct vrclient_init_params *params )
#undef LOAD_FUNC
load_vk_unwrappers( params->winevulkan );
return true;
params->_ret = true;
return 0;
}
void *unix_HmdSystemFactory( const char *name, int *return_code )
NTSTATUS vrclient_HmdSystemFactory( void *args )
{
return p_HmdSystemFactory( name, return_code );
struct vrclient_HmdSystemFactory_params *params = (struct vrclient_HmdSystemFactory_params *)args;
params->_ret = p_HmdSystemFactory( params->name, params->return_code );
return 0;
}
void *unix_VRClientCoreFactory( const char *name, int *return_code )
NTSTATUS vrclient_VRClientCoreFactory( void *args )
{
return p_VRClientCoreFactory( name, return_code );
struct vrclient_VRClientCoreFactory_params *params = (struct vrclient_VRClientCoreFactory_params *)args;
params->_ret = p_VRClientCoreFactory( params->name, params->return_code );
return 0;
}

View file

@ -45,13 +45,24 @@ struct render_model_texture_map
struct vrclient_init_params
{
bool _ret;
HMODULE winevulkan;
char *unix_path;
};
extern bool unix_vrclient_init( struct vrclient_init_params *params );
extern void *unix_HmdSystemFactory( const char *name, int *return_code );
extern void *unix_VRClientCoreFactory( const char *name, int *return_code );
struct vrclient_HmdSystemFactory_params
{
void *_ret;
const char *name;
int *return_code;
};
struct vrclient_VRClientCoreFactory_params
{
void *_ret;
const char *name;
int *return_code;
};
typedef NTSTATUS (*unixlib_entry_t)( void *args );
extern const unixlib_entry_t __wine_unix_call_funcs[];

View file

@ -4,6 +4,9 @@
extern "C" const unixlib_entry_t __wine_unix_call_funcs[] =
{
vrclient_init,
vrclient_HmdSystemFactory,
vrclient_VRClientCoreFactory,
IVRApplications_IVRApplications_001_AddApplicationManifest,
IVRApplications_IVRApplications_001_RemoveApplicationManifest,
IVRApplications_IVRApplications_001_IsApplicationInstalled,

View file

@ -28859,6 +28859,9 @@ struct IVRTrackedCamera_IVRTrackedCamera_006_GetCameraTrackingSpace_params
enum unix_funcs
{
unix_vrclient_init,
unix_vrclient_HmdSystemFactory,
unix_vrclient_VRClientCoreFactory,
unix_IVRApplications_IVRApplications_001_AddApplicationManifest,
unix_IVRApplications_IVRApplications_001_RemoveApplicationManifest,
unix_IVRApplications_IVRApplications_001_IsApplicationInstalled,

View file

@ -260,7 +260,8 @@ static int load_vrclient(void)
TRACE( "got openvr runtime path: %s\n", params.unix_path );
if (unix_vrclient_init( &params )) loaded = TRUE;
VRCLIENT_CALL( vrclient_init, &params );
if (params._ret) loaded = TRUE;
HeapFree( GetProcessHeap(), 0, params.unix_path );
return loaded;
@ -268,16 +269,20 @@ static int load_vrclient(void)
void *CDECL HmdSystemFactory(const char *name, int *return_code)
{
struct vrclient_HmdSystemFactory_params params = {.name = name, .return_code = return_code};
TRACE("name: %s, return_code: %p\n", name, return_code);
if (!load_vrclient()) return NULL;
return create_win_interface( name, unix_HmdSystemFactory( name, return_code ) );
VRCLIENT_CALL( vrclient_HmdSystemFactory, &params );
return create_win_interface( name, params._ret );
}
void *CDECL VRClientCoreFactory(const char *name, int *return_code)
{
struct vrclient_VRClientCoreFactory_params params = {.name = name, .return_code = return_code};
TRACE("name: %s, return_code: %p\n", name, return_code);
if (!load_vrclient()) return NULL;
return create_win_interface( name, unix_VRClientCoreFactory( name, return_code ) );
VRCLIENT_CALL( vrclient_VRClientCoreFactory, &params );
return create_win_interface( name, params._ret );
}
static bool is_hmd_present_reg(void)