# vkCmdCopyBuffer(3) Manual Page

## Name

vkCmdCopyBuffer - Copy data between buffer regions

## C Specification

To copy data between buffer objects, call:

    void vkCmdCopyBuffer(
        VkCommandBuffer                             commandBuffer,
        VkBuffer                                    srcBuffer,
        VkBuffer                                    dstBuffer,
        uint32_t                                    regionCount,
        const VkBufferCopy*                         pRegions);

## Parameters

- `commandBuffer` is the command buffer into which the command will be recorded.

- `srcBuffer` is the source buffer.

- `dstBuffer` is the destination buffer.

- `regionCount` is the number of regions to copy.

- `pRegions` is a pointer to an array of VkBufferCopy structures specifying the regions to copy.

## Description

Each region in `pRegions` is copied from the source buffer to the same region of the destination buffer. `srcBuffer` and `dstBuffer` can be the same buffer or alias the same memory, but the resulting values are undefined if the copy regions overlap in memory.

Valid Usage

- The `srcOffset` member of each element of `pRegions` must be less than the size of `srcBuffer`

- The `dstOffset` member of each element of `pRegions` must be less than the size of `dstBuffer`

- The `size` member of each element of `pRegions` must be less than or equal to the size of `srcBuffer` minus `srcOffset`

- The `size` member of each element of `pRegions` must be less than or equal to the size of `dstBuffer` minus `dstOffset`

- The union of the source regions, and the union of the destination regions, specified by the elements of `pRegions`, must not overlap in memory

- `srcBuffer` must have been created with `VK_BUFFER_USAGE_TRANSFER_SRC_BIT` usage flag

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

- `dstBuffer` must have been created with `VK_BUFFER_USAGE_TRANSFER_DST_BIT` usage flag

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

- If `commandBuffer` is an unprotected command buffer, then `srcBuffer` must not be a protected buffer

- If `commandBuffer` is an unprotected command buffer, then `dstBuffer` must not be a protected buffer

- If `commandBuffer` is a protected command buffer, then `dstBuffer` must not be an unprotected buffer

Valid Usage (Implicit)

- `commandBuffer` must be a valid VkCommandBuffer handle

- `srcBuffer` must be a valid VkBuffer handle

- `dstBuffer` must be a valid VkBuffer handle

- `pRegions` must be a valid pointer to an array of `regionCount` valid VkBufferCopy structures

- `commandBuffer` must be in the recording state

- The `VkCommandPool` that `commandBuffer` was allocated from must support transfer, graphics, or compute operations

- This command must only be called outside of a render pass instance

- `regionCount` must be greater than `0`

- Each of `commandBuffer`, `dstBuffer`, and `srcBuffer` must have been created, allocated, or retrieved from the same VkDevice

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 | Pipeline Type
--- | --- | --- | ---
Primary Secondary | Outside | Transfer Graphics Compute | Transfer

## See Also

VkBuffer, VkBufferCopy, VkCommandBuffer

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