Moving away from using VkFence and Binary Semaphores
Originally you would have to use VkFence to manage the offloading from the Host (CPU) to the Device (GPU).
By using fence, they only allow you to use to signal once when the GPU has finished its current task before it can record the next frame.
It is because it has to stop to record. This requires the CPU thread to sleep then wake up every time a task is finished. Which is not ideal in a thread-environment situation.
Only signaling when entire submissions (via vkQueueSubmit) has been finished.
Comparison of Timeline Semaphores and Fences
| Comparison |
Timeline Semaphore |
VkFence |
| Granularity |
Track partial submission and signaling multiple values to a singular command stream. |
Entire submissions. Only signal when an entire submission is completed. |
| CPU-GPU |
CPU can signal GPU to start, GPU can signal when finished. |
Only GPU can signal a fence for the CPU to wait. |
| Order Management |
Specify wait value of n before submitting code gets executed. |
Requires valid VkFence handle to be created before using it in a task submission operation |
| State Management |
64-bit counter which never needs resetting. Simply logic is as if(value >= n) |
Must manually reset each VkFence using the vkResetFence API. Bug-prone to signaling errors |
| Wait Logic |
Multiple threads can use a single semaphore to be timelined at specific values. One thread can have its wait value set to 5, another thread wait value at 10, another thread wait value set to 100. |
To track multiple events. You would need to keep track of multiple VkFence objects per thread. |
| Debugging |
Can query current value to exactly where the GPU is idle |
Are only given options to know if the fence is Finished or Incomplete |
Moving away from using VkFence and Binary Semaphores
Originally you would have to use
VkFenceto manage the offloading from the Host (CPU) to the Device (GPU).By using fence, they only allow you to use to signal once when the GPU has finished its current task before it can record the next frame.
It is because it has to stop to record. This requires the CPU thread to sleep then wake up every time a task is finished. Which is not ideal in a thread-environment situation.
Only signaling when entire submissions (via
vkQueueSubmit) has been finished.Comparison of Timeline Semaphores and Fences
Timeline SemaphoreVkFencevalues to a singular command stream.
an entire submission is completed.
GPU can signal when finished.
the CPU to wait.
nbefore submittingcode gets executed.
VkFencehandle to be created before using it ina task submission operation
if(value >= n)VkFenceusing thevkResetFenceAPI. Bug-prone to signaling errorsOne thread can have its wait value set to 5, another thread wait value at 10, another thread wait value set to 100.
VkFenceobjects per thread.FinishedorIncomplete