- 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.

This commit is contained in:
Christoph Oelckers 2018-06-23 13:51:19 +02:00
parent 282fdac660
commit 1cf3af9c41
7 changed files with 4 additions and 11 deletions

View file

@ -86,7 +86,6 @@ extern bool NoInterpolateView;
FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
{ {
framebuffer = fb; framebuffer = fb;
mCurrentPortal = nullptr;
mMirrorCount = 0; mMirrorCount = 0;
mPlaneMirrorCount = 0; mPlaneMirrorCount = 0;
mVBO = nullptr; mVBO = nullptr;

View file

@ -66,8 +66,6 @@ class FGLRenderer
public: public:
OpenGLFrameBuffer *framebuffer; OpenGLFrameBuffer *framebuffer;
//GLPortal *mClipPortal;
GLPortal *mCurrentPortal;
int mMirrorCount; int mMirrorCount;
int mPlaneMirrorCount; int mPlaneMirrorCount;
FShaderManager *mShaderManager; FShaderManager *mShaderManager;

View file

@ -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 = FDrawInfo::StartDrawInfo(outer_di->Viewpoint, &outer_di->VPUniforms);
(*pDi)->mCurrentPortal = this;
// save viewpoint // save viewpoint
savedvisibility = outer_di->Viewpoint.camera ? outer_di->Viewpoint.camera->renderflags & RF_MAYBEINVISIBLE : ActorRenderFlags::FromInt(0); savedvisibility = outer_di->Viewpoint.camera ? outer_di->Viewpoint.camera->renderflags & RF_MAYBEINVISIBLE : ActorRenderFlags::FromInt(0);
PrevPortal = GLRenderer->mCurrentPortal;
GLRenderer->mCurrentPortal = this;
return true; return true;
} }
@ -263,7 +260,6 @@ void GLPortal::End(HWDrawInfo *di, bool usestencil)
bool needdepth = NeedDepthBuffer(); bool needdepth = NeedDepthBuffer();
Clocker c(PortalAll); Clocker c(PortalAll);
GLRenderer->mCurrentPortal = PrevPortal;
di = static_cast<FDrawInfo*>(di)->EndDrawInfo(); di = static_cast<FDrawInfo*>(di)->EndDrawInfo();
di->ApplyVPUniforms(); di->ApplyVPUniforms();

View file

@ -53,7 +53,6 @@ private:
void DrawPortalStencil(); void DrawPortalStencil();
ActorRenderFlags savedvisibility; ActorRenderFlags savedvisibility;
GLPortal *PrevPortal;
TArray<unsigned int> mPrimIndices; TArray<unsigned int> mPrimIndices;
protected: protected:

View file

@ -130,7 +130,7 @@ void FDrawInfo::CreateScene()
PreparePlayerSprites(vp.sector, in_area); PreparePlayerSprites(vp.sector, in_area);
// Process all the sprites on the current portal's back side which touch the portal. // 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(); Bsp.Unclock();
// And now the crappy hacks that have to be done to avoid rendering anomalies. // 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; int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
CurrentMapSections.Set(mapsection); CurrentMapSections.Set(mapsection);
GLRenderer->mCurrentPortal = nullptr;
DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN);
} }

View file

@ -95,6 +95,7 @@ void HWDrawInfo::ClearBuffers()
memset(&no_renderflags[0], 0, level.nodes.Size() * sizeof(no_renderflags[0])); memset(&no_renderflags[0], 0, level.nodes.Size() * sizeof(no_renderflags[0]));
mClipPortal = nullptr; mClipPortal = nullptr;
mCurrentPortal = nullptr;
} }
//========================================================================== //==========================================================================

View file

@ -99,6 +99,7 @@ struct HWDrawInfo
int FullbrightFlags; int FullbrightFlags;
std::atomic<int> spriteindex; std::atomic<int> spriteindex;
IPortal *mClipPortal; IPortal *mClipPortal;
IPortal *mCurrentPortal;
//FRotator mAngles; //FRotator mAngles;
IShadowMap *mShadowMap; IShadowMap *mShadowMap;
Clipper *mClipper; Clipper *mClipper;