KhronosGroup / KhronosGroup/Vulkan-Samples
Timestamp sample pipelineStage correctness
- Dominant language
- C++
- Stars
- 5.4k
- Forks
- 835
- Avg merge
- 2h 16m
- Merged PRs (30d)
- 1
Description
I'm inspecting the `vkCmdWriteTimestamp` example and I want to verify whether I'm either misunderstanding something or whether it's something about the sample.
The text (and code) say the following:
> To measure GPU times for the draw calls(s) we first tell the GPU to write a timestamp at the VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT pipeline stage. This is not a real pipeline stage (as in e.g. the vertex or fragment stages) but a special constant that tells the GPU to write the timestamp when all previous commands have been processed by the GPU’s command processor. This ensures that we get a timestamp right before starting on the draw calls we want to measure, which will be the base for calculating our delta time.
>
> The second timestamp is written at the VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT pipeline stage. Once again this is not a real pipeline stage, but it again tells the GPU to write the timestamp after all work has been finished.
But it seems a bit weird to use VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT here before we do the first `vkCmdWriteTimestamp` call, since as the spec states:
> The first [synchronization scope](https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-dependencies-scopes) includes all commands that occur earlier in [submission order](https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-submission-order). The synchronization scope is limited to operations on the pipeline stage specified by pipelineStage.
Waiting on VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT would mean that we are waiting before the _start_ of the previous command, would it not? My expectation would be that this should match the bottom write call, i.e. `VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT`, so that we wait until after the previous command has been executed.
Note: This suggestion seems to be the same as https://github.com/KhronosGroup/Vulkan-Samples/pull/519#discussion_r971200305, but the sample ended up with using TOP instead so wondering why that decision was made :)
Contributor guide
Assessment
This issue has not been assessed yet.