To clear one or more regions of color and depth/stencil attachments inside a render pass instance, call:
// Provided by VK_VERSION_1_0 void vkCmdClearAttachments( VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects);
commandBufferis the command buffer into which the command will be recorded.
attachmentCountis the number of entries in the
pAttachmentsis a pointer to an array of VkClearAttachment structures defining the attachments to clear and the clear values to use. If any attachment index to be cleared is not backed by an image view, then the clear has no effect.
rectCountis the number of entries in the
pRectsis a pointer to an array of VkClearRect structures defining regions within each selected attachment to clear.
If the render pass has a fragment density map attachment, clears follow the operations of fragment density maps as if each clear region was a primitive which generates fragments. The clear color is applied to all pixels inside each fragment’s area regardless if the pixels lie outside of the clear region. Clears may have a different set of supported fragment areas than draws.
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
Clears to depth/stencil attachments are executed as depth
writes and writes by the
vkCmdClearAttachments is not affected by the bound pipeline state.
It’s generally advised that attachments are cleared by using the
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.