2018-01-18 20:29:49 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2022-12-13 19:55:47 +01:00
|
|
|
#include "winternl.h"
|
2018-01-18 20:29:49 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2018-04-04 17:20:44 +02:00
|
|
|
#include "initguid.h"
|
2021-02-02 19:32:10 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
#include "d3d11_4.h"
|
2024-04-15 12:00:19 +02:00
|
|
|
#include "vkd3d-proton-interop.h"
|
2018-05-11 02:18:06 +02:00
|
|
|
#include "dxvk-interop.h"
|
2018-04-04 17:20:44 +02:00
|
|
|
|
2023-09-26 23:56:43 +02:00
|
|
|
#include "vrclient_private.h"
|
|
|
|
|
2018-06-04 17:45:00 +02:00
|
|
|
#include "flatapi.h"
|
|
|
|
|
2022-12-13 19:55:47 +01:00
|
|
|
#include "wine/unixlib.h"
|
|
|
|
|
2023-11-07 20:56:28 +01:00
|
|
|
#define PATH_MAX 4096
|
|
|
|
|
2018-01-18 20:29:49 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
|
|
|
|
|
2023-10-02 20:00:22 +02:00
|
|
|
CREATE_TYPE_INFO_VTABLE;
|
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
struct compositor_data compositor_data = {0};
|
2024-02-10 01:20:52 +01:00
|
|
|
static BOOL vrclient_loaded;
|
2021-01-26 11:05:00 +01:00
|
|
|
|
2018-01-18 20:29:49 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %u, %p)\n", instance, reason, reserved);
|
|
|
|
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(instance);
|
2023-10-02 20:00:22 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
init_type_info_rtti( (char *)instance );
|
|
|
|
init_rtti( (char *)instance );
|
|
|
|
#endif /* __x86_64__ */
|
2023-11-07 20:56:28 +01:00
|
|
|
__wine_init_unix_call();
|
2018-01-18 20:29:49 +01:00
|
|
|
break;
|
2021-01-26 11:05:00 +01:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2023-10-19 12:38:31 +02:00
|
|
|
if (compositor_data.client_core_linux_side)
|
2021-01-26 11:05:00 +01:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Cleanup_params params =
|
2021-03-30 19:27:10 +02:00
|
|
|
{
|
2023-10-19 12:38:31 +02:00
|
|
|
.linux_side = compositor_data.client_core_linux_side,
|
|
|
|
};
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Cleanup, ¶ms );
|
2023-10-19 12:38:31 +02:00
|
|
|
compositor_data.client_core_linux_side = NULL;
|
2021-01-26 11:05:00 +01:00
|
|
|
}
|
2024-02-10 01:20:52 +01:00
|
|
|
VRCLIENT_CALL( vrclient_unload, NULL );
|
|
|
|
vrclient_loaded = FALSE;
|
2021-01-26 11:05:00 +01:00
|
|
|
break;
|
2018-01-18 20:29:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-04-19 15:50:32 +02:00
|
|
|
static BOOL array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
|
|
|
|
{
|
|
|
|
SIZE_T max_capacity, new_capacity;
|
|
|
|
void *new_elements;
|
|
|
|
|
|
|
|
if (count <= *capacity)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
max_capacity = ~(SIZE_T)0 / size;
|
|
|
|
if (count > max_capacity)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
new_capacity = max(1, *capacity);
|
|
|
|
while (new_capacity < count && new_capacity <= max_capacity / 2)
|
|
|
|
new_capacity *= 2;
|
|
|
|
if (new_capacity < count)
|
|
|
|
new_capacity = count;
|
|
|
|
|
|
|
|
if (!*elements)
|
|
|
|
new_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_capacity * size);
|
|
|
|
else
|
|
|
|
new_elements = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *elements, new_capacity * size);
|
|
|
|
if (!new_elements)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*elements = new_elements;
|
|
|
|
*capacity = new_capacity;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-09-24 14:50:45 +02:00
|
|
|
struct w_steam_iface *create_win_interface(const char *name, void *linux_side)
|
2018-01-18 20:29:49 +01:00
|
|
|
{
|
2023-09-30 12:02:30 +02:00
|
|
|
iface_constructor constructor;
|
2018-01-18 20:29:49 +01:00
|
|
|
|
|
|
|
TRACE("trying to create %s\n", name);
|
|
|
|
|
2023-09-30 12:02:30 +02:00
|
|
|
if (!linux_side) return NULL;
|
|
|
|
if ((constructor = find_iface_constructor( name ))) return constructor( linux_side );
|
2018-01-18 20:29:49 +01:00
|
|
|
|
|
|
|
ERR("Don't recognize interface name: %s\n", name);
|
2018-04-19 15:50:32 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-01-18 20:29:49 +01:00
|
|
|
static int load_vrclient(void)
|
|
|
|
{
|
2023-09-20 09:36:01 +02:00
|
|
|
static const WCHAR PROTON_VR_RUNTIME_W[] = {'P','R','O','T','O','N','_','V','R','_','R','U','N','T','I','M','E',0};
|
2023-10-02 19:57:26 +02:00
|
|
|
static const WCHAR winevulkanW[] = {'w','i','n','e','v','u','l','k','a','n','.','d','l','l',0};
|
2023-10-19 12:38:31 +02:00
|
|
|
|
2023-10-02 19:57:26 +02:00
|
|
|
struct vrclient_init_params params = {.winevulkan = LoadLibraryW( winevulkanW )};
|
2020-02-26 17:50:10 +01:00
|
|
|
WCHAR pathW[PATH_MAX];
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
static const char append_path[] = "/bin/linux64/vrclient.so";
|
|
|
|
#else
|
|
|
|
static const char append_path[] = "/bin/vrclient.so";
|
|
|
|
#endif
|
2018-01-18 20:29:49 +01:00
|
|
|
|
2024-02-10 01:20:52 +01:00
|
|
|
if (vrclient_loaded) return 1;
|
2018-01-18 20:29:49 +01:00
|
|
|
|
|
|
|
/* PROTON_VR_RUNTIME is provided by the proton setup script */
|
2023-09-20 09:36:01 +02:00
|
|
|
if(!GetEnvironmentVariableW(PROTON_VR_RUNTIME_W, pathW, ARRAY_SIZE(pathW)))
|
2020-02-26 17:50:10 +01:00
|
|
|
{
|
2022-07-28 19:22:30 +02:00
|
|
|
DWORD type, size;
|
|
|
|
LSTATUS status;
|
|
|
|
HKEY vr_key;
|
|
|
|
|
|
|
|
if ((status = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, KEY_READ, &vr_key)))
|
|
|
|
{
|
|
|
|
WINE_WARN("Could not create key, status %#x.\n", status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(pathW);
|
2023-09-20 09:36:01 +02:00
|
|
|
if ((status = RegQueryValueExW(vr_key, PROTON_VR_RUNTIME_W, NULL, &type, (BYTE *)pathW, &size)))
|
2022-07-28 19:22:30 +02:00
|
|
|
{
|
|
|
|
WINE_WARN("Could not query value, status %#x.\n", status);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (type != REG_SZ)
|
|
|
|
{
|
|
|
|
WINE_ERR("Unexpected value type %#x.\n", type);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RegCloseKey(vr_key);
|
2018-01-18 20:29:49 +01:00
|
|
|
}
|
|
|
|
|
2020-02-26 17:50:10 +01:00
|
|
|
sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL);
|
|
|
|
if(!sz)
|
|
|
|
{
|
|
|
|
ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
params.unix_path = HeapAlloc( GetProcessHeap(), 0, sz + sizeof(append_path) );
|
2020-02-26 17:50:10 +01:00
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
sz = WideCharToMultiByte( CP_UNIXCP, 0, pathW, -1, params.unix_path, sz, NULL, NULL );
|
2020-02-26 17:50:10 +01:00
|
|
|
if(!sz)
|
|
|
|
{
|
|
|
|
ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW));
|
2023-10-19 12:38:31 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, params.unix_path);
|
2020-02-26 17:50:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
strcat( params.unix_path, append_path );
|
2020-02-26 17:50:10 +01:00
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
TRACE( "got openvr runtime path: %s\n", params.unix_path );
|
2019-08-06 11:18:50 +02:00
|
|
|
|
2023-09-30 14:15:53 +02:00
|
|
|
VRCLIENT_CALL( vrclient_init, ¶ms );
|
2024-02-10 01:20:52 +01:00
|
|
|
if (params._ret) vrclient_loaded = TRUE;
|
2018-01-18 20:29:49 +01:00
|
|
|
|
2023-10-19 12:38:31 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, params.unix_path );
|
2024-02-10 01:20:52 +01:00
|
|
|
return vrclient_loaded;
|
2018-01-18 20:29:49 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 11:18:50 +02:00
|
|
|
void *CDECL HmdSystemFactory(const char *name, int *return_code)
|
|
|
|
{
|
2023-09-30 14:15:53 +02:00
|
|
|
struct vrclient_HmdSystemFactory_params params = {.name = name, .return_code = return_code};
|
2019-08-06 11:18:50 +02:00
|
|
|
TRACE("name: %s, return_code: %p\n", name, return_code);
|
2023-10-19 12:38:31 +02:00
|
|
|
if (!load_vrclient()) return NULL;
|
2023-09-30 14:15:53 +02:00
|
|
|
VRCLIENT_CALL( vrclient_HmdSystemFactory, ¶ms );
|
|
|
|
return create_win_interface( name, params._ret );
|
2019-08-06 11:18:50 +02:00
|
|
|
}
|
|
|
|
|
2018-01-18 20:29:49 +01:00
|
|
|
void *CDECL VRClientCoreFactory(const char *name, int *return_code)
|
|
|
|
{
|
2023-09-30 14:15:53 +02:00
|
|
|
struct vrclient_VRClientCoreFactory_params params = {.name = name, .return_code = return_code};
|
2018-01-18 20:29:49 +01:00
|
|
|
TRACE("name: %s, return_code: %p\n", name, return_code);
|
2023-10-19 12:38:31 +02:00
|
|
|
if (!load_vrclient()) return NULL;
|
2023-09-30 14:15:53 +02:00
|
|
|
VRCLIENT_CALL( vrclient_VRClientCoreFactory, ¶ms );
|
|
|
|
return create_win_interface( name, params._ret );
|
2018-01-18 20:29:49 +01:00
|
|
|
}
|
2018-04-04 17:20:44 +02:00
|
|
|
|
2023-10-04 22:02:15 +02:00
|
|
|
static int8_t is_hmd_present_reg(void)
|
2021-05-03 21:10:55 +02:00
|
|
|
{
|
|
|
|
DWORD type, value, wait_status, size;
|
|
|
|
DWORD is_hmd_present = 0;
|
|
|
|
LSTATUS status;
|
|
|
|
HANDLE event;
|
|
|
|
HKEY vr_key;
|
|
|
|
|
|
|
|
if ((status = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, KEY_READ, &vr_key)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not create key, status %#x.\n", status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(value);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "state", NULL, &type, (BYTE *)&value, &size)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not query value, status %#x.\n", status);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (type != REG_DWORD)
|
|
|
|
{
|
|
|
|
WINE_ERR("Unexpected value type %#x.\n", type);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return value == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = CreateEventA( NULL, FALSE, FALSE, NULL );
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (RegNotifyChangeKeyValue(vr_key, FALSE, REG_NOTIFY_CHANGE_LAST_SET, event, TRUE))
|
|
|
|
{
|
|
|
|
WINE_ERR("Error registering registry change notification.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
size = sizeof(value);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "state", NULL, &type, (BYTE *)&value, &size)))
|
|
|
|
{
|
|
|
|
WINE_ERR("Could not query value, status %#x.\n", status);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (value)
|
|
|
|
break;
|
|
|
|
while ((wait_status = WaitForSingleObject(event, 1000)) == WAIT_TIMEOUT)
|
|
|
|
WINE_ERR("VR state wait timeout.\n");
|
|
|
|
|
|
|
|
if (wait_status != WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
WINE_ERR("Got unexpected wait status %#x.\n", wait_status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value != 1)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = sizeof(is_hmd_present);
|
|
|
|
if ((status = RegQueryValueExA(vr_key, "is_hmd_present", NULL, &type, (BYTE *)&is_hmd_present, &size)))
|
|
|
|
WINE_ERR("Could not query is_hmd_present value, status %#x.\n", status);
|
|
|
|
|
|
|
|
done:
|
|
|
|
CloseHandle(event);
|
|
|
|
RegCloseKey(vr_key);
|
|
|
|
return is_hmd_present;
|
|
|
|
}
|
|
|
|
|
2023-09-27 09:39:03 +02:00
|
|
|
static void *ivrclientcore_get_generic_interface( void *object, const char *name_and_version, struct client_core_data *user_data )
|
2021-05-03 21:10:55 +02:00
|
|
|
{
|
2023-09-24 14:50:45 +02:00
|
|
|
struct w_steam_iface *win_object;
|
2018-04-19 15:50:32 +02:00
|
|
|
struct generic_interface *iface;
|
2023-09-30 12:02:30 +02:00
|
|
|
iface_destructor destructor;
|
2018-04-19 15:50:32 +02:00
|
|
|
|
2023-09-27 09:39:03 +02:00
|
|
|
TRACE( "%p %p\n", object, name_and_version );
|
2018-04-19 15:50:32 +02:00
|
|
|
|
|
|
|
if (!(win_object = create_win_interface(name_and_version, object)))
|
|
|
|
{
|
|
|
|
ERR("Failed to create win object %s.\n", name_and_version);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-30 12:02:30 +02:00
|
|
|
if ((destructor = find_iface_destructor( name_and_version )))
|
2018-04-19 15:50:32 +02:00
|
|
|
{
|
|
|
|
EnterCriticalSection(&user_data->critical_section);
|
|
|
|
if (array_reserve((void **)&user_data->created_interfaces,
|
|
|
|
&user_data->created_interfaces_size, user_data->created_interface_count + 1,
|
|
|
|
sizeof(*user_data->created_interfaces)))
|
|
|
|
{
|
|
|
|
iface = &user_data->created_interfaces[user_data->created_interface_count++];
|
|
|
|
iface->object = win_object;
|
|
|
|
iface->dtor = destructor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Failed to add interface to array.\n");
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&user_data->critical_section);
|
|
|
|
}
|
|
|
|
|
2018-06-04 17:45:00 +02:00
|
|
|
if (name_and_version && !strncmp(name_and_version, "FnTable:", 8))
|
|
|
|
return *((void **)win_object);
|
2018-04-19 15:50:32 +02:00
|
|
|
return win_object;
|
|
|
|
}
|
|
|
|
|
2021-02-03 12:14:28 +01:00
|
|
|
static void destroy_compositor_data(void)
|
|
|
|
{
|
|
|
|
TRACE("Destroying compositor data.\n");
|
2024-04-15 12:00:19 +02:00
|
|
|
free_compositor_data_d3d12_device();
|
2021-02-03 12:14:28 +01:00
|
|
|
memset(&compositor_data, 0, sizeof(compositor_data));
|
|
|
|
}
|
|
|
|
|
2023-09-27 09:39:03 +02:00
|
|
|
static void ivrclientcore_cleanup( struct client_core_data *user_data )
|
2018-04-19 15:50:32 +02:00
|
|
|
{
|
|
|
|
struct generic_interface *iface;
|
|
|
|
SIZE_T i;
|
|
|
|
|
|
|
|
EnterCriticalSection(&user_data->critical_section);
|
|
|
|
for (i = 0; i < user_data->created_interface_count; ++i)
|
|
|
|
{
|
|
|
|
iface = &user_data->created_interfaces[i];
|
|
|
|
|
|
|
|
iface->dtor(iface->object);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, user_data->created_interfaces);
|
|
|
|
user_data->created_interfaces = NULL;
|
|
|
|
user_data->created_interfaces_size = 0;
|
|
|
|
user_data->created_interface_count = 0;
|
|
|
|
LeaveCriticalSection(&user_data->critical_section);
|
|
|
|
|
|
|
|
DeleteCriticalSection(&user_data->critical_section);
|
|
|
|
}
|
|
|
|
|
2023-09-29 11:28:17 +02:00
|
|
|
w_Texture_t vrclient_translate_texture_dxvk( const w_Texture_t *texture, w_VRVulkanTextureData_t *vkdata,
|
|
|
|
IDXGIVkInteropSurface *dxvk_surface, IDXGIVkInteropDevice **p_dxvk_device,
|
|
|
|
VkImageLayout *image_layout, VkImageCreateInfo *image_info )
|
2020-08-16 22:31:33 +02:00
|
|
|
{
|
2023-09-29 11:28:17 +02:00
|
|
|
w_Texture_t vktexture;
|
2020-08-16 22:31:33 +02:00
|
|
|
VkImage image_handle;
|
|
|
|
|
|
|
|
dxvk_surface->lpVtbl->GetDevice(dxvk_surface, p_dxvk_device);
|
|
|
|
|
|
|
|
(*p_dxvk_device)->lpVtbl->GetVulkanHandles(*p_dxvk_device, &vkdata->m_pInstance,
|
|
|
|
&vkdata->m_pPhysicalDevice, &vkdata->m_pDevice);
|
|
|
|
|
|
|
|
(*p_dxvk_device)->lpVtbl->GetSubmissionQueue(*p_dxvk_device, &vkdata->m_pQueue, &vkdata->m_nQueueFamilyIndex);
|
|
|
|
|
|
|
|
image_info->sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
|
|
|
image_info->pNext = NULL;
|
|
|
|
|
|
|
|
dxvk_surface->lpVtbl->GetVulkanImageInfo(dxvk_surface, &image_handle, image_layout, image_info);
|
|
|
|
|
|
|
|
vkdata->m_nImage = (uint64_t)image_handle;
|
|
|
|
vkdata->m_nWidth = image_info->extent.width;
|
|
|
|
vkdata->m_nHeight = image_info->extent.height;
|
|
|
|
vkdata->m_nFormat = image_info->format;
|
|
|
|
vkdata->m_nSampleCount = image_info->samples;
|
|
|
|
|
|
|
|
vktexture = *texture;
|
|
|
|
vktexture.handle = vkdata;
|
|
|
|
vktexture.eType = TextureType_Vulkan;
|
|
|
|
|
|
|
|
return vktexture;
|
|
|
|
}
|
|
|
|
|
2024-04-15 12:00:19 +02:00
|
|
|
w_Texture_t vrclient_translate_texture_d3d12( const w_Texture_t *texture, w_VRVulkanTextureData_t *vkdata,
|
|
|
|
ID3D12DXVKInteropDevice *d3d12_device, ID3D12Resource *d3d12_resource,
|
|
|
|
ID3D12CommandQueue *d3d12_queue, VkImageLayout *image_layout,
|
|
|
|
VkImageCreateInfo *image_info )
|
|
|
|
{
|
|
|
|
w_Texture_t vktexture;
|
|
|
|
VkImage image_handle;
|
|
|
|
UINT64 buffer_offset;
|
|
|
|
D3D12_RESOURCE_DESC resource_desc;
|
|
|
|
VkFormat vk_format = VK_FORMAT_UNDEFINED;
|
|
|
|
TRACE("%p %p %p %p %p %p\n", texture, vkdata, d3d12_device, d3d12_resource, d3d12_queue, image_layout);
|
|
|
|
d3d12_resource->lpVtbl->GetDesc(d3d12_resource, &resource_desc);
|
|
|
|
switch (resource_desc.Format)
|
|
|
|
{
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: vk_format = VK_FORMAT_R8G8B8A8_SRGB; break;
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_UNORM: vk_format = VK_FORMAT_R8G8B8A8_UNORM; break;
|
|
|
|
default:
|
|
|
|
ERR("Unsupported DXGI format %#x.\n", resource_desc.Format);
|
|
|
|
return *texture;
|
|
|
|
}
|
|
|
|
if (resource_desc.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D)
|
|
|
|
{
|
|
|
|
ERR("Unsupported resource dimension %#x.\n", resource_desc.Dimension);
|
|
|
|
return *texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("DXGI format: %#x, width: %I64u, height: %u, mip levels: %u, array size: %u, sample count: %u, VkFormat %#x.\n",
|
|
|
|
resource_desc.Format, resource_desc.Width, resource_desc.Height, resource_desc.MipLevels,
|
|
|
|
resource_desc.DepthOrArraySize, resource_desc.SampleDesc.Count, vk_format);
|
|
|
|
|
|
|
|
d3d12_device->lpVtbl->GetVulkanHandles(d3d12_device, &vkdata->m_pInstance, &vkdata->m_pPhysicalDevice, &vkdata->m_pDevice);
|
|
|
|
d3d12_device->lpVtbl->GetVulkanQueueInfo(d3d12_device, d3d12_queue, &vkdata->m_pQueue, &vkdata->m_nQueueFamilyIndex);
|
|
|
|
d3d12_device->lpVtbl->GetVulkanImageLayout(d3d12_device, d3d12_resource, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, image_layout);
|
|
|
|
d3d12_device->lpVtbl->GetVulkanResourceInfo(d3d12_device, d3d12_resource, (UINT64*)&image_handle, &buffer_offset);
|
|
|
|
|
|
|
|
/* For now, only these fields are used. */
|
|
|
|
image_info->mipLevels = resource_desc.MipLevels;
|
|
|
|
image_info->arrayLayers = resource_desc.DepthOrArraySize;
|
|
|
|
|
|
|
|
vkdata->m_nImage = (uint64_t)image_handle;
|
|
|
|
vkdata->m_nWidth = resource_desc.Width;
|
|
|
|
vkdata->m_nHeight = resource_desc.Height;
|
|
|
|
vkdata->m_nFormat = vk_format;
|
|
|
|
vkdata->m_nSampleCount = resource_desc.SampleDesc.Count;
|
|
|
|
|
|
|
|
vktexture = *texture;
|
|
|
|
vktexture.handle = vkdata;
|
|
|
|
vktexture.eType = TextureType_Vulkan;
|
|
|
|
|
|
|
|
return vktexture;
|
|
|
|
}
|
|
|
|
|
2023-09-14 16:22:47 +02:00
|
|
|
uint32_t __thiscall winIVRClientCore_IVRClientCore_002_Init( struct w_steam_iface *_this, uint32_t eApplicationType )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_002_Init_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.eApplicationType = eApplicationType,
|
|
|
|
};
|
2023-09-27 09:09:37 +02:00
|
|
|
|
|
|
|
TRACE( "%p\n", _this );
|
|
|
|
|
|
|
|
InitializeCriticalSection( &_this->user_data.critical_section );
|
|
|
|
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_Init, ¶ms );
|
2023-09-27 11:05:52 +02:00
|
|
|
if (params._ret) WARN( "error %#x\n", params._ret );
|
|
|
|
return params._ret;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void __thiscall winIVRClientCore_IVRClientCore_002_Cleanup( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_002_Cleanup_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
};
|
2023-09-27 09:09:37 +02:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 09:39:03 +02:00
|
|
|
ivrclientcore_cleanup( &_this->user_data );
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_Cleanup, ¶ms );
|
2023-09-27 09:39:03 +02:00
|
|
|
destroy_compositor_data();
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void *__thiscall winIVRClientCore_IVRClientCore_002_GetGenericInterface( struct w_steam_iface *_this,
|
2023-09-14 16:22:47 +02:00
|
|
|
const char *pchNameAndVersion, uint32_t *peError )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_002_GetGenericInterface_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.pchNameAndVersion = pchNameAndVersion,
|
|
|
|
.peError = peError,
|
|
|
|
};
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 09:09:37 +02:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
|
|
|
/* In theory we could pass this along, but we'd have to generate a separate
|
|
|
|
* set of thunks for it. Hopefully this will work as it is. */
|
2023-09-27 11:05:52 +02:00
|
|
|
if (pchNameAndVersion && !strncmp( pchNameAndVersion, "FnTable:", 8 )) params.pchNameAndVersion += 8;
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_GetGenericInterface, ¶ms );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
if (!params._ret)
|
2023-09-27 09:39:03 +02:00
|
|
|
{
|
|
|
|
WARN( "Failed to create %s.\n", pchNameAndVersion );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
params._ret = ivrclientcore_get_generic_interface( params._ret, pchNameAndVersion, &_this->user_data );
|
|
|
|
return params._ret;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
2023-10-04 22:02:15 +02:00
|
|
|
int8_t __thiscall winIVRClientCore_IVRClientCore_002_BIsHmdPresent( struct w_steam_iface *_this )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_002_BIsHmdPresent_params params = {.linux_side = _this->u_iface};
|
2023-09-27 09:39:03 +02:00
|
|
|
|
|
|
|
TRACE( "linux_side %p, compositor_data.client_core_linux_side %p.\n", _this->u_iface,
|
|
|
|
compositor_data.client_core_linux_side );
|
|
|
|
|
|
|
|
/* BIsHmdPresent() currently always returns FALSE on Linux if called before Init().
|
|
|
|
* Return true if the value stored by steam.exe helper in registry says the HMD is presnt. */
|
|
|
|
if (compositor_data.client_core_linux_side || !is_hmd_present_reg())
|
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_002_BIsHmdPresent, ¶ms );
|
2023-09-27 11:05:52 +02:00
|
|
|
return params._ret;
|
2023-09-27 09:39:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
2023-09-14 16:22:47 +02:00
|
|
|
uint32_t __thiscall winIVRClientCore_IVRClientCore_003_Init( struct w_steam_iface *_this,
|
|
|
|
uint32_t eApplicationType, const char *pStartupInfo )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Init_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.eApplicationType = eApplicationType,
|
|
|
|
.pStartupInfo = pStartupInfo,
|
|
|
|
};
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 09:09:37 +02:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
|
|
|
InitializeCriticalSection( &_this->user_data.critical_section );
|
|
|
|
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Init, ¶ms );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
if (params._ret) WARN( "error %#x\n", params._ret );
|
|
|
|
else compositor_data.client_core_linux_side = params.linux_side;
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
return params._ret;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void __thiscall winIVRClientCore_IVRClientCore_003_Cleanup( struct w_steam_iface *_this )
|
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_003_Cleanup_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
};
|
2023-09-27 09:09:37 +02:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 09:39:03 +02:00
|
|
|
ivrclientcore_cleanup( &_this->user_data );
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Cleanup, ¶ms );
|
2023-09-27 09:39:03 +02:00
|
|
|
destroy_compositor_data();
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void *__thiscall winIVRClientCore_IVRClientCore_003_GetGenericInterface( struct w_steam_iface *_this,
|
2023-09-14 16:22:47 +02:00
|
|
|
const char *pchNameAndVersion, uint32_t *peError )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_003_GetGenericInterface_params params =
|
2023-09-27 11:05:52 +02:00
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.pchNameAndVersion = pchNameAndVersion,
|
|
|
|
.peError = peError,
|
|
|
|
};
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 09:09:37 +02:00
|
|
|
TRACE( "%p\n", _this );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
|
|
|
/* In theory we could pass this along, but we'd have to generate a separate
|
|
|
|
* set of thunks for it. Hopefully this will work as it is. */
|
2023-09-27 11:05:52 +02:00
|
|
|
if (pchNameAndVersion && !strncmp( pchNameAndVersion, "FnTable:", 8 )) params.pchNameAndVersion += 8;
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_GetGenericInterface, ¶ms );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
if (!params._ret)
|
2023-09-27 09:39:03 +02:00
|
|
|
{
|
|
|
|
WARN( "Failed to create %s.\n", pchNameAndVersion );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
params._ret = ivrclientcore_get_generic_interface( params._ret, pchNameAndVersion, &_this->user_data );
|
|
|
|
return params._ret;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
|
|
|
|
2023-10-04 22:02:15 +02:00
|
|
|
int8_t __thiscall winIVRClientCore_IVRClientCore_003_BIsHmdPresent( struct w_steam_iface *_this )
|
2023-09-27 09:09:37 +02:00
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
struct IVRClientCore_IVRClientCore_003_BIsHmdPresent_params params = {.linux_side = _this->u_iface};
|
2023-09-27 09:39:03 +02:00
|
|
|
|
2023-09-27 11:05:52 +02:00
|
|
|
TRACE( "linux_side %p, compositor_data.client_core_linux_side %p.\n", _this->u_iface,
|
|
|
|
compositor_data.client_core_linux_side );
|
2023-09-27 09:39:03 +02:00
|
|
|
|
|
|
|
/* BIsHmdPresent() currently always returns FALSE on Linux if called before Init().
|
|
|
|
* Return true if the value stored by steam.exe helper in registry says the HMD is presnt. */
|
|
|
|
if (compositor_data.client_core_linux_side || !is_hmd_present_reg())
|
|
|
|
{
|
2023-09-30 13:08:49 +02:00
|
|
|
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_BIsHmdPresent, ¶ms );
|
2023-09-27 11:05:52 +02:00
|
|
|
return params._ret;
|
2023-09-27 09:39:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2023-09-27 09:09:37 +02:00
|
|
|
}
|
2023-10-05 14:28:29 +02:00
|
|
|
|
|
|
|
const w_CameraVideoStreamFrame_t_0914 * __thiscall winIVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame(struct w_steam_iface *_this, uint32_t nDeviceIndex)
|
|
|
|
{
|
|
|
|
static w_CameraVideoStreamFrame_t_0914 w_frame;
|
|
|
|
struct IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame_params params =
|
|
|
|
{
|
|
|
|
.linux_side = _this->u_iface,
|
|
|
|
.nDeviceIndex = nDeviceIndex,
|
|
|
|
._ret = &w_frame,
|
|
|
|
};
|
|
|
|
TRACE("%p\n", _this);
|
|
|
|
VRCLIENT_CALL( IVRTrackedCamera_IVRTrackedCamera_001_GetVideoStreamFrame, ¶ms );
|
|
|
|
return params._ret;
|
|
|
|
}
|