cwfitzgerald / fiber-tasking-library

A library for enabling task-based multi-threading. It allows execution of task graphs with arbitrary dependencies.
Apache License 2.0
0 stars 1 forks source link

Separate thread pool for blocking tasks #5

Open DethRaid opened 5 years ago

DethRaid commented 5 years ago

I have a number of tasks that need to wait on the GPU to finish some work, and thus will block the thread they're in. I'd like ftl::TaskScheduler to allow me to schedule these tasks separately from tasks which do not require blocking the thread

Use case is that I can't upload new mesh data to my megamesh buffers until mesh rendering is done, so I have to wait on a VkFence (because the megamesh buffers get rendered on the graphics queue, but transferred to on the transfer queue). I'd like to be able to relenquish CPU time to other tasks can execute (if needed) while this one is waiting on the GPU

Blocking code:

vkWaitForFences(device, 1, &mesh_rendering_done, VK_TRUE, 0xffffffffffffffffL);

That waits on fence mesh_rendering_done with a timeout of the max value of a 64-bit unsigned number. I'd like to be able to submit a separate tasks for waiting on the fence. My main task can wait on a ftl::AtomicCounter