Skip to content

Commit 6392d30

Browse files
committed
Shader: Implement geometry shader support.
1 parent 97d304d commit 6392d30

File tree

8 files changed

+199
-119
lines changed

8 files changed

+199
-119
lines changed

src/Layers/xrRender/R_Backend.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class ECORE_API CBackend
173173
CTexture* textures_ps [CTexture::mtMaxPixelShaderTextures]; // stages
174174
//CTexture* textures_vs [5 ]; // dmap + 4 vs
175175
CTexture* textures_vs [CTexture::mtMaxVertexShaderTextures]; // 4 vs
176-
#if defined(USE_DX10) || defined(USE_DX11)
176+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
177177
CTexture* textures_gs [CTexture::mtMaxGeometryShaderTextures]; // 4 vs
178178
# ifdef USE_DX11
179179
CTexture* textures_hs [CTexture::mtMaxHullShaderTextures]; // 4 vs
@@ -295,8 +295,12 @@ class ECORE_API CBackend
295295
#endif // USE_OGL
296296
ICF void set_PS (ref_ps& _ps) { set_PS(_ps->ps,_ps->cName.c_str()); }
297297

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

302306
# ifdef USE_DX11

src/Layers/xrRender/ResourceManager.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ECORE_API CResourceManager
3535
DEFINE_MAP_PRED(const char*,CRT*, map_RT, map_RTIt, str_pred);
3636
// DX10 cut DEFINE_MAP_PRED(const char*,CRTC*, map_RTC, map_RTCIt, str_pred);
3737
DEFINE_MAP_PRED(const char*,SVS*, map_VS, map_VSIt, str_pred);
38-
#if defined(USE_DX10) || defined(USE_DX11)
38+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
3939
DEFINE_MAP_PRED(const char*,SGS*, map_GS, map_GSIt, str_pred);
4040
#endif // USE_DX10
4141
#ifdef USE_DX11
@@ -56,7 +56,7 @@ class ECORE_API CResourceManager
5656
// DX10 cut map_RTC m_rtargets_c;
5757
map_VS m_vs;
5858
map_PS m_ps;
59-
#if defined(USE_DX10) || defined(USE_DX11)
59+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
6060
map_GS m_gs;
6161
#endif // USE_DX10
6262
map_TD m_td;
@@ -145,7 +145,7 @@ class ECORE_API CResourceManager
145145

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

177+
#ifdef USE_OGL
178+
SDeclaration* _CreateDecl (u32 FVF);
179+
#endif // USE_OGL
177180
SDeclaration* _CreateDecl (D3DVERTEXELEMENT9* dcl);
178181
void _DeleteDecl (const SDeclaration* dcl);
179182

src/Layers/xrRender/SH_Atomic.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ SPS::~SPS()
4848
RImplementation.Resources->_DeletePS(this);
4949
}
5050

51-
#if defined(USE_DX10) || defined(USE_DX11)
51+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
5252
///////////////////////////////////////////////////////////////////////
5353
// SGS
5454
SGS::~SGS ()
5555
{
56-
_RELEASE(gs);
56+
#ifdef USE_OGL
57+
CHK_GL(glDeleteProgram(gs));
58+
#else
59+
_RELEASE(gs);
60+
#endif // USE_OGL
5761
RImplementation.Resources->_DeleteGS(this);
5862
}
5963

@@ -74,7 +78,9 @@ SCS::~SCS ()
7478
RImplementation.Resources->_DeleteCS(this);
7579
}
7680
# endif
81+
#endif // USE_DX10
7782

83+
#if defined(USE_DX10) || defined(USE_DX11)
7884
///////////////////////////////////////////////////////////////////////
7985
// SInputSignature
8086
SInputSignature::SInputSignature(ID3DBlob* pBlob) { VERIFY(pBlob); signature=pBlob; signature->AddRef();};

src/Layers/xrRender/SH_Atomic.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,15 @@ struct ECORE_API SPS : public xr_resource_named
5454
};
5555
typedef resptr_core<SPS,resptr_base<SPS> > ref_ps;
5656

57-
#if defined(USE_DX10) || defined(USE_DX11)
57+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
5858
//////////////////////////////////////////////////////////////////////////
5959
struct ECORE_API SGS : public xr_resource_named
6060
{
61+
#ifdef USE_OGL
62+
GLuint gs;
63+
#else
6164
ID3DGeometryShader* gs;
65+
#endif // USE_OGL
6266
R_constant_table constants;
6367
~SGS ();
6468
};

src/Layers/xrRender/SH_Texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CTheoraSurface;
1010
class ECORE_API CTexture : public xr_resource_named
1111
{
1212
public:
13-
#if defined(USE_DX10) || defined(USE_DX11)
13+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
1414
enum MaxTextures
1515
{
1616
// Actually these values are 128

src/Layers/xrRender/Shader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ BOOL SPass::equal(const SPass& other)
5959
if (state != other.state) return FALSE;
6060
if (ps != other.ps) return FALSE;
6161
if (vs != other.vs) return FALSE;
62-
#if defined(USE_DX10) || defined(USE_DX11)
62+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
6363
if (gs != other.gs) return FALSE;
6464
# ifdef USE_DX11
6565
if (hs != other.hs) return FALSE;

src/Layers/xrRender/Shader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct ECORE_API SPass : public xr_resource_flagged {
8989
ref_state state; // Generic state, like Z-Buffering, samplers, etc
9090
ref_ps ps; // may be NULL = FFP, in that case "state" must contain TSS setup
9191
ref_vs vs; // may be NULL = FFP, in that case "state" must contain RS setup, *and* FVF-compatible declaration must be used
92-
#if defined(USE_DX10) || defined(USE_DX11)
92+
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
9393
ref_gs gs; // may be NULL = don't use geometry shader at all
9494
# ifdef USE_DX11
9595
ref_hs hs; // may be NULL = don't use hull shader at all

0 commit comments

Comments
 (0)