From f8f9cf707b47ffb6e20d16bb9342f042940b0cad Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 4 Jul 2023 02:23:07 +0200 Subject: [PATCH] Add support for gl_multithread while gl_meshcache is active Stop building geometry for lines that have a portal (when gl_meshcache is active) --- src/rendering/hwrenderer/scene/hw_bsp.cpp | 49 +++++++++++++-------- src/rendering/hwrenderer/scene/hw_walls.cpp | 4 ++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/rendering/hwrenderer/scene/hw_bsp.cpp b/src/rendering/hwrenderer/scene/hw_bsp.cpp index 2236ed10a3..b0dbe472a6 100644 --- a/src/rendering/hwrenderer/scene/hw_bsp.cpp +++ b/src/rendering/hwrenderer/scene/hw_bsp.cpp @@ -142,10 +142,6 @@ void HWDrawInfo::WorkerThread() case RenderJob::WallJob: { - HWWall wall; - SetupWall.Clock(); - wall.sub = job->sub; - front = hw_FakeFlat(drawctx, job->sub->sector, in_area, false); auto seg = job->seg; auto backsector = seg->backsector; @@ -173,9 +169,23 @@ void HWDrawInfo::WorkerThread() } else back = nullptr; - wall.Process(this, state, job->seg, front, back); - rendered_lines++; - SetupWall.Unclock(); + if (MeshBSP) + { + SetupWall.Clock(); + HWPortalWall portalwall; + portalwall.Process(this, state, job->seg, front, back); + rendered_lines++; + SetupWall.Unclock(); + } + else + { + HWWall wall; + SetupWall.Clock(); + wall.sub = job->sub; + wall.Process(this, state, job->seg, front, back); + rendered_lines++; + SetupWall.Unclock(); + } break; } @@ -743,17 +753,20 @@ void HWDrawInfo::DoSubsector(subsector_t * sub, FRenderState& state) { srf |= SSRF_PROCESSED; - if (multithread) + if (!MeshBSP) { - jobQueue.AddJob(RenderJob::FlatJob, sub); - } - else if (!MeshBSP) - { - HWFlat flat; - flat.section = sub->section; - SetupFlat.Clock(); - flat.ProcessSector(this, state, fakesector); - SetupFlat.Unclock(); + if (multithread) + { + jobQueue.AddJob(RenderJob::FlatJob, sub); + } + else + { + HWFlat flat; + flat.section = sub->section; + SetupFlat.Clock(); + flat.ProcessSector(this, state, fakesector); + SetupFlat.Unclock(); + } } } // mark subsector as processed - but mark for rendering only if it has an actual area. @@ -854,7 +867,7 @@ void HWDrawInfo::RenderBSP(void *node, bool drawpsprites, FRenderState& state) validcount++; // used for processing sidedefs only once by the renderer. MeshBSP = gl_meshcache; - multithread = gl_multithread && !MeshBSP; + multithread = gl_multithread; if (multithread) { jobQueue.ReleaseAll(); diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index a41ce8384e..e2397a8151 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -44,6 +44,7 @@ #include "hw_renderstate.h" #include "hw_skydome.h" +EXTERN_CVAR(Bool, gl_meshcache); void SetGlowPlanes(FRenderState &state, const secplane_t& top, const secplane_t& bottom) { @@ -492,6 +493,9 @@ const char HWWall::passflag[] = { //========================================================================== void HWWall::PutWall(HWDrawInfo *di, FRenderState& state, bool translucent) { + if (gl_meshcache && !di->MeshBuilding) // Don't draw walls when only collecting portals + return; + if (texture && texture->GetTranslucency() && passflag[type] == 2) { translucent = true;