# VkBufferMemoryBarrier(3) Manual Page

## Name

VkBufferMemoryBarrier - Structure specifying a buffer memory barrier

## C Specification

The `VkBufferMemoryBarrier` structure is defined as:

    typedef struct VkBufferMemoryBarrier {
        VkStructureType    sType;
        const void*        pNext;
        VkAccessFlags      srcAccessMask;
        VkAccessFlags      dstAccessMask;
        uint32_t           srcQueueFamilyIndex;
        uint32_t           dstQueueFamilyIndex;
        VkBuffer           buffer;
        VkDeviceSize       offset;
        VkDeviceSize       size;
    } VkBufferMemoryBarrier;

## Members

- `sType` is the type of this structure.

- `pNext` is `NULL` or a pointer to an extension-specific structure.

- `srcAccessMask` is a bitmask of VkAccessFlagBits specifying a source access mask.

- `dstAccessMask` is a bitmask of VkAccessFlagBits specifying a destination access mask.

- `srcQueueFamilyIndex` is the source queue family for a queue family ownership transfer.

- `dstQueueFamilyIndex` is the destination queue family for a queue family ownership transfer.

- `buffer` is a handle to the buffer whose backing memory is affected by the barrier.

- `offset` is an offset in bytes into the backing memory for `buffer`; this is relative to the base offset as bound to the buffer (see vkBindBufferMemory).

- `size` is a size in bytes of the affected area of backing memory for `buffer`, or `VK_WHOLE_SIZE` to use the range from `offset` to the end of the buffer.

## Description

The first access scope is limited to access to memory through the specified buffer range, via access types in the source access mask specified by `srcAccessMask`. If `srcAccessMask` includes `VK_ACCESS_HOST_WRITE_BIT`, memory writes performed by that access type are also made visible, as that access type is not performed through a resource.

The second access scope is limited to access to memory through the specified buffer range, via access types in the destination access mask. specified by `dstAccessMask`. If `dstAccessMask` includes `VK_ACCESS_HOST_WRITE_BIT` or `VK_ACCESS_HOST_READ_BIT`, available memory writes are also made visible to accesses of those types, as those access types are not performed through a resource.

If `srcQueueFamilyIndex` is not equal to `dstQueueFamilyIndex`, and `srcQueueFamilyIndex` is equal to the current queue family, then the memory barrier defines a queue family release operation for the specified buffer range, and the second access scope includes no access, as if `dstAccessMask` was `0`.

If `dstQueueFamilyIndex` is not equal to `srcQueueFamilyIndex`, and `dstQueueFamilyIndex` is equal to the current queue family, then the memory barrier defines a queue family acquire operation for the specified buffer range, and the first access scope includes no access, as if `srcAccessMask` was `0`.

Valid Usage

- `offset` must be less than the size of `buffer`

- If `size` is not equal to `VK_WHOLE_SIZE`, `size` must be greater than `0`

- If `size` is not equal to `VK_WHOLE_SIZE`, `size` must be less than or equal to than the size of `buffer` minus `offset`

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_CONCURRENT`, at least one of `srcQueueFamilyIndex` and `dstQueueFamilyIndex` must be `VK_QUEUE_FAMILY_IGNORED`

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_CONCURRENT`, and one of `srcQueueFamilyIndex` and `dstQueueFamilyIndex` is `VK_QUEUE_FAMILY_IGNORED`, the other must be `VK_QUEUE_FAMILY_IGNORED` or a special queue family reserved for external memory ownership transfers, as described in https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-queue-transfers.

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_EXCLUSIVE` and `srcQueueFamilyIndex` is `VK_QUEUE_FAMILY_IGNORED`, `dstQueueFamilyIndex` must also be `VK_QUEUE_FAMILY_IGNORED`

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_EXCLUSIVE` and `srcQueueFamilyIndex` is not `VK_QUEUE_FAMILY_IGNORED`, it must be a valid queue family or a special queue family reserved for external memory transfers, as described in https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-queue-transfers.

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_EXCLUSIVE` and `dstQueueFamilyIndex` is not `VK_QUEUE_FAMILY_IGNORED`, it must be a valid queue family or a special queue family reserved for external memory transfers, as described in https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-queue-transfers.

- If `buffer` was created with a sharing mode of `VK_SHARING_MODE_EXCLUSIVE`, and `srcQueueFamilyIndex` and `dstQueueFamilyIndex` are not `VK_QUEUE_FAMILY_IGNORED`, at least one of them must be the same as the family of the queue that will execute this barrier

- If `buffer` is non-sparse then it must be bound completely and contiguously to a single `VkDeviceMemory` object

Valid Usage (Implicit)

- `sType` must be `VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER`

- `pNext` must be `NULL`

- `buffer` must be a valid VkBuffer handle

## See Also

VkAccessFlags, VkBuffer, `VkDeviceSize`, VkStructureType, vkCmdPipelineBarrier, vkCmdWaitEvents

## 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

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.