Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* REFACTOR: [Engine] Use options.new_shader_support, removed ssfx specific flags #1550

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Shader* CResourceManager::_cpp_Create(
_ParseList(C.L_matrices, s_matrices);

#if defined(USE_DX11)
if (RImplementation.hud_loading && RImplementation.o.ssfx_hud_raindrops)
if (RImplementation.hud_loading && RImplementation.o.new_shader_support)
{
C.HudElement = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/blenders/Blender_tree_deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void CBlender_Tree::Compile(CBlender_Compile& C)
{
case SE_R2_NORMAL_HQ: // deffer
// Is a branch/bush. Use a different VS
if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT) && oBlend.value && RImplementation.o.ssfx_branches)
if (RImplementation.o.new_shader_support && oBlend.value)
tvs = "tree_branch";

if (bUseATOC)
Expand Down
10 changes: 5 additions & 5 deletions src/Layers/xrRender/dxRainRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dxRainRender::dxRainRender()
hGeom_Drops.create(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, RImplementation.Vertex.Buffer(), RImplementation.Index.Buffer());

#if defined(USE_DX11)
if (RImplementation.o.ssfx_rain)
if (RImplementation.o.new_shader_support)
SH_Splash.create("effects\\rain_splash", "fx\\fx_rain");
#endif

Expand All @@ -59,7 +59,7 @@ void dxRainRender::Render(CEffect_Rain& owner)

// SSS Rain shader is available
#if defined(USE_DX11)
if (RImplementation.o.ssfx_rain)
if (RImplementation.o.new_shader_support)
{
_drop_len = ps_ssfx_rain_1.x;
_drop_width = ps_ssfx_rain_1.y;
Expand Down Expand Up @@ -169,7 +169,7 @@ void dxRainRender::Render(CEffect_Rain& owner)
// Build line
Fvector& pos_head = one.P;
Fvector pos_trail;
if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT))
if (RImplementation.o.new_shader_support)
pos_trail.mad(pos_head, one.D, -_drop_len * factor_visual);
else
pos_trail.mad(pos_head, one.D, -drop_length * factor_visual);
Expand All @@ -192,7 +192,7 @@ void dxRainRender::Render(CEffect_Rain& owner)
camDir.sub(sC, vEye);
camDir.normalize();
lineTop.crossproduct(camDir, lineD);
float w = ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT) ? _drop_width : drop_width;
float w = RImplementation.o.new_shader_support ? _drop_width : drop_width;
u32 s = one.uv_set;
P.mad(pos_trail, lineTop, -w);
verts->set(P, u_rain_color, UV[s][0].x, UV[s][0].y);
Expand Down Expand Up @@ -232,7 +232,7 @@ void dxRainRender::Render(CEffect_Rain& owner)
{
float dt = Device.fTimeDelta;
_IndexStream& _IS = RImplementation.Index;
if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT))
if (RImplementation.o.new_shader_support)
{
RCache.set_Shader(_splash_SH);
RCache.set_c(s_shader_setup, ps_ssfx_rain_3); // Alpha, Refraction
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/dxWallMarkArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void dxWallMarkArray::AppendMark(LPCSTR s_textures)
ref_shader s;
LPCSTR sh_name = "effects" DELIMITER "wallmark";
#if defined(USE_DX11)
if (RImplementation.o.ssfx_blood)
if (RImplementation.o.new_shader_support)
{
// Use the blood shader for any texture with the name wm_blood_*
if (strstr(s_textures, "wm_blood_"))
Expand Down
6 changes: 6 additions & 0 deletions src/Layers/xrRenderPC_R1/FStaticRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ ShaderElement* CRender::rimp_select_sh_static(dxRender_Visual* pVisual, float cd
#endif
}

void CRender::OnDeviceCreate(pcstr shName)
{
o.new_shader_support = 0;
D3DXRenderBase::OnDeviceCreate(shName);
}

//////////////////////////////////////////////////////////////////////////
void CRender::create()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderPC_R1/FStaticRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CRender : public D3DXRenderBase
u32 forceskinw : 1; // config
u32 no_detail_textures : 1; // config
u32 ffp : 1; // don't use shaders, only fixed-function pipeline or software processing
u32 new_shader_support : 1; // always disabled for r1
} o;

public:
Expand Down Expand Up @@ -105,6 +106,7 @@ class CRender : public D3DXRenderBase
virtual u32 get_dx_level() override { return 0x00090000; }
virtual bool is_sun_static() override { return true; }
// Loading / Unloading
virtual void OnDeviceCreate(pcstr shName) override;
virtual void create() override;
virtual void destroy() override;
virtual void reset_begin() override;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_rendertarget_phase_combine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void CRenderTarget::phase_combine()

RCache.set_Stencil(FALSE);

if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT))
if (RImplementation.o.new_shader_support)
{
//(Anomaly) Compute blur textures
phase_blur();
Expand Down
15 changes: 0 additions & 15 deletions src/Layers/xrRender_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,10 @@ static bool must_enable_old_cascades()
void CRender::OnDeviceCreate(pcstr shName)
{
o.new_shader_support = 0;
o.ssfx_rain = 0;
o.ssfx_blood = 0;
o.ssfx_branches = 0;
o.ssfx_hud_raindrops = 0;

#if defined(USE_DX11)
o.new_shader_support = HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT);
// Ascii's Screen Space Shaders - Check if SSS shaders exist
string_path fn;
o.ssfx_rain = FS.exist(fn, "$game_shaders$", "r3\\effects_rain_splash", ".ps") ? 1 : 0;
o.ssfx_blood = FS.exist(fn, "$game_shaders$", "r3\\effects_wallmark_blood", ".ps") ? 1 : 0;
o.ssfx_branches = FS.exist(fn, "$game_shaders$", "r3\\deffer_tree_branch_bump-hq", ".vs") ? 1 : 0;
o.ssfx_hud_raindrops = FS.exist(fn, "$game_shaders$", "r3\\deffer_base_hud_bump", ".ps") ? 1 : 0;

Msg("- NEW SHADER SUPPORT ENABLED %i", o.new_shader_support);
Msg("- SSS HUD RAINDROPS SHADER INSTALLED %i", o.ssfx_hud_raindrops);
Msg("- SSS RAIN SHADER INSTALLED %i", o.ssfx_rain);
Msg("- SSS BLOOD SHADER INSTALLED %i", o.ssfx_blood);
Msg("- SSS BRANCHES SHADER INSTALLED %i", o.ssfx_branches);
#endif

D3DXRenderBase::OnDeviceCreate(shName);
Expand Down
5 changes: 0 additions & 5 deletions src/Layers/xrRender_R2/r2.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,6 @@ class CRender final : public D3DXRenderBase

// Yohji - New shader support
u32 new_shader_support : 1;
// Ascii - Screen Space Shaders
u32 ssfx_branches : 1;
u32 ssfx_blood : 1;
u32 ssfx_rain : 1;
u32 ssfx_hud_raindrops : 1;
} o;

struct RenderR2Statistics
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender_R2/render_phase_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void render_sun::init()
{
float fBias = -0.0000025f;

if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT))
if (RImplementation.o.new_shader_support)
{
m_sun_cascades[0].reset_chain = true;
m_sun_cascades[0].size = ps_ssfx_shadow_cascades.x;
Expand Down Expand Up @@ -158,7 +158,7 @@ void render_sun::calculate()
float map_size = m_sun_cascades[cascade_ind].size;
#if defined(USE_OGL)
XRMatrixOrthoOffCenterLH(&mdir_Project, -map_size * 0.5f, map_size * 0.5f, -map_size * 0.5f,
map_size * 0.5f, 0.1f, dist + /*sqrt(2)*/1.41421f * map_size);
map_size * 0.5f, 0.1f, dist + /*sqrt(2)*/1.41421f * map_size);
Xottab-DUTY marked this conversation as resolved.
Show resolved Hide resolved
#else
#ifdef USE_DX9
XMStoreFloat4x4((XMFLOAT4X4*)&mdir_Project, XMMatrixOrthographicOffCenterLH(
Expand Down Expand Up @@ -334,7 +334,7 @@ void render_sun::render()
dsgraph.render_graph(0);
if (ps_r2_ls_flags.test(R2FLAG_SUN_DETAILS))
{
if (ps_r2_ls_flags_ext.test(R4FLAGEXT_NEW_SHADER_SUPPORT))
if (RImplementation.o.new_shader_support)
{
if (cascade_ind <= ps_ssfx_grass_shadows.x)
{
Expand Down