- reduce executable size by 12 megabytes!

This commit is contained in:
Magnus Norddahl 2018-11-03 03:50:14 +01:00
parent dce5c510e3
commit f86358daf5
2 changed files with 10 additions and 2 deletions

View file

@ -43,6 +43,7 @@
#include <vector>
extern int Multisample;
extern thread_local kexVec3 *colorSamples;
const kexVec3 kexLightmapBuilder::gridSize(64, 64, 128);
@ -413,8 +414,6 @@ void kexLightmapBuilder::BuildSurfaceParams(surface_t *surface)
// For each non-occluded trace, color is accumulated and saved off into the lightmap texture based on what block is mapped to
void kexLightmapBuilder::TraceSurface(surface_t *surface)
{
static thread_local kexVec3 colorSamples[1024 * 1024];
int sampleWidth;
int sampleHeight;
kexVec3 normal;

View file

@ -1,11 +1,16 @@
#include "worker.h"
#include "common.h"
#include <vector>
#include <thread>
#include <algorithm>
#undef min
#undef max
extern int NumThreads;
thread_local kexVec3 *colorSamples;
void kexWorker::RunJob(int count, std::function<void(int)> callback)
{
int numThreads = NumThreads;
@ -21,6 +26,8 @@ void kexWorker::RunJob(int count, std::function<void(int)> callback)
{
threads.push_back(std::thread([=]() {
colorSamples = new kexVec3[1024 * 1024];
int start = threadIndex * count / numThreads;
int end = std::min((threadIndex + 1) * count / numThreads, count);
for (int i = start; i < end; i++)
@ -28,6 +35,8 @@ void kexWorker::RunJob(int count, std::function<void(int)> callback)
callback(i);
}
delete[] colorSamples;
}));
}