From da706d89a561de271d366c1cd9beb494637b03f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Jun 2025 22:18:57 +0200 Subject: [PATCH] absolutely disgusting hack for sky issues instead of homremoval, we draw the fucking skyplane before everything lmao there probably is a right way to fix this, but im too dumb for that needs some performance testing, but since i could move the semaphores back, its even better in some instances --- src/r_main.cpp | 6 +++++- src/r_plane.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- src/r_plane.h | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index bfbf8781a..fca456509 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1391,13 +1391,15 @@ void R_RenderPlayerView(player_t *player) R_ClearClipSegs(); R_ClearDrawSegs(); + R_DrawSkyPlanes(); R_ClearPlanes(); R_ClearSprites(); + R_RenderViewpoint(&masks[nummasks - 1], false); R_ClipSprites(drawsegs, NULL); + R_DrawSkyPlanes(); // draw the fucker again to prevent some artifacts R_DrawPlanes(); - // well sometimes synchronization is off and may result in some visual glitching, oh well R_DrawMasked(masks, nummasks); } PS_STOP_TIMING(ps_skyboxtime); @@ -1479,6 +1481,8 @@ void R_RenderPlayerView(player_t *player) PS_STOP_TIMING(ps_sw_portaltime); PS_START_TIMING(ps_sw_planetime); + if (!skybox) + R_DrawSkyPlanes(); R_DrawPlanes(); PS_STOP_TIMING(ps_sw_planetime); // draw mid texture and sprite diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cef2d2f50..2b0d8ae0e 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -698,9 +698,9 @@ void R_DrawPlanes(void) R_UpdatePlaneRipple(&ds); + srb2::g_main_threadpool->begin_sema(); 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) @@ -708,10 +708,37 @@ 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); } + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); +} + +static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel); + +void R_DrawSkyPlanes(void) +{ + visplane_t *pl; + INT32 i; + srb2::ThreadPool::Sema tp_sema; + + srb2::g_main_threadpool->begin_sema(); + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->ffloor != NULL || pl->polyobj != NULL) + continue; + + if (pl->picnum != skyflatnum) + continue; + + R_DrawSkyPlane(pl, colfunc, 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); } static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel) @@ -723,9 +750,6 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b // This probably utterly ruins sky rendering for FOFs and polyobjects, unfortunately if (!newview->sky) { - // Mark that the sky was visible here for next tic - // (note: this is a hack and it sometimes can cause HOMs to appear for a tic IIRC) - skyVisible = true; return; } @@ -941,7 +965,12 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle // sky flat if (pl->picnum == skyflatnum) { - R_DrawSkyPlane(pl, colfunc, allow_parallel); + // horrific + if (!newview->sky) + { + skyVisible = true; + } + return; } diff --git a/src/r_plane.h b/src/r_plane.h index 78b92cc83..35e3f2b08 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -79,6 +79,7 @@ void R_AllocPlaneMemory(void); void R_ClearPlanes(void); void R_ClearFFloorClips (void); +void R_DrawSkyPlanes(void); void R_DrawPlanes(void); visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,