Skip to content

Commit

Permalink
xrRender: Add missing OpenGL implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 26, 2015
1 parent e19d65f commit 33affdb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 28 deletions.
8 changes: 5 additions & 3 deletions src/Layers/xrRender/D3DXRenderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class D3DXRenderBase : public IRender, public pureFrame

// Runtime structures
xr_vector<R_dsgraph::mapNormalVS::TNode*,render_alloc<R_dsgraph::mapNormalVS::TNode*> > nrmVS;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
xr_vector<R_dsgraph::mapNormalGS::TNode*,render_alloc<R_dsgraph::mapNormalGS::TNode*> > nrmGS;
#endif // USE_DX10
xr_vector<R_dsgraph::mapNormalPS::TNode*,render_alloc<R_dsgraph::mapNormalPS::TNode*> > nrmPS;
Expand All @@ -58,7 +58,7 @@ class D3DXRenderBase : public IRender, public pureFrame
xr_vector<R_dsgraph::mapNormalTextures::TNode*,render_alloc<R_dsgraph::mapNormalTextures::TNode*> > nrmTexturesTemp;

xr_vector<R_dsgraph::mapMatrixVS::TNode*,render_alloc<R_dsgraph::mapMatrixVS::TNode*> > matVS;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
xr_vector<R_dsgraph::mapMatrixGS::TNode*,render_alloc<R_dsgraph::mapMatrixGS::TNode*> > matGS;
#endif // USE_DX10
xr_vector<R_dsgraph::mapMatrixPS::TNode*,render_alloc<R_dsgraph::mapMatrixPS::TNode*> > matPS;
Expand Down Expand Up @@ -228,5 +228,7 @@ class D3DXRenderBase : public IRender, public pureFrame
ref_shader m_SelectionShader;

private:
CGammaControl m_Gamma;
#ifndef USE_OGL
CGammaControl m_Gamma;
#endif // !USE_OGL
};
46 changes: 36 additions & 10 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector


#ifdef USE_RESOURCE_DEBUGGER
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
mapMatrixVS::TNode* Nvs = map.insert (pass.vs);
mapMatrixGS::TNode* Ngs = Nvs->val.insert (pass.gs);
mapMatrixPS::TNode* Nps = Ngs->val.insert (pass.ps);
Expand All @@ -170,7 +170,11 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector
mapMatrixPS::TNode* Nps = Nvs->val.insert (pass.ps);
#endif // USE_DX10
#else
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_OGL)
mapMatrixVS::TNode* Nvs = map.insert (pass.vs->vs);
mapMatrixGS::TNode* Ngs = Nvs->val.insert (pass.gs->gs);
mapMatrixPS::TNode* Nps = Ngs->val.insert (pass.ps->ps);
#elif defined(USE_DX10) || defined(USE_DX11)
mapMatrixVS::TNode* Nvs = map.insert (&*pass.vs);
mapMatrixGS::TNode* Ngs = Nvs->val.insert (pass.gs->gs);
mapMatrixPS::TNode* Nps = Ngs->val.insert (pass.ps->ps);
Expand Down Expand Up @@ -207,11 +211,11 @@ void D3DXRenderBase::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector
#else
if (SSA>Nps->val.ssa) { Nps->val.ssa = SSA;
#endif
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
if (SSA>Ngs->val.ssa) { Ngs->val.ssa = SSA;
#endif // USE_DX10
if (SSA>Nvs->val.ssa) { Nvs->val.ssa = SSA;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
} } } } } }
#else // USE_DX10
} } } } }
Expand Down Expand Up @@ -322,7 +326,7 @@ void D3DXRenderBase::r_dsgraph_insert_static (dxRender_Visual *pVisual)
//#endif

#ifdef USE_RESOURCE_DEBUGGER
# if defined(USE_DX10) || defined(USE_DX11)
# if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
mapNormalVS::TNode* Nvs = map.insert (pass.vs);
mapNormalGS::TNode* Ngs = Nvs->val.insert (pass.gs);
mapNormalPS::TNode* Nps = Ngs->val.insert (pass.ps);
Expand All @@ -331,7 +335,11 @@ void D3DXRenderBase::r_dsgraph_insert_static (dxRender_Visual *pVisual)
mapNormalPS::TNode* Nps = Nvs->val.insert (pass.ps);
# endif // USE_DX10
#else // USE_RESOURCE_DEBUGGER
# if defined(USE_DX10) || defined(USE_DX11)
# if defined(USE_OGL)
mapNormalVS::TNode* Nvs = map.insert (pass.vs->vs);
mapNormalGS::TNode* Ngs = Nvs->val.insert (pass.gs->gs);
mapNormalPS::TNode* Nps = Ngs->val.insert (pass.ps->ps);
# elif defined(USE_DX10) || defined(USE_DX11)
mapNormalVS::TNode* Nvs = map.insert (&*pass.vs);
mapNormalGS::TNode* Ngs = Nvs->val.insert (pass.gs->gs);
mapNormalPS::TNode* Nps = Ngs->val.insert (pass.ps->ps);
Expand Down Expand Up @@ -764,16 +772,32 @@ void D3DXRenderBase::Copy(IRender &_in)
{ *this = *(D3DXRenderBase*)&_in; }

void D3DXRenderBase::setGamma(float fGamma)
{ m_Gamma.Gamma(fGamma); }
{
#ifndef USE_OGL
m_Gamma.Gamma(fGamma);
#endif // !USE_OGL
}

void D3DXRenderBase::setBrightness(float fGamma)
{ m_Gamma.Brightness(fGamma); }
{
#ifndef USE_OGL
m_Gamma.Brightness(fGamma);
#endif // !USE_OGL
}

void D3DXRenderBase::setContrast(float fGamma)
{ m_Gamma.Contrast(fGamma); }
{
#ifndef USE_OGL
m_Gamma.Contrast(fGamma);
#endif // !USE_OGL
}

void D3DXRenderBase::updateGamma()
{ m_Gamma.Update(); }
{
#ifndef USE_OGL
m_Gamma.Update();
#endif // !USE_OGL
}

void D3DXRenderBase::OnDeviceDestroy(bool bKeepTextures)
{
Expand Down Expand Up @@ -875,7 +899,9 @@ void D3DXRenderBase::OnDeviceCreate(const char *shName)
{
// Signal everyone - device created
RCache.OnDeviceCreate();
#ifndef USE_OGL
m_Gamma.Update();
#endif // !USE_OGL
Resources->OnDeviceCreate(shName);
create();
if (!g_dedicated_server)
Expand Down
10 changes: 5 additions & 5 deletions src/Layers/xrRender/r__dsgraph_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ IC bool cmp_ps_mat (mapMatrixPS::TNode* N1, mapMatrixPS::TNode* N2)
#endif
}

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
IC bool cmp_gs_nrm (mapNormalGS::TNode* N1, mapNormalGS::TNode* N2) { return (N1->val.ssa > N2->val.ssa); }
IC bool cmp_gs_mat (mapMatrixGS::TNode* N1, mapMatrixGS::TNode* N2) { return (N1->val.ssa > N2->val.ssa); }
#endif // USE_DX10
Expand Down Expand Up @@ -282,7 +282,7 @@ void D3DXRenderBase::r_dsgraph_render_graph (u32 _priority, bool _clear)
mapNormalVS::TNode* Nvs = nrmVS[vs_id];
RCache.set_VS (Nvs->key);

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
// GS setup
mapNormalGS& gs = Nvs->val; gs.ssa = 0;

Expand Down Expand Up @@ -351,7 +351,7 @@ void D3DXRenderBase::r_dsgraph_render_graph (u32 _priority, bool _clear)
}
nrmPS.clear ();
if(_clear) ps.clear ();
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
}
nrmGS.clear ();
if(_clear) gs.clear ();
Expand All @@ -376,7 +376,7 @@ void D3DXRenderBase::r_dsgraph_render_graph (u32 _priority, bool _clear)
mapMatrixVS::TNode* Nvs = matVS[vs_id];
RCache.set_VS (Nvs->key);

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
mapMatrixGS& gs = Nvs->val; gs.ssa = 0;

gs.getANY_P (matGS);
Expand Down Expand Up @@ -443,7 +443,7 @@ void D3DXRenderBase::r_dsgraph_render_graph (u32 _priority, bool _clear)
}
matPS.clear ();
if(_clear) ps.clear ();
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
}
matGS.clear ();
if(_clear) gs.clear ();
Expand Down
5 changes: 3 additions & 2 deletions src/Layers/xrRender/r__dsgraph_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace R_dsgraph
#ifdef USE_OGL
typedef GLuint vs_type;
typedef GLuint ps_type;
typedef GLuint gs_type;
#else
#if defined(USE_DX10) || defined(USE_DX11) // DX10 needs shader signature to propperly bind deometry to shader
typedef SVS* vs_type;
Expand Down Expand Up @@ -127,7 +128,7 @@ namespace R_dsgraph
#else
struct mapNormalPS : public FixedMAP<ps_type, mapNormalCS,render_allocator> { float ssa; };
#endif // USE_DX11
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
struct mapNormalGS : public FixedMAP<gs_type, mapNormalPS,render_allocator> { float ssa; };
struct mapNormalVS : public FixedMAP<vs_type, mapNormalGS,render_allocator> { };
#else // USE_DX10
Expand All @@ -153,7 +154,7 @@ namespace R_dsgraph
#else
struct mapMatrixPS : public FixedMAP<ps_type, mapMatrixCS,render_allocator> { float ssa; };
#endif // USE_DX11
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
struct mapMatrixGS : public FixedMAP<gs_type, mapMatrixPS,render_allocator> { float ssa; };
struct mapMatrixVS : public FixedMAP<vs_type, mapMatrixGS,render_allocator> { };
#else // USE_DX10
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRender/r_constants.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "stdafx.h"
#pragma hdrstop

#pragma warning(disable:4995)
#include <d3dx9.h>
#pragma warning(default:4995)

#include "ResourceManager.h"
#include "xrCore/xrPool.h"
#include "r_constants.h"
Expand Down Expand Up @@ -52,7 +48,7 @@ ref_constant R_constant_table::get (shared_str& S)
return 0;
}

#if !defined(USE_DX10) && !defined(USE_DX11)
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
BOOL R_constant_table::parse (void* _desc, u32 destination)
{
D3DXSHADER_CONSTANTTABLE* desc = (D3DXSHADER_CONSTANTTABLE*) _desc;
Expand Down Expand Up @@ -201,7 +197,7 @@ void R_constant_table::merge(R_constant_table* T)
C->type = src->type;
C->ps = src->ps;
C->vs = src->vs;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
C->gs = src->gs;
# ifdef USE_DX11
C->hs = src->hs;
Expand All @@ -221,6 +217,10 @@ void R_constant_table::merge(R_constant_table* T)
R_constant_load& dL = C->get_load(src->destination);
dL.index = sL.index;
dL.cls = sL.cls;
#ifdef USE_OGL
dL.location = sL.location;
dL.program = sL.program;
#endif // USE_OGL
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/r_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct ECORE_API R_constant :public xr_resource

R_constant_load ps;
R_constant_load vs;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
R_constant_load gs;
# ifdef USE_DX11
R_constant_load hs;
Expand All @@ -121,7 +121,7 @@ struct ECORE_API R_constant :public xr_resource
return vs;
case RC_dest_pixel:
return ps;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
case RC_dest_geometry:
return gs;
# ifdef USE_DX11
Expand Down

0 comments on commit 33affdb

Please sign in to comment.