Function Prototype

vkCmdPipelineBarrier2

Insert a memory dependency

To record a pipeline barrier, call:

void vkCmdPipelineBarrier2KHR(
    VkCommandBuffer                   commandBuffer,
    const VkDependencyInfo*                             pDependencyInfo);
  • commandBuffer is the command buffer into which the command is recorded.
  • pDependencyInfo is a pointer to a VkDependencyInfo structure defining the scopes of this operation.

When vkCmdPipelineBarrier2 is submitted to a queue, it defines memory dependencies between commands that were submitted to the same queue before it, and those submitted to the same queue after it.

The first synchronization scope and access scope of each memory dependency defined by pDependencyInfo are applied to operations that occurred earlier in submission order.

The second synchronization scope and access scope of each memory dependency defined by pDependencyInfo are applied to operations that occurred later in submission order.

If vkCmdPipelineBarrier2 is recorded within a render pass instance, the synchronization scopes are limited to a subset of operations within the same subpass or render pass instance.

Valid Usage

VUID-vkCmdPipelineBarrier2-None-07889

If vkCmdPipelineBarrier2 is called within a render pass instance using a VkRenderPass object, the render pass must have been created with at least one subpass dependency that expresses a dependency from the current subpass to itself, does not include VK_DEPENDENCY_BY_REGION_BIT if this command does not, does not include VK_DEPENDENCY_VIEW_LOCAL_BIT if this command does not, and has synchronization scopes and access scopes that are all supersets of the scopes defined in this command

VUID-vkCmdPipelineBarrier2-bufferMemoryBarrierCount-01178

If vkCmdPipelineBarrier2 is called within a render pass instance using a VkRenderPass object, it must not include any buffer memory barriers

VUID-vkCmdPipelineBarrier2-image-04073

If vkCmdPipelineBarrier2 is called within a render pass instance using a VkRenderPass object, the image member of any image memory barrier included in this command must be an attachment used in the current subpass both as an input attachment, and as either a color, color resolve, or depth/stencil attachment

VUID-vkCmdPipelineBarrier2-image-09373

If vkCmdPipelineBarrier2 is called within a render pass instance using a VkRenderPass object, and the image member of any image memory barrier is a color resolve attachment, the corresponding color attachment must be VK_ATTACHMENT_UNUSED

VUID-vkCmdPipelineBarrier2-image-09374

If vkCmdPipelineBarrier2 is called within a render pass instance using a VkRenderPass object, and the image member of any image memory barrier is a color resolve attachment, it must have been created with a non-zero VkExternalFormatANDROID::externalFormat value

VUID-vkCmdPipelineBarrier2-oldLayout-01181

If vkCmdPipelineBarrier2 is called within a render pass instance, the oldLayout and newLayout members of any image memory barrier included in this command must be equal

VUID-vkCmdPipelineBarrier2-srcQueueFamilyIndex-01182

If vkCmdPipelineBarrier2 is called within a render pass instance, the srcQueueFamilyIndex and dstQueueFamilyIndex members of any memory barrier included in this command must be equal

VUID-vkCmdPipelineBarrier2-None-07890

If vkCmdPipelineBarrier2 is called within a render pass instance, and the source stage masks of any memory barriers include framebuffer-space stages, destination stage masks of all memory barriers must only include framebuffer-space stages

VUID-vkCmdPipelineBarrier2-dependencyFlags-07891

If vkCmdPipelineBarrier2 is called within a render pass instance, and the source stage masks of any memory barriers include framebuffer-space stages, then dependencyFlags must include VK_DEPENDENCY_BY_REGION_BIT

VUID-vkCmdPipelineBarrier2-None-07892

If vkCmdPipelineBarrier2 is called within a render pass instance, the source and destination stage masks of any memory barriers must only include graphics pipeline stages

VUID-vkCmdPipelineBarrier2-dependencyFlags-01186

If vkCmdPipelineBarrier2 is called outside of a render pass instance, the dependency flags must not include VK_DEPENDENCY_VIEW_LOCAL_BIT

VUID-vkCmdPipelineBarrier2-None-07893

If vkCmdPipelineBarrier2 is called inside a render pass instance, and there is more than one view in the current subpass, dependency flags must include VK_DEPENDENCY_VIEW_LOCAL_BIT

VUID-vkCmdPipelineBarrier2-None-09553

If
none of the [`shaderTileImageColorReadAccess`](xref::features-shaderTileImageColorReadAccess),
[`shaderTileImageStencilReadAccess`](xref::features-shaderTileImageStencilReadAccess), or
[`shaderTileImageDepthReadAccess`](xref::features-shaderTileImageDepthReadAccess) features are enabled,

and the dynamicRenderingLocalRead feature is not enabled, vkCmdPipelineBarrier2 must not be called within a render pass instance started with vkCmdBeginRendering

VUID-vkCmdPipelineBarrier2-None-09554

If the dynamicRenderingLocalRead feature is not enabled, and vkCmdPipelineBarrier2 is called within a render pass instance started with vkCmdBeginRendering, there must be no buffer or image memory barriers specified by this command

VUID-vkCmdPipelineBarrier2-None-09586

If the dynamicRenderingLocalRead feature is not enabled, and vkCmdPipelineBarrier2 is called within a render pass instance started with vkCmdBeginRendering, memory barriers specified by this command must only include VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT, or VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT in their access masks

VUID-vkCmdPipelineBarrier2-image-09555

If vkCmdPipelineBarrier2 is called within a render pass instance started with vkCmdBeginRendering, and the image member of any image memory barrier is used as an attachment in the current render pass instance, it must be in the VK_IMAGE_LAYOUT_RENDERING_LOCAL_READ_KHR or VK_IMAGE_LAYOUT_GENERAL layout

VUID-vkCmdPipelineBarrier2-srcStageMask-09556

If vkCmdPipelineBarrier2 is called within a render pass instance started with vkCmdBeginRendering, this command must only specify framebuffer-space stages in srcStageMask and dstStageMask

VUID-vkCmdPipelineBarrier2-srcStageMask-09673

The srcStageMask member of any element of the pMemoryBarriers member of pDependencyInfo must only include pipeline stages valid for the queue family that was used to create the command pool that commandBuffer was allocated from

VUID-vkCmdPipelineBarrier2-dstStageMask-09674

The dstStageMask member of any element of the pMemoryBarriers member of pDependencyInfo must only include pipeline stages valid for the queue family that was used to create the command pool that commandBuffer was allocated from

VUID-vkCmdPipelineBarrier2-srcStageMask-09675

If a buffer or image memory barrier does not specify an acquire operation, the respective srcStageMask member of the element of the pBufferMemoryBarriers or pImageMemoryBarriers members of pDependencyInfo must only include pipeline stages valid for the queue family that was used to create the command pool that commandBuffer was allocated from

VUID-vkCmdPipelineBarrier2-dstStageMask-09676

If a buffer or image memory barrier does not specify an release operation, the respective dstStageMask member of the element of the pBufferMemoryBarriers or pImageMemoryBarriers members of pDependencyInfo must only include pipeline stages valid for the queue family that was used to create the command pool that commandBuffer was allocated from

Valid Usage (Implicit)

VUID-vkCmdPipelineBarrier2-pDependencyInfo-parameter

pDependencyInfo must be a valid pointer to a valid VkDependencyInfo structure

VUID-vkCmdPipelineBarrier2-commandBuffer-cmdpool

The VkCommandPool that commandBuffer was allocated from must support transfer, graphics, compute, decode, or encode operations

Host Synchronization

  • Host access to commandBuffer must be externally synchronized
  • Host access to the VkCommandPool that commandBuffer was allocated from must be externally synchronized ::