Revert "omit realloc and use unique_ptr for our tiltlighting buffer"
This reverts commit 7e2a9abfda.
This commit is contained in:
1 parent
c9ec0593b7
commit
2794f8bd5c
2 files changed
+18
-16
No files matched your search
+18
-14
@@ -36,15 +36,6 @@
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#include "core/thread_pool.h"
|
||||
#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
|
||||
|
||||
// ==========================================================================
|
||||
@@ -90,7 +81,19 @@ floatv3_t *ds_su, *ds_sv, *ds_sz;
|
||||
float focallengthf;
|
||||
|
||||
// For, uh, tilted lighting, duh.
|
||||
local_for_thread std::unique_ptr<INT32[]> tiltlight;
|
||||
#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;
|
||||
|
||||
// --------------------------------------------
|
||||
// c drawer routines
|
||||
@@ -483,12 +486,13 @@ static void R_AllocViewMemory(void)
|
||||
|
||||
xtoviewangle = static_cast<angle_t*>(Z_Realloc(xtoviewangle, sizeof(*xtoviewangle) * (viewwidth + 1), PU_STATIC, NULL));
|
||||
|
||||
auto init_tiltlighting = [](INT32 size) {
|
||||
tiltlight = std::make_unique<INT32[]>(size);
|
||||
auto init_tiltlighting = [] {
|
||||
tiltlighting = static_cast<INT32*>(realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth)); // dont use Zone memory since its not thread safe
|
||||
};
|
||||
init_tiltlighting(viewwidth); // allocate for main thread
|
||||
|
||||
init_tiltlighting();
|
||||
#ifdef HAVE_THREADS
|
||||
srb2::g_main_threadpool->for_each([=] { init_tiltlighting(viewwidth); });
|
||||
srb2::g_main_threadpool->for_each(std::move(init_tiltlighting));
|
||||
#endif
|
||||
|
||||
R_AllocSegMemory();
|
||||
|
||||
@@ -217,7 +217,6 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
const INT32 nflatyshift = ds->nflatyshift;
|
||||
const INT32 nflatmask = ds->nflatmask;
|
||||
const INT32 stride = vid.width;
|
||||
INT32 * restrict tiltlighting = tiltlight.get();
|
||||
|
||||
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
|
||||
@@ -406,7 +405,6 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds)
|
||||
|
||||
dest = R_Address(ds->x1, ds->y);
|
||||
const INT32 stride = vid.width;
|
||||
INT32 * restrict tiltlighting = tiltlight.get();
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user