C Specification

To record a pipeline barrier, call:

// Provided by VK_KHR_synchronization2
void vkCmdPipelineBarrier2KHR(
    VkCommandBuffer                             commandBuffer,
    const VkDependencyInfoKHR*                  pDependencyInfo);

Parameters

  • commandBuffer is the command buffer into which the command is recorded.

  • pDependencyInfo is a pointer to a VkDependencyInfoKHR structure defining the scopes of this operation.

Description

When vkCmdPipelineBarrier2KHR is submitted to a queue, it defines memory dependencies between commands that were submitted before it, and those submitted 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 vkCmdPipelineBarrier2KHR is recorded within a render pass instance, the synchronization scopes are limited to operations within the same subpass.

Valid Usage
  • VUID-vkCmdPipelineBarrier2KHR-pDependencies-02285
    If vkCmdPipelineBarrier2KHR is called within a render pass instance, the render pass must have been created with at least one VkSubpassDependency instance in VkRenderPassCreateInfo::pDependencies that expresses a dependency from the current subpass to itself, with synchronization scopes and access scopes that are all supersets of the scopes defined in this command

  • VUID-vkCmdPipelineBarrier2KHR-bufferMemoryBarrierCount-01178
    If vkCmdPipelineBarrier2KHR is called within a render pass instance, it must not include any buffer memory barriers

  • VUID-vkCmdPipelineBarrier2KHR-image-04073
    If vkCmdPipelineBarrier2KHR is called within a render pass instance, 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 or depth/stencil attachment

  • VUID-vkCmdPipelineBarrier2KHR-oldLayout-01181
    If vkCmdPipelineBarrier2KHR 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-vkCmdPipelineBarrier2KHR-srcQueueFamilyIndex-01182
    If vkCmdPipelineBarrier2KHR is called within a render pass instance, the srcQueueFamilyIndex and dstQueueFamilyIndex members of any image memory barrier included in this command must be equal

  • VUID-vkCmdPipelineBarrier2KHR-dependencyFlags-01186
    If vkCmdPipelineBarrier2KHR is called outside of a render pass instance, VK_DEPENDENCY_VIEW_LOCAL_BIT must not be included in the dependency flags

  • VUID-vkCmdPipelineBarrier2KHR-synchronization2-03848
    The synchronization2 feature must be enabled

  • VUID-vkCmdPipelineBarrier2KHR-srcStageMask-03849
    The srcStageMask member of any element of the pMemoryBarriers, 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-vkCmdPipelineBarrier2KHR-dstStageMask-03850
    The dstStageMask member of any element of the pMemoryBarriers, 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-vkCmdPipelineBarrier2KHR-commandBuffer-parameter
    commandBuffer must be a valid VkCommandBuffer handle

  • VUID-vkCmdPipelineBarrier2KHR-pDependencyInfo-parameter
    pDependencyInfo must be a valid pointer to a valid VkDependencyInfoKHR structure

  • VUID-vkCmdPipelineBarrier2KHR-commandBuffer-recording
    commandBuffer must be in the recording state

  • VUID-vkCmdPipelineBarrier2KHR-commandBuffer-cmdpool
    The VkCommandPool that commandBuffer was allocated from must support transfer, graphics, or compute 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

Command Properties
Command Buffer Levels Render Pass Scope Supported Queue Types

Primary
Secondary

Both

Transfer
Graphics
Compute

See Also

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2021 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0