diff --git a/vrclient_x64/Makefile.in b/vrclient_x64/Makefile.in index 992d9b5e..919563d1 100644 --- a/vrclient_x64/Makefile.in +++ b/vrclient_x64/Makefile.in @@ -8,6 +8,7 @@ EXTRADEFS = -DWINE_NO_LONG_TYPES -DGNUC C_SRCS = \ vrclient_x64/flatapi.c \ vrclient_x64/vrclient_main.c \ + vrclient_x64/vroverlay_manual.c \ vrclient_x64/vrsystem_manual.c \ vrclient_x64/vrrendermodels_manual.c \ vrclient_x64/winIVRApplications.c \ diff --git a/vrclient_x64/vrclient_x64/vrclient_main.c b/vrclient_x64/vrclient_x64/vrclient_main.c index 5a99286b..6a651d67 100644 --- a/vrclient_x64/vrclient_x64/vrclient_main.c +++ b/vrclient_x64/vrclient_x64/vrclient_main.c @@ -12,16 +12,14 @@ #include "winternl.h" #include "wine/debug.h" -#include "vrclient_defs.h" -#include "vrclient_private.h" - #include "initguid.h" - #define COBJMACROS #include "d3d11_4.h" - #include "dxvk-interop.h" +#include "vrclient_defs.h" +#include "vrclient_private.h" + #include "flatapi.h" #include "cppIVRClientCore_IVRClientCore_003.h" @@ -727,9 +725,9 @@ VRCompositorError ivrcompositor_008_submit( return cpp_func(linux_side, eye, api, texture, bounds, flags); } -static Texture_t vrclient_translate_texture_dxvk(const Texture_t *texture, struct VRVulkanTextureData_t *vkdata, - IDXGIVkInteropSurface *dxvk_surface, IDXGIVkInteropDevice **p_dxvk_device, VkImageLayout *image_layout, - VkImageCreateInfo *image_info) +Texture_t vrclient_translate_texture_dxvk( const Texture_t *texture, struct VRVulkanTextureData_t *vkdata, + IDXGIVkInteropSurface *dxvk_surface, IDXGIVkInteropDevice **p_dxvk_device, + VkImageLayout *image_layout, VkImageCreateInfo *image_info ) { struct Texture_t vktexture; VkImage image_handle; @@ -763,45 +761,6 @@ static Texture_t vrclient_translate_texture_dxvk(const Texture_t *texture, struc return vktexture; } -static EVROverlayError ivroverlay_set_overlay_texture_dxvk( - EVROverlayError (*cpp_func)(void *, VROverlayHandle_t, const Texture_t *), - void *linux_side, VROverlayHandle_t overlayHandle, const Texture_t *texture, - unsigned int version, IDXGIVkInteropSurface *dxvk_surface) -{ - struct VRVulkanTextureData_t vkdata; - IDXGIVkInteropDevice *dxvk_device; - struct Texture_t vktexture; - - VkImageLayout image_layout; - VkImageCreateInfo image_info; - VkImageSubresourceRange subresources; - - EVRCompositorError err; - - vktexture = vrclient_translate_texture_dxvk(texture, &vkdata, dxvk_surface, &dxvk_device, &image_layout, &image_info); - - subresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - subresources.baseMipLevel = 0; - subresources.levelCount = image_info.mipLevels; - subresources.baseArrayLayer = 0; - subresources.layerCount = image_info.arrayLayers; - - dxvk_device->lpVtbl->TransitionSurfaceLayout(dxvk_device, dxvk_surface, &subresources, - image_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); - dxvk_device->lpVtbl->FlushRenderingCommands(dxvk_device); - dxvk_device->lpVtbl->LockSubmissionQueue(dxvk_device); - - err = cpp_func(linux_side, overlayHandle, &vktexture); - - dxvk_device->lpVtbl->ReleaseSubmissionQueue(dxvk_device); - dxvk_device->lpVtbl->TransitionSurfaceLayout(dxvk_device, dxvk_surface, &subresources, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_layout); - - dxvk_device->lpVtbl->Release(dxvk_device); - dxvk_surface->lpVtbl->Release(dxvk_surface); - return err; -} - static EVRCompositorError ivrcompositor_submit_dxvk( EVRCompositorError (*cpp_func)(void *, EVREye, const Texture_t *, const VRTextureBounds_t *, EVRSubmitFlags), void *linux_side, EVREye eye, const Texture_t *texture, const VRTextureBounds_t *bounds, EVRSubmitFlags flags, @@ -854,28 +813,6 @@ static EVRCompositorError ivrcompositor_submit_dxvk( return err; } -static EVROverlayError ivroverlay_set_overlay_texture_vulkan( - EVROverlayError (*cpp_func)(void *, VROverlayHandle_t, const Texture_t *), - void *linux_side, VROverlayHandle_t overlay_handle, const Texture_t *texture, - unsigned int version) -{ - struct VRVulkanTextureData_t our_vkdata, *their_vkdata; - Texture_t our_texture; - - their_vkdata = texture->handle; - - our_vkdata = *their_vkdata; - our_vkdata.m_pDevice = get_native_VkDevice(our_vkdata.m_pDevice); - our_vkdata.m_pPhysicalDevice = get_native_VkPhysicalDevice(our_vkdata.m_pPhysicalDevice); - our_vkdata.m_pInstance = get_native_VkInstance(our_vkdata.m_pInstance); - our_vkdata.m_pQueue = get_native_VkQueue(our_vkdata.m_pQueue); - - our_texture = *texture; - our_texture.handle = &our_vkdata; - - return cpp_func(linux_side, overlay_handle, &our_texture); -} - static EVRCompositorError ivrcompositor_submit_vulkan( EVRCompositorError (*cpp_func)(void *, EVREye, const Texture_t *, const VRTextureBounds_t *, EVRSubmitFlags), void *linux_side, EVREye eye, const Texture_t *texture, const VRTextureBounds_t *bounds, EVRSubmitFlags flags, @@ -942,67 +879,6 @@ static EVRCompositorError ivrcompositor_submit_vulkan( return cpp_func(linux_side, eye, tex, bounds, flags); } -EVROverlayError ivroverlay_set_overlay_texture( - EVROverlayError (*cpp_func)(void *, VROverlayHandle_t, const Texture_t *), - void *linux_side, VROverlayHandle_t overlayHandle, const Texture_t *texture, - unsigned int version) -{ - IUnknown *texture_iface; - HRESULT hr; - - TRACE("%p, overlayHandle = %s, texture = %p\n", linux_side, wine_dbgstr_longlong(overlayHandle), texture); - - switch (texture->eType) - { - case TextureType_DirectX: - { - IDXGIVkInteropSurface *dxvk_surface; - - TRACE("D3D11\n"); - - if (!texture->handle) { - WARN("No D3D11 texture %p.\n", texture); - return cpp_func(linux_side, overlayHandle, texture); - } - - texture_iface = texture->handle; - - if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface, &IID_IDXGIVkInteropSurface, (void **)&dxvk_surface))) { - return ivroverlay_set_overlay_texture_dxvk(cpp_func, linux_side, overlayHandle, texture, version, dxvk_surface); - } - - WARN("Invalid D3D11 texture %p.\n", texture); - return cpp_func(linux_side, overlayHandle, texture); - } - - case TextureType_Vulkan: - TRACE("Vulkan\n"); - return ivroverlay_set_overlay_texture_vulkan(cpp_func, linux_side, overlayHandle, texture, version); - default: - return cpp_func(linux_side, overlayHandle, texture); - } -} - -EVROverlayError ivroverlay_005_set_overlay_texture( - VROverlayError (*cpp_func)(void *, VROverlayHandle_t, GraphicsAPIConvention, void *), - void *linux_side, VROverlayHandle_t overlayHandle, GraphicsAPIConvention api, const void *texture, - unsigned int version) -{ - /* hopefully no one actually uses this old interface... Vulkan support - * wasn't added until later; how can we pass in a DirectX texture? */ - FIXME("unimplemented!\n"); - return VROverlayError_InvalidHandle; -} - -EVROverlayError ivroverlay_001_set_overlay_texture( - VROverlayError (*cpp_func)(void *, VROverlayHandle_t, void *), - void *linux_side, VROverlayHandle_t overlayHandle, const void *texture, - unsigned int version) -{ - /* probably no one actually uses this old interface... */ - FIXME("unimplemented!\n"); - return VROverlayError_InvalidHandle; -} EVRCompositorError ivrcompositor_submit( EVRCompositorError (*cpp_func)(void *, EVREye, const Texture_t *, const VRTextureBounds_t *, EVRSubmitFlags), diff --git a/vrclient_x64/vrclient_x64/vrclient_private.h b/vrclient_x64/vrclient_x64/vrclient_private.h index 1b1374ad..68dafa30 100644 --- a/vrclient_x64/vrclient_x64/vrclient_private.h +++ b/vrclient_x64/vrclient_x64/vrclient_private.h @@ -165,6 +165,12 @@ EVRInputError ivrinput_get_digital_action_data( void *linux_side, VRActionHandle_t action_handle, void *action_data, uint32_t action_data_size, VRInputValueHandle_t restrict_to_device, unsigned int version); +#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, + VkImageLayout *image_layout, VkImageCreateInfo *image_info ); +#endif /* __dxvk_interop_h__ */ + extern VkDevice_T *get_native_VkDevice( VkDevice_T *device ); extern VkInstance_T *get_native_VkInstance( VkInstance_T *instance ); extern VkPhysicalDevice_T *get_native_VkPhysicalDevice( VkPhysicalDevice_T *device ); diff --git a/vrclient_x64/vrclient_x64/vroverlay_manual.c b/vrclient_x64/vrclient_x64/vroverlay_manual.c new file mode 100644 index 00000000..b3786c07 --- /dev/null +++ b/vrclient_x64/vrclient_x64/vroverlay_manual.c @@ -0,0 +1,143 @@ +#include +#include +#include + +#include "windef.h" +#include "winbase.h" + +#define COBJMACROS +#include "d3d11_4.h" +#include "dxvk-interop.h" + +#include "wine/debug.h" +#include "vrclient_defs.h" +#include "vrclient_private.h" + +#include "flatapi.h" + +#include "struct_converters.h" + +WINE_DEFAULT_DEBUG_CHANNEL(vrclient); + +static EVROverlayError ivroverlay_set_overlay_texture_dxvk( EVROverlayError (*cpp_func)( void *, VROverlayHandle_t, const Texture_t * ), + void *linux_side, VROverlayHandle_t overlayHandle, + const Texture_t *texture, unsigned int version, + IDXGIVkInteropSurface *dxvk_surface ) +{ + struct VRVulkanTextureData_t vkdata; + IDXGIVkInteropDevice *dxvk_device; + struct Texture_t vktexture; + + VkImageLayout image_layout; + VkImageCreateInfo image_info; + VkImageSubresourceRange subresources; + + EVRCompositorError err; + + vktexture = vrclient_translate_texture_dxvk( texture, &vkdata, dxvk_surface, &dxvk_device, &image_layout, &image_info ); + + subresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresources.baseMipLevel = 0; + subresources.levelCount = image_info.mipLevels; + subresources.baseArrayLayer = 0; + subresources.layerCount = image_info.arrayLayers; + + dxvk_device->lpVtbl->TransitionSurfaceLayout( dxvk_device, dxvk_surface, &subresources, + image_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL ); + dxvk_device->lpVtbl->FlushRenderingCommands( dxvk_device ); + dxvk_device->lpVtbl->LockSubmissionQueue( dxvk_device ); + + err = cpp_func( linux_side, overlayHandle, &vktexture ); + + dxvk_device->lpVtbl->ReleaseSubmissionQueue( dxvk_device ); + dxvk_device->lpVtbl->TransitionSurfaceLayout( dxvk_device, dxvk_surface, &subresources, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_layout ); + + dxvk_device->lpVtbl->Release( dxvk_device ); + dxvk_surface->lpVtbl->Release( dxvk_surface ); + return err; +} + +static EVROverlayError ivroverlay_set_overlay_texture_vulkan( EVROverlayError (*cpp_func)( void *, VROverlayHandle_t, const Texture_t * ), + void *linux_side, VROverlayHandle_t overlay_handle, + const Texture_t *texture, unsigned int version ) +{ + struct VRVulkanTextureData_t our_vkdata, *their_vkdata; + Texture_t our_texture; + + their_vkdata = texture->handle; + + our_vkdata = *their_vkdata; + our_vkdata.m_pDevice = get_native_VkDevice( our_vkdata.m_pDevice ); + our_vkdata.m_pPhysicalDevice = get_native_VkPhysicalDevice( our_vkdata.m_pPhysicalDevice ); + our_vkdata.m_pInstance = get_native_VkInstance( our_vkdata.m_pInstance ); + our_vkdata.m_pQueue = get_native_VkQueue( our_vkdata.m_pQueue ); + + our_texture = *texture; + our_texture.handle = &our_vkdata; + + return cpp_func( linux_side, overlay_handle, &our_texture ); +} + +EVROverlayError ivroverlay_set_overlay_texture( EVROverlayError (*cpp_func)( void *, VROverlayHandle_t, const Texture_t * ), + void *linux_side, VROverlayHandle_t overlayHandle, + const Texture_t *texture, unsigned int version ) +{ + IUnknown *texture_iface; + HRESULT hr; + + TRACE( "%p, overlayHandle = %s, texture = %p\n", linux_side, wine_dbgstr_longlong( overlayHandle ), texture ); + + switch (texture->eType) + { + case TextureType_DirectX: + { + IDXGIVkInteropSurface *dxvk_surface; + + TRACE( "D3D11\n" ); + + if (!texture->handle) + { + WARN( "No D3D11 texture %p.\n", texture ); + return cpp_func( linux_side, overlayHandle, texture ); + } + + texture_iface = texture->handle; + + if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface( texture_iface, &IID_IDXGIVkInteropSurface, + (void **)&dxvk_surface ))) + { + return ivroverlay_set_overlay_texture_dxvk( cpp_func, linux_side, overlayHandle, texture, version, dxvk_surface ); + } + + WARN( "Invalid D3D11 texture %p.\n", texture ); + return cpp_func( linux_side, overlayHandle, texture ); + } + + case TextureType_Vulkan: + TRACE( "Vulkan\n" ); + return ivroverlay_set_overlay_texture_vulkan( cpp_func, linux_side, overlayHandle, texture, version ); + + default: + return cpp_func( linux_side, overlayHandle, texture ); + } +} + +EVROverlayError ivroverlay_005_set_overlay_texture( VROverlayError (*cpp_func)( void *, VROverlayHandle_t, GraphicsAPIConvention, void * ), + void *linux_side, VROverlayHandle_t overlayHandle, + GraphicsAPIConvention api, const void *texture, unsigned int version ) +{ + /* hopefully no one actually uses this old interface... Vulkan support + * wasn't added until later; how can we pass in a DirectX texture? */ + FIXME( "unimplemented!\n" ); + return VROverlayError_InvalidHandle; +} + +EVROverlayError ivroverlay_001_set_overlay_texture( VROverlayError (*cpp_func)( void *, VROverlayHandle_t, void * ), + void *linux_side, VROverlayHandle_t overlayHandle, + const void *texture, unsigned int version ) +{ + /* probably no one actually uses this old interface... */ + FIXME( "unimplemented!\n" ); + return VROverlayError_InvalidHandle; +}