Clear Commands


Color and depth/stencil images can be cleared outside a render pass instance using vkCmdClearColorImage or vkCmdClearDepthStencilImage, respectively. These commands are only allowed outside of a render pass instance.

void vkCmdClearColorImage( VkCommandBuffer VkImage VkImageLayout const VkClearColorValue* uint32_t const VkImageSubresourceRange* commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);

void FVulkanSurface::SetInitialImageState(FVulkanCommandListContext& Context, VkImageLayout InitialLayout, bool bClear, const FClearValueBinding& ClearValueBinding)

void FVulkanViewport::CreateSwapchain(FVulkanSwapChainRecreateInfo* RecreateInfo)

Clears outside render pass instances are treated as transfer operations for the purposes of memory barriers.

void vkCmdClearDepthStencilImage( VkCommandBuffer VkImage VkImageLayout const VkClearDepthStencilValue* uint32_t const VkImageSubresourceRange* commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges);

void FVulkanSurface::SetInitialImageState(FVulkanCommandListContext& Context, VkImageLayout InitialLayout, bool bClear, const FClearValueBinding& ClearValueBinding)

Clears outside render pass instances are treated as transfer operations for the purposes of memory barriers.

void vkCmdClearAttachments( VkCommandBuffer uint32_t const VkClearAttachment* uint32_t const VkClearRect* commandBuffer, attachmentCount, pAttachments, rectCount, pRects);

void FVulkanCommandListContext::InternalClearMRT(FVulkanCmdBuffer* CmdBuffer, bool bClearColor, int32 NumClearColors, const FLinearColor* ClearColorArray, bool bClearDepth, float Depth, bool bClearStencil, uint32 Stencil)

Unlike other clear commands, vkCmdClearAttachments executes as a drawing command, rather than a transfer command, with writes performed by it executing in rasterization order. Clears to color attachments are executed as color attachment writes, by the VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage. Clears to depth/stencil attachments are executed as depth writes and writes by the VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT and VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT stages. vkCmdClearAttachments is not affected by the bound pipeline state.

If the image has more than one sample, the same value is written to all samples for any pixels being cleared.

void vkCmdFillBuffer( VkCommandBuffer VkBuffer VkDeviceSize VkDeviceSize uint32_t commandBuffer, dstBuffer, dstOffset, size, data);

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)

vkCmdFillBuffer is treated as a “transfer” operation for the purposes of synchronization barriers. The VK_BUFFER_USAGE_TRANSFER_DST_BIT must be specified in usage of VkBufferCreateInfo in order for the buffer to be compatible with vkCmdFillBuffer.

void vkCmdUpdateBuffer( VkCommandBuffer VkBuffer VkDeviceSize VkDeviceSize const void* commandBuffer, dstBuffer, dstOffset, dataSize, pData);

dataSize must be less than or equal to 65536 bytes. For larger updates, applications can use buffer to buffer copies.

vkCmdUpdateBuffer is only allowed outside of a render pass. This command is treated as a “transfer” operation for the purposes of synchronization barriers. The VK_BUFFER_USAGE_TRANSFER_DST_BIT must be specified in usage of VkBufferCreateInfo in order for the buffer to be compatible with vkCmdUpdateBuffer.

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

谢谢大家,再见!


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