Search

A technology, a device or an article

A GPU counter makes a buffer reusable

A timeline semaphore can connect a GPU milestone to a buffer’s last use. Why the counter helps reclamation without measuring elapsed time.

A red working ribbon connects a spool, milestone pegs, and several tables.
ITNWS AI-generated conceptual illustration. A metaphor for a staging region’s lifetime, not a GPU execution trace.ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

The buffer is already needed again. The central processor has prepared the next portion of data, there is not much free space, and the previous sending to the GPU looks complete by all everyday signs: the function of sending commands has returned, the window continues to update, the application does not report an error. However, none of these signs in itself gives the right to erase the bytes that the device can still read. For this right, the program needs a certain event. In Vulkan it is convenient to associate it with the timeline semaphore value.

Let’s imagine a hypothetical dispatch record of the dispatch manager. It does not contain delays measured by the editors and no real video card trace. There is a staging buffer from which data is copied, and a record “return the section after use is complete.” The number 17 is stored nearby. This is not milliseconds, not the pixel number, and not the percentage of readiness. The program assigned a meaning to the value: the milestone reached means that a specific job capable of reading a given section has been completed in the desired synchronization region. Without this purpose, the number would simply be a counter.

In Khronos sample on timeline semaphore such an object is described as a means of linking the operation of queues and the host through an increasing value. Waiting does not consume the signal the way waiting on a regular binary semaphore does. Several consumers are able to wait for one milestone. But this convenient feature does not turn any signal into evidence of the entire operation of the device. First, the dispatcher must determine what actions precede the signal and why they cover the last access to the resource.

Let a submission copy the data from the staging buffer to another buffer that is used later. If staging is no longer needed after copying that is correctly covered by the signal, the corresponding milestone may allow its reuse. In this case, the destination data can still participate in later computation. Two objects have different lifetimes even when the user perceives them as one upload. Releasing a source does not require the completion of every future operation on its copy. It is enough to prove the end of operations that still access the source itself.

In a working note, it is useful to keep this distinction in words. “Data sent” is too vague: command descriptions have been submitted, the transfer has completed, the shader has ended, or the picture has appeared? “The staging section is no longer being read after milestone 17” names both the object and the basis of the decision. It is precisely this statement that can be checked when changing the work graph. If the developer later adds another read of the original section in another queue, the previous mark will no longer prove everything necessary, even if the number in the interface remains the same.

The next entry does not mean the next point in time

Timeline semaphore contains a 64-bit value that is incremented with valid signals. A wait has a threshold: it is satisfied by the achieved value not less than the required value. Therefore, the dispatcher can check whether the old milestones have been completed when the counter has already moved on. But the distance between the numbers does not measure the duration of the work. If after 17 the application chose 25, the difference of 8 does not report either the time or the number of commands actually executed. The scale was determined by the program, not the hardware stopwatch.

Signal and wait scopes are significant in the Vulkan synchronization specification. For vkQueueSubmit2, the steps specified by semaphore submit info are involved in determining which operations are covered. The hypothetical example here assumes that the last access to the returned region actually fell into the first synchronization scope of the corresponding signal. In a real engine, this statement needs to be checked using commands and stage masks. The familiar name semaphore alone will not correct a signal delivered before the access, the end of which it must certify.

Moving between queues adds the same responsibility on the other side. The consumer waits for the milestone, then accesses the transmitted data in the specified wait scope. With a correctly formed dependency, semaphore coordinates execution and the necessary memory effects. But an image with an incorrect layout does not acquire the correct layout simply because the counter has increased. Transfer of ownership between queue families, when required, also has separate rules. A synchronization object connects parts of a contract; it does not replace the description of the resources themselves.

For the host there is vkWaitSemaphores. The call can wait for one or more specified values to be reached, given the selected wait condition and timeout. Zero timeout allows you to check the status without waiting a long time. Returning VK_TIMEOUT means that the required condition has not yet been satisfied; it does not declare the device hung and does not release the resource. Success refers to the specified condition. If the wait was configured to accept any one of several semaphores, success cannot be read as completion of all of them.

A different log entry appears when vkGetSemaphoreCounterValue: the dispatcher asks for the current value without waiting for the selected future threshold. The snapshot may become out of date immediately after being returned. To complete the old correctly assigned milestone, monotonicity is useful: the value was already at least 17, therefore, a subsequent increase does not change this fact. But the query doesn’t say when the next milestone will be reached. The same observation operation provides stable evidence of the past and a weak basis for predicting the future.

A pale thread on blue branches toward two separate frames.
ITNWS AI-generated conceptual illustration. Multiple consumers can wait on one timeline; distances do not encode duration. — ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

There are now several areas awaiting release on the hypothetical ledger. One is associated with 17, another with 19, a third with 22. If the query returns 20 and the milestones form a correctly ordered story, the first two can be considered complete in their intended meaning. The third one is still waiting. This is not a permission to release all submission objects with a lower sequence number at all. Each should retain a connection to its last use. The frame number and signal number can be correlated in the same engine architecture, but are not the same concept according to the standard.

It is especially easy to make a mistake when a resource is read by several independent queues. The end of reading in one queue does not end the life of the resource. The dispatcher can wait for all the necessary milestones or build a final dependency, after which one signal actually covers all consumers. The implementation method is chosen according to the graph. If the union is not built, it cannot be completed in your head based on the largest number you see. Numerical comparison has meaning within the proven history of a particular semaphore, not between arbitrary objects with similar values.

For the same reason, increasing signals from different queues require an explicit order. To receive the number 22 before the work in progress, conventionally designated 19, and then treat the counter as a general completion sheet would be an incorrect design. Both compliance with Vulkan signal requirements and correct application interpretation are required. It is often easier to have a separate timeline for the sequential queue or a specially crafted dependency connection. The convenience of a common counter does not relieve the author from determining why the larger value includes the desired prior commitments.

The dispatcher must be able to finish recording

Timeline semaphores allow a wait to be submitted before the corresponding signal is submitted. This helps the task system prepare submissions in a less rigid order. However, being able to describe a future dependency does not prove that someone will actually submit work that will satisfy it. If the host blocks waiting for a milestone whose signal was supposed to be submitted by that same blocked path, the result would be no progress. The counter does not create a producer. In the work record, there must be a reachable signal source next to the wait that takes into account the queue order and dependencies of the remaining tasks.

Returning to staging, stopping the application becomes a test of the entire design. The last submissions must either reach their milestones or receive the intended error handling. Removing the buffer upon the termination of the preparation of new frames does not prove the end of the old ones. Waiting indefinitely is also not a necessary consequence of accuracy: the API gives timeouts and errors, and the application must define a termination policy. The device lost state requires separate processing; normal completion signal and device loss cannot be lumped together under the same "done" mark.

There is also memory availability to the host itself. If the GPU was writing data that the CPU is going to read, completion and host-visible memory rules must be consistent. Non-coherent memory may require appropriate invalidate operations; to transfer the content recorded by the host to the device – flush under the provided conditions. What we’re looking at here is the lifespan of a section, not the promise that any CPU pointer will automatically see any new bytes after any polling. Visibility and completion are bound by API rules, and not by one convenient everyday formulation.

The counter also has limits on acceptable value differences, described by device properties, including maxTimelineSemaphoreValueDifference. The representation of uint64_t does not mean that the application is allowed to set arbitrarily far future thresholds without restrictions. For a long process life, a managed value and object policy is needed. This is not a reason to consider overflow a typical cause of frame delay. This is a reminder that the software scale must comply with published requirements, even if a large bit depth makes the boundary psychologically invisible.

Binary semaphore retains its place, in particular in the usual ways of interacting with swapchain. Timeline cannot be mechanically substituted into every API parameter with a similar name. Image acquisition and presentation have their own requirements. The mixed system is quite natural: one part of the graph controls the life of internal buffers across boundaries, the other uses objects valid for WSI. A good working notation explains the transition rather than declaring one type to be a universal replacement for all others.

The question of how the ledger itself is stored is also relevant. If multiple host threads add resources to the deferred release queue, its own structures require normal multi-threaded coherence. GPU semaphore does not automatically protect the list of pointers in application memory. The reached milestone allows a specific action on the resource, but does not serialize two attempts to delete the same record at the same time. It is useful to store the identity of the version, the assigned milestone, and the sole owner of the release operation. Then memory reuse and ledger-entry reuse do not start to live by different rules. This is especially important when canceling tasks that have not yet been sent: they may not receive the signal that the previously created entry was expecting.

Sources verified November 4, 2026. The article describes the existing Vulkan model, not a new driver or measured graphics card acceleration. Enabling features requires device support and correct object creation; The date the document was read does not confirm the settings of an arbitrary computer. Conceptual images show the relationships of the works. Their lines are not a graph of actual performance, and the distances between the marks do not represent nanoseconds.

You can now return to the original buffer without guessing from the moving window. The dispatcher has a specific version of the resource, a list of its consumers and the achieved milestone covering the last use. If these connections are preserved, returning the region becomes a consequence of completed obligations. GPU did not say that “everything is ready”; the program received exactly the evidence to which it had previously assigned a verifiable meaning. New bytes can be written because no one needs the old ones anymore according to the rules of the work constructed.

Sources & documentation

  1. Vulkan specification: Synchronization and Cache Control ↗
  2. Khronos Vulkan sample: Timeline semaphore ↗
  3. Vulkan reference: vkWaitSemaphores ↗
  4. Vulkan reference: vkGetSemaphoreCounterValue ↗