vrclient: Factor out ivrcompositor_submit_vulkan().

This commit is contained in:
Józef Kucia 2018-09-10 17:51:02 +02:00 committed by Andrew Eikum
parent 53b798a62f
commit cad4edfed8

View File

@ -654,60 +654,20 @@ static EVRCompositorError ivrcompositor_submit_dxvk(
}
#endif
EVRCompositorError ivrcompositor_submit(
static EVRCompositorError ivrcompositor_submit_vulkan(
EVRCompositorError (*cpp_func)(void *, EVREye, Texture_t *, VRTextureBounds_t *, EVRSubmitFlags),
void *linux_side, EVREye eye, Texture_t *texture, VRTextureBounds_t *bounds, EVRSubmitFlags flags,
unsigned int version, struct compositor_data *user_data)
{
IWineD3D11Texture2D *wine_texture;
IUnknown *texture_iface;
HRESULT hr;
TRACE("%p, %#x, %p, %p, %#x\n", linux_side, eye, texture, bounds, flags);
switch (texture->eType)
{
case TextureType_DirectX:
{
TRACE("D3D11\n");
texture_iface = texture->handle;
if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
&IID_IWineD3D11Texture2D, (void **)&wine_texture)))
{
return ivrcompositor_submit_wined3d(cpp_func, linux_side,
eye, texture, bounds, flags, version, user_data, wine_texture);
}
#if !defined(__APPLE__) || defined(__x86_64__)
{
IDXGIVkInteropSurface *dxvk_surface;
if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
&IID_IDXGIVkInteropSurface, (void **)&dxvk_surface)))
{
return ivrcompositor_submit_dxvk(cpp_func, linux_side,
eye, texture, bounds, flags, version, user_data, dxvk_surface);
}
}
#endif
ERR("Invalid D3D11 texture %p.\n", texture);
return cpp_func(linux_side, eye, texture, bounds, flags);
}
case TextureType_Vulkan:
{
struct VRVulkanTextureData_t our_vkdata, our_depth_vkdata, *their_vkdata;
Texture_t our_texture, *tex;
VRTextureWithPose_t our_pose;
VRTextureWithDepth_t our_depth;
VRTextureWithPoseAndDepth_t our_both;
VRTextureWithDepth_t our_depth;
VRTextureWithPose_t our_pose;
Texture_t our_texture, *tex;
load_vk_unwrappers();
their_vkdata = (struct VRVulkanTextureData_t*)texture->handle;
their_vkdata = (struct VRVulkanTextureData_t *)texture->handle;
our_vkdata = *their_vkdata;
our_vkdata.m_pDevice = get_native_VkDevice(our_vkdata.m_pDevice);
@ -715,7 +675,8 @@ EVRCompositorError ivrcompositor_submit(
our_vkdata.m_pInstance = get_native_VkInstance(our_vkdata.m_pInstance);
our_vkdata.m_pQueue = get_native_VkQueue(our_vkdata.m_pQueue);
switch(flags & (Submit_TextureWithPose | Submit_TextureWithDepth)){
switch (flags & (Submit_TextureWithPose | Submit_TextureWithDepth))
{
case 0:
our_texture = *texture;
our_texture.handle = &our_vkdata;
@ -763,10 +724,56 @@ EVRCompositorError ivrcompositor_submit(
break;
}
return cpp_func(linux_side, eye, tex, bounds, flags);
}
EVRCompositorError ivrcompositor_submit(
EVRCompositorError (*cpp_func)(void *, EVREye, Texture_t *, VRTextureBounds_t *, EVRSubmitFlags),
void *linux_side, EVREye eye, Texture_t *texture, VRTextureBounds_t *bounds, EVRSubmitFlags flags,
unsigned int version, struct compositor_data *user_data)
{
IWineD3D11Texture2D *wine_texture;
IUnknown *texture_iface;
HRESULT hr;
TRACE("%p, %#x, %p, %p, %#x\n", linux_side, eye, texture, bounds, flags);
switch (texture->eType)
{
case TextureType_DirectX:
{
TRACE("D3D11\n");
texture_iface = texture->handle;
if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
&IID_IWineD3D11Texture2D, (void **)&wine_texture)))
{
return ivrcompositor_submit_wined3d(cpp_func, linux_side,
eye, texture, bounds, flags, version, user_data, wine_texture);
}
#if !defined(__APPLE__) || defined(__x86_64__)
{
IDXGIVkInteropSurface *dxvk_surface;
if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
&IID_IDXGIVkInteropSurface, (void **)&dxvk_surface)))
{
return ivrcompositor_submit_dxvk(cpp_func, linux_side,
eye, texture, bounds, flags, version, user_data, dxvk_surface);
}
}
#endif
ERR("Invalid D3D11 texture %p.\n", texture);
return cpp_func(linux_side, eye, texture, bounds, flags);
}
case TextureType_Vulkan:
return ivrcompositor_submit_vulkan(cpp_func, linux_side,
eye, texture, bounds, flags, version, user_data);
default:
return cpp_func(linux_side, eye, texture, bounds, flags);
}