Let’s say I have two buffers. One is a vertex-buffer, one is a shared staging-buffer (i.e. not only used for copying to the vertex-buffer).
For doing a copy my first approach was to insert one pipeline-barrier before the copy-commands, and one after. But now I am thinking: It is probably not valid to coalesce the access- and stage-masks for the staging-buffer and the vertex-buffer together, since there might be access- and stage-masks in there which are such that the access does not happen in the stage. Am I correct that in this scenario I need two pipeline-barriers before the copy, and two after?
Like this (pseudo-code):
vkCmdPipelineBarrier sync_staging_before; vkCmdPipelineBarrier sync_vertex_before; vkCmdCopyBuffer copy; vkCmdPipelineBarrier sync_vertex_after; vkCmdPipelnineBarrier sync_staging_after;
Does this make sense?
edit: Taking a closer look at the spec, I see that for any member of AccessMask, the stageMask only has to include one or more members that support the given access. So it would be valid to coalesce it all into one pipeline-barrier. Which version would you prefer?