Skip to content

Timestamp sample pipelineStage correctness #1370

@Athosvk

Description

@Athosvk

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 includes all commands that occur earlier in 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 #519 (comment), but the sample ended up with using TOP instead so wondering why that decision was made :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions