KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.76k stars 419 forks source link

Enforce barrier when sampling timestamps #2236

Closed PENGUINLIONG closed 4 months ago

PENGUINLIONG commented 4 months ago

Some context: https://github.com/KhronosGroup/MoltenVK/issues/2235.

CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.

SRSaunders commented 4 months ago

Will there be a performance hit by doing this? If so, then perhaps it needs to be an optional parm.

PENGUINLIONG commented 4 months ago

@SRSaunders Is there anything I could refer to?

billhollings commented 4 months ago

Will there be a performance hit by doing this? If so, then perhaps it needs to be an optional parm.

This is a good point, and probably the reason we originally set barrier to NO.

Apple's doc does indicate that it may affect GPU performance, as one would expect from any barrier.

However, the Vulkan spec explicitly states:

When 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.

which would indicate that a barrier is required and expected here, and that timestamp scope accuracy is more important than absolute performance.