1e5c31af7Sopenharmony_ci// Copyright 2015-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ci[[clears]]
6e5c31af7Sopenharmony_ci= Clear Commands
7e5c31af7Sopenharmony_ci
8e5c31af7Sopenharmony_ci
9e5c31af7Sopenharmony_ci[[clears-outside]]
10e5c31af7Sopenharmony_ci== Clearing Images Outside a Render Pass Instance
11e5c31af7Sopenharmony_ci
12e5c31af7Sopenharmony_ciColor and depth/stencil images can: be cleared outside a render pass
13e5c31af7Sopenharmony_ciinstance using flink:vkCmdClearColorImage or
14e5c31af7Sopenharmony_ciflink:vkCmdClearDepthStencilImage, respectively.
15e5c31af7Sopenharmony_ciThese commands are only allowed outside of a render pass instance.
16e5c31af7Sopenharmony_ci
17e5c31af7Sopenharmony_ci[open,refpage='vkCmdClearColorImage',desc='Clear regions of a color image',type='protos']
18e5c31af7Sopenharmony_ci--
19e5c31af7Sopenharmony_ciTo clear one or more subranges of a color image, call:
20e5c31af7Sopenharmony_ci
21e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdClearColorImage.adoc[]
22e5c31af7Sopenharmony_ci
23e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
24e5c31af7Sopenharmony_ci    recorded.
25e5c31af7Sopenharmony_ci  * pname:image is the image to be cleared.
26e5c31af7Sopenharmony_ci  * pname:imageLayout specifies the current layout of the image subresource
27e5c31af7Sopenharmony_ci    ranges to be cleared, and must: be
28e5c31af7Sopenharmony_ciifdef::VK_KHR_shared_presentable_image[]
29e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
30e5c31af7Sopenharmony_ciendif::VK_KHR_shared_presentable_image[]
31e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_GENERAL or
32e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL.
33e5c31af7Sopenharmony_ci  * pname:pColor is a pointer to a slink:VkClearColorValue structure
34e5c31af7Sopenharmony_ci    containing the values that the image subresource ranges will be cleared
35e5c31af7Sopenharmony_ci    to (see <<clears-values>> below).
36e5c31af7Sopenharmony_ci  * pname:rangeCount is the number of image subresource range structures in
37e5c31af7Sopenharmony_ci    pname:pRanges.
38e5c31af7Sopenharmony_ci  * pname:pRanges is a pointer to an array of slink:VkImageSubresourceRange
39e5c31af7Sopenharmony_ci    structures describing a range of mipmap levels, array layers, and
40e5c31af7Sopenharmony_ci    aspects to be cleared, as described in <<resources-image-views,Image
41e5c31af7Sopenharmony_ci    Views>>.
42e5c31af7Sopenharmony_ci
43e5c31af7Sopenharmony_ciEach specified range in pname:pRanges is cleared to the value specified by
44e5c31af7Sopenharmony_cipname:pColor.
45e5c31af7Sopenharmony_ci
46e5c31af7Sopenharmony_ci.Valid Usage
47e5c31af7Sopenharmony_ci****
48e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
49e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-image-01993]]
50e5c31af7Sopenharmony_ci    The <<resources-image-format-features,format features>> of pname:image
51e5c31af7Sopenharmony_ci    must: contain ename:VK_FORMAT_FEATURE_TRANSFER_DST_BIT
52e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
53e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-image-00002]]
54e5c31af7Sopenharmony_ci    pname:image must: have been created with
55e5c31af7Sopenharmony_ci    ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag
56e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
57e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-image-01545]]
58e5c31af7Sopenharmony_ci    pname:image must: not use any of the
59e5c31af7Sopenharmony_ci    <<formats-requiring-sampler-ycbcr-conversion, formats that require a
60e5c31af7Sopenharmony_ci    sampler {YCbCr} conversion>>
61e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
62e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-image-00003]]
63e5c31af7Sopenharmony_ci    If pname:image is non-sparse then it must: be bound completely and
64e5c31af7Sopenharmony_ci    contiguously to a single sname:VkDeviceMemory object
65e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-imageLayout-00004]]
66e5c31af7Sopenharmony_ci    pname:imageLayout must: specify the layout of the image subresource
67e5c31af7Sopenharmony_ci    ranges of pname:image specified in pname:pRanges at the time this
68e5c31af7Sopenharmony_ci    command is executed on a sname:VkDevice
69e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-imageLayout-01394]]
70e5c31af7Sopenharmony_ci    pname:imageLayout must: be
71e5c31af7Sopenharmony_ciifdef::VK_KHR_shared_presentable_image[]
72e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR,
73e5c31af7Sopenharmony_ciendif::VK_KHR_shared_presentable_image[]
74e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or
75e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_GENERAL
76e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-aspectMask-02498]]
77e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:aspectMask members of the
78e5c31af7Sopenharmony_ci    elements of the pname:pRanges array must: each only include
79e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_COLOR_BIT
80e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-baseMipLevel-01470]]
81e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:baseMipLevel members of the
82e5c31af7Sopenharmony_ci    elements of the pname:pRanges array must: each be less than the
83e5c31af7Sopenharmony_ci    pname:mipLevels specified in slink:VkImageCreateInfo when pname:image
84e5c31af7Sopenharmony_ci    was created
85e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-pRanges-01692]]
86e5c31af7Sopenharmony_ci    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
87e5c31af7Sopenharmony_ci    pname:levelCount member is not ename:VK_REMAINING_MIP_LEVELS, then
88e5c31af7Sopenharmony_ci    [eq]#pname:baseMipLevel {plus} pname:levelCount# must: be less than or
89e5c31af7Sopenharmony_ci    equal to the pname:mipLevels specified in slink:VkImageCreateInfo when
90e5c31af7Sopenharmony_ci    pname:image was created
91e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-baseArrayLayer-01472]]
92e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:baseArrayLayer members of the
93e5c31af7Sopenharmony_ci    elements of the pname:pRanges array must: each be less than the
94e5c31af7Sopenharmony_ci    pname:arrayLayers specified in slink:VkImageCreateInfo when pname:image
95e5c31af7Sopenharmony_ci    was created
96e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-pRanges-01693]]
97e5c31af7Sopenharmony_ci    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
98e5c31af7Sopenharmony_ci    pname:layerCount member is not ename:VK_REMAINING_ARRAY_LAYERS, then
99e5c31af7Sopenharmony_ci    [eq]#pname:baseArrayLayer {plus} pname:layerCount# must: be less than or
100e5c31af7Sopenharmony_ci    equal to the pname:arrayLayers specified in slink:VkImageCreateInfo when
101e5c31af7Sopenharmony_ci    pname:image was created
102e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-image-00007]]
103e5c31af7Sopenharmony_ci    pname:image must: not have a compressed or depth/stencil format
104e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-pColor-04961]]
105e5c31af7Sopenharmony_ci    pname:pColor must: be a valid pointer to a slink:VkClearColorValue union
106e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
107e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-commandBuffer-01805]]
108e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
109e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
110e5c31af7Sopenharmony_ci    pname:image must: not be a protected image
111e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearColorImage-commandBuffer-01806]]
112e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
113e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
114e5c31af7Sopenharmony_ci    must: not be an unprotected image
115e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
116e5c31af7Sopenharmony_ci****
117e5c31af7Sopenharmony_ci
118e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdClearColorImage.adoc[]
119e5c31af7Sopenharmony_ci--
120e5c31af7Sopenharmony_ci
121e5c31af7Sopenharmony_ci[open,refpage='vkCmdClearDepthStencilImage',desc='Fill regions of a combined depth/stencil image',type='protos']
122e5c31af7Sopenharmony_ci--
123e5c31af7Sopenharmony_ciTo clear one or more subranges of a depth/stencil image, call:
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdClearDepthStencilImage.adoc[]
126e5c31af7Sopenharmony_ci
127e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
128e5c31af7Sopenharmony_ci    recorded.
129e5c31af7Sopenharmony_ci  * pname:image is the image to be cleared.
130e5c31af7Sopenharmony_ci  * pname:imageLayout specifies the current layout of the image subresource
131e5c31af7Sopenharmony_ci    ranges to be cleared, and must: be ename:VK_IMAGE_LAYOUT_GENERAL or
132e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL.
133e5c31af7Sopenharmony_ci  * pname:pDepthStencil is a pointer to a slink:VkClearDepthStencilValue
134e5c31af7Sopenharmony_ci    structure containing the values that the depth and stencil image
135e5c31af7Sopenharmony_ci    subresource ranges will be cleared to (see <<clears-values>> below).
136e5c31af7Sopenharmony_ci  * pname:rangeCount is the number of image subresource range structures in
137e5c31af7Sopenharmony_ci    pname:pRanges.
138e5c31af7Sopenharmony_ci  * pname:pRanges is a pointer to an array of slink:VkImageSubresourceRange
139e5c31af7Sopenharmony_ci    structures describing a range of mipmap levels, array layers, and
140e5c31af7Sopenharmony_ci    aspects to be cleared, as described in <<resources-image-views,Image
141e5c31af7Sopenharmony_ci    Views>>.
142e5c31af7Sopenharmony_ci
143e5c31af7Sopenharmony_ci.Valid Usage
144e5c31af7Sopenharmony_ci****
145e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
146e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-image-01994]]
147e5c31af7Sopenharmony_ci    The <<resources-image-format-features,format features>> of pname:image
148e5c31af7Sopenharmony_ci    must: contain ename:VK_FORMAT_FEATURE_TRANSFER_DST_BIT
149e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
150e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
151e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-pRanges-02658]]
152e5c31af7Sopenharmony_ci    If the pname:aspect member of any element of pname:pRanges includes
153e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_STENCIL_BIT, and pname:image was created with
154e5c31af7Sopenharmony_ci    <<VkImageStencilUsageCreateInfo,separate stencil usage>>,
155e5c31af7Sopenharmony_ci    ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT must: have been included in the
156e5c31af7Sopenharmony_ci    slink:VkImageStencilUsageCreateInfo::pname:stencilUsage used to create
157e5c31af7Sopenharmony_ci    pname:image
158e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
159e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-pRanges-02659]]
160e5c31af7Sopenharmony_ci    If the pname:aspect member of any element of pname:pRanges includes
161e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_STENCIL_BIT,
162e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
163e5c31af7Sopenharmony_ci    and pname:image was not created with
164e5c31af7Sopenharmony_ci    <<VkImageStencilUsageCreateInfo,separate stencil usage>>,
165e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_separate_stencil_usage[]
166e5c31af7Sopenharmony_ci    ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT must: have been included in the
167e5c31af7Sopenharmony_ci    slink:VkImageCreateInfo::pname:usage used to create pname:image
168e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-pRanges-02660]]
169e5c31af7Sopenharmony_ci    If the pname:aspect member of any element of pname:pRanges includes
170e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_DEPTH_BIT, ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT
171e5c31af7Sopenharmony_ci    must: have been included in the slink:VkImageCreateInfo::pname:usage
172e5c31af7Sopenharmony_ci    used to create pname:image
173e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-image-00010]]
174e5c31af7Sopenharmony_ci    If pname:image is non-sparse then it must: be bound completely and
175e5c31af7Sopenharmony_ci    contiguously to a single sname:VkDeviceMemory object
176e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-imageLayout-00011]]
177e5c31af7Sopenharmony_ci    pname:imageLayout must: specify the layout of the image subresource
178e5c31af7Sopenharmony_ci    ranges of pname:image specified in pname:pRanges at the time this
179e5c31af7Sopenharmony_ci    command is executed on a sname:VkDevice
180e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-imageLayout-00012]]
181e5c31af7Sopenharmony_ci    pname:imageLayout must: be either of
182e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or
183e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_GENERAL
184e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-aspectMask-02824]]
185e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:aspectMask member of each
186e5c31af7Sopenharmony_ci    element of the pname:pRanges array must: not include bits other than
187e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_DEPTH_BIT or ename:VK_IMAGE_ASPECT_STENCIL_BIT
188e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-image-02825]]
189e5c31af7Sopenharmony_ci    If the pname:image's format does not have a stencil component, then the
190e5c31af7Sopenharmony_ci    slink:VkImageSubresourceRange::pname:aspectMask member of each element
191e5c31af7Sopenharmony_ci    of the pname:pRanges array must: not include the
192e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_STENCIL_BIT bit
193e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-image-02826]]
194e5c31af7Sopenharmony_ci    If the pname:image's format does not have a depth component, then the
195e5c31af7Sopenharmony_ci    slink:VkImageSubresourceRange::pname:aspectMask member of each element
196e5c31af7Sopenharmony_ci    of the pname:pRanges array must: not include the
197e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_DEPTH_BIT bit
198e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-baseMipLevel-01474]]
199e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:baseMipLevel members of the
200e5c31af7Sopenharmony_ci    elements of the pname:pRanges array must: each be less than the
201e5c31af7Sopenharmony_ci    pname:mipLevels specified in slink:VkImageCreateInfo when pname:image
202e5c31af7Sopenharmony_ci    was created
203e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-pRanges-01694]]
204e5c31af7Sopenharmony_ci    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
205e5c31af7Sopenharmony_ci    pname:levelCount member is not ename:VK_REMAINING_MIP_LEVELS, then
206e5c31af7Sopenharmony_ci    [eq]#pname:baseMipLevel {plus} pname:levelCount# must: be less than or
207e5c31af7Sopenharmony_ci    equal to the pname:mipLevels specified in slink:VkImageCreateInfo when
208e5c31af7Sopenharmony_ci    pname:image was created
209e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-baseArrayLayer-01476]]
210e5c31af7Sopenharmony_ci    The slink:VkImageSubresourceRange::pname:baseArrayLayer members of the
211e5c31af7Sopenharmony_ci    elements of the pname:pRanges array must: each be less than the
212e5c31af7Sopenharmony_ci    pname:arrayLayers specified in slink:VkImageCreateInfo when pname:image
213e5c31af7Sopenharmony_ci    was created
214e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-pRanges-01695]]
215e5c31af7Sopenharmony_ci    For each slink:VkImageSubresourceRange element of pname:pRanges, if the
216e5c31af7Sopenharmony_ci    pname:layerCount member is not ename:VK_REMAINING_ARRAY_LAYERS, then
217e5c31af7Sopenharmony_ci    [eq]#pname:baseArrayLayer {plus} pname:layerCount# must: be less than or
218e5c31af7Sopenharmony_ci    equal to the pname:arrayLayers specified in slink:VkImageCreateInfo when
219e5c31af7Sopenharmony_ci    pname:image was created
220e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-image-00014]]
221e5c31af7Sopenharmony_ci    pname:image must: have a depth/stencil format
222e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
223e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-commandBuffer-01807]]
224e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
225e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
226e5c31af7Sopenharmony_ci    pname:image must: not be a protected image
227e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearDepthStencilImage-commandBuffer-01808]]
228e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
229e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
230e5c31af7Sopenharmony_ci    pname:image must: not be an unprotected image
231e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
232e5c31af7Sopenharmony_ci****
233e5c31af7Sopenharmony_ci
234e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdClearDepthStencilImage.adoc[]
235e5c31af7Sopenharmony_ci--
236e5c31af7Sopenharmony_ci
237e5c31af7Sopenharmony_ciClears outside render pass instances are treated as transfer operations for
238e5c31af7Sopenharmony_cithe purposes of memory barriers.
239e5c31af7Sopenharmony_ci
240e5c31af7Sopenharmony_ci
241e5c31af7Sopenharmony_ci[[clears-inside]]
242e5c31af7Sopenharmony_ci== Clearing Images Inside a Render Pass Instance
243e5c31af7Sopenharmony_ci
244e5c31af7Sopenharmony_ci[open,refpage='vkCmdClearAttachments',desc='Clear regions within bound framebuffer attachments',type='protos']
245e5c31af7Sopenharmony_ci--
246e5c31af7Sopenharmony_ciTo clear one or more regions of color and depth/stencil attachments inside a
247e5c31af7Sopenharmony_cirender pass instance, call:
248e5c31af7Sopenharmony_ci
249e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdClearAttachments.adoc[]
250e5c31af7Sopenharmony_ci
251e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
252e5c31af7Sopenharmony_ci    recorded.
253e5c31af7Sopenharmony_ci  * pname:attachmentCount is the number of entries in the pname:pAttachments
254e5c31af7Sopenharmony_ci    array.
255e5c31af7Sopenharmony_ci  * pname:pAttachments is a pointer to an array of slink:VkClearAttachment
256e5c31af7Sopenharmony_ci    structures defining the attachments to clear and the clear values to
257e5c31af7Sopenharmony_ci    use.
258e5c31af7Sopenharmony_ci  * pname:rectCount is the number of entries in the pname:pRects array.
259e5c31af7Sopenharmony_ci  * pname:pRects is a pointer to an array of slink:VkClearRect structures
260e5c31af7Sopenharmony_ci    defining regions within each selected attachment to clear.
261e5c31af7Sopenharmony_ci
262e5c31af7Sopenharmony_ciifdef::VK_EXT_fragment_density_map[]
263e5c31af7Sopenharmony_ciIf the render pass has a <<renderpass-fragmentdensitymapattachment,fragment
264e5c31af7Sopenharmony_cidensity map attachment>>, clears follow the
265e5c31af7Sopenharmony_ci<<fragmentdensitymapops,operations of fragment density maps>> as if each
266e5c31af7Sopenharmony_ciclear region was a primitive which generates fragments.
267e5c31af7Sopenharmony_ciThe clear color is applied to all pixels inside each fragment's area
268e5c31af7Sopenharmony_ciregardless if the pixels lie outside of the clear region.
269e5c31af7Sopenharmony_ciClears may: have a different set of supported fragment areas than draws.
270e5c31af7Sopenharmony_ciendif::VK_EXT_fragment_density_map[]
271e5c31af7Sopenharmony_ci
272e5c31af7Sopenharmony_ciUnlike other <<clears,clear commands>>, flink:vkCmdClearAttachments is not a
273e5c31af7Sopenharmony_citransfer command.
274e5c31af7Sopenharmony_ciIt performs its operations in <<primsrast-order, rasterization order>>.
275e5c31af7Sopenharmony_ciFor color attachments, the operations are executed as color attachment
276e5c31af7Sopenharmony_ciwrites, by the ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage.
277e5c31af7Sopenharmony_ciFor depth/stencil attachments, the operations are executed as
278e5c31af7Sopenharmony_ci<<fragops-depth, depth writes>> and <<fragops-stencil, stencil writes>> by
279e5c31af7Sopenharmony_cithe ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT and
280e5c31af7Sopenharmony_ciename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT stages.
281e5c31af7Sopenharmony_ci
282e5c31af7Sopenharmony_cifname:vkCmdClearAttachments is not affected by the bound pipeline state.
283e5c31af7Sopenharmony_ci
284e5c31af7Sopenharmony_ci[NOTE]
285e5c31af7Sopenharmony_ci.Note
286e5c31af7Sopenharmony_ci====
287e5c31af7Sopenharmony_ciIt is generally preferable to clear attachments by using the
288e5c31af7Sopenharmony_ciename:VK_ATTACHMENT_LOAD_OP_CLEAR load operation at the start of rendering,
289e5c31af7Sopenharmony_cias it is more efficient on some implementations.
290e5c31af7Sopenharmony_ci====
291e5c31af7Sopenharmony_ci
292e5c31af7Sopenharmony_ciIf any attachment's pname:aspectMask to be cleared is not backed by an image
293e5c31af7Sopenharmony_ciview, the clear has no effect on that aspect.
294e5c31af7Sopenharmony_ci
295e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
296e5c31af7Sopenharmony_ciIf an attachment being cleared refers to an image view created with an
297e5c31af7Sopenharmony_cipname:aspectMask equal to one of ename:VK_IMAGE_ASPECT_PLANE_0_BIT,
298e5c31af7Sopenharmony_ciename:VK_IMAGE_ASPECT_PLANE_1_BIT or ename:VK_IMAGE_ASPECT_PLANE_2_BIT, it
299e5c31af7Sopenharmony_ciis considered to be ename:VK_IMAGE_ASPECT_COLOR_BIT for purposes of this
300e5c31af7Sopenharmony_cicommand, and must: be cleared with the ename:VK_IMAGE_ASPECT_COLOR_BIT
301e5c31af7Sopenharmony_ciaspect as specified by <<image-views-plane-promotion,image view creation>>.
302e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ci.Valid Usage
305e5c31af7Sopenharmony_ci****
306e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-aspectMask-07884]]
307e5c31af7Sopenharmony_ci    If
308e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[]
309e5c31af7Sopenharmony_ci    the current render pass instance does not use dynamic rendering, and
310e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_KHR_dynamic_rendering[]
311e5c31af7Sopenharmony_ci    the pname:aspectMask member of any element of pname:pAttachments
312e5c31af7Sopenharmony_ci    contains ename:VK_IMAGE_ASPECT_DEPTH_BIT, the current subpass instance's
313e5c31af7Sopenharmony_ci    depth-stencil attachment must: be either ename:VK_ATTACHMENT_UNUSED or
314e5c31af7Sopenharmony_ci    the attachment pname:format must: contain a depth component
315e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-aspectMask-07885]]
316e5c31af7Sopenharmony_ci    If
317e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_KHR_dynamic_rendering[]
318e5c31af7Sopenharmony_ci    the current render pass instance does not use dynamic rendering, and
319e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_KHR_dynamic_rendering[]
320e5c31af7Sopenharmony_ci    the pname:aspectMask member of any element of pname:pAttachments
321e5c31af7Sopenharmony_ci    contains ename:VK_IMAGE_ASPECT_STENCIL_BIT, the current subpass
322e5c31af7Sopenharmony_ci    instance's depth-stencil attachment must: be either
323e5c31af7Sopenharmony_ci    ename:VK_ATTACHMENT_UNUSED or the attachment pname:format must: contain
324e5c31af7Sopenharmony_ci    a stencil component
325e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-aspectMask-07271]]
326e5c31af7Sopenharmony_ci    If the pname:aspectMask member of any element of pname:pAttachments
327e5c31af7Sopenharmony_ci    contains ename:VK_IMAGE_ASPECT_COLOR_BIT, the pname:colorAttachment
328e5c31af7Sopenharmony_ci    must: be a valid color attachment index in the current render pass
329e5c31af7Sopenharmony_ci    instance
330e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-rect-02682]]
331e5c31af7Sopenharmony_ci    The pname:rect member of each element of pname:pRects must: have an
332e5c31af7Sopenharmony_ci    pname:extent.width greater than `0`
333e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-rect-02683]]
334e5c31af7Sopenharmony_ci    The pname:rect member of each element of pname:pRects must: have an
335e5c31af7Sopenharmony_ci    pname:extent.height greater than `0`
336e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-pRects-00016]]
337e5c31af7Sopenharmony_ci    The rectangular region specified by each element of pname:pRects must:
338e5c31af7Sopenharmony_ci    be contained within the render area of the current render pass instance
339e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-pRects-06937]]
340e5c31af7Sopenharmony_ci    The layers specified by each element of pname:pRects must: be contained
341e5c31af7Sopenharmony_ci    within every attachment that pname:pAttachments refers to, i.e. for each
342e5c31af7Sopenharmony_ci    element of pname:pRects, slink:VkClearRect::pname:baseArrayLayer {plus}
343e5c31af7Sopenharmony_ci    slink:VkClearRect::pname:layerCount must: be less than or equal to the
344e5c31af7Sopenharmony_ci    number of layers rendered to in the current render pass instance
345e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-layerCount-01934]]
346e5c31af7Sopenharmony_ci    The pname:layerCount member of each element of pname:pRects must: not be
347e5c31af7Sopenharmony_ci    `0`
348e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
349e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-commandBuffer-02504]]
350e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
351e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
352e5c31af7Sopenharmony_ci    each attachment to be cleared must: not be a protected image
353e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-commandBuffer-02505]]
354e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
355e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
356e5c31af7Sopenharmony_ci    each attachment to be cleared must: not be an unprotected image
357e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
358e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[]
359e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-baseArrayLayer-00018]]
360e5c31af7Sopenharmony_ci    If the render pass instance this is recorded in uses multiview, then
361e5c31af7Sopenharmony_ci    pname:baseArrayLayer must: be zero and pname:layerCount must: be one
362e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[]
363e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_format_resolve[]
364e5c31af7Sopenharmony_ci  * [[VUID-vkCmdClearAttachments-aspectMask-09298]]
365e5c31af7Sopenharmony_ci    If the subpass this is recorded in performs an external format resolve,
366e5c31af7Sopenharmony_ci    the pname:aspectMask member of any element of pname:pAttachments must:
367e5c31af7Sopenharmony_ci    not include `VK_IMAGE_ASPECT_PLANE__{ibit}__BIT` for any index _i_
368e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_format_resolve[]
369e5c31af7Sopenharmony_ci****
370e5c31af7Sopenharmony_ci
371e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdClearAttachments.adoc[]
372e5c31af7Sopenharmony_ci--
373e5c31af7Sopenharmony_ci
374e5c31af7Sopenharmony_ci[open,refpage='VkClearRect',desc='Structure specifying a clear rectangle',type='structs']
375e5c31af7Sopenharmony_ci--
376e5c31af7Sopenharmony_ciThe sname:VkClearRect structure is defined as:
377e5c31af7Sopenharmony_ci
378e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkClearRect.adoc[]
379e5c31af7Sopenharmony_ci
380e5c31af7Sopenharmony_ci  * pname:rect is the two-dimensional region to be cleared.
381e5c31af7Sopenharmony_ci  * pname:baseArrayLayer is the first layer to be cleared.
382e5c31af7Sopenharmony_ci  * pname:layerCount is the number of layers to clear.
383e5c31af7Sopenharmony_ci
384e5c31af7Sopenharmony_ciThe layers [eq]#[pname:baseArrayLayer, pname:baseArrayLayer {plus}
385e5c31af7Sopenharmony_cipname:layerCount)# counting from the base layer of the attachment image view
386e5c31af7Sopenharmony_ciare cleared.
387e5c31af7Sopenharmony_ci
388e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkClearRect.adoc[]
389e5c31af7Sopenharmony_ci--
390e5c31af7Sopenharmony_ci
391e5c31af7Sopenharmony_ci[open,refpage='VkClearAttachment',desc='Structure specifying a clear attachment',type='structs']
392e5c31af7Sopenharmony_ci--
393e5c31af7Sopenharmony_ciThe sname:VkClearAttachment structure is defined as:
394e5c31af7Sopenharmony_ci
395e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkClearAttachment.adoc[]
396e5c31af7Sopenharmony_ci
397e5c31af7Sopenharmony_ci  * pname:aspectMask is a mask selecting the color, depth and/or stencil
398e5c31af7Sopenharmony_ci    aspects of the attachment to be cleared.
399e5c31af7Sopenharmony_ci  * pname:colorAttachment is only meaningful if
400e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_COLOR_BIT is set in pname:aspectMask, in which
401e5c31af7Sopenharmony_ci    case it is an index into the currently bound color attachments.
402e5c31af7Sopenharmony_ci  * pname:clearValue is the color or depth/stencil value to clear the
403e5c31af7Sopenharmony_ci    attachment to, as described in <<clears-values,Clear Values>> below.
404e5c31af7Sopenharmony_ci
405e5c31af7Sopenharmony_ci.Valid Usage
406e5c31af7Sopenharmony_ci****
407e5c31af7Sopenharmony_ci  * [[VUID-VkClearAttachment-aspectMask-00019]]
408e5c31af7Sopenharmony_ci    If pname:aspectMask includes ename:VK_IMAGE_ASPECT_COLOR_BIT, it must:
409e5c31af7Sopenharmony_ci    not include ename:VK_IMAGE_ASPECT_DEPTH_BIT or
410e5c31af7Sopenharmony_ci    ename:VK_IMAGE_ASPECT_STENCIL_BIT
411e5c31af7Sopenharmony_ci  * [[VUID-VkClearAttachment-aspectMask-00020]]
412e5c31af7Sopenharmony_ci    pname:aspectMask must: not include ename:VK_IMAGE_ASPECT_METADATA_BIT
413e5c31af7Sopenharmony_ciifdef::VK_EXT_image_drm_format_modifier[]
414e5c31af7Sopenharmony_ci  * [[VUID-VkClearAttachment-aspectMask-02246]]
415e5c31af7Sopenharmony_ci    pname:aspectMask must: not include
416e5c31af7Sopenharmony_ci    `VK_IMAGE_ASPECT_MEMORY_PLANE__{ibit}__BIT_EXT` for any index _i_
417e5c31af7Sopenharmony_ciendif::VK_EXT_image_drm_format_modifier[]
418e5c31af7Sopenharmony_ci****
419e5c31af7Sopenharmony_ci
420e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkClearAttachment.adoc[]
421e5c31af7Sopenharmony_ci--
422e5c31af7Sopenharmony_ci
423e5c31af7Sopenharmony_ci
424e5c31af7Sopenharmony_ci[[clears-values]]
425e5c31af7Sopenharmony_ci== Clear Values
426e5c31af7Sopenharmony_ci
427e5c31af7Sopenharmony_ci[open,refpage='VkClearColorValue',desc='Structure specifying a clear color value',type='structs']
428e5c31af7Sopenharmony_ci--
429e5c31af7Sopenharmony_ciThe sname:VkClearColorValue structure is defined as:
430e5c31af7Sopenharmony_ci
431e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkClearColorValue.adoc[]
432e5c31af7Sopenharmony_ci
433e5c31af7Sopenharmony_ci  * pname:float32 are the color clear values when the format of the image or
434e5c31af7Sopenharmony_ci    attachment is one of the <<formats-numericformat, numeric formats>> with
435e5c31af7Sopenharmony_ci    a numeric type that is floating-point.
436e5c31af7Sopenharmony_ci    Floating point values are automatically converted to the format of the
437e5c31af7Sopenharmony_ci    image, with the clear value being treated as linear if the image is
438e5c31af7Sopenharmony_ci    sRGB.
439e5c31af7Sopenharmony_ci  * pname:int32 are the color clear values when the format of the image or
440e5c31af7Sopenharmony_ci    attachment has a numeric type that is signed integer (etext:SINT).
441e5c31af7Sopenharmony_ci    Signed integer values are converted to the format of the image by
442e5c31af7Sopenharmony_ci    casting to the smaller type (with negative 32-bit values mapping to
443e5c31af7Sopenharmony_ci    negative values in the smaller type).
444e5c31af7Sopenharmony_ci    If the integer clear value is not representable in the target type (e.g.
445e5c31af7Sopenharmony_ci    would overflow in conversion to that type), the clear value is
446e5c31af7Sopenharmony_ci    undefined:.
447e5c31af7Sopenharmony_ci  * pname:uint32 are the color clear values when the format of the image or
448e5c31af7Sopenharmony_ci    attachment has a numeric type that is unsigned integer (etext:UINT).
449e5c31af7Sopenharmony_ci    Unsigned integer values are converted to the format of the image by
450e5c31af7Sopenharmony_ci    casting to the integer type with fewer bits.
451e5c31af7Sopenharmony_ci
452e5c31af7Sopenharmony_ciThe four array elements of the clear color map to R, G, B, and A components
453e5c31af7Sopenharmony_ciof image formats, in order.
454e5c31af7Sopenharmony_ci
455e5c31af7Sopenharmony_ciIf the image has more than one sample, the same value is written to all
456e5c31af7Sopenharmony_cisamples for any pixels being cleared.
457e5c31af7Sopenharmony_ci
458e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkClearColorValue.adoc[]
459e5c31af7Sopenharmony_ci--
460e5c31af7Sopenharmony_ci
461e5c31af7Sopenharmony_ci[open,refpage='VkClearDepthStencilValue',desc='Structure specifying a clear depth stencil value',type='structs']
462e5c31af7Sopenharmony_ci--
463e5c31af7Sopenharmony_ciThe sname:VkClearDepthStencilValue structure is defined as:
464e5c31af7Sopenharmony_ci
465e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkClearDepthStencilValue.adoc[]
466e5c31af7Sopenharmony_ci
467e5c31af7Sopenharmony_ci  * pname:depth is the clear value for the depth aspect of the depth/stencil
468e5c31af7Sopenharmony_ci    attachment.
469e5c31af7Sopenharmony_ci    It is a floating-point value which is automatically converted to the
470e5c31af7Sopenharmony_ci    attachment's format.
471e5c31af7Sopenharmony_ci  * pname:stencil is the clear value for the stencil aspect of the
472e5c31af7Sopenharmony_ci    depth/stencil attachment.
473e5c31af7Sopenharmony_ci    It is a 32-bit integer value which is converted to the attachment's
474e5c31af7Sopenharmony_ci    format by taking the appropriate number of LSBs.
475e5c31af7Sopenharmony_ci
476e5c31af7Sopenharmony_ci.Valid Usage
477e5c31af7Sopenharmony_ci****
478e5c31af7Sopenharmony_ci  * [[VUID-VkClearDepthStencilValue-depth-00022]]
479e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_range_unrestricted[]
480e5c31af7Sopenharmony_ci    Unless the `apiext:VK_EXT_depth_range_unrestricted` extension is enabled
481e5c31af7Sopenharmony_ciendif::VK_EXT_depth_range_unrestricted[]
482e5c31af7Sopenharmony_ci    pname:depth must: be between `0.0` and `1.0`, inclusive
483e5c31af7Sopenharmony_ci****
484e5c31af7Sopenharmony_ci
485e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkClearDepthStencilValue.adoc[]
486e5c31af7Sopenharmony_ci--
487e5c31af7Sopenharmony_ci
488e5c31af7Sopenharmony_ci[open,refpage='VkClearValue',desc='Structure specifying a clear value',type='structs']
489e5c31af7Sopenharmony_ci--
490e5c31af7Sopenharmony_ciThe sname:VkClearValue union is defined as:
491e5c31af7Sopenharmony_ci
492e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkClearValue.adoc[]
493e5c31af7Sopenharmony_ci
494e5c31af7Sopenharmony_ci  * pname:color specifies the color image clear values to use when clearing
495e5c31af7Sopenharmony_ci    a color image or attachment.
496e5c31af7Sopenharmony_ci  * pname:depthStencil specifies the depth and stencil clear values to use
497e5c31af7Sopenharmony_ci    when clearing a depth/stencil image or attachment.
498e5c31af7Sopenharmony_ci
499e5c31af7Sopenharmony_ciThis union is used where part of the API requires either color or
500e5c31af7Sopenharmony_cidepth/stencil clear values, depending on the attachment, and defines the
501e5c31af7Sopenharmony_ciinitial clear values in the slink:VkRenderPassBeginInfo structure.
502e5c31af7Sopenharmony_ci
503e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkClearValue.adoc[]
504e5c31af7Sopenharmony_ci--
505e5c31af7Sopenharmony_ci
506e5c31af7Sopenharmony_ci
507e5c31af7Sopenharmony_ci[[clears-filling-buffers]]
508e5c31af7Sopenharmony_ci== Filling Buffers
509e5c31af7Sopenharmony_ci
510e5c31af7Sopenharmony_ci[open,refpage='vkCmdFillBuffer',desc='Fill a region of a buffer with a fixed value',type='protos']
511e5c31af7Sopenharmony_ci--
512e5c31af7Sopenharmony_ciTo clear buffer data, call:
513e5c31af7Sopenharmony_ci
514e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdFillBuffer.adoc[]
515e5c31af7Sopenharmony_ci
516e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
517e5c31af7Sopenharmony_ci    recorded.
518e5c31af7Sopenharmony_ci  * pname:dstBuffer is the buffer to be filled.
519e5c31af7Sopenharmony_ci  * pname:dstOffset is the byte offset into the buffer at which to start
520e5c31af7Sopenharmony_ci    filling, and must: be a multiple of 4.
521e5c31af7Sopenharmony_ci  * pname:size is the number of bytes to fill, and must: be either a
522e5c31af7Sopenharmony_ci    multiple of 4, or ename:VK_WHOLE_SIZE to fill the range from
523e5c31af7Sopenharmony_ci    pname:offset to the end of the buffer.
524e5c31af7Sopenharmony_ci    If ename:VK_WHOLE_SIZE is used and the remaining size of the buffer is
525e5c31af7Sopenharmony_ci    not a multiple of 4, then the nearest smaller multiple is used.
526e5c31af7Sopenharmony_ci  * pname:data is the 4-byte word written repeatedly to the buffer to fill
527e5c31af7Sopenharmony_ci    pname:size bytes of data.
528e5c31af7Sopenharmony_ci    The data word is written to memory according to the host endianness.
529e5c31af7Sopenharmony_ci
530e5c31af7Sopenharmony_cifname:vkCmdFillBuffer is treated as a "`transfer`" operation for the
531e5c31af7Sopenharmony_cipurposes of synchronization barriers.
532e5c31af7Sopenharmony_ciThe ename:VK_BUFFER_USAGE_TRANSFER_DST_BIT must: be specified in pname:usage
533e5c31af7Sopenharmony_ciof slink:VkBufferCreateInfo in order for the buffer to be compatible with
534e5c31af7Sopenharmony_cifname:vkCmdFillBuffer.
535e5c31af7Sopenharmony_ci
536e5c31af7Sopenharmony_ci.Valid Usage
537e5c31af7Sopenharmony_ci****
538e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-dstOffset-00024]]
539e5c31af7Sopenharmony_ci    pname:dstOffset must: be less than the size of pname:dstBuffer
540e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-dstOffset-00025]]
541e5c31af7Sopenharmony_ci    pname:dstOffset must: be a multiple of `4`
542e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-size-00026]]
543e5c31af7Sopenharmony_ci    If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: be
544e5c31af7Sopenharmony_ci    greater than `0`
545e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-size-00027]]
546e5c31af7Sopenharmony_ci    If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: be
547e5c31af7Sopenharmony_ci    less than or equal to the size of pname:dstBuffer minus pname:dstOffset
548e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-size-00028]]
549e5c31af7Sopenharmony_ci    If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: be a
550e5c31af7Sopenharmony_ci    multiple of `4`
551e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-dstBuffer-00029]]
552e5c31af7Sopenharmony_ci    pname:dstBuffer must: have been created with
553e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_TRANSFER_DST_BIT usage flag
554e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-apiVersion-07894]]
555e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
556e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
557e5c31af7Sopenharmony_ci    If the apiext:VK_KHR_maintenance1 extension is not enabled and
558e5c31af7Sopenharmony_ci    slink:VkPhysicalDeviceProperties::pname:apiVersion is less than Vulkan
559e5c31af7Sopenharmony_ci    1.1, the
560e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
561e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
562e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_1,VK_KHR_maintenance1[The]
563e5c31af7Sopenharmony_ci    slink:VkCommandPool that pname:commandBuffer was allocated from must:
564e5c31af7Sopenharmony_ci    support graphics or compute operations
565e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-dstBuffer-00031]]
566e5c31af7Sopenharmony_ci    If pname:dstBuffer is non-sparse then it must: be bound completely and
567e5c31af7Sopenharmony_ci    contiguously to a single slink:VkDeviceMemory object
568e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
569e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-commandBuffer-01811]]
570e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
571e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
572e5c31af7Sopenharmony_ci    pname:dstBuffer must: not be a protected buffer
573e5c31af7Sopenharmony_ci  * [[VUID-vkCmdFillBuffer-commandBuffer-01812]]
574e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
575e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
576e5c31af7Sopenharmony_ci    pname:dstBuffer must: not be an unprotected buffer
577e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
578e5c31af7Sopenharmony_ci****
579e5c31af7Sopenharmony_ci
580e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdFillBuffer.adoc[]
581e5c31af7Sopenharmony_ci--
582e5c31af7Sopenharmony_ci
583e5c31af7Sopenharmony_ci
584e5c31af7Sopenharmony_ci[[clears-updating-buffers]]
585e5c31af7Sopenharmony_ci== Updating Buffers
586e5c31af7Sopenharmony_ci
587e5c31af7Sopenharmony_ci[open,refpage='vkCmdUpdateBuffer',desc='Update a buffer\'s contents from host memory',type='protos']
588e5c31af7Sopenharmony_ci--
589e5c31af7Sopenharmony_ciTo update buffer data inline in a command buffer, call:
590e5c31af7Sopenharmony_ci
591e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdUpdateBuffer.adoc[]
592e5c31af7Sopenharmony_ci
593e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
594e5c31af7Sopenharmony_ci    recorded.
595e5c31af7Sopenharmony_ci  * pname:dstBuffer is a handle to the buffer to be updated.
596e5c31af7Sopenharmony_ci  * pname:dstOffset is the byte offset into the buffer to start updating,
597e5c31af7Sopenharmony_ci    and must: be a multiple of 4.
598e5c31af7Sopenharmony_ci  * pname:dataSize is the number of bytes to update, and must: be a multiple
599e5c31af7Sopenharmony_ci    of 4.
600e5c31af7Sopenharmony_ci  * pname:pData is a pointer to the source data for the buffer update, and
601e5c31af7Sopenharmony_ci    must: be at least pname:dataSize bytes in size.
602e5c31af7Sopenharmony_ci
603e5c31af7Sopenharmony_cipname:dataSize must: be less than or equal to 65536 bytes.
604e5c31af7Sopenharmony_ciFor larger updates, applications can: use buffer to buffer
605e5c31af7Sopenharmony_ci<<copies-buffers,copies>>.
606e5c31af7Sopenharmony_ci
607e5c31af7Sopenharmony_ci[NOTE]
608e5c31af7Sopenharmony_ci.Note
609e5c31af7Sopenharmony_ci====
610e5c31af7Sopenharmony_ciBuffer updates performed with fname:vkCmdUpdateBuffer first copy the data
611e5c31af7Sopenharmony_ciinto command buffer memory when the command is recorded (which requires
612e5c31af7Sopenharmony_ciadditional storage and may incur an additional allocation), and then copy
613e5c31af7Sopenharmony_cithe data from the command buffer into pname:dstBuffer when the command is
614e5c31af7Sopenharmony_ciexecuted on a device.
615e5c31af7Sopenharmony_ci
616e5c31af7Sopenharmony_ciThe additional cost of this functionality compared to <<copies-buffers,
617e5c31af7Sopenharmony_cibuffer to buffer copies>> means it is only recommended for very small
618e5c31af7Sopenharmony_ciamounts of data, and is why it is limited to only 65536 bytes.
619e5c31af7Sopenharmony_ci
620e5c31af7Sopenharmony_ciApplications can: work around this by issuing multiple
621e5c31af7Sopenharmony_cifname:vkCmdUpdateBuffer commands to different ranges of the same buffer, but
622e5c31af7Sopenharmony_ciit is strongly recommended that they should: not.
623e5c31af7Sopenharmony_ci====
624e5c31af7Sopenharmony_ci
625e5c31af7Sopenharmony_ciThe source data is copied from the user pointer to the command buffer when
626e5c31af7Sopenharmony_cithe command is called.
627e5c31af7Sopenharmony_ci
628e5c31af7Sopenharmony_cifname:vkCmdUpdateBuffer is only allowed outside of a render pass.
629e5c31af7Sopenharmony_ciThis command is treated as a "`transfer`" operation for the purposes of
630e5c31af7Sopenharmony_cisynchronization barriers.
631e5c31af7Sopenharmony_ciThe ename:VK_BUFFER_USAGE_TRANSFER_DST_BIT must: be specified in pname:usage
632e5c31af7Sopenharmony_ciof slink:VkBufferCreateInfo in order for the buffer to be compatible with
633e5c31af7Sopenharmony_cifname:vkCmdUpdateBuffer.
634e5c31af7Sopenharmony_ci
635e5c31af7Sopenharmony_ci.Valid Usage
636e5c31af7Sopenharmony_ci****
637e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dstOffset-00032]]
638e5c31af7Sopenharmony_ci    pname:dstOffset must: be less than the size of pname:dstBuffer
639e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dataSize-00033]]
640e5c31af7Sopenharmony_ci    pname:dataSize must: be less than or equal to the size of
641e5c31af7Sopenharmony_ci    pname:dstBuffer minus pname:dstOffset
642e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dstBuffer-00034]]
643e5c31af7Sopenharmony_ci    pname:dstBuffer must: have been created with
644e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_TRANSFER_DST_BIT usage flag
645e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dstBuffer-00035]]
646e5c31af7Sopenharmony_ci    If pname:dstBuffer is non-sparse then it must: be bound completely and
647e5c31af7Sopenharmony_ci    contiguously to a single sname:VkDeviceMemory object
648e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dstOffset-00036]]
649e5c31af7Sopenharmony_ci    pname:dstOffset must: be a multiple of `4`
650e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dataSize-00037]]
651e5c31af7Sopenharmony_ci    pname:dataSize must: be less than or equal to `65536`
652e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-dataSize-00038]]
653e5c31af7Sopenharmony_ci    pname:dataSize must: be a multiple of `4`
654e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
655e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-commandBuffer-01813]]
656e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
657e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
658e5c31af7Sopenharmony_ci    pname:dstBuffer must: not be a protected buffer
659e5c31af7Sopenharmony_ci  * [[VUID-vkCmdUpdateBuffer-commandBuffer-01814]]
660e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
661e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
662e5c31af7Sopenharmony_ci    pname:dstBuffer must: not be an unprotected buffer
663e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
664e5c31af7Sopenharmony_ci****
665e5c31af7Sopenharmony_ci
666e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdUpdateBuffer.adoc[]
667e5c31af7Sopenharmony_ci--
668e5c31af7Sopenharmony_ci
669e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
670e5c31af7Sopenharmony_ci[NOTE]
671e5c31af7Sopenharmony_ci.Note
672e5c31af7Sopenharmony_ci====
673e5c31af7Sopenharmony_ciThe pname:pData parameter was of type code:uint32_t* instead of code:void*
674e5c31af7Sopenharmony_ciprior to version 1.0.19 of the Specification and dlink:VK_HEADER_VERSION 19
675e5c31af7Sopenharmony_ciof the <<boilerplate-headers,Vulkan Header Files>>.
676e5c31af7Sopenharmony_ciThis was a historical anomaly, as the source data may be of other types.
677e5c31af7Sopenharmony_ci====
678e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
679