omit realloc and use unique_ptr for our tiltlighting buffer
this makes asan shut up, since those effectively clean up after themselves
This commit is contained in:
1 parent
9764cbbfe0
commit
7e2a9abfda
2 files changed
+16
-18
No files matched your search
+14
-18
@@ -36,6 +36,15 @@
|
||||
|
||||
#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
|
||||
|
||||
// ==========================================================================
|
||||
@@ -81,19 +90,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;
|
||||
local_for_thread std::unique_ptr<INT32[]> tiltlight;
|
||||
|
||||
// --------------------------------------------
|
||||
// c drawer routines
|
||||
@@ -486,13 +483,12 @@ 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
|
||||
auto init_tiltlighting = [](INT32 size) {
|
||||
tiltlight = std::make_unique<INT32[]>(size);
|
||||
};
|
||||
|
||||
init_tiltlighting();
|
||||
init_tiltlighting(viewwidth); // allocate for main thread
|
||||
#ifdef HAVE_THREADS
|
||||
srb2::g_main_threadpool->for_each(std::move(init_tiltlighting));
|
||||
srb2::g_main_threadpool->for_each([=] { init_tiltlighting(viewwidth); });
|
||||
#endif
|
||||
|
||||
R_AllocSegMemory();
|
||||
|
||||
@@ -204,6 +204,7 @@ 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);
|
||||
|
||||
@@ -392,6 +393,7 @@ 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