There are situations in which we cannot rely only on implicit attachment clearings performed as initial render pass operations, and we need to clear attachments explicitly in one of the sub-passes. We can do this by calling a vkCmdClearAttachments() function.
Clearing render pass attachments
How to do it...
- Take a command buffer that is in a recording state and store its handle in a variable of type VkCommandBuffer named command_buffer.
- Create a vector variable of type std::vector<VkClearAttachment> named attachments. For each framebuffer attachment that should be cleared inside a current sub-pass of a render pass, add an element to the vector and initialize it with the following values:
- The attachment's aspect (color, depth, or stencil) for aspectMask...