From 1a64adf2be4725609f7e152141d2d88f23f5546f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 28 Dec 2022 23:56:26 +0100 Subject: [PATCH] Add gl_meshcache cvar for toggling it on and off --- .../hwrenderer/scene/hw_drawinfo.cpp | 36 ++++++++++++------- .../hwrenderer/scene/hw_meshcache.cpp | 4 +++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 4259096caa..022bce1d4d 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -63,6 +63,8 @@ CVAR(Float, gl_mask_sprite_threshold, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, gl_coronas, true, CVAR_ARCHIVE); +CVAR(Bool, gl_meshcache, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); //========================================================================== @@ -452,7 +454,8 @@ void HWDrawInfo::CreateScene(bool drawpsprites) screen->mLights->Map(); screen->mBones->Map(); - //RenderBSP(Level->HeadNode(), drawpsprites); + if (!gl_meshcache) + RenderBSP(Level->HeadNode(), drawpsprites); // And now the crappy hacks that have to be done to avoid rendering anomalies. // These cannot be multithreaded when the time comes because all these depend @@ -509,10 +512,13 @@ void HWDrawInfo::RenderScene(FRenderState &state) drawlists[GLDL_PLAINWALLS].DrawWalls(this, state, false); drawlists[GLDL_PLAINFLATS].DrawFlats(this, state, false); - for (HWCachedSector& cachedsector : meshcache.Sectors) + if (gl_meshcache) { - if (cachedsector.Opaque) - cachedsector.Opaque->Draw(state); + for (HWCachedSector& cachedsector : meshcache.Sectors) + { + if (cachedsector.Opaque) + cachedsector.Opaque->Draw(state); + } } // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show @@ -520,10 +526,13 @@ void HWDrawInfo::RenderScene(FRenderState &state) drawlists[GLDL_MASKEDWALLS].DrawWalls(this, state, false); drawlists[GLDL_MASKEDFLATS].DrawFlats(this, state, false); - for (HWCachedSector& cachedsector : meshcache.Sectors) + if (gl_meshcache) { - if (cachedsector.Translucent) - cachedsector.Translucent->Draw(state); + for (HWCachedSector& cachedsector : meshcache.Sectors) + { + if (cachedsector.Translucent) + cachedsector.Translucent->Draw(state); + } } // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. @@ -534,13 +543,16 @@ void HWDrawInfo::RenderScene(FRenderState &state) state.ClearDepthBias(); } - state.SetDepthBias(-1, -128); - for (HWCachedSector& cachedsector : meshcache.Sectors) + if (gl_meshcache) { - if (cachedsector.TranslucentDepthBiased) - cachedsector.TranslucentDepthBiased->Draw(state); + state.SetDepthBias(-1, -128); + for (HWCachedSector& cachedsector : meshcache.Sectors) + { + if (cachedsector.TranslucentDepthBiased) + cachedsector.TranslucentDepthBiased->Draw(state); + } + state.ClearDepthBias(); } - state.ClearDepthBias(); drawlists[GLDL_MODELS].Draw(this, state, false); diff --git a/src/rendering/hwrenderer/scene/hw_meshcache.cpp b/src/rendering/hwrenderer/scene/hw_meshcache.cpp index 07c77bfcf7..abd0f2b1c3 100644 --- a/src/rendering/hwrenderer/scene/hw_meshcache.cpp +++ b/src/rendering/hwrenderer/scene/hw_meshcache.cpp @@ -10,6 +10,7 @@ EXTERN_CVAR(Bool, gl_texture) EXTERN_CVAR(Float, gl_mask_threshold) +EXTERN_CVAR(Bool, gl_meshcache) HWMeshCache meshcache; @@ -21,6 +22,9 @@ void HWMeshCache::Clear() void HWMeshCache::Update(FRenderViewpoint& vp) { + if (!gl_meshcache) + return; + auto level = vp.ViewLevel; unsigned int count = level->sectors.Size(); Sectors.Resize(count);