Skip to content

Commit

Permalink
CBlender_Compile: Add OpenGL-specific implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Dec 2, 2015
1 parent ca185f4 commit 0cbdf6d
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void CBlender_Compile::r_ColorWriteEnable( bool cR, bool cG, bool cB, bool cA)
RS.SetRS( D3DRS_COLORWRITEENABLE3, Mask);
}

#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
#if !defined(USE_DX10) && !defined(USE_DX11)
u32 CBlender_Compile::i_Sampler (LPCSTR _name)
{
//
Expand Down
12 changes: 10 additions & 2 deletions src/Layers/xrRender/blenders/Blender_Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CBlender_Compile
void StageEnd ();

// R1/R2-compiler [programmable]
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
#if defined(USE_DX10) || defined(USE_DX11)
void i_dx10Address (u32 s, u32 address);
void i_dx10Filter_Min (u32 s, u32 f);
void i_dx10Filter_Mip (u32 s, u32 f);
Expand Down Expand Up @@ -134,7 +134,9 @@ class CBlender_Compile
void r_Stencil(BOOL Enable, u32 Func=D3DCMP_ALWAYS, u32 Mask=0x00, u32 WriteMask=0x00, u32 Fail=D3DSTENCILOP_KEEP, u32 Pass=D3DSTENCILOP_KEEP, u32 ZFail=D3DSTENCILOP_KEEP);
void r_StencilRef(u32 Ref);
void r_CullMode(D3DCULL Mode);

#endif // USE_DX10

#if defined(USE_DX10) || defined(USE_DX11)
void r_dx10Texture(LPCSTR ResourceName, LPCSTR texture);
void r_dx10Texture(LPCSTR ResourceName, shared_str texture) { return r_dx10Texture(ResourceName, texture.c_str());};
u32 r_dx10Sampler(LPCSTR ResourceName);
Expand All @@ -147,6 +149,12 @@ class CBlender_Compile
void r_Sampler_clf (LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide=false);
void r_Sampler_clw (LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide=false);
#endif // USE_DX10

#ifdef USE_OGL
void i_Comparison(u32 s, u32 func);
void r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
#endif // USE_OGL

void r_ColorWriteEnable( bool cR=true, bool cG=true, bool cB=true, bool cA=true);
void r_End ();

Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRenderDX10/Blender_Recorder_R3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask,
RS.SetRS( D3DRS_STENCILFAIL, Fail);
RS.SetRS( D3DRS_STENCILPASS, Pass);
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
#ifndef USE_OGL
// Since we never really support different options for
// CW/CCW stencil use it to mimic DX9 behaviour for
// single-sided stencil
RS.SetRS( D3DRS_CCW_STENCILFUNC, Func);
RS.SetRS( D3DRS_CCW_STENCILFAIL, Fail);
RS.SetRS( D3DRS_CCW_STENCILPASS, Pass);
RS.SetRS( D3DRS_CCW_STENCILZFAIL, ZFail);
#endif // !USE_OGL
}

void CBlender_Compile::r_StencilRef(u32 Ref)
Expand Down
83 changes: 83 additions & 0 deletions src/Layers/xrRenderGL/Blender_Recorder_GL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "stdafx.h"
#pragma hdrstop

#include "Layers/xrRender/ResourceManager.h"
#include "Layers/xrRender/blenders/Blender_Recorder.h"
#include "Layers/xrRender/blenders/Blender.h"
#include "Layers/xrRender/tss.h"

void fix_texture_name(LPSTR fn);

void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask, u32 Fail, u32 Pass, u32 ZFail)
{
RS.SetRS( D3DRS_STENCILENABLE, BC(Enable) );
if (!Enable) return;
RS.SetRS( D3DRS_STENCILFUNC, Func);
RS.SetRS( D3DRS_STENCILMASK, Mask);
RS.SetRS( D3DRS_STENCILWRITEMASK, WriteMask);
RS.SetRS( D3DRS_STENCILFAIL, Fail);
RS.SetRS( D3DRS_STENCILPASS, Pass);
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
}

void CBlender_Compile::r_StencilRef(u32 Ref)
{
RS.SetRS( D3DRS_STENCILREF, Ref);
}

void CBlender_Compile::r_CullMode(D3DCULL Mode)
{
RS.SetRS( D3DRS_CULLMODE, (u32)Mode);
}

void CBlender_Compile::i_Comparison(u32 s, u32 func)
{
RS.SetSAMP(s, (u32)GL_TEXTURE_COMPARE_MODE, (u32)GL_COMPARE_REF_TO_TEXTURE);
RS.SetSAMP(s, (u32)GL_TEXTURE_COMPARE_FUNC, func);
}

void CBlender_Compile::r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide)
{
u32 s = r_Sampler(name, texture, b_ps1x_ProjectiveDivide, D3DTADDRESS_CLAMP, D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_LINEAR);
if (u32(-1) != s)
{
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, (u32)D3D_COMPARISON_LESS_EQUAL);
}
}

void CBlender_Compile::r_Pass (LPCSTR _vs, LPCSTR _gs, LPCSTR _ps, bool bFog, BOOL bZtest, BOOL bZwrite, BOOL bABlend, D3DBLEND abSRC, D3DBLEND abDST, BOOL aTest, u32 aRef)
{
RS.Invalidate ();
ctable.clear ();
passTextures.clear ();
passMatrices.clear ();
passConstants.clear ();
dwStage = 0;

// Setup FF-units (Z-buffer, blender)
PassSET_ZB (bZtest,bZwrite);
PassSET_Blend (bABlend,abSRC,abDST,aTest,aRef);
PassSET_LightFog (FALSE,bFog);

// Create shaders
SPS* ps = RImplementation.Resources->_CreatePS(_ps);
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
SGS* gs = RImplementation.Resources->_CreateGS(_gs);
dest.ps = ps;
dest.vs = vs;
dest.gs = gs;
#ifdef USE_DX11
dest.hs = RImplementation.Resources->_CreateHS("null");
dest.ds = RImplementation.Resources->_CreateDS("null");
#endif
ctable.merge (&ps->constants);
ctable.merge (&vs->constants);
ctable.merge (&gs->constants);

// Last Stage - disable
if (0==stricmp(_ps,"null")) {
RS.SetTSS (0,D3DTSS_COLOROP,D3DTOP_DISABLE);
RS.SetTSS (0,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
}
}
15 changes: 4 additions & 11 deletions src/Layers/xrRenderPC_GL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@

IC void jitter(CBlender_Compile& C)
{
// C.r_Sampler ("jitter0", JITTER(0), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
// C.r_Sampler ("jitter1", JITTER(1), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
// C.r_Sampler ("jitter2", JITTER(2), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
// C.r_Sampler ("jitter3", JITTER(3), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
C.r_dx10Texture ("jitter0", JITTER(0));
C.r_dx10Texture ("jitter1", JITTER(1));
C.r_dx10Texture ("jitter2", JITTER(2));
C.r_dx10Texture ("jitter3", JITTER(3));
C.r_dx10Texture ("jitter4", JITTER(4));
C.r_dx10Texture ("jitterMipped", r2_jitter_mipped);
C.r_dx10Sampler ("smp_jitter");
C.r_Sampler ("jitter0", JITTER(0), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
C.r_Sampler ("jitter1", JITTER(1), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
C.r_Sampler ("jitter2", JITTER(2), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
C.r_Sampler ("jitter3", JITTER(3), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
}
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\xrRenderDX10\Blender_Recorder_R3.cpp" />
<ClCompile Include="..\xrRenderDX10\DX10 Rain\dx10RainBlender.cpp" />
<ClCompile Include="..\xrRenderDX10\dx10MinMaxSMBlender.cpp" />
<ClCompile Include="..\xrRenderDX10\MSAA\dx10MSAABlender.cpp" />
<ClCompile Include="..\xrRenderGL\Blender_Recorder_GL.cpp" />
<ClCompile Include="..\xrRenderGL\glHW.cpp" />
<ClCompile Include="..\xrRenderGL\glBufferUtils.cpp" />
<ClCompile Include="..\xrRenderGL\glDetailManager_VS.cpp" />
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,6 @@
<ClCompile Include="..\xrRender\ColorMapManager.cpp">
<Filter>Core_Target\ColorMap</Filter>
</ClCompile>
<ClCompile Include="..\xrRenderDX10\Blender_Recorder_R3.cpp">
<Filter>Refactored\Execution &amp; 3D\Shaders\Blender</Filter>
</ClCompile>
<ClCompile Include="..\xrRender\D3DUtils.cpp">
<Filter>Refactored\Execution &amp; 3D\DebugDraw</Filter>
</ClCompile>
Expand Down Expand Up @@ -681,6 +678,9 @@
<ClCompile Include="..\xrRenderDX10\MSAA\dx10MSAABlender.cpp">
<Filter>Interface implementations\MSAARender</Filter>
</ClCompile>
<ClCompile Include="..\xrRenderGL\Blender_Recorder_GL.cpp">
<Filter>Refactored\Execution &amp; 3D\Shaders\Blender</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
Expand Down

0 comments on commit 0cbdf6d

Please sign in to comment.