From 1a7ff21a045ea5ec965244c8a286560f5b0eca93 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Jun 2025 22:55:27 +0200 Subject: [PATCH] fix some warnings and plane ripple --- src/core/thread_pool.cpp | 4 +-- src/cxxutil.hpp | 2 +- src/r_draw.h | 1 - src/r_main.cpp | 46 +++++++++++++++-------------- src/r_plane.cpp | 64 ++++++++++++++++++++++++---------------- 5 files changed, 66 insertions(+), 51 deletions(-) diff --git a/src/core/thread_pool.cpp b/src/core/thread_pool.cpp index 820f21f67..6917aee93 100644 --- a/src/core/thread_pool.cpp +++ b/src/core/thread_pool.cpp @@ -45,7 +45,7 @@ static void do_work(ThreadPool::Task& work) } static void pool_executor( - int thread_index, + //int thread_index, std::shared_ptr> pool_alive, std::shared_ptr worker_ready_mutex, std::shared_ptr worker_ready_condvar, @@ -158,7 +158,7 @@ ThreadPool::ThreadPool(size_t threads) thread = std::thread { pool_executor, - i, + //i, pool_alive_, worker_ready_mutexes_[i], worker_ready_condvars_[i], diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp index 74349a0ff..545d38dfd 100644 --- a/src/cxxutil.hpp +++ b/src/cxxutil.hpp @@ -71,7 +71,7 @@ public: class NoOpAssertHandler { public: - static void handle(const SourceLocation& source_location, const char* expression) {} + static void handle(const SourceLocation& source_location, const char* expression) {(void)source_location; (void)expression;} }; /// @brief Assert a precondition expression, aborting the application if it fails. diff --git a/src/r_draw.h b/src/r_draw.h index f2e6e8050..12ab3f584 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -66,7 +66,6 @@ typedef struct INT32 x1; INT32 x2; lighttable_t* colormap; - lighttable_t* fullbright; lighttable_t* translation; fixed_t xfrac; diff --git a/src/r_main.cpp b/src/r_main.cpp index 55475c407..4530e6c19 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -104,23 +104,23 @@ extracolormap_t extra_colormaps[MAXCOLORMAPS]; // Performance stats precise_t ps_prevframetime = 0; -ps_metric_t ps_rendercalltime = {0}; -ps_metric_t ps_otherrendertime = {0}; -ps_metric_t ps_uitime = {0}; -ps_metric_t ps_swaptime = {0}; +ps_metric_t ps_rendercalltime = {}; +ps_metric_t ps_otherrendertime = {}; +ps_metric_t ps_uitime = {}; +ps_metric_t ps_swaptime = {}; -ps_metric_t ps_skyboxtime = {0}; -ps_metric_t ps_bsptime = {0}; +ps_metric_t ps_skyboxtime = {}; +ps_metric_t ps_bsptime = {}; -ps_metric_t ps_sw_spritecliptime = {0}; -ps_metric_t ps_sw_portaltime = {0}; -ps_metric_t ps_sw_planetime = {0}; -ps_metric_t ps_sw_maskedtime = {0}; +ps_metric_t ps_sw_spritecliptime = {}; +ps_metric_t ps_sw_portaltime = {}; +ps_metric_t ps_sw_planetime = {}; +ps_metric_t ps_sw_maskedtime = {}; -ps_metric_t ps_numbspcalls = {0}; -ps_metric_t ps_numsprites = {0}; -ps_metric_t ps_numdrawnodes = {0}; -ps_metric_t ps_numpolyobjects = {0}; +ps_metric_t ps_numbspcalls = {}; +ps_metric_t ps_numsprites = {}; +ps_metric_t ps_numdrawnodes = {}; +ps_metric_t ps_numpolyobjects = {}; static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, @@ -1341,9 +1341,6 @@ void R_RenderPlayerView(player_t *player) const boolean skybox = (skyboxmo[0] && cv_skybox.value); UINT8 i; - srb2::ThreadPool::Sema tp_sema; - srb2::g_main_threadpool->begin_sema(); - // if this is display player 1 if (cv_homremoval.value && player == &players[displayplayers[0]]) { @@ -1391,6 +1388,8 @@ void R_RenderPlayerView(player_t *player) Portal_InitList(); + srb2::ThreadPool::Sema tp_sema; + PS_START_TIMING(ps_skyboxtime); if (skybox && skyVisible) { @@ -1403,6 +1402,7 @@ 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(); @@ -1414,7 +1414,6 @@ void R_RenderPlayerView(player_t *player) 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_DrawMasked(masks, nummasks); } PS_STOP_TIMING(ps_skyboxtime); @@ -1454,10 +1453,13 @@ 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(); + if (skybox && skyVisible) + { + 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); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index bc4007162..47cac7e13 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -144,21 +144,19 @@ void R_AllocPlaneMemory(void) // Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. // -static void R_CalculatePlaneRipple(drawspandata_t* ds, visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac) +static fixed_t R_CalculateRippleOffset(drawspandata_t* ds, INT32 y) { - fixed_t distance = FixedMul(plheight, yslope[y]); + fixed_t distance = FixedMul(ds->planeheight, yslope[y]); const INT32 yay = (ds->planeripple.offset + (distance>>9)) & 8191; + return FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; +} - // ripples da water texture - ds->bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; - - if (calcfrac) - { - angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT; - angle = (angle + 2048) & 8191; // 90 degrees - ds->planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds->bgofs<planeripple.yfrac = FixedMul(FINESINE(angle), (ds->bgofs<>= ANGLETOFINESHIFT; + angle = (angle + 2048) & 8191; // 90 degrees + ds->planeripple.xfrac = FixedMul(FINECOSINE(angle), ds->bgofs); + ds->planeripple.yfrac = FixedMul(FINESINE(angle), ds->bgofs); } static void R_UpdatePlaneRipple(drawspandata_t* ds) @@ -259,6 +257,8 @@ static void R_MapPlane(drawspandata_t *ds, void(*spanfunc2)(drawspandata_t*), IN fixed_t distance = 0, span; size_t pindex; + (void)allow_parallel; + if (!R_CheckMapPlane(__func__, y, x1, x2)) return; @@ -288,7 +288,10 @@ static void R_MapPlane(drawspandata_t *ds, void(*spanfunc2)(drawspandata_t*), IN if (ds->planeripple.active) { // Needed for ds_bgofs - R_CalculatePlaneRipple(ds, ds->currentplane, y, ds->planeheight, (!ds->currentplane->slope)); + + ds->bgofs = R_CalculateRippleOffset(ds, y); + + R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); ds->xfrac += ds->planeripple.xfrac; ds->yfrac += ds->planeripple.yfrac; @@ -319,16 +322,24 @@ static void R_MapPlane(drawspandata_t *ds, void(*spanfunc2)(drawspandata_t*), IN static void R_MapTiltedPlane(drawspandata_t *ds, void(*spanfunc2)(drawspandata_t*), INT32 y, INT32 x1, INT32 x2, boolean allow_parallel) { + (void)allow_parallel; + if (!R_CheckMapPlane(__func__, y, x1, x2)) return; // Water ripple effect if (ds->planeripple.active) { + ds->bgofs = R_CalculateRippleOffset(ds, y); + R_SetTiltedSpan(ds, std::clamp(y, 0, viewheight)); - R_CalculatePlaneRipple(ds, ds->currentplane, y, ds->planeheight, false); - R_SetSlopePlaneVectors(ds, ds->currentplane, y, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac), 0); + float fudgecanyon = 0; + // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -fickle + fudgecanyon = ((1<nflatshiftup)+1.0f)/(1<nflatshiftup); + + R_CalculatePlaneRipple(ds, ds->currentplane->viewangle + ds->currentplane->plangle); + R_SetSlopePlaneVectors(ds, ds->currentplane, y, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac), fudgecanyon); if ((y + ds->bgofs) >= viewheight) ds->bgofs = viewheight-y-1; @@ -341,11 +352,9 @@ static void R_MapTiltedPlane(drawspandata_t *ds, void(*spanfunc2)(drawspandata_t else ds->colormap = colormaps; - ds->fullbright = colormaps; if (encoremap && !ds->currentplane->noencore) { ds->colormap += COLORMAP_REMAPOFFSET; - ds->fullbright += COLORMAP_REMAPOFFSET; } ds->y = y; @@ -765,11 +774,13 @@ void R_DrawPlanes(void) { visplane_t *pl; INT32 i; - drawspandata_t ds = {0}; + drawspandata_t ds = {}; spanfunc = basespanfunc; wallcolfunc = walldrawerfunc; + R_UpdatePlaneRipple(&ds); + for (i = 0; i < MAXVISPLANES; i++, pl++) { for (pl = visplanes[i]; pl; pl = pl->next) @@ -780,14 +791,12 @@ void R_DrawPlanes(void) R_DrawSinglePlane(&ds, pl, true); } } - - R_UpdatePlaneRipple(&ds); } static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel) { INT32 x; - drawcolumndata_t dc = {0}; + drawcolumndata_t dc = {}; if (!newview->sky) { @@ -971,6 +980,8 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle if (!(pl->minx <= pl->maxx)) return; + R_UpdatePlaneRipple(ds); + // sky flat if (pl->picnum == skyflatnum) { @@ -986,7 +997,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle spanfunc = R_DrawTranslucentSpan; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) - if (pl->polyobj->translucency >= 10) + if (pl->polyobj->translucency >= NUMTRANSMAPS) return; // Don't even draw it else if (pl->polyobj->translucency > 0) ds->transmap = R_GetTranslucencyTable(pl->polyobj->translucency); @@ -1127,7 +1138,6 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ds->xoffs = pl->xoffs; ds->yoffs = pl->yoffs; - ds->planeheight = abs(pl->height - pl->viewz); if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; @@ -1199,13 +1209,14 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle if (ds->planeripple.active) { - fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + ds->planeheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); R_PlaneBounds(pl); for (x = pl->high; x < pl->low; x++) { - R_CalculatePlaneRipple(ds, pl, x, plheight, true); + ds->bgofs = R_CalculateRippleOffset(ds, x); + R_CalculatePlaneRipple(ds, pl->viewangle + pl->plangle); R_SetSlopePlaneVectors(ds, pl, x, (ds->xoffs + ds->planeripple.xfrac), (ds->yoffs + ds->planeripple.yfrac), fudgecanyon); } } @@ -1224,7 +1235,10 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ds->planezlight = scalelight[light]; } else + { + ds->planeheight = abs(pl->height - pl->viewz); ds->planezlight = zlight[light]; + } // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff;