Clearing a depth-stencil image
Similarly to color images, we sometimes need to manually clear a depth-stencil image outside of a render pass.
How to do it...
- Take the command buffer that is in a recording state and has no render pass currently started in it. Using its handle, initialize a variable of type
VkCommandBuffer
namedcommand_buffer
. - Take the handle of a depth-stencil image and store it in a variable of type
VkImage
namedimage
. - Store the value representing the layout, in which the
image
will have during clearing, in a variable of typeVkImageLayout
namedimage_layout
. - Create a variable of type
std::vector<VkImageSubresourceRange>
namedimage_subresource_ranges
, which will contain a list of mipmap levels of all theimage
's and array layers, which should be cleared. For each such range, add a new element to theimage_subresource_ranges
vector and use the following values to initialize its members:- The depth and/or stencil aspect for
aspectMask
- The first mipmap level to be cleared...
- The depth and/or stencil aspect for