Skip to content

Commit

Permalink
xrRender: Implement OpenGL support in various headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 23, 2015
1 parent bf18a31 commit 769a401
Show file tree
Hide file tree
Showing 63 changed files with 555 additions and 905 deletions.
11 changes: 8 additions & 3 deletions src/Layers/xrRender/DetailManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ class ECORE_API CDetailManager
// Hardware processor
ref_geom hw_Geom;
u32 hw_BatchSize;
ID3DVertexBuffer* hw_VB;
ID3DIndexBuffer* hw_IB;
#ifdef USE_OGL
GLuint hw_VB;
GLuint hw_IB;
#else
ID3DVertexBuffer* hw_VB;
ID3DIndexBuffer* hw_IB;
#endif // USE_OGL
ref_constant hwc_consts;
ref_constant hwc_wave;
ref_constant hwc_wind;
Expand All @@ -155,7 +160,7 @@ class ECORE_API CDetailManager
void hw_Load_Shaders ();
void hw_Unload ();
void hw_Render ();
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
void hw_Render_dump (const Fvector4 &consts, const Fvector4 &wave, const Fvector4 &wind, u32 var_id, u32 lod_id);
#else // USE_DX10
void hw_Render_dump (ref_constant array, u32 var_id, u32 lod_id, u32 c_base);
Expand Down
12 changes: 10 additions & 2 deletions src/Layers/xrRender/FBasicVisual.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ struct IRender_Mesh
ref_geom rm_geom;

// verts
ID3DVertexBuffer* p_rm_Vertices;
#ifdef USE_OGL
GLuint p_rm_Vertices;
#else
ID3DVertexBuffer* p_rm_Vertices;
#endif // USE_OGL
u32 vBase;
u32 vCount;

// indices
ID3DIndexBuffer* p_rm_Indices;
#ifdef USE_OGL
GLuint p_rm_Indices;
#else
ID3DIndexBuffer* p_rm_Indices;
#endif // USE_OGL
u32 iBase;
u32 iCount;
u32 dwPrimitives;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "hwcaps.h"

#ifndef _MAYA_EXPORT
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
#include "stats_manager.h"
#endif

Expand Down Expand Up @@ -116,7 +116,7 @@ class CHW
D3DPRESENT_PARAMETERS DevPP;
#endif

#ifndef _MAYA_EXPORT
#if !defined(_MAYA_EXPORT) && !defined(USE_OGL)
stats_manager stats_manager;
#endif
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
Expand Down
12 changes: 8 additions & 4 deletions src/Layers/xrRender/HWCaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "hwcaps.h"
#include "hw.h"

#ifndef _EDITOR
#if !defined(_EDITOR) && !defined(USE_OGL)
#include <nvapi.h>
#endif

namespace
{

#ifndef _EDITOR
#if !defined(_EDITOR) && !defined(USE_OGL)
u32 GetNVGpuNum()
{
NvLogicalGpuHandle logicalGPUs[NVAPI_MAX_LOGICAL_GPUS];
Expand Down Expand Up @@ -108,7 +108,7 @@ u32 GetGpuNum()
#endif
}

#if !defined(USE_DX10) && !defined(USE_DX11)
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
void CHWCaps::Update()
{
D3DCAPS9 caps;
Expand Down Expand Up @@ -266,7 +266,11 @@ void CHWCaps::Update()
dwMaxStencilValue=(1<<8)-1;

// DEV INFO

#ifdef USE_OGL
// TODO: OGL: SLI/Crossfire support.
iGPUNum = 1;
#else
iGPUNum = GetGpuNum();
#endif // !USE_OGL
}
#endif // USE_DX10
89 changes: 60 additions & 29 deletions src/Layers/xrRender/QueryHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,69 @@
#pragma once

// Interface
IC HRESULT CreateQuery( ID3DQuery **ppQuery , D3DQUERYTYPE Type);
IC HRESULT GetData( ID3DQuery *pQuery, void *pData, UINT DataSize );
IC HRESULT BeginQuery( ID3DQuery *pQuery);
IC HRESULT EndQuery( ID3DQuery *pQuery);

#ifdef USE_OGL

IC HRESULT CreateQuery(GLuint* pQuery);
IC HRESULT GetData(GLuint query, void *pData, UINT DataSize);
IC HRESULT BeginQuery(GLuint query);
IC HRESULT EndQuery(GLuint query);
IC HRESULT ReleaseQuery(GLuint pQuery);

#else

IC HRESULT CreateQuery(ID3DQuery **ppQuery);
IC HRESULT GetData(ID3DQuery *pQuery, void *pData, UINT DataSize);
IC HRESULT BeginQuery(ID3DQuery *pQuery);
IC HRESULT EndQuery(ID3DQuery *pQuery);
IC HRESULT ReleaseQuery(ID3DQuery *pQuery);

#endif // USE_OGL

// Implementation

#if defined(USE_DX11)
#if defined(USE_OGL)

IC HRESULT CreateQuery(GLuint *pQuery)
{
glGenQueries(1, pQuery);
return S_OK;
}

IC HRESULT GetData(GLuint query, void *pData, UINT DataSize)
{
if (DataSize == sizeof(GLint64))
CHK_GL(glGetQueryObjecti64v(query, GL_QUERY_RESULT, (GLint64*)pData));
else
CHK_GL(glGetQueryObjectiv(query, GL_QUERY_RESULT, (GLint*)pData));
return S_OK;
}

IC HRESULT BeginQuery(GLuint query)
{
CHK_GL(glBeginQuery(GL_SAMPLES_PASSED, query));
return S_OK;
}

IC HRESULT EndQuery(GLuint query)
{
CHK_GL(glEndQuery(GL_SAMPLES_PASSED));
return S_OK;
}

IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
IC HRESULT ReleaseQuery(GLuint query)
{
CHK_GL(glDeleteQueries(1, &query));
return S_OK;
}

#elif defined(USE_DX11)

IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
{
D3D_QUERY_DESC desc;
desc.MiscFlags = 0;

switch (Type)
{
case D3DQUERYTYPE_OCCLUSION:
desc.Query = D3D_QUERY_OCCLUSION;
break;
default:
VERIFY(!"No default.");
}

desc.Query = D3D_QUERY_OCCLUSION;
return HW.pDevice->CreateQuery( &desc, ppQuery);
}

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

#elif defined(USE_DX10)

IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
{
D3D_QUERY_DESC desc;
desc.MiscFlags = 0;

switch (Type)
{
case D3DQUERYTYPE_OCCLUSION:
desc.Query = D3D_QUERY_OCCLUSION;
break;
default:
VERIFY(!"No default.");
}

desc.Query = D3D_QUERY_OCCLUSION;
return HW.pDevice->CreateQuery( &desc, ppQuery);
}

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

#else // USE_DX10

IC HRESULT CreateQuery ( ID3DQuery **ppQuery, D3DQUERYTYPE Type)
IC HRESULT CreateQuery ( ID3DQuery **ppQuery)
{
return HW.pDevice->CreateQuery(Type, ppQuery);
return HW.pDevice->CreateQuery(D3D_QUERY_OCCLUSION, ppQuery);
}

IC HRESULT GetData( ID3DQuery *pQuery, void *pData, UINT DataSize )
Expand Down
Loading

0 comments on commit 769a401

Please sign in to comment.