Copy Commands


An application can copy buffer and image data using several methods depending on the type of data transfer. Data can be copied between buffer objects with vkCmdCopyBuffer2 and vkCmdCopyBuffer and a portion of an image can be copied to another image with vkCmdCopyImage2 and vkCmdCopyImage. Image data can also be copied to and from buffer memory using vkCmdCopyImageToBuffer2, vkCmdCopyImageToBuffer, vkCmdCopyBufferToImage2, and vkCmdCopyBufferToImage. Image data can be blitted (with or without scaling and filtering) with vkCmdBlitImage2 and vkCmdBlitImage. Multisampled images can be resolved to a non-multisampled image with vkCmdResolveImage2 and vkCmdResolveImage.

Copy commands must be recorded outside of a render pass instance.

The set of all bytes bound to all the source regions must not overlap the set of all bytes bound to the destination regions.

The set of all bytes bound to each destination region must not overlap the set of all bytes bound to another destination region.

Copy regions must be non-empty.

All copy commands are treated as “transfer” operations for the purposes of synchronization barriers.

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

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.

void FVulkanCommandListContext::RHICopyToStagingBuffer(FRHIVertexBuffer* SourceBufferRHI, FRHIStagingBuffer* StagingBufferRHI, uint32 Offset, uint32 NumBytes)

void* FVulkanResourceMultiBuffer::Lock(bool bFromRenderingThread, EResourceLockMode LockMode, uint32 Size, uint32 Offset)

inline void FVulkanResourceMultiBuffer::InternalUnlock(FVulkanCommandListContext& Context, VulkanRHI::FPendingBufferLock& PendingLock, FVulkanResourceMultiBuffer* MultiBuffer, int32 InDynamicBufferIndex)

void FVulkanCommandListContext::RHICopyBufferRegion(FRHIVertexBuffer* DstBuffer, uint64 DstOffset, FRHIVertexBuffer* SrcBuffer, uint64 SrcOffset, uint64 NumBytes)

inline void FVulkanDynamicRHI::UpdateUniformBuffer(FVulkanUniformBuffer* UniformBuffer, const void* Contents)

void vkCmdCopyBuffer2( VkCommandBuffer commandBuffer, const VkCopyBufferInfo2* pCopyBufferInfo);

void vkCmdCopyImage( VkCommandBuffer VkImage VkImageLayout VkImage VkImageLayout uint32_t const VkImageCopy* commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);

void FVulkanCommandListContext::RHICopyToResolveTarget(FRHITexture* SourceTextureRHI, FRHITexture* DestTextureRHI, const FResolveParams& InResolveParams)

void FVulkanSurface::MoveSurface(FVulkanDevice& InDevice, FVulkanCommandListContext& Context, FVulkanAllocation& NewAllocation)

void FVulkanSurface::OnFullDefrag(FVulkanDevice& InDevice, FVulkanCommandListContext& Context, uint32 NewOffset)

void FVulkanSurface::EvictSurface(FVulkanDevice& InDevice)

static void DoAsyncReallocateTexture2D(FVulkanCommandListContext& Context, FVulkanTexture2D* OldTexture, FVulkanTexture2D* NewTexture, int32 NewMipCount, int32 NewSizeX, int32 NewSizeY, FThreadSafeCounter* RequestStatus)

void FVulkanCommandListContext::RHICopyTexture(FRHITexture* SourceTexture, FRHITexture* DestTexture, const FRHICopyTextureInfo& CopyInfo)

inline static void CopyImageToBackBuffer(FVulkanCommandListContext* Context, FVulkanCmdBuffer* CmdBuffer, VkImage SrcSurface, VkImage DstSurface, int32 SizeX, int32 SizeY, int32 WindowSizeX, int32 WindowSizeY)

void vkCmdCopyImage2( VkCommandBuffer commandBuffer, const VkCopyImageInfo2* pCopyImageInfo);

void vkCmdCopyBufferToImage( VkCommandBuffer VkBuffer VkImage VkImageLayout uint32_t const VkBufferImageCopy* commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);

inline void FVulkanSurface::InternalLockWrite(FVulkanCommandListContext& Context, FVulkanSurface* Surface, const VkImageSubresourceRange& SubresourceRange, const VkBufferImageCopy& Region, VulkanRHI::FStagingBuffer* StagingBuffer)

void vkCmdCopyImageToBuffer( VkCommandBuffer VkImage VkImageLayout VkBuffer uint32_t const VkBufferImageCopy* commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);

void FVulkanCommandListContext::RHICopyToResolveTarget(FRHITexture* SourceTextureRHI, FRHITexture* DestTextureRHI, const FResolveParams& InResolveParams)

void FVulkanDynamicRHI::RHIReadSurfaceData(FRHITexture* TextureRHI, FIntRect Rect, TArray<.FColor>& OutData, FReadSurfaceDataFlags InFlags)

void FVulkanDynamicRHI::RHIReadSurfaceFloatData(FRHITexture* TextureRHI, FIntRect Rect, TArray<.FFloat16Color>& OutData, ECubeFace CubeFace,int32 ArrayIndex,int32 MipIndex)

void FVulkanDynamicRHI::RHIRead3DSurfaceFloatData(FRHITexture* TextureRHI,FIntRect InRect,FIntPoint ZMinMax,TArray<.FFloat16Color>& OutData)

void FVulkanCommandListContext::RHICopyTexture(FRHITexture* SourceTexture, FRHITexture* DestTexture, const FRHICopyTextureInfo& CopyInfo)

When copying to or from a depth or stencil aspect, the data in buffer memory uses a layout that is a (mostly) tightly packed representation of the depth or stencil data

Because depth or stencil aspect buffer to image copies may require format conversions on some implementations, they are not supported on queues that do not support graphics.

void vkCmdCopyBufferToImage2( VkCommandBuffer commandBuffer, const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo);

void vkCmdCopyImageToBuffer2( VkCommandBuffer commandBuffer, const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo);

void vkCmdBlitImage( VkCommandBuffer VkImage VkImageLayout VkImage VkImageLayout uint32_t const VkImageBlit* VkFilter commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);

To copy regions of a source image into a destination image, potentially performing format conversion, arbitrary scaling, and filtering,

vkCmdBlitImage must not be used for multisampled source or destination images. Use vkCmdResolveImage for this purpose.

As the sizes of the source and destination extents can differ in any dimension, texels in the source extent are scaled and filtered to the destination extent.

These coordinates are used to sample from the source image, as described in Image Operations chapter, with the filter mode equal to that of filter, a mipmap mode of VK_SAMPLER_MIPMAP_MODE_NEAREST and an address mode of VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE. Implementations must clamp at the edge of the source image, and may additionally clamp to the edge of the source region.

inline static void CopyImageToBackBuffer(FVulkanCommandListContext* Context, FVulkanCmdBuffer* CmdBuffer, VkImage SrcSurface, VkImage DstSurface, int32 SizeX, int32 SizeY, int32 WindowSizeX, int32 WindowSizeY)

void vkCmdBlitImage2( VkCommandBuffer commandBuffer, const VkBlitImageInfo2* pBlitImageInfo);

void vkCmdResolveImage( VkCommandBuffer VkImage VkImageLayout VkImage VkImageLayout uint32_t const VkImageResolve* commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);

void FVulkanCommandListContext::RHICopyToResolveTarget(FRHITexture* SourceTextureRHI, FRHITexture* DestTextureRHI, const FResolveParams& InResolveParams)

void vkCmdResolveImage2( VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo);

本节教程就到此结束,希望大家继续阅读我之后的教程。

谢谢大家,再见!


原创技术文章,撰写不易,转载请注明出处:电子设备中的画家|王烁 于 2021 年 5 月 10 日发表,原文链接(http://geekfaner.com/shineengine/blog20_Vulkanv1.2_6.html)