vkCmdCopyBufferToImage(3)
C Specification
To copy data from a buffer object to an image object, call:
// Provided by VK_VERSION_1_0void vkCmdCopyBufferToImage( VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions);Parameters
commandBufferis the command buffer into which the command will berecorded.srcBufferis the source buffer.dstImageis the destination image.dstImageLayoutis the layout of the destination image subresourcesfor the copy.regionCountis the number of regions to copy.pRegionsis a pointer to an array ofVkBufferImageCopystructures specifying the regions to copy.
Description
Each source region specified bypRegions is copied from the sourcebuffer to the destination region of the destination image according to theaddressing calculations for eachresource.If any of the specified regions insrcBuffer overlaps in memory withany of the specified regions indstImage, values read from thoseoverlapping regions areundefined.If any region accesses a depth aspect indstImageand theVK_EXT_depth_range_unrestricted extension is not enabled,values copied fromsrcBuffer outside of the range[0,1] will bewritten asundefined values to the destination image.
Copy regions for the imagemust be aligned to a multiple of the texel blockextent in each dimension, except at the edges of the image, where regionextentsmust match the edge of the image.
VUID-vkCmdCopyBufferToImage-dstImage-07966
IfdstImageis non-sparse then the imageor each specifieddisjoint planemust be bound completely and contiguously to a singleVkDeviceMemoryobjectVUID-vkCmdCopyBufferToImage-imageSubresource-07967
TheimageSubresource.mipLevelmember of each element ofpRegionsmust be less than themipLevelsspecified inVkImageCreateInfo whendstImagewas createdVUID-vkCmdCopyBufferToImage-imageSubresource-07968
IfimageSubresource.layerCountis notVK_REMAINING_ARRAY_LAYERS,imageSubresource.baseArrayLayer+imageSubresource.layerCountof each element ofpRegionsmust be less than or equal to thearrayLayersspecified inVkImageCreateInfo whendstImagewas createdVUID-vkCmdCopyBufferToImage-dstImage-07969
dstImagemust not have been created withflagscontainingVK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT
VUID-vkCmdCopyBufferToImage-imageSubresource-07971
For each element ofpRegions,imageOffset.xand(imageExtent.width+imageOffset.x)mustboth be greater than or equal to0and less than or equal to the widthof the specifiedimageSubresourceofdstImageVUID-vkCmdCopyBufferToImage-imageSubresource-07972
For each element ofpRegions,imageOffset.yand(imageExtent.height+imageOffset.y)mustboth be greater than or equal to0and less than or equal to theheight of the specifiedimageSubresourceofdstImage
VUID-vkCmdCopyBufferToImage-dstImage-07973
dstImagemust have a sample count equal toVK_SAMPLE_COUNT_1_BIT
VUID-vkCmdCopyBufferToImage-commandBuffer-01828
IfcommandBufferis an unprotected command buffer andprotectedNoFaultis not supported,srcBuffermust not be a protected bufferVUID-vkCmdCopyBufferToImage-commandBuffer-01829
IfcommandBufferis an unprotected command buffer andprotectedNoFaultis not supported,dstImagemust not be a protected imageVUID-vkCmdCopyBufferToImage-commandBuffer-01830
IfcommandBufferis a protected command buffer andprotectedNoFaultis not supported,dstImagemust not be an unprotected imageVUID-vkCmdCopyBufferToImage-commandBuffer-07737
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT orVK_QUEUE_COMPUTE_BIT, thebufferOffsetmember of any element ofpRegionsmust be amultiple of4VUID-vkCmdCopyBufferToImage-imageOffset-07738
TheimageOffsetandimageExtentmembers of each element ofpRegionsmust respect the image transfer granularity requirementsofcommandBuffer’s command pool’s queue family, as described inVkQueueFamilyPropertiesVUID-vkCmdCopyBufferToImage-commandBuffer-07739
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT,and themaintenance10feature is notenabled,for each element ofpRegions, theaspectMaskmember ofimageSubresourcemust not beVK_IMAGE_ASPECT_DEPTH_BIT orVK_IMAGE_ASPECT_STENCIL_BITVUID-vkCmdCopyBufferToImage-commandBuffer-11778
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT but does supportVK_QUEUE_COMPUTE_BIT,and in any element ofpRegionstheaspectMaskmember ofimageSubresourceisVK_IMAGE_ASPECT_DEPTH_BIT, then theformat features ofdstImagemust containVK_FORMAT_FEATURE_2_DEPTH_COPY_ON_COMPUTE_QUEUE_BIT_KHRVUID-vkCmdCopyBufferToImage-commandBuffer-11779
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT andVK_QUEUE_COMPUTE_BIT, but doessupportVK_QUEUE_TRANSFER_BIT, and in any element ofpRegionstheaspectMaskmember ofimageSubresourceisVK_IMAGE_ASPECT_DEPTH_BIT, then theformat features ofdstImagemust containVK_FORMAT_FEATURE_2_DEPTH_COPY_ON_TRANSFER_QUEUE_BIT_KHRVUID-vkCmdCopyBufferToImage-commandBuffer-11780
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT but does supportVK_QUEUE_COMPUTE_BIT,and in any element ofpRegionstheaspectMaskmember ofimageSubresourceisVK_IMAGE_ASPECT_STENCIL_BIT, then theformat features ofdstImagemust containVK_FORMAT_FEATURE_2_STENCIL_COPY_ON_COMPUTE_QUEUE_BIT_KHRVUID-vkCmdCopyBufferToImage-commandBuffer-11781
If the queue family used to create theVkCommandPool whichcommandBufferwas allocated from does not supportVK_QUEUE_GRAPHICS_BIT andVK_QUEUE_COMPUTE_BIT, but doessupportVK_QUEUE_TRANSFER_BIT, and in any element ofpRegionstheaspectMaskmember ofimageSubresourceisVK_IMAGE_ASPECT_STENCIL_BIT, then theformat features ofdstImagemust containVK_FORMAT_FEATURE_2_STENCIL_COPY_ON_TRANSFER_QUEUE_BIT_KHR
VUID-vkCmdCopyBufferToImage-pRegions-00171
srcBuffermust be large enough to contain all buffer locationsthat are accessed according toBuffer and Image Addressing, for each element ofpRegionsVUID-vkCmdCopyBufferToImage-pRegions-00173
The union of all source regions, and the union of all destinationregions, specified by the elements ofpRegions,must not overlapin memoryVUID-vkCmdCopyBufferToImage-srcBuffer-00174
srcBuffermust have been created with theVK_BUFFER_USAGE_TRANSFER_SRC_BIT usage flag setVUID-vkCmdCopyBufferToImage-dstImage-01997
Theformat features ofdstImagemust containVK_FORMAT_FEATURE_TRANSFER_DST_BITVUID-vkCmdCopyBufferToImage-srcBuffer-00176
IfsrcBufferis non-sparse then itmust be bound completely andcontiguously to a singleVkDeviceMemoryobjectVUID-vkCmdCopyBufferToImage-dstImage-00177
dstImagemust have been created with theVK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag setVUID-vkCmdCopyBufferToImage-dstImageLayout-00180
dstImageLayoutmust specify the layout of the image subresourcesofdstImagespecified inpRegionsat the time this commandis executed on aVkDeviceVUID-vkCmdCopyBufferToImage-dstImageLayout-01396
dstImageLayoutmust beVK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, orVK_IMAGE_LAYOUT_GENERALVUID-vkCmdCopyBufferToImage-pRegions-07931
IfVK_EXT_depth_range_unrestricted is not enabled, foreach element ofpRegionswhoseimageSubresourcecontains adepth aspect, the data insrcBuffermust be in the range[0,1]
VUID-vkCmdCopyBufferToImage-dstImage-07979
IfdstImageis of typeVK_IMAGE_TYPE_1D, then for eachelement ofpRegions,imageOffset.ymust be0andimageExtent.heightmust be1VUID-vkCmdCopyBufferToImage-imageOffset-09104
For each element ofpRegions,imageOffset.zand(imageExtent.depth+imageOffset.z)mustboth be greater than or equal to0and less than or equal to the depthof the specifiedimageSubresourceofdstImageVUID-vkCmdCopyBufferToImage-dstImage-07980
IfdstImageis of typeVK_IMAGE_TYPE_1D orVK_IMAGE_TYPE_2D, then for each element ofpRegions,imageOffset.zmust be0andimageExtent.depthmustbe1VUID-vkCmdCopyBufferToImage-dstImage-07274
For each element ofpRegions,ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR orVK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR,imageOffset.xmust be a multiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10051
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR orVK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, andimageOffset.xdoes not equal the width of the subresource specified byimageSubresource,imageOffset.xmust be a multiple ofthetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-dstImage-07275
For each element ofpRegions,ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR orVK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR,imageOffset.ymust be a multiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10052
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR orVK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, andimageOffset.ydoes not equal the height of the subresource specified byimageSubresource,imageOffset.ymust be a multiple ofthetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-dstImage-07276
For each element ofpRegions,imageOffset.zmust be amultiple of thetexel block extent depth of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-dstImage-00207
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,the sum ofimageOffset.xandextent.widthdoes not equalthe width of the subresource specified byimageSubresource,extent.widthmust be a multiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10053
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, the difference ofimageOffset.xandextent.heightmust be a multiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10054
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, the difference ofimageOffset.xandextent.widthmust be a multiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10055
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, the sum ofimageOffset.xandextent.heightdoes not equal the widthof the subresource specified byimageSubresource,extent.heightmust be a multiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-dstImage-00208
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, andthe sum ofimageOffset.yandextent.heightdoes not equalthe height of the subresource specified byimageSubresource,extent.heightmust be a multiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10056
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR, the sum ofimageOffset.yandextent.widthdoes not equal the heightof the subresource specified byimageSubresource,extent.widthmust be a multiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10057
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR, the difference ofimageOffset.yandextent.heightmust be a multiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageOffset-10058
For each element ofpRegions, ifVkCopyCommandTransformInfoQCOM::transformis equal toVK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR, the difference ofimageOffset.yandextent.widthmust be a multiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-dstImage-00209
For each element ofpRegions, if the sum ofimageOffset.zandextent.depthdoes not equal the depth of the subresourcespecified bysrcSubresource,extent.depthmust be amultiple of thetexel block extent depth of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-imageSubresource-09105
For each element ofpRegions,imageSubresource.aspectMaskmust specify aspects present indstImageVUID-vkCmdCopyBufferToImage-dstImage-07981
IfdstImagehas amulti-planar format, then for each element ofpRegions,imageSubresource.aspectMaskmust be a single validmulti-planar aspect mask bitVUID-vkCmdCopyBufferToImage-dstImage-07983
IfdstImageis of typeVK_IMAGE_TYPE_3D, for eachelement ofpRegions,imageSubresource.baseArrayLayermustbe0andimageSubresource.layerCountmust be1
VUID-vkCmdCopyBufferToImage-bufferRowLength-09106
For each element ofpRegions,bufferRowLengthmust be amultiple of thetexel block extent width of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-bufferImageHeight-09107
For each element ofpRegions,bufferImageHeightmust be amultiple of thetexel block extent height of theVkFormat ofdstImageVUID-vkCmdCopyBufferToImage-bufferRowLength-09108
For each element ofpRegions,bufferRowLengthdivided bythetexel block extent width and thenmultiplied by the texel block size ofdstImagemust be lessthan or equal to231-1
VUID-vkCmdCopyBufferToImage-dstImage-07975
IfdstImagedoes not have either a depth/stencil formator amulti-planar format,then for each element ofpRegions,bufferOffsetmust be amultiple of thetexel block sizeVUID-vkCmdCopyBufferToImage-dstImage-07976
IfdstImagehas amulti-planar format, then for each element ofpRegions,bufferOffsetmust be a multiple of the element size of the compatible format for theformat and theaspectMaskof theimageSubresourceas definedinCompatible Formats of Planes of Multi-Planar FormatsVUID-vkCmdCopyBufferToImage-dstImage-07978
IfdstImagehas a depth/stencil format, thebufferOffsetmember of any element ofpRegionsmust be a multiple of4
VUID-vkCmdCopyBufferToImage-commandBuffer-parameter
commandBuffermust be a validVkCommandBuffer handleVUID-vkCmdCopyBufferToImage-srcBuffer-parameter
srcBuffermust be a validVkBuffer handleVUID-vkCmdCopyBufferToImage-dstImage-parameter
dstImagemust be a validVkImage handleVUID-vkCmdCopyBufferToImage-dstImageLayout-parameter
dstImageLayoutmust be a validVkImageLayout valueVUID-vkCmdCopyBufferToImage-pRegions-parameter
pRegionsmust be a valid pointer to an array ofregionCountvalidVkBufferImageCopy structuresVUID-vkCmdCopyBufferToImage-commandBuffer-recording
commandBuffermust be in therecording stateVUID-vkCmdCopyBufferToImage-commandBuffer-cmdpool
TheVkCommandPoolthatcommandBufferwas allocated frommust supportVK_QUEUE_COMPUTE_BIT,VK_QUEUE_GRAPHICS_BIT, orVK_QUEUE_TRANSFER_BIT operationsVUID-vkCmdCopyBufferToImage-renderpass
This commandmust only be called outside of a render pass instanceVUID-vkCmdCopyBufferToImage-suspended
This commandmust not be called between suspended render pass instancesVUID-vkCmdCopyBufferToImage-videocoding
This commandmust only be called outside of a video coding scopeVUID-vkCmdCopyBufferToImage-regionCount-arraylength
regionCountmust be greater than0VUID-vkCmdCopyBufferToImage-commonparent
Each ofcommandBuffer,dstImage, andsrcBuffermust have been created, allocated, or retrieved from the sameVkDevice
Host access to
commandBuffermust be externally synchronizedHost access to the
VkCommandPoolthatcommandBufferwas allocated frommust be externally synchronized
| Command Buffer Levels | Render Pass Scope | Video Coding Scope | Supported Queue Types | Command Type |
|---|---|---|---|---|
Primary | Outside | Outside | VK_QUEUE_COMPUTE_BIT | Action |
vkCmdCopyBufferToImage is not affected byconditional rendering
Document Notes
For more information, see theVulkan Specification.
This page is extracted from the Vulkan Specification.Fixes and changes should be made to the Specification, not directly.