Skip to content

Add vk::timeline_semaphore for modernized synchronization support. #36

@SpinnerX

Description

@SpinnerX

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    💳 Tech DebtTasks that have some kind of user API tech debt📐designTasks that involve the core systems. Highly involve in API design.
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions