Skip to content

Commit 769a401

Browse files
committed
xrRender: Implement OpenGL support in various headers.
1 parent bf18a31 commit 769a401

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+555
-905
lines changed

src/Layers/xrRender/DetailManager.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,13 @@ class ECORE_API CDetailManager
141141
// Hardware processor
142142
ref_geom hw_Geom;
143143
u32 hw_BatchSize;
144-
ID3DVertexBuffer* hw_VB;
145-
ID3DIndexBuffer* hw_IB;
144+
#ifdef USE_OGL
145+
GLuint hw_VB;
146+
GLuint hw_IB;
147+
#else
148+
ID3DVertexBuffer* hw_VB;
149+
ID3DIndexBuffer* hw_IB;
150+
#endif // USE_OGL
146151
ref_constant hwc_consts;
147152
ref_constant hwc_wave;
148153
ref_constant hwc_wind;
@@ -155,7 +160,7 @@ class ECORE_API CDetailManager
155160
void hw_Load_Shaders ();
156161
void hw_Unload ();
157162
void hw_Render ();
158-
#if defined(USE_DX10) || defined(USE_DX11)
163+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
159164
void hw_Render_dump (const Fvector4 &consts, const Fvector4 &wave, const Fvector4 &wind, u32 var_id, u32 lod_id);
160165
#else // USE_DX10
161166
void hw_Render_dump (ref_constant array, u32 var_id, u32 lod_id, u32 c_base);

src/Layers/xrRender/FBasicVisual.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ struct IRender_Mesh
1919
ref_geom rm_geom;
2020

2121
// verts
22-
ID3DVertexBuffer* p_rm_Vertices;
22+
#ifdef USE_OGL
23+
GLuint p_rm_Vertices;
24+
#else
25+
ID3DVertexBuffer* p_rm_Vertices;
26+
#endif // USE_OGL
2327
u32 vBase;
2428
u32 vCount;
2529

2630
// indices
27-
ID3DIndexBuffer* p_rm_Indices;
31+
#ifdef USE_OGL
32+
GLuint p_rm_Indices;
33+
#else
34+
ID3DIndexBuffer* p_rm_Indices;
35+
#endif // USE_OGL
2836
u32 iBase;
2937
u32 iCount;
3038
u32 dwPrimitives;

src/Layers/xrRender/HW.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "hwcaps.h"
1010

11-
#ifndef _MAYA_EXPORT
11+
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
1212
#include "stats_manager.h"
1313
#endif
1414

@@ -116,7 +116,7 @@ class CHW
116116
D3DPRESENT_PARAMETERS DevPP;
117117
#endif
118118

119-
#ifndef _MAYA_EXPORT
119+
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
120120
stats_manager stats_manager;
121121
#endif
122122
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)

src/Layers/xrRender/HWCaps.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#include "hwcaps.h"
55
#include "hw.h"
66

7-
#ifndef _EDITOR
7+
#if !defined(_EDITOR) && !defined(USE_OGL)
88
#include <nvapi.h>
99
#endif
1010

1111
namespace
1212
{
1313

14-
#ifndef _EDITOR
14+
#if !defined(_EDITOR) && !defined(USE_OGL)
1515
u32 GetNVGpuNum()
1616
{
1717
NvLogicalGpuHandle logicalGPUs[NVAPI_MAX_LOGICAL_GPUS];
@@ -108,7 +108,7 @@ u32 GetGpuNum()
108108
#endif
109109
}
110110

111-
#if !defined(USE_DX10) && !defined(USE_DX11)
111+
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
112112
void CHWCaps::Update()
113113
{
114114
D3DCAPS9 caps;
@@ -266,7 +266,11 @@ void CHWCaps::Update()
266266
dwMaxStencilValue=(1<<8)-1;
267267

268268
// DEV INFO
269-
269+
#ifdef USE_OGL
270+
// TODO: OGL: SLI/Crossfire support.
271+
iGPUNum = 1;
272+
#else
270273
iGPUNum = GetGpuNum();
274+
#endif // !USE_OGL
271275
}
272276
#endif // USE_DX10

src/Layers/xrRender/QueryHelper.h

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,69 @@
33
#pragma once
44

55
// Interface
6-
IC HRESULT CreateQuery( ID3DQuery **ppQuery , D3DQUERYTYPE Type);
7-
IC HRESULT GetData( ID3DQuery *pQuery, void *pData, UINT DataSize );
8-
IC HRESULT BeginQuery( ID3DQuery *pQuery);
9-
IC HRESULT EndQuery( ID3DQuery *pQuery);
6+
7+
#ifdef USE_OGL
8+
9+
IC HRESULT CreateQuery(GLuint* pQuery);
10+
IC HRESULT GetData(GLuint query, void *pData, UINT DataSize);
11+
IC HRESULT BeginQuery(GLuint query);
12+
IC HRESULT EndQuery(GLuint query);
13+
IC HRESULT ReleaseQuery(GLuint pQuery);
14+
15+
#else
16+
17+
IC HRESULT CreateQuery(ID3DQuery **ppQuery);
18+
IC HRESULT GetData(ID3DQuery *pQuery, void *pData, UINT DataSize);
19+
IC HRESULT BeginQuery(ID3DQuery *pQuery);
20+
IC HRESULT EndQuery(ID3DQuery *pQuery);
21+
IC HRESULT ReleaseQuery(ID3DQuery *pQuery);
22+
23+
#endif // USE_OGL
1024

1125
// Implementation
1226

13-
#if defined(USE_DX11)
27+
#if defined(USE_OGL)
28+
29+
IC HRESULT CreateQuery(GLuint *pQuery)
30+
{
31+
glGenQueries(1, pQuery);
32+
return S_OK;
33+
}
34+
35+
IC HRESULT GetData(GLuint query, void *pData, UINT DataSize)
36+
{
37+
if (DataSize == sizeof(GLint64))
38+
CHK_GL(glGetQueryObjecti64v(query, GL_QUERY_RESULT, (GLint64*)pData));
39+
else
40+
CHK_GL(glGetQueryObjectiv(query, GL_QUERY_RESULT, (GLint*)pData));
41+
return S_OK;
42+
}
43+
44+
IC HRESULT BeginQuery(GLuint query)
45+
{
46+
CHK_GL(glBeginQuery(GL_SAMPLES_PASSED, query));
47+
return S_OK;
48+
}
49+
50+
IC HRESULT EndQuery(GLuint query)
51+
{
52+
CHK_GL(glEndQuery(GL_SAMPLES_PASSED));
53+
return S_OK;
54+
}
1455

15-
IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
56+
IC HRESULT ReleaseQuery(GLuint query)
57+
{
58+
CHK_GL(glDeleteQueries(1, &query));
59+
return S_OK;
60+
}
61+
62+
#elif defined(USE_DX11)
63+
64+
IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
1665
{
1766
D3D_QUERY_DESC desc;
1867
desc.MiscFlags = 0;
19-
20-
switch (Type)
21-
{
22-
case D3DQUERYTYPE_OCCLUSION:
23-
desc.Query = D3D_QUERY_OCCLUSION;
24-
break;
25-
default:
26-
VERIFY(!"No default.");
27-
}
28-
68+
desc.Query = D3D_QUERY_OCCLUSION;
2969
return HW.pDevice->CreateQuery( &desc, ppQuery);
3070
}
3171

@@ -49,20 +89,11 @@ IC HRESULT EndQuery( ID3DQuery *pQuery)
4989

5090
#elif defined(USE_DX10)
5191

52-
IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
92+
IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
5393
{
5494
D3D_QUERY_DESC desc;
5595
desc.MiscFlags = 0;
56-
57-
switch (Type)
58-
{
59-
case D3DQUERYTYPE_OCCLUSION:
60-
desc.Query = D3D_QUERY_OCCLUSION;
61-
break;
62-
default:
63-
VERIFY(!"No default.");
64-
}
65-
96+
desc.Query = D3D_QUERY_OCCLUSION;
6697
return HW.pDevice->CreateQuery( &desc, ppQuery);
6798
}
6899

@@ -86,9 +117,9 @@ IC HRESULT EndQuery( ID3DQuery *pQuery)
86117

87118
#else // USE_DX10
88119

89-
IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
120+
IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
90121
{
91-
return HW.pDevice->CreateQuery(Type, ppQuery);
122+
return HW.pDevice->CreateQuery(D3D_QUERY_OCCLUSION, ppQuery);
92123
}
93124

94125
IC HRESULT GetData( ID3DQuery *pQuery, void *pData, UINT DataSize )

0 commit comments

Comments
 (0)