Skip to content

Commit

Permalink
Shader: Implement geometry shader support.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Nov 24, 2015
1 parent 97d304d commit 6392d30
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 119 deletions.
8 changes: 6 additions & 2 deletions src/Layers/xrRender/R_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ECORE_API CBackend
CTexture* textures_ps [CTexture::mtMaxPixelShaderTextures]; // stages
//CTexture* textures_vs [5 ]; // dmap + 4 vs
CTexture* textures_vs [CTexture::mtMaxVertexShaderTextures]; // 4 vs
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
CTexture* textures_gs [CTexture::mtMaxGeometryShaderTextures]; // 4 vs
# ifdef USE_DX11
CTexture* textures_hs [CTexture::mtMaxHullShaderTextures]; // 4 vs
Expand Down Expand Up @@ -295,8 +295,12 @@ class ECORE_API CBackend
#endif // USE_OGL
ICF void set_PS (ref_ps& _ps) { set_PS(_ps->ps,_ps->cName.c_str()); }

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
#ifdef USE_OGL
ICF void set_GS (GLuint _gs, LPCSTR _n=0);
#else
ICF void set_GS (ID3DGeometryShader* _gs, LPCSTR _n=0);
#endif // USE_OGL
ICF void set_GS (ref_gs& _gs) { set_GS(_gs->gs,_gs->cName.c_str()); }

# ifdef USE_DX11
Expand Down
9 changes: 6 additions & 3 deletions src/Layers/xrRender/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ECORE_API CResourceManager
DEFINE_MAP_PRED(const char*,CRT*, map_RT, map_RTIt, str_pred);
// DX10 cut DEFINE_MAP_PRED(const char*,CRTC*, map_RTC, map_RTCIt, str_pred);
DEFINE_MAP_PRED(const char*,SVS*, map_VS, map_VSIt, str_pred);
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
DEFINE_MAP_PRED(const char*,SGS*, map_GS, map_GSIt, str_pred);
#endif // USE_DX10
#ifdef USE_DX11
Expand All @@ -56,7 +56,7 @@ class ECORE_API CResourceManager
// DX10 cut map_RTC m_rtargets_c;
map_VS m_vs;
map_PS m_ps;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
map_GS m_gs;
#endif // USE_DX10
map_TD m_td;
Expand Down Expand Up @@ -145,7 +145,7 @@ class ECORE_API CResourceManager

// DX10 cut CRTC* _CreateRTC (LPCSTR Name, u32 size, D3DFORMAT f);
// DX10 cut void _DeleteRTC (const CRTC* RT );
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
SGS* _CreateGS (LPCSTR Name);
void _DeleteGS (const SGS* GS );
#endif // USE_DX10
Expand Down Expand Up @@ -174,6 +174,9 @@ class ECORE_API CResourceManager
SState* _CreateState (SimulatorStates& Code);
void _DeleteState (const SState* SB);

#ifdef USE_OGL
SDeclaration* _CreateDecl (u32 FVF);
#endif // USE_OGL
SDeclaration* _CreateDecl (D3DVERTEXELEMENT9* dcl);
void _DeleteDecl (const SDeclaration* dcl);

Expand Down
10 changes: 8 additions & 2 deletions src/Layers/xrRender/SH_Atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ SPS::~SPS()
RImplementation.Resources->_DeletePS(this);
}

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
///////////////////////////////////////////////////////////////////////
// SGS
SGS::~SGS ()
{
_RELEASE(gs);
#ifdef USE_OGL
CHK_GL(glDeleteProgram(gs));
#else
_RELEASE(gs);
#endif // USE_OGL
RImplementation.Resources->_DeleteGS(this);
}

Expand All @@ -74,7 +78,9 @@ SCS::~SCS ()
RImplementation.Resources->_DeleteCS(this);
}
# endif
#endif // USE_DX10

#if defined(USE_DX10) || defined(USE_DX11)
///////////////////////////////////////////////////////////////////////
// SInputSignature
SInputSignature::SInputSignature(ID3DBlob* pBlob) { VERIFY(pBlob); signature=pBlob; signature->AddRef();};
Expand Down
6 changes: 5 additions & 1 deletion src/Layers/xrRender/SH_Atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ struct ECORE_API SPS : public xr_resource_named
};
typedef resptr_core<SPS,resptr_base<SPS> > ref_ps;

#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
//////////////////////////////////////////////////////////////////////////
struct ECORE_API SGS : public xr_resource_named
{
#ifdef USE_OGL
GLuint gs;
#else
ID3DGeometryShader* gs;
#endif // USE_OGL
R_constant_table constants;
~SGS ();
};
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/SH_Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CTheoraSurface;
class ECORE_API CTexture : public xr_resource_named
{
public:
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
enum MaxTextures
{
// Actually these values are 128
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BOOL SPass::equal(const SPass& other)
if (state != other.state) return FALSE;
if (ps != other.ps) return FALSE;
if (vs != other.vs) return FALSE;
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
if (gs != other.gs) return FALSE;
# ifdef USE_DX11
if (hs != other.hs) return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct ECORE_API SPass : public xr_resource_flagged {
ref_state state; // Generic state, like Z-Buffering, samplers, etc
ref_ps ps; // may be NULL = FFP, in that case "state" must contain TSS setup
ref_vs vs; // may be NULL = FFP, in that case "state" must contain RS setup, *and* FVF-compatible declaration must be used
#if defined(USE_DX10) || defined(USE_DX11)
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
ref_gs gs; // may be NULL = don't use geometry shader at all
# ifdef USE_DX11
ref_hs hs; // may be NULL = don't use hull shader at all
Expand Down
Loading

0 comments on commit 6392d30

Please sign in to comment.