17.3. Clear Values

The VkClearColorValue structure is defined as:

 

typedef union VkClearColorValue {
    float       float32[4];
    int32_t     int32[4];
    uint32_t    uint32[4];
} VkClearColorValue;

Color clear values are taken from the VkClearColorValue union based on the format of the image or attachment. Floating point, unorm, snorm, uscaled, packed float, and sRGB images use the float32 member, unsigned integer formats use the uint32 member, and signed integer formats use the int32 member. Floating point values are automatically converted to the format of the image, with the clear value being treated as linear if the image is sRGB.

Unsigned integer values are converted to the format of the image by casting to the integer type with fewer bits. Signed integer values are converted to the format of the image by casting to the smaller type (with negative 32-bit values mapping to negative values in the smaller type). If the integer clear value is not representable in the target type (e.g. would overflow in conversion to that type), the clear value is undefined.

The four array elements of the clear color map to R, G, B, and A components of image formats, in order.

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

The VkClearDepthStencilValue structure is defined as:

 

typedef struct VkClearDepthStencilValue {
    float       depth;
    uint32_t    stencil;
} VkClearDepthStencilValue;

Some parts of the API require either color or depth/stencil clear values, depending on the attachment. The VkClearValue union represents such values.

The VkClearValue union is defined as:

 

typedef union VkClearValue {
    VkClearColorValue           color;
    VkClearDepthStencilValue    depthStencil;
} VkClearValue;

This union is used to define the initial clear values in the VkRenderPassBeginInfo structure.