mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-29 15:12:25 +00:00
Display percentage progress instead of dots
This commit is contained in:
parent
cc273c5f38
commit
152b5092b9
3 changed files with 20 additions and 9 deletions
|
@ -507,10 +507,22 @@ void CPURaytracer::RunJob(int count, std::function<void(int)> callback)
|
||||||
{
|
{
|
||||||
threads.push_back(std::thread([&, threadIndex]() {
|
threads.push_back(std::thread([&, threadIndex]() {
|
||||||
|
|
||||||
|
if (threadIndex == 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i += numThreads)
|
||||||
|
{
|
||||||
|
if((i / numThreads) % 8192 == 0)
|
||||||
|
printf("\r%.1f%%\t%d/%d", double(i) / double(count) * 100, i, count);
|
||||||
|
callback(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (int i = threadIndex; i < count; i += numThreads)
|
for (int i = threadIndex; i < count; i += numThreads)
|
||||||
{
|
{
|
||||||
callback(i);
|
callback(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m);
|
std::unique_lock<std::mutex> lock(m);
|
||||||
threadsleft--;
|
threadsleft--;
|
||||||
|
@ -525,9 +537,8 @@ void CPURaytracer::RunJob(int count, std::function<void(int)> callback)
|
||||||
while (threadsleft != 0)
|
while (threadsleft != 0)
|
||||||
{
|
{
|
||||||
condvar.wait_for(lock, std::chrono::milliseconds(500), [&]() { return threadsleft == 0; });
|
condvar.wait_for(lock, std::chrono::milliseconds(500), [&]() { return threadsleft == 0; });
|
||||||
printf(".");
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\r%.1f%%\t%d/%d\n", 100.0, count, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numThreads; i++)
|
for (int i = 0; i < numThreads; i++)
|
||||||
|
|
|
@ -93,10 +93,11 @@ void GPURaytracer::Raytrace(LevelMesh* level)
|
||||||
//printf("Ray tracing with %d bounce(s)\n", mesh->map->LightBounce);
|
//printf("Ray tracing with %d bounce(s)\n", mesh->map->LightBounce);
|
||||||
printf("Ray tracing in progress...\n");
|
printf("Ray tracing in progress...\n");
|
||||||
|
|
||||||
RunWithProgressDots([&]() {
|
RunAsync([&]() {
|
||||||
size_t maxTasks = (size_t)rayTraceImageSize * rayTraceImageSize;
|
size_t maxTasks = (size_t)rayTraceImageSize * rayTraceImageSize;
|
||||||
for (size_t startTask = 0; startTask < tasks.size(); startTask += maxTasks)
|
for (size_t startTask = 0; startTask < tasks.size(); startTask += maxTasks)
|
||||||
{
|
{
|
||||||
|
printf("\r%.1f%%\t%d/%d", double(startTask) / double(tasks.size()) * 100, startTask, tasks.size());
|
||||||
size_t numTasks = std::min(tasks.size() - startTask, maxTasks);
|
size_t numTasks = std::min(tasks.size() - startTask, maxTasks);
|
||||||
UploadTasks(tasks.data() + startTask, numTasks);
|
UploadTasks(tasks.data() + startTask, numTasks);
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ void GPURaytracer::Raytrace(LevelMesh* level)
|
||||||
EndTracing();
|
EndTracing();
|
||||||
DownloadTasks(tasks.data() + startTask, numTasks);
|
DownloadTasks(tasks.data() + startTask, numTasks);
|
||||||
}
|
}
|
||||||
|
printf("\r%.1f%%\t%d/%d\n", 100.0, tasks.size(), tasks.size());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (device->renderdoc)
|
if (device->renderdoc)
|
||||||
|
@ -971,7 +973,7 @@ float GPURaytracer::RadicalInverse_VdC(uint32_t bits)
|
||||||
return float(bits) * 2.3283064365386963e-10f; // / 0x100000000
|
return float(bits) * 2.3283064365386963e-10f; // / 0x100000000
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPURaytracer::RunWithProgressDots(std::function<void()> callback)
|
void GPURaytracer::RunAsync(std::function<void()> callback)
|
||||||
{
|
{
|
||||||
std::exception_ptr e;
|
std::exception_ptr e;
|
||||||
std::condition_variable condvar;
|
std::condition_variable condvar;
|
||||||
|
@ -1003,9 +1005,7 @@ void GPURaytracer::RunWithProgressDots(std::function<void()> callback)
|
||||||
while (!stop)
|
while (!stop)
|
||||||
{
|
{
|
||||||
condvar.wait_for(lock, std::chrono::milliseconds(500), [&]() { return stop; });
|
condvar.wait_for(lock, std::chrono::milliseconds(500), [&]() { return stop; });
|
||||||
printf(".");
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.join();
|
t.join();
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
static float RadicalInverse_VdC(uint32_t bits);
|
static float RadicalInverse_VdC(uint32_t bits);
|
||||||
static vec2 Hammersley(uint32_t i, uint32_t N);
|
static vec2 Hammersley(uint32_t i, uint32_t N);
|
||||||
|
|
||||||
static void RunWithProgressDots(std::function<void()> callback);
|
static void RunAsync(std::function<void()> callback);
|
||||||
|
|
||||||
const int coverageSampleCount = 256;
|
const int coverageSampleCount = 256;
|
||||||
const int bounceSampleCount = 2048;
|
const int bounceSampleCount = 2048;
|
||||||
|
|
Loading…
Reference in a new issue