mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-12 23:54:27 +00:00
- reduce executable size by 12 megabytes!
This commit is contained in:
parent
dce5c510e3
commit
f86358daf5
2 changed files with 10 additions and 2 deletions
|
@ -43,6 +43,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
extern int Multisample;
|
extern int Multisample;
|
||||||
|
extern thread_local kexVec3 *colorSamples;
|
||||||
|
|
||||||
const kexVec3 kexLightmapBuilder::gridSize(64, 64, 128);
|
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
|
// 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)
|
void kexLightmapBuilder::TraceSurface(surface_t *surface)
|
||||||
{
|
{
|
||||||
static thread_local kexVec3 colorSamples[1024 * 1024];
|
|
||||||
|
|
||||||
int sampleWidth;
|
int sampleWidth;
|
||||||
int sampleHeight;
|
int sampleHeight;
|
||||||
kexVec3 normal;
|
kexVec3 normal;
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
|
#include "common.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
extern int NumThreads;
|
extern int NumThreads;
|
||||||
|
|
||||||
|
thread_local kexVec3 *colorSamples;
|
||||||
|
|
||||||
void kexWorker::RunJob(int count, std::function<void(int)> callback)
|
void kexWorker::RunJob(int count, std::function<void(int)> callback)
|
||||||
{
|
{
|
||||||
int numThreads = NumThreads;
|
int numThreads = NumThreads;
|
||||||
|
@ -21,6 +26,8 @@ void kexWorker::RunJob(int count, std::function<void(int)> callback)
|
||||||
{
|
{
|
||||||
threads.push_back(std::thread([=]() {
|
threads.push_back(std::thread([=]() {
|
||||||
|
|
||||||
|
colorSamples = new kexVec3[1024 * 1024];
|
||||||
|
|
||||||
int start = threadIndex * count / numThreads;
|
int start = threadIndex * count / numThreads;
|
||||||
int end = std::min((threadIndex + 1) * count / numThreads, count);
|
int end = std::min((threadIndex + 1) * count / numThreads, count);
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
|
@ -28,6 +35,8 @@ void kexWorker::RunJob(int count, std::function<void(int)> callback)
|
||||||
callback(i);
|
callback(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] colorSamples;
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue