mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-22 03:51:26 +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,9 +507,21 @@ void CPURaytracer::RunJob(int count, std::function<void(int)> callback)
|
|||
{
|
||||
threads.push_back(std::thread([&, threadIndex]() {
|
||||
|
||||
for (int i = threadIndex; i < count; i += numThreads)
|
||||
if (threadIndex == 0)
|
||||
{
|
||||
callback(i);
|
||||
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)
|
||||
{
|
||||
callback(i);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
|
@ -525,9 +537,8 @@ void CPURaytracer::RunJob(int count, std::function<void(int)> callback)
|
|||
while (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++)
|
||||
|
|
|
@ -93,10 +93,11 @@ void GPURaytracer::Raytrace(LevelMesh* level)
|
|||
//printf("Ray tracing with %d bounce(s)\n", mesh->map->LightBounce);
|
||||
printf("Ray tracing in progress...\n");
|
||||
|
||||
RunWithProgressDots([&]() {
|
||||
RunAsync([&]() {
|
||||
size_t maxTasks = (size_t)rayTraceImageSize * rayTraceImageSize;
|
||||
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);
|
||||
UploadTasks(tasks.data() + startTask, numTasks);
|
||||
|
||||
|
@ -144,6 +145,7 @@ void GPURaytracer::Raytrace(LevelMesh* level)
|
|||
EndTracing();
|
||||
DownloadTasks(tasks.data() + startTask, numTasks);
|
||||
}
|
||||
printf("\r%.1f%%\t%d/%d\n", 100.0, tasks.size(), tasks.size());
|
||||
});
|
||||
|
||||
if (device->renderdoc)
|
||||
|
@ -971,7 +973,7 @@ float GPURaytracer::RadicalInverse_VdC(uint32_t bits)
|
|||
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::condition_variable condvar;
|
||||
|
@ -1003,9 +1005,7 @@ void GPURaytracer::RunWithProgressDots(std::function<void()> callback)
|
|||
while (!stop)
|
||||
{
|
||||
condvar.wait_for(lock, std::chrono::milliseconds(500), [&]() { return stop; });
|
||||
printf(".");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
t.join();
|
||||
|
|
|
@ -89,7 +89,7 @@ private:
|
|||
static float RadicalInverse_VdC(uint32_t bits);
|
||||
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 bounceSampleCount = 2048;
|
||||
|
|
Loading…
Reference in a new issue