From 8461449f2f73e86d38dcb1cc910873da2c3e7443 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 11:47:05 +0100 Subject: [PATCH] more opitmizations stuff --- src/doomtype.h | 4 ++++ src/hardware/hw_main.c | 6 +++--- src/hardware/hw_main.h | 2 +- src/r_main.c | 4 ++-- src/r_main.h | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index dd7c26b5d..5a04f77ba 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -249,6 +249,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 #define FUNCDEAD __attribute__ ((deprecated)) #define FUNCINLINE __attribute__((always_inline)) + #define PUREFUNC __attribute__((pure)) #define FUNCNONNULL __attribute__((nonnull)) #endif @@ -321,6 +322,9 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #ifndef ATTRNOINLINE #define ATTRNOINLINE #endif +#ifndef PUREFUNC +#define PUREFUNC +#endif /* Miscellaneous types that don't fit anywhere else (Can this be changed?) */ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b151e5696..46c3c4267 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2690,7 +2690,7 @@ doaddline: // // modified to use local variables -boolean HWR_CheckBBox(fixed_t *bspcoord) +boolean HWR_CheckBBox(const fixed_t *bspcoord) { INT32 boxpos; fixed_t px1, py1, px2, py2; @@ -3443,7 +3443,7 @@ skip_stuff_for_portals: // use returned value as multiplier for the added values from p_thrust thing // P_InterceptVector needs divlines which need dx and dy, dx=x2-x1 dy=y2-y1 -static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) +static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) { vertex_t closest_point; if (!portalclipline) @@ -3494,7 +3494,7 @@ void HWR_RenderBSPNode(INT32 bspnum) while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { - node_t *bsp = &nodes[bspnum]; + const node_t *bsp = &nodes[bspnum]; // Decide which side the view point is on. INT32 side = R_PointOnSide(viewx, viewy, bsp); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ab5d57159..16b09be8d 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -140,7 +140,7 @@ void HWR_AddPolyObjectSegs(void); void HWR_RenderBSPNode(INT32 bspnum); void HWR_Subsector(size_t num); void HWR_AddLine(seg_t *line); -boolean HWR_CheckBBox(fixed_t *bspcoord); +boolean HWR_CheckBBox(const fixed_t *bspcoord); void HWR_RenderDrawNodes(void); // hw_main.c: Sprites diff --git a/src/r_main.c b/src/r_main.c index 8a975498d..fce4fd92e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -331,7 +331,7 @@ static void FlipCam4_OnChange(void) // // killough 5/2/98: reformatted // -INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) +PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -350,7 +350,7 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) } // killough 5/2/98: reformatted -INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) +PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { fixed_t lx = line->v1->x; fixed_t ly = line->v1->y; diff --git a/src/r_main.h b/src/r_main.h index 63c7c3ab5..c8c3f4e8c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -65,8 +65,8 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; #define NUMCOLORMAPS 32 // Utility functions. -INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node); -INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); +INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); +INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1);