Using vkCmdWriteTimestamp to measure the execution time of a command buffer

I am trying to measure the execution time of a command buffer using vkCmdWriteTimestamp.

For this, I am using:

vkCmdWriteTimestamp(this->drawCmdBuffers[currentBuffer], VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, this->timestampPool, currentBuffer * TIMESTAMP_MAX + TIMESTAMP_TOP);
vkCmdWriteTimestamp(this->drawCmdBuffers[currentBuffer], VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, this->timestampPool, currentBuffer * TIMESTAMP_MAX + TIMESTAMP_BOTTOM);

And I query the results when it’s available.

However, I am getting pretty much the same time whatever the load in the command buffer… I have the same result on AMD and NVIDIA so I expect I am not quite understanding how this feature is supposed to work.

When I use vkCmdWriteTimestamp between frames, I am getting something relevant to get a frame rate using either VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT or VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT.

Is it possible to measure the execution time of a command buffer?
Is there some good documentation somewhere?

I already read which led me to believe I could measure the execution time of the GPU for a command buffer but I am guessing I misunderstand something here…

I resolved my issue.

To get relevant results for a command buffer, I just need to use two vkCmdWriteTimestamp, one just after vkBeginCommandBuffer and one just before vkEndCommandBuffer and compute the difference.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.