I want to use the query system to retrieve the execution time of the fragment shader.
I am creating a query pool with two timestamp queries and I am using vkCmdWriteTimestamp
.
device.cmd_draw_indexed(draw_command_buffer, 6, 1, 0, 0, 1);
device.cmd_write_timestamp(
draw_command_buffer,
vk::PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
query_pool,
0,
);
device.cmd_write_timestamp(
draw_command_buffer,
vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
query_pool,
1,
);
device.cmd_end_render_pass(draw_command_buffer);
Which pipeline stages do I need to specify to only track the time for the fragment shader?
vkCmdWriteTimestamp latches the value of the timer when all previous commands have completed executing as far as the specified pipeline stage, and writes the timestamp value to memory. When the timestamp value is written, the availability status of the query is set to available.
Does this include the specified pipeline stage? For example if I specify VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
, will it latch the timer before or after the fragment shader has finished?
When do I need to call vkCmdWriteTimestamp
? I have noticed that if both calls to vkCmdWriteTimestamp
are directly on top of each other, the resulting delta will be close to 0. Initially I thought it shouldn't matter when I call them because I specify the pipeline stage.