To request a timestamp and write the value to memory, call:
// Provided by VK_VERSION_1_0
commandBufferis the command buffer into which the command will be recorded.
pipelineStageis a VkPipelineStageFlagBits value, specifying a stage of the pipeline.
queryPoolis the query pool that will manage the timestamp.
queryis the query within the query pool that will contain the timestamp.
vkCmdWriteTimestamp is submitted to a queue, it defines an
execution dependency on commands that were submitted before it, and writes a
timestamp to a query pool.
The second synchronization scope includes only the timestamp write operation.
Implementations may write the timestamp at any stage that is
logically later than
Any timestamp write that happens-after another timestamp write in the same submission must not
have a lower value unless its value overflows the maximum supported integer
bit width of the query.
VK_EXT_calibrated_timestamps is enabled, this extends to
timestamp writes across all submissions on the same logical device: any
timestamp write that happens-after another must not have a lower value unless its value
overflows the maximum supported integer bit width of the query.
Timestamps written by this command must be in the
VK_TIME_DOMAIN_DEVICE_EXT time domain.
If an overflow occurs, the timestamp value must wrap back to zero.
Comparisons between timestamps should be done between timestamps where they
are guaranteed to not decrease.
For example, subtracting an older timestamp from a newer one to determine
the execution time of a sequence of commands is only a reliable measurement
if the two timestamp writes were performed in the same
submission, or if the writes were performed on the same logical device and
vkCmdWriteTimestamp is called while executing a render pass
instance that has multiview enabled, the timestamp uses N consecutive
query indices in the query pool (starting at
query) where N is
the number of bits set in the view mask of the subpass the command is
The resulting query values are determined by an implementation-dependent
choice of one of the following behaviors:
The first query is a timestamp value and (if more than one bit is set in the view mask) zero is written to the remaining queries. If two timestamps are written in the same subpass, the sum of the execution time of all views between those commands is the difference between the first query written by each command.
All N queries are timestamp values. If two timestamps are written in the same subpass, the sum of the execution time of all views between those commands is the sum of the difference between corresponding queries written by each command. The difference between corresponding queries may be the execution time of a single view.
In either case, the application can sum the differences between all N queries to determine the total execution time.
For more information, see the Vulkan Specification
This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.