Skip to content

Commit 0e88131

Browse files
committed
xrRender_R3-R4: Backwards compatibility for old R1-R2 shader scripting system
Untested and probably undone xrRender/Light_Package.h: use forward declaration instead of include
1 parent b19d2a4 commit 0e88131

File tree

6 files changed

+192
-142
lines changed

6 files changed

+192
-142
lines changed

src/Layers/xrRender/Blender_Recorder_R2.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ void CBlender_Compile::r_ColorWriteEnable(bool cR, bool cG, bool cB, bool cA)
6969
RS.SetRS(D3DRS_COLORWRITEENABLE3, Mask);
7070
}
7171

72-
#if !defined(USE_DX10) && !defined(USE_DX11)
7372
u32 CBlender_Compile::i_Sampler(LPCSTR _name)
7473
{
75-
//
7674
string256 name;
7775
xr_strcpy(name, _name);
78-
//. andy if (strext(name)) *strext(name)=0;
7976
fix_texture_name(name);
8077

8178
// Find index
@@ -90,19 +87,20 @@ u32 CBlender_Compile::i_Sampler(LPCSTR _name)
9087
// while (stage>=passTextures.size()) passTextures.push_back (NULL);
9188
return stage;
9289
}
90+
9391
void CBlender_Compile::i_Texture(u32 s, LPCSTR name)
9492
{
9593
if (name)
9694
passTextures.push_back(std::make_pair(s, ref_texture(RImplementation.Resources->_CreateTexture(name))));
9795
}
96+
9897
void CBlender_Compile::i_Projective(u32 s, bool b)
9998
{
10099
if (b)
101100
RS.SetTSS(s, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE | D3DTTFF_PROJECTED);
102101
else
103102
RS.SetTSS(s, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
104103
}
105-
#endif // USE_DX10
106104

107105
void CBlender_Compile::i_Address(u32 s, u32 address)
108106
{
@@ -121,7 +119,6 @@ void CBlender_Compile::i_Filter(u32 s, u32 _min, u32 _mip, u32 _mag)
121119
i_Filter_Mag(s, _mag);
122120
}
123121

124-
#if !defined(USE_DX10) && !defined(USE_DX11)
125122
u32 CBlender_Compile::r_Sampler(
126123
LPCSTR _name, LPCSTR texture, bool b_ps1x_ProjectiveDivide, u32 address, u32 fmin, u32 fmip, u32 fmag)
127124
{
@@ -189,4 +186,3 @@ void CBlender_Compile::r_End()
189186
#endif
190187
SH->passes.push_back(RImplementation.Resources->_CreatePass(dest));
191188
}
192-
#endif // USE_DX10

src/Layers/xrRender/Light_Package.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

3-
#include "light.h"
4-
3+
class light;
54
class light_Package
65
{
76
public:

src/Layers/xrRender/blenders/Blender_Recorder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ void CBlender_Compile::StageSET_XForm(u32 tf, u32 tc)
295295
void CBlender_Compile::StageSET_Color(u32 a1, u32 op, u32 a2) { RS.SetColor(Stage(), a1, op, a2); }
296296
void CBlender_Compile::StageSET_Color3(u32 a1, u32 op, u32 a2, u32 a3) { RS.SetColor3(Stage(), a1, op, a2, a3); }
297297
void CBlender_Compile::StageSET_Alpha(u32 a1, u32 op, u32 a2) { RS.SetAlpha(Stage(), a1, op, a2); }
298-
#if !defined(USE_DX10) && !defined(USE_DX11)
299298
void CBlender_Compile::StageSET_TMC(LPCSTR T, LPCSTR M, LPCSTR C, int UVW_channel)
300299
{
301300
Stage_Texture(T);
@@ -326,7 +325,6 @@ void CBlender_Compile::Stage_Texture(LPCSTR name, u32, u32 fmin, u32 fmip, u32 f
326325
// i_Address (Stage(),address);
327326
i_Filter(Stage(), fmin, fmip, fmag);
328327
}
329-
#endif // USE_DX10
330328
void CBlender_Compile::Stage_Matrix(LPCSTR name, int iChannel)
331329
{
332330
sh_list& lst = L_matrices;

src/Layers/xrRender/blenders/Blender_Recorder.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,18 @@ class CBlender_Compile
108108
void StageSET_Color(u32 a1, u32 op, u32 a2);
109109
void StageSET_Color3(u32 a1, u32 op, u32 a2, u32 a3);
110110
void StageSET_Alpha(u32 a1, u32 op, u32 a2);
111-
#if !defined(USE_DX10) && !defined(USE_DX11)
112111
void StageSET_TMC(LPCSTR T, LPCSTR M, LPCSTR C, int UVW_channel);
113112
void Stage_Texture(LPCSTR name, u32 address = D3DTADDRESS_WRAP, u32 fmin = D3DTEXF_LINEAR,
114113
u32 fmip = D3DTEXF_LINEAR, u32 fmag = D3DTEXF_LINEAR);
115114
void StageTemplate_LMAP0();
116-
#endif // USE_DX10
117115
void Stage_Matrix(LPCSTR name, int UVW_channel);
118116
void Stage_Constant(LPCSTR name);
119117
void StageEnd();
120118

121119
// R1/R2-compiler [programmable]
122-
#if defined(USE_DX9) || defined(USE_OGL)
123120
u32 i_Sampler(LPCSTR name);
124121
void i_Texture(u32 s, LPCSTR name);
125122
void i_Projective(u32 s, bool b);
126-
#endif
127123
void i_Address(u32 s, u32 address);
128124
void i_Filter_Min(u32 s, u32 f);
129125
void i_Filter_Mip(u32 s, u32 f);
@@ -161,7 +157,8 @@ class CBlender_Compile
161157
return r_dx10Texture(ResourceName, texture.c_str());
162158
};
163159
u32 r_dx10Sampler(LPCSTR ResourceName);
164-
#else // USE_DX10
160+
#endif // USE_DX10
161+
165162
u32 r_Sampler(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false, u32 address = D3DTADDRESS_WRAP,
166163
u32 fmin = D3DTEXF_LINEAR, u32 fmip = D3DTEXF_LINEAR, u32 fmag = D3DTEXF_LINEAR);
167164
u32 r_Sampler(LPCSTR name, shared_str texture, bool b_ps1x_ProjectiveDivide = false, u32 address = D3DTADDRESS_WRAP,
@@ -172,7 +169,6 @@ class CBlender_Compile
172169
void r_Sampler_rtf(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
173170
void r_Sampler_clf(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
174171
void r_Sampler_clw(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
175-
#endif // USE_DX10
176172

177173
#ifdef USE_OGL
178174
void i_Comparison(u32 s, u32 func);

src/Layers/xrRenderDX10/Blender_Recorder_R3.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,13 @@ void CBlender_Compile::i_dx10FilterAnizo(u32 s, BOOL value)
6060

6161
u32 CBlender_Compile::r_dx10Sampler(LPCSTR ResourceName)
6262
{
63-
// TEST
64-
// return ((u32)-1);
65-
VERIFY(ResourceName);
66-
string256 name;
67-
xr_strcpy(name, ResourceName);
68-
fix_texture_name(name);
63+
// TODO: DX10: Check if we can use dwStage
64+
u32 stage = i_Sampler(ResourceName);
6965

70-
// Find index
71-
// ref_constant C = ctable.get(ResourceName);
72-
ref_constant C = ctable.get(name);
73-
// VERIFY(C);
74-
if (!C)
66+
if (stage == u32(-1))
7567
return u32(-1);
7668

77-
R_ASSERT(C->type == RC_sampler);
78-
u32 stage = C->samp.index;
79-
80-
// init defaults here
69+
// init defaults here:
8170

8271
// Use D3DTADDRESS_CLAMP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT
8372
if (0 == xr_strcmp(ResourceName, "smp_nofilter"))
@@ -192,14 +181,3 @@ void CBlender_Compile::r_ComputePass(LPCSTR cs)
192181
ctable.merge(&dest.cs->constants);
193182
}
194183
#endif
195-
196-
void CBlender_Compile::r_End()
197-
{
198-
SetMapping();
199-
dest.constants = RImplementation.Resources->_CreateConstantTable(ctable);
200-
dest.state = RImplementation.Resources->_CreateState(RS.GetContainer());
201-
dest.T = RImplementation.Resources->_CreateTextureList(passTextures);
202-
dest.C = 0;
203-
ref_matrix_list temp(0);
204-
SH->passes.push_back(RImplementation.Resources->_CreatePass(dest));
205-
}

0 commit comments

Comments
 (0)