From 1bbc9f6730328987b3c8af6df3a7190c063d1c93 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Oct 2018 09:53:07 +0100 Subject: [PATCH] - removed two of the state flags in SetStencil and handle them explicitly. --- src/gl/renderer/gl_renderstate.cpp | 6 ------ src/gl/renderer/gl_renderstate.h | 1 - src/hwrenderer/scene/hw_drawinfo.h | 2 -- src/hwrenderer/scene/hw_flats.cpp | 6 ++++-- src/hwrenderer/scene/hw_portal.cpp | 10 +++++++--- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 90aeeb2c8..5a6ab35ca 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -441,12 +441,6 @@ void FGLRenderState::SetStencil(int offs, int op, int flags) bool cmon = !(flags & SF_ColorMaskOff); glColorMask(cmon, cmon, cmon, cmon); // don't write to the graphics buffer glDepthMask(!(flags & SF_DepthMaskOff)); - if (flags & SF_DepthTestOff) - glDisable(GL_DEPTH_TEST); - else - glEnable(GL_DEPTH_TEST); - if (flags & SF_DepthClear) - glClear(GL_DEPTH_BUFFER_BIT); } void FGLRenderState::SetCulling(int mode) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index ec2a23e5e..8c61451ec 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -99,7 +99,6 @@ public: void Apply(); void ApplyBuffers(); - void ApplyLightIndex(int index); void ApplyBlendMode(); void ResetVertexBuffer() diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index 10d1d28c3..908225a24 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -39,8 +39,6 @@ enum EStencilFlags SF_AllOn = 0, SF_ColorMaskOff = 1, SF_DepthMaskOff = 2, - SF_DepthTestOff = 4, - SF_DepthClear = 8 }; enum EStencilOp diff --git a/src/hwrenderer/scene/hw_flats.cpp b/src/hwrenderer/scene/hw_flats.cpp index 66d5fd167..40e922485 100644 --- a/src/hwrenderer/scene/hw_flats.cpp +++ b/src/hwrenderer/scene/hw_flats.cpp @@ -255,17 +255,19 @@ void GLFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state) // Draw projected plane into stencil state.EnableTexture(true); state.SetEffect(EFF_NONE); - state.SetStencil(1, SOP_Keep, SF_DepthMaskOff | SF_DepthTestOff); + state.SetStencil(1, SOP_Keep, SF_DepthMaskOff); + state.EnableDepthTest(false); state.Draw(DT_TriangleFan,fnode->vertexindex + 4, 4); // clear stencil state.SetEffect(EFF_STENCIL); state.EnableTexture(false); - state.SetStencil(1, SOP_Decrement, SF_ColorMaskOff | SF_DepthMaskOff | SF_DepthTestOff); + state.SetStencil(1, SOP_Decrement, SF_ColorMaskOff | SF_DepthMaskOff); state.Draw(DT_TriangleFan,fnode->vertexindex, 4); // restore old stencil op. state.EnableTexture(true); + state.EnableDepthTest(true); state.SetEffect(EFF_NONE); state.SetDepthBias(0, 0); state.SetStencil(0, SOP_Keep, SF_AllOn); diff --git a/src/hwrenderer/scene/hw_portal.cpp b/src/hwrenderer/scene/hw_portal.cpp index 0ae80a22c..edb347946 100644 --- a/src/hwrenderer/scene/hw_portal.cpp +++ b/src/hwrenderer/scene/hw_portal.cpp @@ -238,7 +238,8 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil state.SetDepthFunc(DF_Less); DrawPortalStencil(state, STP_AllInOne); - state.SetStencil(1, SOP_Keep, SF_DepthTestOff | SF_DepthMaskOff); + state.SetStencil(1, SOP_Keep, SF_DepthMaskOff); + state.EnableDepthTest(false); state.EnableTexture(true); state.SetEffect(EFF_NONE); } @@ -249,7 +250,8 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil { if (!NeedDepthBuffer()) { - state.SetStencil(0, SOP_Keep, SF_DepthTestOff | SF_DepthMaskOff); + state.SetStencil(0, SOP_Keep, SF_DepthMaskOff); + state.EnableDepthTest(false); } } @@ -266,6 +268,7 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci auto &vp = di->Viewpoint; if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility; + state.EnableDepthTest(true); if (usestencil) { state.SetEffect(EFF_NONE); @@ -298,7 +301,8 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci state.EnableTexture(false); state.SetRenderStyle(STYLE_Source); - state.SetStencil(0, SOP_Keep, needdepth ? SF_ColorMaskOff | SF_DepthClear : SF_ColorMaskOff); + state.SetStencil(0, SOP_Keep, SF_ColorMaskOff); + if (needdepth) state.Clear(CT_Depth); state.SetDepthRange(0, 1); state.SetDepthFunc(DF_LEqual); DrawPortalStencil(state, STP_DepthRestore);