// Copyright 2015-2024 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

[[clears]]
= Clear Commands


[[clears-outside]]
== Clearing Images Outside A Render Pass Instance

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

[open,refpage='vkCmdClearColorImage',desc='Clear regions of a color image',type='protos']
--
To clear one or more subranges of a color image, call:

include::{generated}/api/protos/vkCmdClearColorImage.adoc[]

.Valid Usage
****
  * [[VUID-vkCmdClearColorImage-aspectMask-02498]]
    The slink:VkImageSubresourceRange::pname:aspectMask members of the
    elements of the pname:pRanges array must: each only include
    ename:VK_IMAGE_ASPECT_COLOR_BIT
  * [[VUID-vkCmdClearColorImage-baseMipLevel-01470]]
    The slink:VkImageSubresourceRange::pname:baseMipLevel members of the
    elements of the pname:pRanges array must: each be less than the
    pname:mipLevels specified in slink:VkImageCreateInfo when pname:image
    was created
  * [[VUID-vkCmdClearColorImage-pRanges-02498]]
    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
    pname:levelCount member is not ename:VK_REMAINING_MIP_LEVELS, then
    [eq]#pname:baseMipLevel {plus} pname:levelCount# must: be less than or
    equal to the pname:mipLevels specified in slink:VkImageCreateInfo when
    pname:image was created
  * [[VUID-vkCmdClearColorImage-baseArrayLayer-00007]]
    The slink:VkImageSubresourceRange::pname:baseArrayLayer members of the
    elements of the pname:pRanges array must: each be less than the
    pname:arrayLayers specified in slink:VkImageCreateInfo when pname:image
    was created
  * [[VUID-vkCmdClearColorImage-pRanges-02498]]
    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
    pname:layerCount member is not ename:VK_REMAINING_ARRAY_LAYERS, then
    [eq]#pname:baseArrayLayer {plus} pname:layerCount# must: be less than or
    equal to the pname:arrayLayers specified in slink:VkImageCreateInfo when
    pname:image was created
  * [[VUID-vkCmdClearColorImage-image-00007]]
    pname:image must: not have a compressed or depth/stencil format
  * [[VUID-vkCmdClearColorImage-pColor-02498]]
    pname:pColor must: be a valid pointer to a slink:VkClearColorValue union
****

include::{generated}/validity/protos/vkCmdClearColorImage.adoc[]
--
