From 57990100c563f828848a4ec37e49a699174aa264 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Oct 2025 17:18:30 +0200 Subject: [PATCH] speed up masked sprites a bit thx eternity engine! --- src/r_things.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 4713bc50e..60dba8a32 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2810,6 +2810,11 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) drawseg_t* ds; INT32 i; + if (visspritecount - clippedvissprites <= 0) + { + return; + } + // e6y // Reducing of cache misses in the following R_DrawSprite() // Makes sense for scenes with huge amount of drawsegs. @@ -2819,13 +2824,9 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) drawsegs_xranges[i].count = 0; } - if (visspritecount - clippedvissprites <= 0) - { - return; - } - if (drawsegs_xrange_size < maxdrawsegs) { + // haleyjd: fix reallocation to track 2x size drawsegs_xrange_size = 2 * maxdrawsegs; for (i = 0; i < DS_RANGES_COUNT; i++) @@ -2865,6 +2866,9 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) } } + // haleyjd: terminate with a nullptr user for faster loop - adds ~3 FPS + drawsegs_xranges[0].items[drawsegs_xranges[0].count].user = nullptr; + for (; clippedvissprites < visspritecount; clippedvissprites++) { vissprite_t *spr = R_GetVisSprite(clippedvissprites);