Revert "allocate tiltlighting buffer in R_AllocViewMemory again"

This reverts commit dbe32317b2.
This commit is contained in:
Alug committed 2025-07-23 15:48:19 +02:00
1 parent 2794f8bd5c
commit a85b61e06a
2 files changed
+32 -26

No files matched your search

+1 -26
View File
@@ -34,10 +34,6 @@
#include "hardware/hw_main.h"
#endif
#ifdef HAVE_THREADS
#include "core/thread_pool.h"
#endif
// ==========================================================================
// COMMON DATA FOR 8bpp AND 16bpp
// ==========================================================================
@@ -81,19 +77,7 @@ floatv3_t *ds_su, *ds_sv, *ds_sz;
float focallengthf;
// For, uh, tilted lighting, duh.
#ifdef HAVE_THREADS
#ifdef _WIN32
#include <windows.h>
#define local_for_thread static __thread
#else
#include <threads.h>
#define local_for_thread thread_local static
#endif
#else
#define local_for_thread static
#endif
local_for_thread INT32 *tiltlighting;
//static INT32 *tiltlighting;
// --------------------------------------------
// c drawer routines
@@ -486,15 +470,6 @@ static void R_AllocViewMemory(void)
xtoviewangle = static_cast<angle_t*>(Z_Realloc(xtoviewangle, sizeof(*xtoviewangle) * (viewwidth + 1), PU_STATIC, NULL));
auto init_tiltlighting = [] {
tiltlighting = static_cast<INT32*>(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth)); // dont use Zone memory since its not thread safe
};
init_tiltlighting();
#ifdef HAVE_THREADS
srb2::g_main_threadpool->for_each(std::move(init_tiltlighting));
#endif
R_AllocSegMemory();
R_AllocClipSegMemory();
R_AllocPlaneMemory();
+31
View File
@@ -13,6 +13,18 @@
/// \brief span drawer functions
/// \note no includes because this is included as part of r_draw.cpp
#ifdef HAVE_THREADS
#ifdef _WIN32
#include <windows.h>
#define local_for_thread static __thread
#else
#include <threads.h>
#define local_for_thread thread_local static
#endif
#else
#define local_for_thread static
#endif
// ==========================================================================
// SPANS
// ==========================================================================
@@ -211,6 +223,15 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
float endz, endu, endv;
UINT32 stepu, stepv;
UINT32 bit;
local_for_thread INT32 *tiltlighting = NULL;
local_for_thread INT32 oldviewwidth = 0;
// dont realloc every frame pls thx
if (tiltlighting == NULL || oldviewwidth != viewwidth)
{
tiltlighting = static_cast<INT32*>(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth));
oldviewwidth = viewwidth;
}
INT32 x1 = ds->x1;
const INT32 nflatxshift = ds->nflatxshift;
@@ -403,6 +424,16 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds)
float iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
UINT8 * restrict dest;
local_for_thread INT32 *tiltlighting = NULL;
local_for_thread INT32 oldviewwidth = 0;
// dont realloc every frame pls thx
if (tiltlighting == NULL || oldviewwidth != viewwidth)
{
tiltlighting = static_cast<INT32*>(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth));
oldviewwidth = viewwidth;
}
dest = R_Address(ds->x1, ds->y);
const INT32 stride = vid.width;