From 264d42179e333892d884e3dcc9fb2c5adb503020 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 21 May 2021 19:07:22 +0200 Subject: [PATCH] - optimized the wall drawer a bit to avoid repeated calls to the render API's deoth bias function. The setters in FRenderState should check if the value actually changes and the wall drawer should only call it for non-translucent wall sprites. --- .../rendering/hwrenderer/data/hw_renderstate.h | 14 ++++++++++++-- source/core/rendering/scene/hw_walls.cpp | 10 +++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/source/common/rendering/hwrenderer/data/hw_renderstate.h b/source/common/rendering/hwrenderer/data/hw_renderstate.h index 54aab25f8..4751cba0b 100644 --- a/source/common/rendering/hwrenderer/data/hw_renderstate.h +++ b/source/common/rendering/hwrenderer/data/hw_renderstate.h @@ -555,18 +555,28 @@ public: mRenderStyle = rs; } + auto GetDepthBias() + { + return mBias; + } + void SetDepthBias(float a, float b) { + mBias.mChanged = mBias.mFactor != a || mBias.mUnits != b; mBias.mFactor = a; mBias.mUnits = b; - mBias.mChanged = true; + } + + void SetDepthBias(FDepthBiasState& bias) + { + SetDepthBias(bias.mFactor, bias.mUnits); } void ClearDepthBias() { + mBias.mChanged = mBias.mFactor != 0 || mBias.mUnits != 0; mBias.mFactor = 0; mBias.mUnits = 0; - mBias.mChanged = true; } private: diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 33bb3c09e..4aacb3df7 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -260,16 +260,20 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags) float xOffset = 1.f / texture->GetDisplayWidth(); state.SetNpotEmulation(float(h2) / h, xOffset); } + RenderWall(di, state, rflags); } else if (!(rflags & RWF_TRANS)) { + auto oldbias = state.GetDepthBias(); if (walldist >= 0) state.SetDepthBias(-1, glseg.x1 == glseg.x2 || glseg.y1 == glseg.y2? -128 : -192); else state.ClearDepthBias(); + RenderWall(di, state, rflags); + state.SetDepthBias(oldbias); + } + else + RenderWall(di, state, rflags); - RenderWall(di, state, rflags); - - if (!(rflags && RWF_TRANS)) state.ClearDepthBias(); state.SetNpotEmulation(0.f, 0.f); state.SetObjectColor(0xffffffff); /* none of these functions is in use.