From 08e91c1cc27ace17291a45b871204f2ab4227b86 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Sep 2025 02:27:25 +0200 Subject: [PATCH] preconvert our polyvertex coords to fixed point yes this is unironically faster, by atleast 5-10fps in the wandering falls test case --- src/hardware/hw_bsp.c | 15 ++++++++++----- src/hardware/hw_defs.h | 5 ++--- src/hardware/hw_main.cpp | 24 ++++++++++++------------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 6982e371b..f4cf3a152 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -175,9 +175,9 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line INT32 ps = -1, pe = -1; INT32 nptfront, nptback; - polyvertex_t vs = {0,0,0}; - polyvertex_t ve = {0,0,0}; - polyvertex_t lastpv = {0,0,0}; + polyvertex_t vs = {}; + polyvertex_t ve = {}; + polyvertex_t lastpv = {}; float fracs = 0.0f, frace = 0.0f; //used to tell which poly is on // the front side of the bsp partition line INT32 psonline = 0, peonline = 0; @@ -349,8 +349,8 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) INT32 i, j; polyvertex_t *pv; INT32 nump = 0, ps, pe; - polyvertex_t vs = {0, 0, 0}, ve = {0, 0, 0}, - p1 = {0, 0, 0}, p2 = {0, 0, 0}; + polyvertex_t vs = {}, ve = {}, + p1 = {}, p2 = {}; float fracs = 0.0f; fdivline_t cutseg; // x, y, dx, dy as start of node_t struct poly_t *temppoly; @@ -936,6 +936,11 @@ static void AdjustSegs(void) pv->y = FIXED_TO_FLOAT(lseg->v2->y); lseg->pv2 = pv; } + + lseg->pv1->x2 = FloatToFixed(lseg->pv1->x); + lseg->pv1->y2 = FloatToFixed(lseg->pv1->y); + lseg->pv2->x2 = FloatToFixed(lseg->pv2->x); + lseg->pv2->y2 = FloatToFixed(lseg->pv2->y); } } } diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index cc8eb4c61..80333ce57 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -95,9 +95,8 @@ typedef struct // a vertex of a Doom 'plane' polygon typedef struct { - float x; - float y; - float z; + float x, y, z; + fixed_t x2, y2, z2; } polyvertex_t; #ifdef _MSC_VER diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 84bb7d527..bd0ce0057 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1371,8 +1371,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { vs.x = gl_curline->pv1->x; vs.y = gl_curline->pv1->y; - v1x = FloatToFixed(vs.x); - v1y = FloatToFixed(vs.y); + v1x = gl_curline->pv1->x2; + v1y = gl_curline->pv1->y2; } else { @@ -1386,8 +1386,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { ve.x = gl_curline->pv2->x; ve.y = gl_curline->pv2->y; - v2x = FloatToFixed(ve.x); - v2y = FloatToFixed(ve.y); + v2x = gl_curline->pv2->x2; + v2y = gl_curline->pv2->y2; } else { @@ -2248,8 +2248,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (LIKELY(gl_curline->pv1)) { - v1x = FloatToFixed(gl_curline->pv1->x); - v1y = FloatToFixed(gl_curline->pv1->y); + v1x = gl_curline->pv1->x2; + v1y = gl_curline->pv1->y2; } else { @@ -2259,8 +2259,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (LIKELY(gl_curline->pv2)) { - v2x = FloatToFixed(gl_curline->pv2->x); - v2y = FloatToFixed(gl_curline->pv2->y); + v2x = gl_curline->pv2->x2; + v2y = gl_curline->pv2->y2; } else { @@ -2476,8 +2476,8 @@ static void HWR_AddLine(seg_t *line) if (LIKELY(gl_curline->pv1)) { - v1x = FloatToFixed(gl_curline->pv1->x); - v1y = FloatToFixed(gl_curline->pv1->y); + v1x = gl_curline->pv1->x2; + v1y = gl_curline->pv1->y2; } else { @@ -2487,8 +2487,8 @@ static void HWR_AddLine(seg_t *line) if (LIKELY(gl_curline->pv2)) { - v2x = FloatToFixed(gl_curline->pv2->x); - v2y = FloatToFixed(gl_curline->pv2->y); + v2x = gl_curline->pv2->x2; + v2y = gl_curline->pv2->y2; } else {