-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathREV_CAPI_D3D.cpp
119 lines (92 loc) · 3.89 KB
/
REV_CAPI_D3D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "OVR_CAPI_D3D.h"
#include "Common.h"
#include "Session.h"
#include "CompositorD3D.h"
#include "TextureD3D.h"
#include <d3d11.h>
OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateTextureSwapChainDX(ovrSession session,
IUnknown* d3dPtr,
const ovrTextureSwapChainDesc* desc,
ovrTextureSwapChain* out_TextureSwapChain)
{
REV_TRACE(ovr_CreateTextureSwapChainDX);
if (!session)
return ovrError_InvalidSession;
if (!d3dPtr || !desc || !out_TextureSwapChain)
return ovrError_InvalidParameter;
if (!session->Compositor)
{
session->Compositor.reset(CompositorD3D::Create(d3dPtr));
if (!session->Compositor)
return ovrError_RuntimeException;
}
if (session->Compositor->GetAPI() != vr::TextureType_DirectX)
return ovrError_RuntimeException;
return session->Compositor->CreateTextureSwapChain(desc, out_TextureSwapChain);
}
OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferDX(ovrSession session,
ovrTextureSwapChain chain,
int index,
IID iid,
void** out_Buffer)
{
REV_TRACE(ovr_GetTextureSwapChainBufferDX);
if (!session)
return ovrError_InvalidSession;
if (!chain || !out_Buffer)
return ovrError_InvalidParameter;
if (index < 0)
index = chain->CurrentIndex;
TextureD3D* texture = dynamic_cast<TextureD3D*>(chain->Textures[index].get());
if (!texture)
return ovrError_InvalidParameter;
HRESULT hr = texture->Texture()->QueryInterface(iid, out_Buffer);
if (FAILED(hr))
return ovrError_InvalidParameter;
return ovrSuccess;
}
OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureDX(ovrSession session,
IUnknown* d3dPtr,
const ovrMirrorTextureDesc* desc,
ovrMirrorTexture* out_MirrorTexture)
{
REV_TRACE(ovr_CreateMirrorTextureDX);
if (!session)
return ovrError_InvalidSession;
if (!d3dPtr || !desc || !out_MirrorTexture)
return ovrError_InvalidParameter;
if (!session->Compositor)
{
session->Compositor.reset(CompositorD3D::Create(d3dPtr));
if (!session->Compositor)
return ovrError_RuntimeException;
}
if (session->Compositor->GetAPI() != vr::TextureType_DirectX)
return ovrError_RuntimeException;
return session->Compositor->CreateMirrorTexture(desc, out_MirrorTexture);
}
OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureWithOptionsDX(ovrSession session,
IUnknown* d3dPtr,
const ovrMirrorTextureDesc* desc,
ovrMirrorTexture* out_MirrorTexture)
{
return ovr_CreateMirrorTextureDX(session, d3dPtr, desc, out_MirrorTexture);
}
OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetMirrorTextureBufferDX(ovrSession session,
ovrMirrorTexture mirrorTexture,
IID iid,
void** out_Buffer)
{
REV_TRACE(ovr_GetMirrorTextureBufferDX);
if (!session)
return ovrError_InvalidSession;
if (!mirrorTexture || !out_Buffer)
return ovrError_InvalidParameter;
TextureD3D* texture = dynamic_cast<TextureD3D*>(mirrorTexture->Texture.get());
if (!texture)
return ovrError_InvalidParameter;
HRESULT hr = texture->Texture()->QueryInterface(iid, out_Buffer);
if (FAILED(hr))
return ovrError_InvalidParameter;
return ovrSuccess;
}