From 0e5e3a726bd69e83b9c24da1600a2b067761c86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 27 Sep 2023 09:09:37 +0200 Subject: [PATCH] vrclient: Use manual methods instead of generated wrappers. CW-Bug-Id: #22729 --- vrclient_x64/gen_wrapper.py | 88 +------------ vrclient_x64/vrclient_x64/vrclient_main.c | 127 ++++++++++++++----- vrclient_x64/vrclient_x64/vrclient_private.h | 16 --- vrclient_x64/vrclient_x64/winIVRClientCore.c | 60 ++------- vrclient_x64/vrclient_x64/winIVRMailbox.c | 8 +- 5 files changed, 109 insertions(+), 190 deletions(-) diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index 7f0517aa..b974f6af 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -255,6 +255,10 @@ all_versions = {} MANUAL_METHODS = { + "IVRClientCore_BIsHmdPresent": True, + "IVRClientCore_Init": True, + "IVRClientCore_GetGenericInterface": True, + "IVRClientCore_Cleanup": True, "IVRSystem_GetDXGIOutputInfo": True, "IVRSystem_GetOutputDevice": lambda ver, abi: ver > 16, "IVRCompositor_Submit": lambda ver, abi: ver > 8, @@ -265,6 +269,7 @@ MANUAL_METHODS = { "IVRRenderModels_LoadTextureD3D11_Async": True, "IVRRenderModels_FreeTextureD3D11": True, "IVRRenderModels_LoadIntoTextureD3D11_Async": True, + "IVRMailbox_undoc3": True, "IVROverlay_SetOverlayTexture": True, "IVRInput_GetDigitalActionData": lambda ver, abi: ver > 3, } @@ -281,64 +286,6 @@ def is_manual_method(klass, method, abi): return needs_manual -def ivrclientcore_is_hmd_present(cppname, method): - return "ivrclientcore_is_hmd_present" - -def ivrclientcore_init(cppname, method): - if "002" in cppname: - return "ivrclientcore_002_init" - return "ivrclientcore_init" - -def ivrclientcore_get_generic_interface(cppname, method): - return "ivrclientcore_get_generic_interface" - -def ivrclientcore_cleanup(cppname, method): - return "ivrclientcore_cleanup" - -def ivrmailbox_undoc3(cppname, method): - assert "001" in cppname - return "ivrmailbox_undoc3" - -def ivroverlay_set_overlay_texture(cppname, method): - if "001" in cppname: - return "ivroverlay_001_set_overlay_texture" - for version in ["002", "003", "004", "005"]: - if version in cppname: - return "ivroverlay_005_set_overlay_texture" - assert \ - "007" in cppname or \ - "008" in cppname or \ - "010" in cppname or \ - "011" in cppname or \ - "012" in cppname or \ - "013" in cppname or \ - "014" in cppname or \ - "016" in cppname or \ - "017" in cppname or \ - "018" in cppname or \ - "019" in cppname or \ - "020" in cppname or \ - "021" in cppname or \ - "022" in cppname or \ - "024" in cppname or \ - "025" in cppname or \ - "026" in cppname or \ - "027" in cppname - return "ivroverlay_set_overlay_texture" - -method_overrides = [ - ("IVRClientCore", "BIsHmdPresent", ivrclientcore_is_hmd_present), - ("IVRClientCore", "Init", ivrclientcore_init), - ("IVRClientCore", "GetGenericInterface", ivrclientcore_get_generic_interface), - ("IVRClientCore", "Cleanup", ivrclientcore_cleanup), - ("IVRMailbox", "undoc3", ivrmailbox_undoc3), -] - -method_overrides_data = [ - ("IVRClientCore", "struct client_core_data", None), -] - - class Method: def __init__(self, sdkver, abi, cursor, index, override): self._sdkver = sdkver @@ -676,16 +623,7 @@ def handle_method_c(klass, method, winclassname, cppname, out): else: out(u' ') - is_method_overridden = False - for classname_pattern, methodname, override_generator in method_overrides: - if method.name == methodname and classname_pattern in klass.spelling: - fn_name = override_generator(cppname, method) - if fn_name: - out("%s(%s_%s, " % (fn_name, cppname, method.name)) - is_method_overridden = True - break - else: - out(f'{cppname}_{method.name}(') + out(f'{cppname}_{method.name}(') def param_call(param, name): if name == '_this': return '_this->u_iface' @@ -695,12 +633,6 @@ def handle_method_c(klass, method, winclassname, cppname, out): params = ['_this'] + list(method.get_arguments()) out(", ".join([param_call(p, n) for p, n in zip(params, names)])) - if is_method_overridden: - out(f', {klass.version[klass.version.find("_") + 1:].lstrip("0")}') - for classname_pattern, user_data_type, _ in method_overrides_data: - if classname_pattern in klass.spelling: - out(u', &_this->user_data') - break out(u');\n') if path_conv and len(path_conv["l2w_names"]) > 0: @@ -818,10 +750,6 @@ def handle_class(klass): out(f'void destroy_{winclassname}(struct w_steam_iface *object)\n') out(u'{\n') out(u' TRACE("%p\\n", object);\n') - for classname_pattern, user_data_type, user_data_destructor in method_overrides_data: - if user_data_destructor and classname_pattern in klass.spelling: - out(f' {user_data_destructor}(&object->user_data);\n') - break out(u' HeapFree(GetProcessHeap(), 0, object);\n') out(u'}\n\n') @@ -848,10 +776,6 @@ def handle_class(klass): out(f'void destroy_{winclassname}_FnTable(struct w_steam_iface *object)\n') out(u'{\n') out(u' TRACE("%p\\n", object);\n') - for classname_pattern, user_data_type, user_data_destructor in method_overrides_data: - if user_data_destructor and classname_pattern in klass.spelling: - out(f' {user_data_destructor}(&object->user_data);\n') - break out(u' VirtualFree(object->vtable[0], 0, MEM_RELEASE);\n') out(u' HeapFree(GetProcessHeap(), 0, object->vtable);\n') out(u' HeapFree(GetProcessHeap(), 0, object);\n') diff --git a/vrclient_x64/vrclient_x64/vrclient_main.c b/vrclient_x64/vrclient_x64/vrclient_main.c index 92cc9053..ac493317 100644 --- a/vrclient_x64/vrclient_x64/vrclient_main.c +++ b/vrclient_x64/vrclient_x64/vrclient_main.c @@ -22,7 +22,10 @@ #include "flatapi.h" +#include "struct_converters.h" +#include "cppIVRClientCore_IVRClientCore_002.h" #include "cppIVRClientCore_IVRClientCore_003.h" +#include "cppIVRMailbox_IVRMailbox_001.h" #include "wine/unixlib.h" @@ -499,8 +502,8 @@ done: return is_hmd_present; } -bool ivrclientcore_is_hmd_present(bool (*cpp_func)(void *), void *linux_side, unsigned int version, - struct client_core_data *user_data) +static bool ivrclientcore_is_hmd_present( bool (*cpp_func)( void * ), void *linux_side, + unsigned int version, struct client_core_data *user_data ) { TRACE("linux_side %p, compositor_data.client_core_linux_side %p.\n", linux_side, compositor_data.client_core_linux_side); @@ -513,25 +516,9 @@ bool ivrclientcore_is_hmd_present(bool (*cpp_func)(void *), void *linux_side, un return TRUE; } -EVRInitError ivrclientcore_002_init(EVRInitError (*cpp_func)(void *, EVRApplicationType), - void *linux_side, EVRApplicationType application_type, - unsigned int version, struct client_core_data *user_data) -{ - EVRInitError error; - - TRACE("%p, %#x\n", linux_side, application_type); - - InitializeCriticalSection(&user_data->critical_section); - - error = cpp_func(linux_side, application_type); - if (error) - WARN("error %#x\n", error); - return error; -} - -EVRInitError ivrclientcore_init(EVRInitError (*cpp_func)(void *, EVRApplicationType, const char *), - void *linux_side, EVRApplicationType application_type, const char *startup_info, - unsigned int version, struct client_core_data *user_data) +static EVRInitError ivrclientcore_init( EVRInitError (*cpp_func)( void *, EVRApplicationType, const char * ), + void *linux_side, EVRApplicationType application_type, const char *startup_info, + unsigned int version, struct client_core_data *user_data ) { char *startup_info_converted; EVRInitError error; @@ -554,9 +541,9 @@ EVRInitError ivrclientcore_init(EVRInitError (*cpp_func)(void *, EVRApplicationT return error; } -void *ivrclientcore_get_generic_interface(void *(*cpp_func)(void *, const char *, EVRInitError *), - void *linux_side, const char *name_and_version, EVRInitError *error, - unsigned int version, struct client_core_data *user_data) +static void *ivrclientcore_get_generic_interface( void *(*cpp_func)( void *, const char *, EVRInitError *), + void *linux_side, const char *name_and_version, EVRInitError *error, + unsigned int version, struct client_core_data *user_data ) { const char *cpp_name_and_version = name_and_version; struct w_steam_iface *win_object; @@ -612,8 +599,8 @@ static void destroy_compositor_data(void) memset(&compositor_data, 0, sizeof(compositor_data)); } -void ivrclientcore_cleanup(void (*cpp_func)(void *), void *linux_side, - unsigned int version, struct client_core_data *user_data) +static void ivrclientcore_cleanup( void (*cpp_func)( void * ), void *linux_side, + unsigned int version, struct client_core_data *user_data ) { struct generic_interface *iface; SIZE_T i; @@ -675,17 +662,91 @@ Texture_t vrclient_translate_texture_dxvk( const Texture_t *texture, struct VRVu return vktexture; } - -vrmb_typeb ivrmailbox_undoc3( - vrmb_typeb (*cpp_func)(void *, vrmb_typea, const char *, const char *), - void *linux_side, vrmb_typea a, const char *b, const char *c, unsigned int version) +EVRInitError __thiscall winIVRClientCore_IVRClientCore_002_Init( struct w_steam_iface *_this, EVRApplicationType eApplicationType ) +{ + EVRInitError _ret; + + TRACE( "%p\n", _this ); + + InitializeCriticalSection( &_this->user_data.critical_section ); + + _ret = cppIVRClientCore_IVRClientCore_002_Init( _this->u_iface, eApplicationType ); + if (_ret) WARN( "error %#x\n", _ret ); + return _ret; +} + +void __thiscall winIVRClientCore_IVRClientCore_002_Cleanup( struct w_steam_iface *_this ) +{ + TRACE( "%p\n", _this ); + ivrclientcore_cleanup( cppIVRClientCore_IVRClientCore_002_Cleanup, _this->u_iface, 2, &_this->user_data ); +} + +void *__thiscall winIVRClientCore_IVRClientCore_002_GetGenericInterface( struct w_steam_iface *_this, + const char *pchNameAndVersion, EVRInitError *peError ) +{ + void *_ret; + TRACE( "%p\n", _this ); + _ret = ivrclientcore_get_generic_interface( cppIVRClientCore_IVRClientCore_002_GetGenericInterface, + _this->u_iface, pchNameAndVersion, peError, 2, + &_this->user_data ); + return _ret; +} + +bool __thiscall winIVRClientCore_IVRClientCore_002_BIsHmdPresent( struct w_steam_iface *_this ) +{ + bool _ret; + TRACE( "%p\n", _this ); + _ret = ivrclientcore_is_hmd_present( cppIVRClientCore_IVRClientCore_002_BIsHmdPresent, + _this->u_iface, 2, &_this->user_data ); + return _ret; +} + +EVRInitError __thiscall winIVRClientCore_IVRClientCore_003_Init( struct w_steam_iface *_this, EVRApplicationType eApplicationType, + const char *pStartupInfo ) +{ + EVRInitError _ret; + TRACE( "%p\n", _this ); + _ret = ivrclientcore_init( cppIVRClientCore_IVRClientCore_003_Init, _this->u_iface, + eApplicationType, pStartupInfo, 3, &_this->user_data ); + return _ret; +} + +void __thiscall winIVRClientCore_IVRClientCore_003_Cleanup( struct w_steam_iface *_this ) +{ + TRACE( "%p\n", _this ); + ivrclientcore_cleanup( cppIVRClientCore_IVRClientCore_003_Cleanup, _this->u_iface, 3, &_this->user_data ); +} + +void *__thiscall winIVRClientCore_IVRClientCore_003_GetGenericInterface( struct w_steam_iface *_this, + const char *pchNameAndVersion, EVRInitError *peError ) +{ + void *_ret; + TRACE( "%p\n", _this ); + _ret = ivrclientcore_get_generic_interface( cppIVRClientCore_IVRClientCore_003_GetGenericInterface, + _this->u_iface, pchNameAndVersion, peError, 3, + &_this->user_data ); + return _ret; +} + +bool __thiscall winIVRClientCore_IVRClientCore_003_BIsHmdPresent( struct w_steam_iface *_this ) +{ + bool _ret; + TRACE( "%p\n", _this ); + _ret = ivrclientcore_is_hmd_present( cppIVRClientCore_IVRClientCore_003_BIsHmdPresent, + _this->u_iface, 3, &_this->user_data ); + return _ret; +} + +vrmb_typeb __thiscall winIVRMailbox_IVRMailbox_001_undoc3( struct w_steam_iface *_this, vrmb_typea a, + const char *b, const char *c ) { - vrmb_typeb r; char *converted = json_convert_paths(c); + vrmb_typeb _ret; - r = cpp_func(linux_side, a, b, converted ? converted : c); + TRACE( "%p\n", _this ); + _ret = cppIVRMailbox_IVRMailbox_001_undoc3( _this->u_iface, a, b, c ); free(converted); - return r; + return _ret; } diff --git a/vrclient_x64/vrclient_x64/vrclient_private.h b/vrclient_x64/vrclient_x64/vrclient_private.h index 3a7c7da9..d47087ff 100644 --- a/vrclient_x64/vrclient_x64/vrclient_private.h +++ b/vrclient_x64/vrclient_x64/vrclient_private.h @@ -106,22 +106,6 @@ struct generic_interface void (*dtor)(struct w_steam_iface *); }; -bool ivrclientcore_is_hmd_present(bool (*cpp_func)(void *), void *linux_side, unsigned int version, - struct client_core_data *user_data); -EVRInitError ivrclientcore_002_init(EVRInitError (*cpp_func)(void *, EVRApplicationType), - void *linux_side, EVRApplicationType application_type, - unsigned int version, struct client_core_data *user_data); -EVRInitError ivrclientcore_init(EVRInitError (*cpp_func)(void *, EVRApplicationType, const char *), - void *linux_side, EVRApplicationType application_type, const char *startup_info, - unsigned int version, struct client_core_data *user_data); - -void *ivrclientcore_get_generic_interface(void *(*cpp_func)(void *, const char *, EVRInitError *), - void *linux_side, const char *name_and_version, EVRInitError *error, - unsigned int version, struct client_core_data *user_data); - -void ivrclientcore_cleanup(void (*cpp_func)(void *), void *linux_side, - unsigned int version, struct client_core_data *user_data); - #ifdef __dxvk_interop_h__ extern Texture_t vrclient_translate_texture_dxvk( const Texture_t *texture, struct VRVulkanTextureData_t *vkdata, IDXGIVkInteropSurface *dxvk_surface, IDXGIVkInteropDevice **p_dxvk_device, diff --git a/vrclient_x64/vrclient_x64/winIVRClientCore.c b/vrclient_x64/vrclient_x64/winIVRClientCore.c index d1065173..8a082e40 100644 --- a/vrclient_x64/vrclient_x64/winIVRClientCore.c +++ b/vrclient_x64/vrclient_x64/winIVRClientCore.c @@ -26,19 +26,9 @@ DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_002_BIsHmdPresent, 4) DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_002_GetEnglishStringForHmdError, 8) DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_002_GetIDForVRInitError, 8) -EVRInitError __thiscall winIVRClientCore_IVRClientCore_002_Init(struct w_steam_iface *_this, EVRApplicationType eApplicationType) -{ - EVRInitError _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_002_init(cppIVRClientCore_IVRClientCore_002_Init, _this->u_iface, eApplicationType, 2, &_this->user_data); - return _ret; -} +extern EVRInitError __thiscall winIVRClientCore_IVRClientCore_002_Init(struct w_steam_iface *_this, EVRApplicationType eApplicationType); -void __thiscall winIVRClientCore_IVRClientCore_002_Cleanup(struct w_steam_iface *_this) -{ - TRACE("%p\n", _this); - ivrclientcore_cleanup(cppIVRClientCore_IVRClientCore_002_Cleanup, _this->u_iface, 2, &_this->user_data); -} +extern void __thiscall winIVRClientCore_IVRClientCore_002_Cleanup(struct w_steam_iface *_this); EVRInitError __thiscall winIVRClientCore_IVRClientCore_002_IsInterfaceVersionValid(struct w_steam_iface *_this, const char *pchInterfaceVersion) { @@ -48,21 +38,9 @@ EVRInitError __thiscall winIVRClientCore_IVRClientCore_002_IsInterfaceVersionVal return _ret; } -void * __thiscall winIVRClientCore_IVRClientCore_002_GetGenericInterface(struct w_steam_iface *_this, const char *pchNameAndVersion, EVRInitError *peError) -{ - void * _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_get_generic_interface(cppIVRClientCore_IVRClientCore_002_GetGenericInterface, _this->u_iface, pchNameAndVersion, peError, 2, &_this->user_data); - return _ret; -} +extern void * __thiscall winIVRClientCore_IVRClientCore_002_GetGenericInterface(struct w_steam_iface *_this, const char *pchNameAndVersion, EVRInitError *peError); -bool __thiscall winIVRClientCore_IVRClientCore_002_BIsHmdPresent(struct w_steam_iface *_this) -{ - bool _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_is_hmd_present(cppIVRClientCore_IVRClientCore_002_BIsHmdPresent, _this->u_iface, 2, &_this->user_data); - return _ret; -} +extern bool __thiscall winIVRClientCore_IVRClientCore_002_BIsHmdPresent(struct w_steam_iface *_this); const char * __thiscall winIVRClientCore_IVRClientCore_002_GetEnglishStringForHmdError(struct w_steam_iface *_this, EVRInitError eError) { @@ -153,19 +131,9 @@ DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_003_BIsHmdPresent, 4) DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_003_GetEnglishStringForHmdError, 8) DEFINE_THISCALL_WRAPPER(winIVRClientCore_IVRClientCore_003_GetIDForVRInitError, 8) -EVRInitError __thiscall winIVRClientCore_IVRClientCore_003_Init(struct w_steam_iface *_this, EVRApplicationType eApplicationType, const char *pStartupInfo) -{ - EVRInitError _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_init(cppIVRClientCore_IVRClientCore_003_Init, _this->u_iface, eApplicationType, pStartupInfo, 3, &_this->user_data); - return _ret; -} +extern EVRInitError __thiscall winIVRClientCore_IVRClientCore_003_Init(struct w_steam_iface *_this, EVRApplicationType eApplicationType, const char *pStartupInfo); -void __thiscall winIVRClientCore_IVRClientCore_003_Cleanup(struct w_steam_iface *_this) -{ - TRACE("%p\n", _this); - ivrclientcore_cleanup(cppIVRClientCore_IVRClientCore_003_Cleanup, _this->u_iface, 3, &_this->user_data); -} +extern void __thiscall winIVRClientCore_IVRClientCore_003_Cleanup(struct w_steam_iface *_this); EVRInitError __thiscall winIVRClientCore_IVRClientCore_003_IsInterfaceVersionValid(struct w_steam_iface *_this, const char *pchInterfaceVersion) { @@ -175,21 +143,9 @@ EVRInitError __thiscall winIVRClientCore_IVRClientCore_003_IsInterfaceVersionVal return _ret; } -void * __thiscall winIVRClientCore_IVRClientCore_003_GetGenericInterface(struct w_steam_iface *_this, const char *pchNameAndVersion, EVRInitError *peError) -{ - void * _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_get_generic_interface(cppIVRClientCore_IVRClientCore_003_GetGenericInterface, _this->u_iface, pchNameAndVersion, peError, 3, &_this->user_data); - return _ret; -} +extern void * __thiscall winIVRClientCore_IVRClientCore_003_GetGenericInterface(struct w_steam_iface *_this, const char *pchNameAndVersion, EVRInitError *peError); -bool __thiscall winIVRClientCore_IVRClientCore_003_BIsHmdPresent(struct w_steam_iface *_this) -{ - bool _ret; - TRACE("%p\n", _this); - _ret = ivrclientcore_is_hmd_present(cppIVRClientCore_IVRClientCore_003_BIsHmdPresent, _this->u_iface, 3, &_this->user_data); - return _ret; -} +extern bool __thiscall winIVRClientCore_IVRClientCore_003_BIsHmdPresent(struct w_steam_iface *_this); const char * __thiscall winIVRClientCore_IVRClientCore_003_GetEnglishStringForHmdError(struct w_steam_iface *_this, EVRInitError eError) { diff --git a/vrclient_x64/vrclient_x64/winIVRMailbox.c b/vrclient_x64/vrclient_x64/winIVRMailbox.c index 52a931fe..ddd20a8a 100644 --- a/vrclient_x64/vrclient_x64/winIVRMailbox.c +++ b/vrclient_x64/vrclient_x64/winIVRMailbox.c @@ -39,13 +39,7 @@ vrmb_typeb __thiscall winIVRMailbox_IVRMailbox_001_undoc2(struct w_steam_iface * return _ret; } -vrmb_typeb __thiscall winIVRMailbox_IVRMailbox_001_undoc3(struct w_steam_iface *_this, vrmb_typea a, const char *b, const char *c) -{ - vrmb_typeb _ret; - TRACE("%p\n", _this); - _ret = ivrmailbox_undoc3(cppIVRMailbox_IVRMailbox_001_undoc3, _this->u_iface, a, b, c, 1); - return _ret; -} +extern vrmb_typeb __thiscall winIVRMailbox_IVRMailbox_001_undoc3(struct w_steam_iface *_this, vrmb_typea a, const char *b, const char *c); vrmb_typeb __thiscall winIVRMailbox_IVRMailbox_001_undoc4(struct w_steam_iface *_this, vrmb_typea a, char *b, uint32_t c, uint32_t *d) {