cadaver/turso3d

Workqueue stuck on loop

Closed this issue · 1 comments

The workqueue gets stuck in it's loop waiting for pending tasks to finish.
Adding the dependency causes the pending tasks to increment, but because the rootLevelOctants is empty there's no work task to decrement it.

workQueue->AddDependency(processShadowCastersTask, processLightsTask);
workQueue->AddDependency(processShadowCastersTask, batchesReadyTask);
// Find octants in view and their plane masks for node frustum culling. At the same time, find lights and process them
// When octant collection tasks complete, they queue tasks for collecting batches from those octants.
for (size_t i = 0; i < rootLevelOctants.size(); ++i)
{
collectOctantsTasks[i]->startOctant = rootLevelOctants[i];
workQueue->AddDependency(processLightsTask, collectOctantsTasks[i]);
}
workQueue->QueueTasks(rootLevelOctants.size(), reinterpret_cast<Task**>(&collectOctantsTasks[0]));

How to reproduce:
Using the supplied Turso3DTest, just put a return statement on scene creation preset 0.

As a workaround the dependency is only set if the rootLevelOctants is not empty, but I'm not sure if that's correct approach.

Thanks, good find! Clients of the WorkQueue need to make sure they don't add dependencies that will not complete, so Renderer should early-out in case of no octants (nothing to render)