Skip to content

Commit

Permalink
xrRender_R3-R4: Backwards compatibility for old R1-R2 shader scriptin…
Browse files Browse the repository at this point in the history
…g system

Untested and probably undone

xrRender/Light_Package.h: use forward declaration instead of include
  • Loading branch information
Xottab-DUTY committed Oct 13, 2018
1 parent b19d2a4 commit 0e88131
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 142 deletions.
8 changes: 2 additions & 6 deletions src/Layers/xrRender/Blender_Recorder_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ 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)
u32 CBlender_Compile::i_Sampler(LPCSTR _name)
{
//
string256 name;
xr_strcpy(name, _name);
//. andy if (strext(name)) *strext(name)=0;
fix_texture_name(name);

// Find index
Expand All @@ -90,19 +87,20 @@ u32 CBlender_Compile::i_Sampler(LPCSTR _name)
// while (stage>=passTextures.size()) passTextures.push_back (NULL);
return stage;
}

void CBlender_Compile::i_Texture(u32 s, LPCSTR name)
{
if (name)
passTextures.push_back(std::make_pair(s, ref_texture(RImplementation.Resources->_CreateTexture(name))));
}

void CBlender_Compile::i_Projective(u32 s, bool b)
{
if (b)
RS.SetTSS(s, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE | D3DTTFF_PROJECTED);
else
RS.SetTSS(s, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
}
#endif // USE_DX10

void CBlender_Compile::i_Address(u32 s, u32 address)
{
Expand All @@ -121,7 +119,6 @@ void CBlender_Compile::i_Filter(u32 s, u32 _min, u32 _mip, u32 _mag)
i_Filter_Mag(s, _mag);
}

#if !defined(USE_DX10) && !defined(USE_DX11)
u32 CBlender_Compile::r_Sampler(
LPCSTR _name, LPCSTR texture, bool b_ps1x_ProjectiveDivide, u32 address, u32 fmin, u32 fmip, u32 fmag)
{
Expand Down Expand Up @@ -189,4 +186,3 @@ void CBlender_Compile::r_End()
#endif
SH->passes.push_back(RImplementation.Resources->_CreatePass(dest));
}
#endif // USE_DX10
3 changes: 1 addition & 2 deletions src/Layers/xrRender/Light_Package.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "light.h"

class light;
class light_Package
{
public:
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRender/blenders/Blender_Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ void CBlender_Compile::StageSET_XForm(u32 tf, u32 tc)
void CBlender_Compile::StageSET_Color(u32 a1, u32 op, u32 a2) { RS.SetColor(Stage(), a1, op, a2); }
void CBlender_Compile::StageSET_Color3(u32 a1, u32 op, u32 a2, u32 a3) { RS.SetColor3(Stage(), a1, op, a2, a3); }
void CBlender_Compile::StageSET_Alpha(u32 a1, u32 op, u32 a2) { RS.SetAlpha(Stage(), a1, op, a2); }
#if !defined(USE_DX10) && !defined(USE_DX11)
void CBlender_Compile::StageSET_TMC(LPCSTR T, LPCSTR M, LPCSTR C, int UVW_channel)
{
Stage_Texture(T);
Expand Down Expand Up @@ -326,7 +325,6 @@ void CBlender_Compile::Stage_Texture(LPCSTR name, u32, u32 fmin, u32 fmip, u32 f
// i_Address (Stage(),address);
i_Filter(Stage(), fmin, fmip, fmag);
}
#endif // USE_DX10
void CBlender_Compile::Stage_Matrix(LPCSTR name, int iChannel)
{
sh_list& lst = L_matrices;
Expand Down
8 changes: 2 additions & 6 deletions src/Layers/xrRender/blenders/Blender_Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,18 @@ class CBlender_Compile
void StageSET_Color(u32 a1, u32 op, u32 a2);
void StageSET_Color3(u32 a1, u32 op, u32 a2, u32 a3);
void StageSET_Alpha(u32 a1, u32 op, u32 a2);
#if !defined(USE_DX10) && !defined(USE_DX11)
void StageSET_TMC(LPCSTR T, LPCSTR M, LPCSTR C, int UVW_channel);
void Stage_Texture(LPCSTR name, u32 address = D3DTADDRESS_WRAP, u32 fmin = D3DTEXF_LINEAR,
u32 fmip = D3DTEXF_LINEAR, u32 fmag = D3DTEXF_LINEAR);
void StageTemplate_LMAP0();
#endif // USE_DX10
void Stage_Matrix(LPCSTR name, int UVW_channel);
void Stage_Constant(LPCSTR name);
void StageEnd();

// R1/R2-compiler [programmable]
#if defined(USE_DX9) || defined(USE_OGL)
u32 i_Sampler(LPCSTR name);
void i_Texture(u32 s, LPCSTR name);
void i_Projective(u32 s, bool b);
#endif
void i_Address(u32 s, u32 address);
void i_Filter_Min(u32 s, u32 f);
void i_Filter_Mip(u32 s, u32 f);
Expand Down Expand Up @@ -161,7 +157,8 @@ class CBlender_Compile
return r_dx10Texture(ResourceName, texture.c_str());
};
u32 r_dx10Sampler(LPCSTR ResourceName);
#else // USE_DX10
#endif // USE_DX10

u32 r_Sampler(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false, u32 address = D3DTADDRESS_WRAP,
u32 fmin = D3DTEXF_LINEAR, u32 fmip = D3DTEXF_LINEAR, u32 fmag = D3DTEXF_LINEAR);
u32 r_Sampler(LPCSTR name, shared_str texture, bool b_ps1x_ProjectiveDivide = false, u32 address = D3DTADDRESS_WRAP,
Expand All @@ -172,7 +169,6 @@ class CBlender_Compile
void r_Sampler_rtf(LPCSTR name, LPCSTR texture, bool b_ps1x_ProjectiveDivide = false);
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);
Expand Down
30 changes: 4 additions & 26 deletions src/Layers/xrRenderDX10/Blender_Recorder_R3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,13 @@ void CBlender_Compile::i_dx10FilterAnizo(u32 s, BOOL value)

u32 CBlender_Compile::r_dx10Sampler(LPCSTR ResourceName)
{
// TEST
// return ((u32)-1);
VERIFY(ResourceName);
string256 name;
xr_strcpy(name, ResourceName);
fix_texture_name(name);
// TODO: DX10: Check if we can use dwStage
u32 stage = i_Sampler(ResourceName);

// Find index
// ref_constant C = ctable.get(ResourceName);
ref_constant C = ctable.get(name);
// VERIFY(C);
if (!C)
if (stage == u32(-1))
return u32(-1);

R_ASSERT(C->type == RC_sampler);
u32 stage = C->samp.index;

// init defaults here
// init defaults here:

// Use D3DTADDRESS_CLAMP, D3DTEXF_POINT, D3DTEXF_NONE, D3DTEXF_POINT
if (0 == xr_strcmp(ResourceName, "smp_nofilter"))
Expand Down Expand Up @@ -192,14 +181,3 @@ void CBlender_Compile::r_ComputePass(LPCSTR cs)
ctable.merge(&dest.cs->constants);
}
#endif

void CBlender_Compile::r_End()
{
SetMapping();
dest.constants = RImplementation.Resources->_CreateConstantTable(ctable);
dest.state = RImplementation.Resources->_CreateState(RS.GetContainer());
dest.T = RImplementation.Resources->_CreateTextureList(passTextures);
dest.C = 0;
ref_matrix_list temp(0);
SH->passes.push_back(RImplementation.Resources->_CreatePass(dest));
}
Loading

0 comments on commit 0e88131

Please sign in to comment.