From f365f6f4338f38c8170bb61c8a21bdc79280b787 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 8 Dec 2019 00:41:02 +0100 Subject: [PATCH] Fix depth test staying active when it shouldn't --- .../polyrenderer/backend/poly_renderstate.cpp | 7 +++---- .../polyrenderer/drawers/poly_triangle.cpp | 14 ++------------ src/rendering/polyrenderer/drawers/poly_triangle.h | 12 ------------ 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/rendering/polyrenderer/backend/poly_renderstate.cpp b/src/rendering/polyrenderer/backend/poly_renderstate.cpp index f63933b8d..61dd19a99 100644 --- a/src/rendering/polyrenderer/backend/poly_renderstate.cpp +++ b/src/rendering/polyrenderer/backend/poly_renderstate.cpp @@ -204,13 +204,12 @@ void PolyRenderState::Apply() mDrawCommands->SetViewport(mViewport.x, mViewport.y, mViewport.width, mViewport.height, mRenderTarget.Canvas, mRenderTarget.DepthStencil); mDrawCommands->SetScissor(mScissor.x, mScissor.y, mScissor.width, mScissor.height); mDrawCommands->SetViewpointUniforms(mViewpointUniforms); - mDrawCommands->EnableDepthTest(mDepthTest); mDrawCommands->SetDepthClamp(mDepthClamp); - mDrawCommands->SetDepthMask(mDepthMask); - mDrawCommands->SetDepthFunc(mDepthFunc); + mDrawCommands->SetDepthMask(mDepthTest && mDepthMask); + mDrawCommands->SetDepthFunc(mDepthTest ? mDepthFunc : DF_Always); mDrawCommands->SetDepthRange(mDepthRangeMin, mDepthRangeMax); - mDrawCommands->EnableStencil(mStencilEnabled); mDrawCommands->SetStencil(mStencilValue, mStencilOp); + mDrawCommands->EnableStencil(mStencilEnabled); mDrawCommands->SetCulling(mCulling); mDrawCommands->SetColorMask(mColorMask[0], mColorMask[1], mColorMask[2], mColorMask[3]); mNeedApply = false; diff --git a/src/rendering/polyrenderer/drawers/poly_triangle.cpp b/src/rendering/polyrenderer/drawers/poly_triangle.cpp index 4da0938fd..5c4dd4a72 100644 --- a/src/rendering/polyrenderer/drawers/poly_triangle.cpp +++ b/src/rendering/polyrenderer/drawers/poly_triangle.cpp @@ -125,11 +125,6 @@ void PolyCommandBuffer::SetScissor(int x, int y, int w, int h) mQueue->Push(x, y, w, h); } -void PolyCommandBuffer::EnableDepthTest(bool on) -{ - mQueue->Push(on); -} - void PolyCommandBuffer::SetRenderStyle(FRenderStyle style) { mQueue->Push(style); @@ -324,7 +319,7 @@ void PolyTriangleThreadData::SetDepthFunc(int func) { DepthTest = true; } - else if (func == DF_Always) + else // if (func == DF_Always) { DepthTest = false; } @@ -380,12 +375,7 @@ void PolyTriangleThreadData::SetCulling(int mode) void PolyTriangleThreadData::EnableStencil(bool on) { StencilTest = on; - WriteStencil = on && StencilTestValue != StencilWriteValue; -} - -void PolyTriangleThreadData::EnableDepthTest(bool on) -{ - DepthTest = on; + WriteStencil = on && (StencilTestValue != StencilWriteValue); } void PolyTriangleThreadData::SetRenderStyle(FRenderStyle style) diff --git a/src/rendering/polyrenderer/drawers/poly_triangle.h b/src/rendering/polyrenderer/drawers/poly_triangle.h index 446edd600..0ba1b0479 100644 --- a/src/rendering/polyrenderer/drawers/poly_triangle.h +++ b/src/rendering/polyrenderer/drawers/poly_triangle.h @@ -65,7 +65,6 @@ public: void SetCulling(int mode); void EnableStencil(bool on); void SetScissor(int x, int y, int w, int h); - void EnableDepthTest(bool on); void SetRenderStyle(FRenderStyle style); void SetTexture(int unit, void *pixels, int width, int height, bool bgra); void SetShader(int specialEffect, int effectState, bool alphaTest); @@ -158,7 +157,6 @@ public: void SetCulling(int mode); void EnableStencil(bool on); void SetScissor(int x, int y, int w, int h); - void EnableDepthTest(bool on); void SetRenderStyle(FRenderStyle style); void SetTexture(int unit, const void *pixels, int width, int height, bool bgra); void SetShader(int specialEffect, int effectState, bool alphaTest); @@ -407,16 +405,6 @@ private: int h; }; -class PolyEnableDepthTestCommand : public PolyDrawerCommand -{ -public: - PolyEnableDepthTestCommand(bool on) : on(on) { } - void Execute(DrawerThread *thread) override { PolyTriangleThreadData::Get(thread)->EnableDepthTest(on); } - -private: - bool on; -}; - class PolySetRenderStyleCommand : public PolyDrawerCommand { public: