From 1cf3af9c418d9dad616b69347a68c2c2ba401358 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Jun 2018 13:51:19 +0200 Subject: [PATCH] - moved the current portal pointer to HWDrawInfo so that the portal managed does not need to save and restore a global variable for each portal. --- src/gl/renderer/gl_renderer.cpp | 1 - src/gl/renderer/gl_renderer.h | 2 -- src/gl/scene/gl_portal.cpp | 6 +----- src/gl/scene/gl_portal.h | 1 - src/gl/scene/gl_scene.cpp | 3 +-- src/hwrenderer/scene/hw_drawinfo.cpp | 1 + src/hwrenderer/scene/hw_drawinfo.h | 1 + 7 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a605025d25..b70c7ed61b 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -86,7 +86,6 @@ extern bool NoInterpolateView; FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) { framebuffer = fb; - mCurrentPortal = nullptr; mMirrorCount = 0; mPlaneMirrorCount = 0; mVBO = nullptr; diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 2aebd01698..44ccfe1a5d 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -66,8 +66,6 @@ class FGLRenderer public: OpenGLFrameBuffer *framebuffer; - //GLPortal *mClipPortal; - GLPortal *mCurrentPortal; int mMirrorCount; int mPlaneMirrorCount; FShaderManager *mShaderManager; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index f8d560f271..201d7bf2fa 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -213,14 +213,11 @@ bool GLPortal::Start(bool usestencil, bool doquery, HWDrawInfo *outer_di, HWDraw } } *pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint, &outer_di->VPUniforms); + (*pDi)->mCurrentPortal = this; // save viewpoint savedvisibility = outer_di->Viewpoint.camera ? outer_di->Viewpoint.camera->renderflags & RF_MAYBEINVISIBLE : ActorRenderFlags::FromInt(0); - - PrevPortal = GLRenderer->mCurrentPortal; - GLRenderer->mCurrentPortal = this; - return true; } @@ -263,7 +260,6 @@ void GLPortal::End(HWDrawInfo *di, bool usestencil) bool needdepth = NeedDepthBuffer(); Clocker c(PortalAll); - GLRenderer->mCurrentPortal = PrevPortal; di = static_cast(di)->EndDrawInfo(); di->ApplyVPUniforms(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index d944617659..cda52886e5 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -53,7 +53,6 @@ private: void DrawPortalStencil(); ActorRenderFlags savedvisibility; - GLPortal *PrevPortal; TArray mPrimIndices; protected: diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 123fd47beb..5d0bd72531 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -130,7 +130,7 @@ void FDrawInfo::CreateScene() PreparePlayerSprites(vp.sector, in_area); // Process all the sprites on the current portal's back side which touch the portal. - if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached(this); + if (mCurrentPortal != nullptr) mCurrentPortal->RenderAttached(this); Bsp.Unclock(); // And now the crappy hacks that have to be done to avoid rendering anomalies. @@ -414,7 +414,6 @@ void FDrawInfo::ProcessScene(bool toscreen) int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection; CurrentMapSections.Set(mapsection); - GLRenderer->mCurrentPortal = nullptr; DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); } diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 994bfc7c2a..69fa2ab98f 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -95,6 +95,7 @@ void HWDrawInfo::ClearBuffers() memset(&no_renderflags[0], 0, level.nodes.Size() * sizeof(no_renderflags[0])); mClipPortal = nullptr; + mCurrentPortal = nullptr; } //========================================================================== diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index f52ae45808..cf34a47785 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -99,6 +99,7 @@ struct HWDrawInfo int FullbrightFlags; std::atomic spriteindex; IPortal *mClipPortal; + IPortal *mCurrentPortal; //FRotator mAngles; IShadowMap *mShadowMap; Clipper *mClipper;