From fc8216809a6b6ab4397dabc19be09aaad246366b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Jun 2025 01:18:50 +0200 Subject: [PATCH] HACK: move semaphores into the drawplane loop, to fix a few visual glitches a bit of slowdown, but i have no clue what exactly causes shit, so this is the best solution for now i guess --- src/r_main.cpp | 14 -------------- src/r_plane.cpp | 9 ++++++++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index d0f9a7428..716e3401e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1006,7 +1006,6 @@ static void R_SetFov(fixed_t playerfov) R_SetSkyScale(); } - // // R_Init // @@ -1388,8 +1387,6 @@ void R_RenderPlayerView(player_t *player) Portal_InitList(); - srb2::ThreadPool::Sema tp_sema; - PS_START_TIMING(ps_skyboxtime); if (skybox && skyVisible) { @@ -1402,7 +1399,6 @@ void R_RenderPlayerView(player_t *player) #ifdef FLOORSPLATS R_ClearVisibleFloorSplats(); #endif - srb2::g_main_threadpool->begin_sema(); R_RenderViewpoint(&masks[nummasks - 1], false); R_ClipSprites(); @@ -1411,9 +1407,6 @@ void R_RenderPlayerView(player_t *player) R_DrawVisibleFloorSplats(); #endif // well sometimes synchronization is off and may result in some visual glitching, oh well - tp_sema = srb2::g_main_threadpool->end_sema(); - srb2::g_main_threadpool->notify_sema(tp_sema); - srb2::g_main_threadpool->wait_sema(tp_sema); R_DrawMasked(masks, nummasks); } PS_STOP_TIMING(ps_skyboxtime); @@ -1450,10 +1443,6 @@ void R_RenderPlayerView(player_t *player) ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; PS_START_TIMING(ps_bsptime); - tp_sema = srb2::g_main_threadpool->end_sema(); - srb2::g_main_threadpool->notify_sema(tp_sema); - srb2::g_main_threadpool->wait_sema(tp_sema); - srb2::g_main_threadpool->begin_sema(); R_RenderViewpoint(&masks[nummasks - 1], true); PS_STOP_TIMING(ps_bsptime); @@ -1505,9 +1494,6 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_sw_planetime); R_DrawPlanes(); - tp_sema = srb2::g_main_threadpool->end_sema(); - srb2::g_main_threadpool->notify_sema(tp_sema); - srb2::g_main_threadpool->wait_sema(tp_sema); PS_STOP_TIMING(ps_sw_planetime); #ifdef FLOORSPLATS R_DrawVisibleFloorSplats(); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 2a85f96a2..9dcc86aa0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -13,6 +13,8 @@ /// while maintaining a per column clipping list only. /// Moreover, the sky areas have to be determined. +#include + #include "doomdef.h" #include "console.h" #include "g_game.h" @@ -29,8 +31,8 @@ #include "p_tick.h" #include "r_fps.h" #include "r_portal.h" + #include "core/thread_pool.h" -#include static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge); static void R_SetTiltedSpan(drawspandata_t* ds, INT32 span); @@ -769,11 +771,13 @@ void R_DrawPlanes(void) visplane_t *pl; INT32 i; drawspandata_t ds = {}; + srb2::ThreadPool::Sema tp_sema; R_UpdatePlaneRipple(&ds); for (i = 0; i < MAXVISPLANES; i++, pl++) { + srb2::g_main_threadpool->begin_sema(); for (pl = visplanes[i]; pl; pl = pl->next) { if (pl->ffloor != NULL || pl->polyobj != NULL) @@ -781,6 +785,9 @@ void R_DrawPlanes(void) R_DrawSinglePlane(&ds, pl, cv_parallelsoftware.value); } + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); } }