diff --git a/src/hwrenderer/scene/hw_bsp.cpp b/src/hwrenderer/scene/hw_bsp.cpp index 35db031731..c05dc92143 100644 --- a/src/hwrenderer/scene/hw_bsp.cpp +++ b/src/hwrenderer/scene/hw_bsp.cpp @@ -96,6 +96,7 @@ void HWDrawInfo::WorkerThread() { sector_t fakefront, fakeback, *front, *back; + WTTotal.Clock(); isWorkerThread = true; // for adding asserts in GL API code. The worker thread may never call any GL API. while (true) { @@ -118,7 +119,7 @@ void HWDrawInfo::WorkerThread() else switch (job->type) { case RenderJob::TerminateJob: - PreparePlayerSprites(Viewpoint.sector, in_area); + WTTotal.Unclock(); return; case RenderJob::WallJob: @@ -727,7 +728,10 @@ void HWDrawInfo::RenderBSP(void *node) jobQueue.AddJob(RenderJob::TerminateJob, nullptr, nullptr); Bsp.Unclock(); - + MTWait.Clock(); future.wait(); jobQueue.ReleaseAll(); + MTWait.Unclock(); + + PreparePlayerSprites(Viewpoint.sector, in_area); } diff --git a/src/hwrenderer/utility/hw_clock.cpp b/src/hwrenderer/utility/hw_clock.cpp index a34b1fdb13..179776a656 100644 --- a/src/hwrenderer/utility/hw_clock.cpp +++ b/src/hwrenderer/utility/hw_clock.cpp @@ -51,6 +51,7 @@ glcycle_t RenderAll; glcycle_t Dirty; glcycle_t drawcalls; glcycle_t twoD, Flush3D; +glcycle_t MTWait, WTTotal; int vertexcount, flatvertices, flatprimitives; int rendered_lines,rendered_flats,rendered_sprites,render_vertexsplit,render_texsplit,rendered_decals, rendered_portals; @@ -73,6 +74,8 @@ void ResetProfilingData() RenderSprite.Reset(); SetupSprite.Reset(); drawcalls.Reset(); + MTWait.Reset(); + WTTotal.Reset(); flatvertices=flatprimitives=vertexcount=0; render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals=rendered_portals = 0; @@ -87,20 +90,22 @@ void ResetProfilingData() static void AppendRenderTimes(FString &str) { double setupwall = SetupWall.TimeMS(); - double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); - double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); + double clipwall = ClipWall.TimeMS(); + double bsp = Bsp.TimeMS() - ClipWall.TimeMS(); str.AppendFormat("BSP = %2.3f, Clip=%2.3f\n" "W: Render=%2.3f, Setup=%2.3f\n" "F: Render=%2.3f, Setup=%2.3f\n" "S: Render=%2.3f, Setup=%2.3f\n" "2D: %2.3f Finish3D: %2.3f\n" + "Main thread total=%2.3f, Main thread waiting=%2.3f Worker thread total=%2.3f, Worker thread waiting=%2.3f\n" "All=%2.3f, Render=%2.3f, Setup=%2.3f, Portal=%2.3f, Drawcalls=%2.3f, Postprocess=%2.3f, Finish=%2.3f\n", bsp, clipwall, RenderWall.TimeMS(), setupwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), RenderSprite.TimeMS(), SetupSprite.TimeMS(), twoD.TimeMS(), Flush3D.TimeMS() - twoD.TimeMS(), + MTWait.TimeMS() + Bsp.TimeMS(), MTWait.TimeMS(), WTTotal.TimeMS(), WTTotal.TimeMS() - setupwall - SetupFlat.TimeMS() - SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), ProcessAll.TimeMS(), PortalAll.TimeMS(), drawcalls.TimeMS(), PostProcess.TimeMS(), Finish.TimeMS()); } diff --git a/src/hwrenderer/utility/hw_clock.h b/src/hwrenderer/utility/hw_clock.h index 243ec49246..8dec4a6de0 100644 --- a/src/hwrenderer/utility/hw_clock.h +++ b/src/hwrenderer/utility/hw_clock.h @@ -13,6 +13,7 @@ extern glcycle_t ProcessAll, PostProcess; extern glcycle_t RenderAll; extern glcycle_t Dirty; extern glcycle_t drawcalls, twoD, Flush3D; +extern glcycle_t MTWait, WTTotal; extern int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render_vertexsplit,render_texsplit;