Skip to content

Commit 0cbdf6d

Browse files
committed
CBlender_Compile: Add OpenGL-specific implementation.
1 parent ca185f4 commit 0cbdf6d

File tree

7 files changed

+102
-20
lines changed

7 files changed

+102
-20
lines changed

src/Layers/xrRender/Blender_Recorder_R2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void CBlender_Compile::r_ColorWriteEnable( bool cR, bool cG, bool cB, bool cA)
6666
RS.SetRS( D3DRS_COLORWRITEENABLE3, Mask);
6767
}
6868

69-
#if !defined(USE_DX10) && !defined(USE_DX11) && !defined(USE_OGL)
69+
#if !defined(USE_DX10) && !defined(USE_DX11)
7070
u32 CBlender_Compile::i_Sampler (LPCSTR _name)
7171
{
7272
//

src/Layers/xrRender/blenders/Blender_Recorder.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class CBlender_Compile
102102
void StageEnd ();
103103

104104
// R1/R2-compiler [programmable]
105-
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
105+
#if defined(USE_DX10) || defined(USE_DX11)
106106
void i_dx10Address (u32 s, u32 address);
107107
void i_dx10Filter_Min (u32 s, u32 f);
108108
void i_dx10Filter_Mip (u32 s, u32 f);
@@ -134,7 +134,9 @@ class CBlender_Compile
134134
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);
135135
void r_StencilRef(u32 Ref);
136136
void r_CullMode(D3DCULL Mode);
137-
137+
#endif // USE_DX10
138+
139+
#if defined(USE_DX10) || defined(USE_DX11)
138140
void r_dx10Texture(LPCSTR ResourceName, LPCSTR texture);
139141
void r_dx10Texture(LPCSTR ResourceName, shared_str texture) { return r_dx10Texture(ResourceName, texture.c_str());};
140142
u32 r_dx10Sampler(LPCSTR ResourceName);
@@ -147,6 +149,12 @@ class CBlender_Compile
147149
void r_Sampler_clf (LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide=false);
148150
void r_Sampler_clw (LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide=false);
149151
#endif // USE_DX10
152+
153+
#ifdef USE_OGL
154+
void i_Comparison(u32 s, u32 func);
155+
void r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
156+
#endif // USE_OGL
157+
150158
void r_ColorWriteEnable( bool cR=true, bool cG=true, bool cB=true, bool cA=true);
151159
void r_End ();
152160

src/Layers/xrRenderDX10/Blender_Recorder_R3.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask,
1818
RS.SetRS( D3DRS_STENCILFAIL, Fail);
1919
RS.SetRS( D3DRS_STENCILPASS, Pass);
2020
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
21-
#ifndef USE_OGL
2221
// Since we never really support different options for
2322
// CW/CCW stencil use it to mimic DX9 behaviour for
2423
// single-sided stencil
2524
RS.SetRS( D3DRS_CCW_STENCILFUNC, Func);
2625
RS.SetRS( D3DRS_CCW_STENCILFAIL, Fail);
2726
RS.SetRS( D3DRS_CCW_STENCILPASS, Pass);
2827
RS.SetRS( D3DRS_CCW_STENCILZFAIL, ZFail);
29-
#endif // !USE_OGL
3028
}
3129

3230
void CBlender_Compile::r_StencilRef(u32 Ref)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "stdafx.h"
2+
#pragma hdrstop
3+
4+
#include "Layers/xrRender/ResourceManager.h"
5+
#include "Layers/xrRender/blenders/Blender_Recorder.h"
6+
#include "Layers/xrRender/blenders/Blender.h"
7+
#include "Layers/xrRender/tss.h"
8+
9+
void fix_texture_name(LPSTR fn);
10+
11+
void CBlender_Compile::r_Stencil(BOOL Enable, u32 Func, u32 Mask, u32 WriteMask, u32 Fail, u32 Pass, u32 ZFail)
12+
{
13+
RS.SetRS( D3DRS_STENCILENABLE, BC(Enable) );
14+
if (!Enable) return;
15+
RS.SetRS( D3DRS_STENCILFUNC, Func);
16+
RS.SetRS( D3DRS_STENCILMASK, Mask);
17+
RS.SetRS( D3DRS_STENCILWRITEMASK, WriteMask);
18+
RS.SetRS( D3DRS_STENCILFAIL, Fail);
19+
RS.SetRS( D3DRS_STENCILPASS, Pass);
20+
RS.SetRS( D3DRS_STENCILZFAIL, ZFail);
21+
}
22+
23+
void CBlender_Compile::r_StencilRef(u32 Ref)
24+
{
25+
RS.SetRS( D3DRS_STENCILREF, Ref);
26+
}
27+
28+
void CBlender_Compile::r_CullMode(D3DCULL Mode)
29+
{
30+
RS.SetRS( D3DRS_CULLMODE, (u32)Mode);
31+
}
32+
33+
void CBlender_Compile::i_Comparison(u32 s, u32 func)
34+
{
35+
RS.SetSAMP(s, (u32)GL_TEXTURE_COMPARE_MODE, (u32)GL_COMPARE_REF_TO_TEXTURE);
36+
RS.SetSAMP(s, (u32)GL_TEXTURE_COMPARE_FUNC, func);
37+
}
38+
39+
void CBlender_Compile::r_Sampler_cmp(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide)
40+
{
41+
u32 s = r_Sampler(name, texture, b_ps1x_ProjectiveDivide, D3DTADDRESS_CLAMP, D3DTEXF_LINEAR, D3DTEXF_NONE, D3DTEXF_LINEAR);
42+
if (u32(-1) != s)
43+
{
44+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFILTER, TRUE);
45+
RS.SetSAMP(s, XRDX10SAMP_COMPARISONFUNC, (u32)D3D_COMPARISON_LESS_EQUAL);
46+
}
47+
}
48+
49+
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)
50+
{
51+
RS.Invalidate ();
52+
ctable.clear ();
53+
passTextures.clear ();
54+
passMatrices.clear ();
55+
passConstants.clear ();
56+
dwStage = 0;
57+
58+
// Setup FF-units (Z-buffer, blender)
59+
PassSET_ZB (bZtest,bZwrite);
60+
PassSET_Blend (bABlend,abSRC,abDST,aTest,aRef);
61+
PassSET_LightFog (FALSE,bFog);
62+
63+
// Create shaders
64+
SPS* ps = RImplementation.Resources->_CreatePS(_ps);
65+
SVS* vs = RImplementation.Resources->_CreateVS(_vs);
66+
SGS* gs = RImplementation.Resources->_CreateGS(_gs);
67+
dest.ps = ps;
68+
dest.vs = vs;
69+
dest.gs = gs;
70+
#ifdef USE_DX11
71+
dest.hs = RImplementation.Resources->_CreateHS("null");
72+
dest.ds = RImplementation.Resources->_CreateDS("null");
73+
#endif
74+
ctable.merge (&ps->constants);
75+
ctable.merge (&vs->constants);
76+
ctable.merge (&gs->constants);
77+
78+
// Last Stage - disable
79+
if (0==stricmp(_ps,"null")) {
80+
RS.SetTSS (0,D3DTSS_COLOROP,D3DTOP_DISABLE);
81+
RS.SetTSS (0,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
82+
}
83+
}

src/Layers/xrRenderPC_GL/stdafx.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,8 @@
4444

4545
IC void jitter(CBlender_Compile& C)
4646
{
47-
// C.r_Sampler ("jitter0", JITTER(0), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
48-
// C.r_Sampler ("jitter1", JITTER(1), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
49-
// C.r_Sampler ("jitter2", JITTER(2), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
50-
// C.r_Sampler ("jitter3", JITTER(3), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
51-
C.r_dx10Texture ("jitter0", JITTER(0));
52-
C.r_dx10Texture ("jitter1", JITTER(1));
53-
C.r_dx10Texture ("jitter2", JITTER(2));
54-
C.r_dx10Texture ("jitter3", JITTER(3));
55-
C.r_dx10Texture ("jitter4", JITTER(4));
56-
C.r_dx10Texture ("jitterMipped", r2_jitter_mipped);
57-
C.r_dx10Sampler ("smp_jitter");
47+
C.r_Sampler ("jitter0", JITTER(0), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
48+
C.r_Sampler ("jitter1", JITTER(1), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
49+
C.r_Sampler ("jitter2", JITTER(2), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
50+
C.r_Sampler ("jitter3", JITTER(3), true, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT);
5851
}

src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@
204204
</Link>
205205
</ItemDefinitionGroup>
206206
<ItemGroup>
207-
<ClCompile Include="..\xrRenderDX10\Blender_Recorder_R3.cpp" />
208207
<ClCompile Include="..\xrRenderDX10\DX10 Rain\dx10RainBlender.cpp" />
209208
<ClCompile Include="..\xrRenderDX10\dx10MinMaxSMBlender.cpp" />
210209
<ClCompile Include="..\xrRenderDX10\MSAA\dx10MSAABlender.cpp" />
210+
<ClCompile Include="..\xrRenderGL\Blender_Recorder_GL.cpp" />
211211
<ClCompile Include="..\xrRenderGL\glHW.cpp" />
212212
<ClCompile Include="..\xrRenderGL\glBufferUtils.cpp" />
213213
<ClCompile Include="..\xrRenderGL\glDetailManager_VS.cpp" />

src/Layers/xrRenderPC_GL/xrRender_GL.vcxproj.filters

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,6 @@
579579
<ClCompile Include="..\xrRender\ColorMapManager.cpp">
580580
<Filter>Core_Target\ColorMap</Filter>
581581
</ClCompile>
582-
<ClCompile Include="..\xrRenderDX10\Blender_Recorder_R3.cpp">
583-
<Filter>Refactored\Execution &amp; 3D\Shaders\Blender</Filter>
584-
</ClCompile>
585582
<ClCompile Include="..\xrRender\D3DUtils.cpp">
586583
<Filter>Refactored\Execution &amp; 3D\DebugDraw</Filter>
587584
</ClCompile>
@@ -681,6 +678,9 @@
681678
<ClCompile Include="..\xrRenderDX10\MSAA\dx10MSAABlender.cpp">
682679
<Filter>Interface implementations\MSAARender</Filter>
683680
</ClCompile>
681+
<ClCompile Include="..\xrRenderGL\Blender_Recorder_GL.cpp">
682+
<Filter>Refactored\Execution &amp; 3D\Shaders\Blender</Filter>
683+
</ClCompile>
684684
</ItemGroup>
685685
<ItemGroup>
686686
<ClInclude Include="stdafx.h">

0 commit comments

Comments
 (0)