vrclient: Add initial support for wined3d D3D11

This commit is contained in:
Józef Kucia 2018-04-04 17:20:44 +02:00 committed by Andrew Eikum
parent 2caa4964d2
commit dae9230aff
2 changed files with 86 additions and 1 deletions

View File

@ -14,6 +14,9 @@
#include "vrclient_defs.h"
#include "vrclient_private.h"
#include "initguid.h"
#include "wined3d-interop.h"
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
@ -148,6 +151,42 @@ void get_dxgi_output_info2(void *cpp_func, void *linux_side, int32_t *adapter_id
*output_idx = 0;
}
struct submit_data
{
void *linux_side;
EVRCompositorError (*submit)(void *, EVREye, Texture_t *, VRTextureBounds_t *, EVRSubmitFlags);
EVREye eye;
Texture_t texture;
VRTextureBounds_t bounds;
EVRSubmitFlags flags;
};
static CDECL void d3d11_texture_callback(unsigned int gl_texture, const void *data, unsigned int data_size)
{
const struct submit_data *submit_data = data;
VRCompositorError error = 0;
VRTextureBounds_t bounds;
Texture_t texture;
TRACE("texture %u, data {%p, %u}\n", gl_texture, data, data_size);
texture = submit_data->texture;
texture.handle = (void *)(UINT_PTR)gl_texture;
texture.eType = TextureType_OpenGL;
/* Textures are upside-down in wined3d. */
bounds = submit_data->bounds;
bounds.vMin = submit_data->bounds.vMax;
bounds.vMax = submit_data->bounds.vMin;
error = submit_data->submit(submit_data->linux_side, submit_data->eye,
&texture, &bounds, submit_data->flags);
if (error)
ERR("error %#x\n", error);
}
void ivrcompositor_005_submit(
void (*cpp_func)(void *, Hmd_Eye, void *, Compositor_TextureBounds *),
void *linux_side, Hmd_Eye eye, void *texture, Compositor_TextureBounds *bounds)
@ -172,6 +211,9 @@ VRCompositorError ivrcompositor_007_submit(
{
TRACE("%p, %#x, %#x, %p, %p\n", linux_side, eye, api, texture, bounds);
if (api == API_DirectX)
FIXME("Not implemented Direct3D API!\n");
return cpp_func(linux_side, eye, api, texture, bounds);
}
@ -183,6 +225,9 @@ VRCompositorError ivrcompositor_008_submit(
{
TRACE("%p, %#x, %#x, %p, %p, %#x\n", linux_side, eye, api, texture, bounds, flags);
if (api == API_DirectX)
FIXME("Not implemented Direct3D API!\n");
return cpp_func(linux_side, eye, api, texture, bounds, flags);
}
@ -190,7 +235,46 @@ 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)
{
IWineD3D11Texture2D *wine_texture;
struct submit_data submit_data;
IUnknown *texture_iface;
HRESULT hr;
TRACE("%p, %#x, %p, %p, %#x\n", linux_side, eye, texture, bounds, flags);
return cpp_func(linux_side, eye, texture, bounds, flags);
switch (texture->eType)
{
case TextureType_DirectX:
TRACE("D3D11\n");
if (flags & (Submit_TextureWithPose | Submit_TextureWithDepth))
{
FIXME("Submit with pose or depth is not supported.\n");
flags &= ~(Submit_TextureWithPose | Submit_TextureWithDepth);
}
texture_iface = texture->handle;
hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
&IID_IWineD3D11Texture2D, (void **)&wine_texture);
if (FAILED(hr))
{
ERR("Invalid D3D11 texture %p.\n", texture);
return cpp_func(linux_side, eye, texture, bounds, flags);
}
submit_data.linux_side = linux_side;
submit_data.submit = cpp_func;
submit_data.eye = eye;
submit_data.texture = *texture;
submit_data.bounds = *bounds;
submit_data.flags = flags;
wine_texture->lpVtbl->access_gl_texture(wine_texture,
d3d11_texture_callback, &submit_data, sizeof(submit_data));
wine_texture->lpVtbl->Release(wine_texture);
return 0;
default:
return cpp_func(linux_side, eye, texture, bounds, flags);
}
}

View File

@ -60,3 +60,4 @@ EVRCompositorError ivrcompositor_submit(
#define TRACE WINE_TRACE
#define ERR WINE_ERR
#define WARN WINE_WARN
#define FIXME WINE_FIXME