• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2015-2018 Khronos Group. This work is licensed under a
2// Creative Commons Attribution 4.0 International License; see
3// http://creativecommons.org/licenses/by/4.0/
4
5[[drawing]]
6= Drawing Commands
7
8_Drawing commands_ (commands with ftext:Draw in the name) provoke work in a
9graphics pipeline.
10Drawing commands are recorded into a command buffer and when executed by a
11queue, will produce work which executes according to the bound graphics
12pipeline.
13A graphics pipeline must: be bound to a command buffer before any drawing
14commands are recorded in that command buffer.
15
16[open,refpage='VkPipelineInputAssemblyStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline input assembly state',type='structs']
17--
18
19Each draw is made up of zero or more vertices and zero or more instances,
20which are processed by the device and result in the assembly of primitives.
21Primitives are assembled according to the pname:pInputAssemblyState member
22of the sname:VkGraphicsPipelineCreateInfo structure, which is of type
23sname:VkPipelineInputAssemblyStateCreateInfo:
24
25include::../api/structs/VkPipelineInputAssemblyStateCreateInfo.txt[]
26
27  * pname:sType is the type of this structure.
28  * pname:pNext is `NULL` or a pointer to an extension-specific structure.
29  * pname:flags is reserved for future use.
30  * pname:topology is a elink:VkPrimitiveTopology defining the primitive
31    topology, as described below.
32  * pname:primitiveRestartEnable controls whether a special vertex index
33    value is treated as restarting the assembly of primitives.
34    This enable only applies to indexed draws (flink:vkCmdDrawIndexed and
35    flink:vkCmdDrawIndexedIndirect), and the special index value is either
36    0xFFFFFFFF when the pname:indexType parameter of
37    fname:vkCmdBindIndexBuffer is equal to ename:VK_INDEX_TYPE_UINT32, or
38    0xFFFF when pname:indexType is equal to ename:VK_INDEX_TYPE_UINT16.
39    Primitive restart is not allowed for "`list`" topologies.
40
41Restarting the assembly of primitives discards the most recent index values
42if those elements formed an incomplete primitive, and restarts the primitive
43assembly using the subsequent indices, but only assembling the immediately
44following element through the end of the originally specified elements.
45The primitive restart index value comparison is performed before adding the
46pname:vertexOffset value to the index value.
47
48.Valid Usage
49****
50  * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428]]
51    If pname:topology is ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
52    ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
53    ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
54    ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY,
55    ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY or
56    ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, pname:primitiveRestartEnable
57    must: be ename:VK_FALSE
58  * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00429]]
59    If the <<features-features-geometryShader,geometry shaders>> feature is
60    not enabled, pname:topology must: not be any of
61    ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY,
62    ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY,
63    ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY or
64    ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY
65  * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00430]]
66    If the <<features-features-tessellationShader,tessellation shaders>>
67    feature is not enabled, pname:topology must: not be
68    ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
69****
70
71include::../validity/structs/VkPipelineInputAssemblyStateCreateInfo.txt[]
72--
73
74[open,refpage='VkPipelineInputAssemblyStateCreateFlags',desc='Reserved for future use',type='enums']
75--
76include::../api/flags/VkPipelineInputAssemblyStateCreateFlags.txt[]
77
78sname:VkPipelineInputAssemblyStateCreateFlags is a bitmask type for setting
79a mask, but is currently reserved for future use.
80--
81
82
83[[drawing-primitive-topologies]]
84== Primitive Topologies
85
86[open,refpage='VkPrimitiveTopology',desc='Supported primitive topologies',type='enums']
87--
88
89_Primitive topology_ determines how consecutive vertices are organized into
90primitives, and determines the type of primitive that is used at the
91beginning of the graphics pipeline.
92The effective topology for later stages of the pipeline is altered by
93tessellation or geometry shading (if either is in use) and depends on the
94execution modes of those shaders.
95Supported topologies are defined by elink:VkPrimitiveTopology and include:
96
97include::../api/enums/VkPrimitiveTopology.txt[]
98
99--
100
101Each primitive topology, and its construction from a list of vertices, is
102summarized below with a supporting diagram.
103In each diagram, the numbered points show the sequencing of vertices in
104order within the vertex arrays; however the positions chosen are arbitrary
105and for illustration only.
106Vertices connected with solid lines belong to the main primitives.
107In the primitive types with adjacency, the vertices connected by dashed
108lines are the adjacent vertices that are accessible in a geometry shader.
109
110[NOTE]
111.Note
112====
113The terminology {ldquo}vertex [eq]#i# {rdquo} means {ldquo}the vertex with
114index [eq]#i# in the ordered list of vertices defining this
115primitive{rdquo}.
116====
117
118[NOTE]
119.Note
120====
121Depending on the <<primsrast-polygonmode,polygon mode>>, a _polygon
122primitive_ generated from a drawing command with pname:topology
123ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN,
124ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
125ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
126ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, or
127ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY is rendered in one
128of several ways, such as outlining its border or filling its interior.
129The order of vertices in such a primitive is significant during
130<<primsrast-polygons-basic,polygon rasterization>> and
131<<shaders-fragment,fragment shading>>.
132====
133
134
135=== Point Lists
136
137A series of individual points are specified with pname:topology
138ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST.
139Each vertex defines a separate point.
140
141.Point Lists
142[%inline]
143image::images/primitive_topology_point_list.svg[align="center"]
144
145
146=== Line Lists
147
148Lists of line segments, with each segment defined by a pair of vertices, are
149specified with pname:topology ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST.
150The first two vertices define the first segment, with subsequent pairs of
151vertices each defining one more segment.
152If the number of vertices is odd, then the last vertex is ignored.
153
154.Line Lists
155[%inline]
156image::images/primitive_topology_line_list.svg[align="center"]
157
158
159=== Line Strips
160
161A series of one or more connected line segments are specified with
162pname:topology ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP.
163In this case, the first vertex specifies the first segment's start point
164while the second vertex specifies the first segment's endpoint and the
165second segment's start point.
166In general, vertex [eq]#i# (for [eq]#i > 0#) specifies the beginning of the
167[eq]##i##th segment and the end of the previous segment.
168The last vertex specifies the end of the last segment.
169If only one vertex is specified, then no primitive is generated.
170
171.Line Strips
172[%inline]
173image::images/primitive_topology_line_strip.svg[align="center"]
174
175
176=== Triangle Lists
177
178Lists of separate triangles are specified with pname:topology
179ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST.
180In this case, vertices [eq]#3 i#, [eq]#3 i {plus} 1#, and [eq]#3 i {plus} 2#
181(in that order) determine a triangle for each [eq]#i = 0, 1, ..., n-1#,
182where there are [eq]#3 n {plus} k# vertices drawn.
183[eq]#k# is either 0, 1, or 2; if [eq]#k# is not zero, the final [eq]#k#
184vertices are ignored.
185
186.Triangle Lists
187[%inline]
188image::images/primitive_topology_triangle_list.svg[align="center"]
189
190
191=== Triangle Strips
192
193A triangle strip is a series of triangles connected along shared edges, and
194is specified with pname:topology ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP.
195In this case, the first three vertices define the first triangle, and their
196order is significant.
197Each subsequent vertex defines a new triangle using that point along with
198the last two vertices from the previous triangle.
199If fewer than three vertices are specified, no primitive is produced.
200The order of vertices in successive triangles changes as shown in the figure
201below, so that all triangle faces have the same orientation.
202
203.Triangle Strips
204[%inline]
205image::images/primitive_topology_triangle_strip.svg[align="center"]
206
207
208=== Triangle Fans
209
210A triangle fan is specified with pname:topology
211ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN.
212It is similar to a triangle strip, but changes the vertex replaced from the
213previous triangle so that all triangles in the fan share a common vertex.
214
215.Triangle Fans
216[%inline]
217image::images/primitive_topology_triangle_fan.svg[align="center"]
218
219
220=== Line Lists With Adjacency
221
222Lines with adjacency are specified with pname:topology
223ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, and are independent
224line segments where each endpoint has a corresponding _adjacent_ vertex that
225is accessible in a <<geometry,geometry shader>>.
226If a geometry shader is not active, the adjacent vertices are ignored.
227
228A line segment is drawn from vertex [eq]#4 i {plus} 1# to vertex [eq]#4 i
229{plus} 2# for each [eq]#i = 0, 1, ..., n-1#, where there are [eq]#4 n {plus}
230k# vertices.
231[eq]#k# is either 0, 1, 2, or 3; if [eq]#k# is not zero, the final [eq]#k#
232vertices are ignored.
233For line segment [eq]#i#, vertices [eq]#4 i# and [eq]#4 i {plus} 3# vertices
234are considered adjacent to vertices [eq]#4 i {plus} 1# and [eq]#4 i {plus}
2352#, respectively.
236
237.Line Lists With Adjacency
238[%inline]
239image::images/primitive_topology_line_list_with_adjacency.svg[align="center"]
240
241
242=== Line Strips With Adjacency
243
244Line strips with adjacency are specified with pname:topology
245ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY and are similar to
246line strips, except that each line segment has a pair of adjacent vertices
247that are accessible in a geometry shader.
248If a geometry shader is not active, the adjacent vertices are ignored.
249
250A line segment is drawn from vertex [eq]#i {plus} 1# vertex to vertex [eq]#i
251{plus} 2# for each [eq]#i = 0, 1, ..., n-1#, where there are [eq]#n {plus}
2523# vertices.
253If there are fewer than four vertices, all vertices are ignored.
254For line segment [eq]#i#, vertices [eq]#i# and [eq]#i {plus} 3# are
255considered adjacent to vertices [eq]#i {plus} 1# and [eq]#i {plus} 2#,
256respectively.
257
258.Line Strips With Adjacency
259[%inline]
260image::images/primitive_topology_line_strip_with_adjacency.svg[align="center"]
261
262
263=== Triangle Lists With Adjacency
264
265Triangles with adjacency are specified with pname:topology
266ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, and are similar to
267separate triangles except that each triangle edge has an adjacent vertex
268that is accessible in a geometry shader.
269If a geometry shader is not active, the adjacent vertices are ignored.
270
271Vertices [eq]#6 i#, [eq]#6 i {plus} 2#, and [eq]#6 i {plus} 4# (in that
272order) determine a triangle for each [eq]#i = 0, 1, ..., n-1#, where there
273are [eq]#6 n+k# vertices.
274[eq]#k# is either 0, 1, 2, 3, 4, or 5; if [eq]#k# is non-zero, the final
275[eq]#k# vertices are ignored.
276For triangle [eq]#i#, vertices [eq]#6 i {plus} 1#, [eq]#6 i {plus} 3#, and
277[eq]#6 i {plus} 5# vertices are considered adjacent to edges from vertex
278[eq]#6 i# to [eq]#6 i {plus} 2#, from [eq]#6 i {plus} 2# to [eq]#6 i {plus}
2794#, and from [eq]#6 i {plus} 4# to [eq]#6 i# vertices, respectively.
280
281.Triangle Lists With Adjacency
282[%inline]
283image::images/primitive_topology_triangle_list_with_adjacency.svg[align="center"]
284
285
286=== Triangle Strips With Adjacency
287
288Triangle strips with adjacency are specified with pname:topology
289ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, and are similar
290to triangle strips except that each triangle edge has an adjacent vertex
291that is accessible in a geometry shader.
292If a geometry shader is not active, the adjacent vertices are ignored.
293
294In triangle strips with adjacency, [eq]#n# triangles are drawn where there
295are [eq]#2 (n {plus} 2) {plus} k# vertices.
296[eq]#k# is either 0 or 1; if [eq]#k# is 1, the final vertex is ignored.
297If there are fewer than 6 vertices, the entire primitive is ignored.
298
299.Triangle Strips With Adjacency
300[%inline]
301image::images/primitive_topology_triangle_strip_with_adjacency.svg[align="center"]
302
303The table below illustrates the vertices and order used to draw each
304triangle, and which vertices are considered adjacent to each edge of those
305triangles.
306Each triangle is drawn using the vertices whose numbers are in the *1st*,
307*2nd*, and *3rd* columns under *Primitive Vertices*, in that order.
308The vertices in the 1/2, 2/3, and 3/1 columns under *Adjacent Vertices* are
309considered adjacent to the edges from the first to the second, from the
310second to the third, and from the third to the first vertex of the triangle,
311respectively.
312The six rows correspond to six cases: the first and only triangle [eq]#(i =
3130, n = 1)#, the first triangle of several [eq]#(i = 0, n > 0)#, _odd_ middle
314triangles [eq]#(i = 1, 3, 5 ...)#, _even_ middle triangles [eq]#(i = 2, 4,
3156, ...)#, and special cases for the last triangle, when [eq]#i# is either
316even or odd.
317For the purposes of this table, both the first vertex and first triangle are
318numbered [eq]#0#.
319
320[[trigenadj]]
321.Triangles generated by triangle strips with adjacency
322[options="header", cols="2,1,1,1,1,1,1"]
323|====
324|                                3+| Primitive Vertices                                         3+| Adjacent Vertices
325| Primitive                        | 1st                | 2nd                | 3rd                | 1/2         | 2/3                | 3/1
326| only ([eq]#i = 0, n = 1#)        | 0                  | 2                  | 4                  | 1           | 5                  | 3
327| first ([eq]#i = 0#)              | 0                  | 2                  | 4                  | 1           | 6                  | 3
328| middle ([eq]#i# odd)             | [eq]#2 i {plus} 2# | [eq]#2 i#          | [eq]#2 i {plus} 4# | [eq]#2 i-2# | [eq]#2 i {plus} 3# | [eq]#2 i {plus} 6#
329| middle ([eq]#i# even)            | [eq]#2 i#          | [eq]#2 i {plus} 2# | [eq]#2 i {plus} 4# | [eq]#2 i-2# | [eq]#2 i {plus} 6# | [eq]#2 i {plus} 3#
330| last ([eq]#i=n-1#, [eq]#i# odd)  | [eq]#2 i {plus} 2# | [eq]#2 i#          | [eq]#2 i {plus} 4# | [eq]#2 i-2# | [eq]#2 i {plus} 3# | [eq]#2 i {plus} 5#
331| last ([eq]#i=n-1#, [eq]#i# even) | [eq]#2 i#          | [eq]#2 i {plus} 2# | [eq]#2 i {plus} 4# | [eq]#2 i-2# | [eq]#2 i {plus} 5# | [eq]#2 i {plus} 3#
332|====
333
334
335[[drawing-primitive-topologies-patches]]
336=== Separate Patches
337
338Separate patches are specified with pname:topology
339ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST.
340A patch is an ordered collection of vertices used for
341<<tessellation,primitive tessellation>>.
342The vertices comprising a patch have no implied geometric ordering, and are
343used by tessellation shaders and the fixed-function tessellator to generate
344new point, line, or triangle primitives.
345
346Each patch in the series has a fixed number of vertices, specified by the
347pname:patchControlPoints member of the
348slink:VkPipelineTessellationStateCreateInfo structure passed to
349flink:vkCreateGraphicsPipelines.
350Once assembled and vertex shaded, these patches are provided as input to the
351tessellation control shader stage.
352
353If the number of vertices in a patch is given by [eq]#v#, vertices [eq]#v
354{times} i# through [eq]#v {times} i {plus} v - 1# (in that order) determine
355a patch for each [eq]#i = 0, 1, ..., n-1#, where there are [eq]#v {times} n
356{plus} k# vertices.
357[eq]#k# is in the range [eq]#[0, v - 1]#; if [eq]#k# is not zero, the final
358[eq]#k# vertices are ignored.
359
360
361[[drawing-primitive-order]]
362== Primitive Order
363
364Primitives generated by <<drawing, drawing commands>> progress through the
365stages of the <<synchronization-pipeline-stages-types, graphics pipeline>>
366in _primitive order_.
367Primitive order is initially determined in the following way:
368
369  . Submission order determines the initial ordering
370  . For indirect draw commands, the order in which accessed instances of the
371    slink:VkDrawIndirectCommand are stored in pname:buffer, from lower
372    indirect buffer addresses to higher addresses.
373  . If a draw command includes multiple instances, the order in which
374    instances are executed, from lower numbered instances to higher.
375  . The order in which primitives are specified by a draw command:
376  ** For non-indexed draws, from vertices with a lower numbered
377     code:vertexIndex to a higher numbered code:vertexIndex.
378  ** For indexed draws, vertices sourced from a lower index buffer addresses
379     to higher addresses.
380
381Within this order implementations further sort primitives:
382
383[start=5]
384  . If tessellation shading is active, by an implementation-dependent order
385    of new primitives generated by <<tessellation-primitive-order,
386    tessellation>>.
387  . If geometry shading is active, by the order new primitives are generated
388    by <<geometry-ordering, geometry shading>>.
389  . If the <<primsrast-polygonmode,polygon mode>> is not
390    ename:VK_POLYGON_MODE_FILL,
391ifdef::VK_NV_fill_rectangle[]
392    or ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV,
393endif::VK_NV_fill_rectangle[]
394    by an implementation-dependent ordering of the new primitives generated
395    within the original primitive.
396
397Primitive order is later used to define <<primrast-order, rasterization
398order>>, which determines the order in which fragments output results to a
399framebuffer.
400
401
402== Programmable Primitive Shading
403
404Once primitives are assembled, they proceed to the vertex shading stage of
405the pipeline.
406If the draw includes multiple instances, then the set of primitives is sent
407to the vertex shading stage multiple times, once for each instance.
408
409It is undefined whether vertex shading occurs on vertices that are discarded
410as part of incomplete primitives, but if it does occur then it operates as
411if they were vertices in complete primitives and such invocations can: have
412side effects.
413
414Vertex shading receives two per-vertex inputs from the primitive assembly
415stage - the code:vertexIndex and the code:instanceIndex.
416How these values are generated is defined below, with each command.
417
418Drawing commands fall roughly into two categories:
419
420  * Non-indexed drawing commands present a sequential code:vertexIndex to
421    the vertex shader.
422    The sequential index is generated automatically by the device (see
423    <<fxvertex,Fixed-Function Vertex Processing>> for details on both
424    specifying the vertex attributes indexed by code:vertexIndex, as well as
425    binding vertex buffers containing those attributes to a command buffer).
426    These commands are:
427  ** flink:vkCmdDraw
428  ** flink:vkCmdDrawIndirect
429ifdef::VK_KHR_draw_indirect_count[]
430  ** flink:vkCmdDrawIndirectCountKHR
431endif::VK_KHR_draw_indirect_count[]
432ifdef::VK_AMD_draw_indirect_count[]
433  ** flink:vkCmdDrawIndirectCountAMD.
434endif::VK_AMD_draw_indirect_count[]
435  * Indexed drawing commands read index values from an _index buffer_ and
436    use this to compute the code:vertexIndex value for the vertex shader.
437    These commands are:
438  ** flink:vkCmdDrawIndexed
439  ** flink:vkCmdDrawIndexedIndirect
440ifdef::VK_KHR_draw_indirect_count[]
441  ** flink:vkCmdDrawIndexedIndirectCountKHR
442endif::VK_KHR_draw_indirect_count[]
443ifdef::VK_AMD_draw_indirect_count[]
444  ** flink:vkCmdDrawIndexedIndirectCountAMD.
445endif::VK_AMD_draw_indirect_count[]
446
447
448[open,refpage='vkCmdBindIndexBuffer',desc='Bind an index buffer to a command buffer',type='protos']
449--
450
451To bind an index buffer to a command buffer, call:
452
453include::../api/protos/vkCmdBindIndexBuffer.txt[]
454
455  * pname:commandBuffer is the command buffer into which the command is
456    recorded.
457  * pname:buffer is the buffer being bound.
458  * pname:offset is the starting offset in bytes within pname:buffer used in
459    index buffer address calculations.
460  * pname:indexType is a elink:VkIndexType value specifying whether indices
461    are treated as 16 bits or 32 bits.
462
463.Valid Usage
464****
465  * [[VUID-vkCmdBindIndexBuffer-offset-00431]]
466    pname:offset must: be less than the size of pname:buffer
467  * [[VUID-vkCmdBindIndexBuffer-offset-00432]]
468    The sum of pname:offset and the address of the range of
469    sname:VkDeviceMemory object that is backing pname:buffer, must: be a
470    multiple of the type indicated by pname:indexType
471  * [[VUID-vkCmdBindIndexBuffer-buffer-00433]]
472    pname:buffer must: have been created with the
473    ename:VK_BUFFER_USAGE_INDEX_BUFFER_BIT flag
474  * [[VUID-vkCmdBindIndexBuffer-buffer-00434]]
475    If pname:buffer is non-sparse then it must: be bound completely and
476    contiguously to a single sname:VkDeviceMemory object
477****
478
479include::../validity/protos/vkCmdBindIndexBuffer.txt[]
480--
481
482
483[open,refpage='VkIndexType',desc='Type of index buffer indices',type='enums']
484--
485
486Possible values of flink:vkCmdBindIndexBuffer::pname:indexType, specifying
487the size of indices, are:
488
489include::../api/enums/VkIndexType.txt[]
490
491  * ename:VK_INDEX_TYPE_UINT16 specifies that indices are 16-bit unsigned
492    integer values.
493  * ename:VK_INDEX_TYPE_UINT32 specifies that indices are 32-bit unsigned
494    integer values.
495
496--
497
498The parameters for each drawing command are specified directly in the
499command or read from buffer memory, depending on the command.
500Drawing commands that source their parameters from buffer memory are known
501as _indirect_ drawing commands.
502
503All drawing commands interact with the
504<<features-features-robustBufferAccess, Robust Buffer Access>> feature.
505
506[open,refpage='vkCmdDraw',desc='Draw primitives',type='protos']
507--
508
509To record a non-indexed draw, call:
510
511include::../api/protos/vkCmdDraw.txt[]
512
513  * pname:commandBuffer is the command buffer into which the command is
514    recorded.
515  * pname:vertexCount is the number of vertices to draw.
516  * pname:instanceCount is the number of instances to draw.
517  * pname:firstVertex is the index of the first vertex to draw.
518  * pname:firstInstance is the instance ID of the first instance to draw.
519
520When the command is executed, primitives are assembled using the current
521primitive topology and pname:vertexCount consecutive vertex indices with the
522first code:vertexIndex value equal to pname:firstVertex.
523The primitives are drawn pname:instanceCount times with code:instanceIndex
524starting with pname:firstInstance and increasing sequentially for each
525instance.
526The assembled primitives execute the bound graphics pipeline.
527
528.Valid Usage
529****
530  * [[VUID-vkCmdDraw-renderPass-00435]]
531    The current render pass must: be <<renderpass-compatibility,compatible>>
532    with the pname:renderPass member of the
533    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
534    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
535  * [[VUID-vkCmdDraw-subpass-00436]]
536    The subpass index of the current render pass must: be equal to the
537    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
538    specified when creating the sname:VkPipeline bound to
539    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
540  * [[VUID-vkCmdDraw-None-00437]]
541    For each set _n_ that is statically used by the sname:VkPipeline bound
542    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
543    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
544    sname:VkPipelineLayout that is compatible for set _n_, with the
545    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
546    described in <<descriptorsets-compatibility>>
547  * [[VUID-vkCmdDraw-None-00438]]
548    For each push constant that is statically used by the sname:VkPipeline
549    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
550    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
551    sname:VkPipelineLayout that is compatible for push constants, with the
552    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
553    described in <<descriptorsets-compatibility>>
554  * [[VUID-vkCmdDraw-None-00439]]
555    Descriptors in each bound descriptor set, specified via
556    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
557    used by the bound sname:VkPipeline object, specified via
558    fname:vkCmdBindPipeline
559  * [[VUID-vkCmdDraw-None-00440]]
560    All vertex input bindings accessed via vertex input variables declared
561    in the vertex shader entry point's interface must: have valid buffers
562    bound
563  * [[VUID-vkCmdDraw-None-00441]]
564    For a given vertex buffer binding, any attribute data fetched must: be
565    entirely contained within the corresponding vertex buffer binding, as
566    described in <<fxvertex-input>>
567  * [[VUID-vkCmdDraw-None-00442]]
568    A valid graphics pipeline must: be bound to the current command buffer
569    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
570  * [[VUID-vkCmdDraw-None-00443]]
571    If the sname:VkPipeline object bound to
572    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
573    state must: have been set on the current command buffer
574  * [[VUID-vkCmdDraw-None-00444]]
575    Every input attachment used by the current subpass must: be bound to the
576    pipeline via a descriptor set
577  * [[VUID-vkCmdDraw-None-00445]]
578    If any sname:VkSampler object that is accessed from a shader by the
579    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
580    unnormalized coordinates, it must: not be used to sample from any
581    sname:VkImage with a sname:VkImageView of the type
582    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
583    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
584    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
585  * [[VUID-vkCmdDraw-None-00446]]
586    If any sname:VkSampler object that is accessed from a shader by the
587    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
588    unnormalized coordinates, it must: not be used with any of the SPIR-V
589    `OpImageSample*` or `OpImageSparseSample*` instructions with
590    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
591    stage
592  * [[VUID-vkCmdDraw-None-00447]]
593    If any sname:VkSampler object that is accessed from a shader by the
594    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
595    unnormalized coordinates, it must: not be used with any of the SPIR-V
596    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
597    LOD bias or any offset values, in any shader stage
598  * [[VUID-vkCmdDraw-None-00448]]
599    If the <<features-features-robustBufferAccess,robust buffer access>>
600    feature is not enabled, and any shader stage in the sname:VkPipeline
601    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
602    buffer, it must: not access values outside of the range of that buffer
603    specified in the bound descriptor set
604  * [[VUID-vkCmdDraw-None-00449]]
605    If the <<features-features-robustBufferAccess,robust buffer access>>
606    feature is not enabled, and any shader stage in the sname:VkPipeline
607    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
608    buffer, it must: not access values outside of the range of that buffer
609    specified in the bound descriptor set
610  * [[VUID-vkCmdDraw-None-01499]]
611    Image subresources used as attachments in the current render pass must:
612    not be accessed in any way other than as an attachment by this command.
613  * [[VUID-vkCmdDraw-None-02009]]
614    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
615    result of this command, then the image view's
616    <<resources-image-view-format-features,format features>> must: contain
617    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
618ifdef::VK_IMG_filter_cubic[]
619  * [[VUID-vkCmdDraw-None-02010]]
620    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
621    result of this command, then the image view's
622    <<resources-image-view-format-features,format features>> must: contain
623    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
624  * [[VUID-vkCmdDraw-None-00452]]
625    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
626    result of this command must: not have a elink:VkImageViewType of
627    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
628    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
629endif::VK_IMG_filter_cubic[]
630ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
631  * [[VUID-vkCmdDraw-maxMultiviewInstanceIndex-00453]]
632    If the draw is recorded in a render pass instance with multiview
633    enabled, the maximum instance index must: be less than or equal to
634    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
635endif::VK_VERSION_1_1,VK_KHR_multiview[]
636ifdef::VK_VERSION_1_1[]
637  * [[VUID-vkCmdDraw-commandBuffer-01850]]
638    If pname:commandBuffer is an unprotected command buffer, and any
639    pipeline stage in the sname:VkPipeline object bound to
640    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
641    or buffer, that image or buffer must: not be a protected image or
642    protected buffer.
643  * [[VUID-vkCmdDraw-commandBuffer-01851]]
644    If pname:commandBuffer is a protected command buffer, and any pipeline
645    stage in the sname:VkPipeline object bound to
646    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
647    that image or buffer must: not be an unprotected image or unprotected
648    buffer.
649  * [[VUID-vkCmdDraw-commandBuffer-01852]]
650    If pname:commandBuffer is a protected command buffer, and any pipeline
651    stage other than the framebuffer-space pipeline stages in the
652    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
653    reads from or writes to any image or buffer, the image or buffer must:
654    not be a protected image or protected buffer.
655endif::VK_VERSION_1_1[]
656ifdef::VK_EXT_sample_locations[]
657  * [[VUID-vkCmdDraw-sampleLocationsEnable-01512]]
658    If the bound graphics pipeline was created with
659    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
660    set to ename:VK_TRUE and the current subpass has a depth/stencil
661    attachment, then that attachment must: have been created with the
662    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
663endif::VK_EXT_sample_locations[]
664****
665
666include::../validity/protos/vkCmdDraw.txt[]
667--
668
669[open,refpage='vkCmdDrawIndexed',desc='Issue an indexed draw into a command buffer',type='protos']
670--
671
672To record an indexed draw, call:
673
674include::../api/protos/vkCmdDrawIndexed.txt[]
675
676  * pname:commandBuffer is the command buffer into which the command is
677    recorded.
678  * pname:indexCount is the number of vertices to draw.
679  * pname:instanceCount is the number of instances to draw.
680  * pname:firstIndex is the base index within the index buffer.
681  * pname:vertexOffset is the value added to the vertex index before
682    indexing into the vertex buffer.
683  * pname:firstInstance is the instance ID of the first instance to draw.
684
685When the command is executed, primitives are assembled using the current
686primitive topology and pname:indexCount vertices whose indices are retrieved
687from the index buffer.
688The index buffer is treated as an array of tightly packed unsigned integers
689of size defined by the flink:vkCmdBindIndexBuffer::pname:indexType parameter
690with which the buffer was bound.
691
692The first vertex index is at an offset of pname:firstIndex * code:indexSize
693+ pname:offset within the bound index buffer, where pname:offset is the
694offset specified by fname:vkCmdBindIndexBuffer and code:indexSize is the
695byte size of the type specified by pname:indexType.
696Subsequent index values are retrieved from consecutive locations in the
697index buffer.
698Indices are first compared to the primitive restart value, then zero
699extended to 32 bits (if the code:indexType is ename:VK_INDEX_TYPE_UINT16)
700and have pname:vertexOffset added to them, before being supplied as the
701code:vertexIndex value.
702
703The primitives are drawn pname:instanceCount times with code:instanceIndex
704starting with pname:firstInstance and increasing sequentially for each
705instance.
706The assembled primitives execute the bound graphics pipeline.
707
708.Valid Usage
709****
710  * [[VUID-vkCmdDrawIndexed-renderPass-00454]]
711    The current render pass must: be <<renderpass-compatibility,compatible>>
712    with the pname:renderPass member of the
713    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
714    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
715  * [[VUID-vkCmdDrawIndexed-subpass-00455]]
716    The subpass index of the current render pass must: be equal to the
717    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
718    specified when creating the sname:VkPipeline bound to
719    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
720  * [[VUID-vkCmdDrawIndexed-None-00456]]
721    For each set _n_ that is statically used by the sname:VkPipeline bound
722    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
723    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
724    sname:VkPipelineLayout that is compatible for set _n_, with the
725    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
726    described in <<descriptorsets-compatibility>>
727  * [[VUID-vkCmdDrawIndexed-None-00457]]
728    For each push constant that is statically used by the sname:VkPipeline
729    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
730    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
731    sname:VkPipelineLayout that is compatible for push constants, with the
732    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
733    described in <<descriptorsets-compatibility>>
734  * [[VUID-vkCmdDrawIndexed-None-00458]]
735    Descriptors in each bound descriptor set, specified via
736    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
737    used by the bound sname:VkPipeline object, specified via
738    fname:vkCmdBindPipeline
739  * [[VUID-vkCmdDrawIndexed-None-00459]]
740    All vertex input bindings accessed via vertex input variables declared
741    in the vertex shader entry point's interface must: have valid buffers
742    bound
743  * [[VUID-vkCmdDrawIndexed-None-00460]]
744    For a given vertex buffer binding, any attribute data fetched must: be
745    entirely contained within the corresponding vertex buffer binding, as
746    described in <<fxvertex-input>>
747  * [[VUID-vkCmdDrawIndexed-None-00461]]
748    A valid graphics pipeline must: be bound to the current command buffer
749    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
750  * [[VUID-vkCmdDrawIndexed-None-00462]]
751    If the sname:VkPipeline object bound to
752    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
753    state must: have been set on the current command buffer
754  * [[VUID-vkCmdDrawIndexed-indexSize-00463]]
755    [eq]#(pname:indexSize * (pname:firstIndex {plus} pname:indexCount)
756    {plus} pname:offset)# must: be less than or equal to the size of the
757    bound index buffer, with indexSize being based on the type specified by
758    pname:indexType, where the index buffer, pname:indexType, and
759    pname:offset are specified via fname:vkCmdBindIndexBuffer
760  * [[VUID-vkCmdDrawIndexed-None-00464]]
761    Every input attachment used by the current subpass must: be bound to the
762    pipeline via a descriptor set
763  * [[VUID-vkCmdDrawIndexed-None-00465]]
764    If any sname:VkSampler object that is accessed from a shader by the
765    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
766    unnormalized coordinates, it must: not be used to sample from any
767    sname:VkImage with a sname:VkImageView of the type
768    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
769    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
770    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
771  * [[VUID-vkCmdDrawIndexed-None-00466]]
772    If any sname:VkSampler object that is accessed from a shader by the
773    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
774    unnormalized coordinates, it must: not be used with any of the SPIR-V
775    `OpImageSample*` or `OpImageSparseSample*` instructions with
776    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
777    stage
778  * [[VUID-vkCmdDrawIndexed-None-00467]]
779    If any sname:VkSampler object that is accessed from a shader by the
780    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
781    unnormalized coordinates, it must: not be used with any of the SPIR-V
782    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
783    LOD bias or any offset values, in any shader stage
784  * [[VUID-vkCmdDrawIndexed-None-00468]]
785    If the <<features-features-robustBufferAccess,robust buffer access>>
786    feature is not enabled, and any shader stage in the sname:VkPipeline
787    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
788    buffer, it must: not access values outside of the range of that buffer
789    specified in the bound descriptor set
790  * [[VUID-vkCmdDrawIndexed-None-00469]]
791    If the <<features-features-robustBufferAccess,robust buffer access>>
792    feature is not enabled, and any shader stage in the sname:VkPipeline
793    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
794    buffer, it must: not access values outside of the range of that buffer
795    specified in the bound descriptor set
796  * [[VUID-vkCmdDrawIndexed-None-02011]]
797    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
798    result of this command, then the image view's
799    <<resources-image-view-format-features,format features>> must: contain
800    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
801  * [[VUID-vkCmdDrawIndexed-None-01500]]
802    Image subresources used as attachments in the current render pass must:
803    not be accessed in any way other than as an attachment by this command.
804ifdef::VK_IMG_filter_cubic[]
805  * [[VUID-vkCmdDrawIndexed-None-02012]]
806    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
807    result of this command, then the image view's
808    <<resources-image-view-format-features,format features>> must: contain
809    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
810  * [[VUID-vkCmdDrawIndexed-None-00472]]
811    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
812    result of this command must: not have a elink:VkImageViewType of
813    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
814    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
815endif::VK_IMG_filter_cubic[]
816ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
817  * [[VUID-vkCmdDrawIndexed-maxMultiviewInstanceIndex-00473]]
818    If the draw is recorded in a render pass instance with multiview
819    enabled, the maximum instance index must: be less than or equal to
820    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
821endif::VK_VERSION_1_1,VK_KHR_multiview[]
822ifdef::VK_VERSION_1_1[]
823  * [[VUID-vkCmdDrawIndexed-commandBuffer-01853]]
824    If pname:commandBuffer is an unprotected command buffer, and any
825    pipeline stage in the sname:VkPipeline object bound to
826    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
827    or buffer, that image or buffer must: not be a protected image or
828    protected buffer.
829  * [[VUID-vkCmdDrawIndexed-commandBuffer-01854]]
830    If pname:commandBuffer is a protected command buffer, and any pipeline
831    stage in the sname:VkPipeline object bound to
832    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
833    that image or buffer must: not be an unprotected image or unprotected
834    buffer.
835  * [[VUID-vkCmdDrawIndexed-commandBuffer-01855]]
836    If pname:commandBuffer is a protected command buffer, and any pipeline
837    stage other than the framebuffer-space pipeline stages in the
838    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
839    reads from or writes to any image or buffer, the image or buffer must:
840    not be a protected image or protected buffer.
841endif::VK_VERSION_1_1[]
842ifdef::VK_EXT_sample_locations[]
843  * [[VUID-vkCmdDrawIndexed-sampleLocationsEnable-01513]]
844    If the bound graphics pipeline was created with
845    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
846    set to ename:VK_TRUE and the current subpass has a depth/stencil
847    attachment, then that attachment must: have been created with the
848    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
849endif::VK_EXT_sample_locations[]
850****
851
852include::../validity/protos/vkCmdDrawIndexed.txt[]
853--
854
855[open,refpage='vkCmdDrawIndirect',desc='Issue an indirect draw into a command buffer',type='protos']
856--
857
858To record a non-indexed indirect draw, call:
859
860include::../api/protos/vkCmdDrawIndirect.txt[]
861
862  * pname:commandBuffer is the command buffer into which the command is
863    recorded.
864  * pname:buffer is the buffer containing draw parameters.
865  * pname:offset is the byte offset into pname:buffer where parameters
866    begin.
867  * pname:drawCount is the number of draws to execute, and can: be zero.
868  * pname:stride is the byte stride between successive sets of draw
869    parameters.
870
871fname:vkCmdDrawIndirect behaves similarly to flink:vkCmdDraw except that the
872parameters are read by the device from a buffer during execution.
873pname:drawCount draws are executed by the command, with parameters taken
874from pname:buffer starting at pname:offset and increasing by pname:stride
875bytes for each successive draw.
876The parameters of each draw are encoded in an array of
877slink:VkDrawIndirectCommand structures.
878If pname:drawCount is less than or equal to one, pname:stride is ignored.
879
880.Valid Usage
881****
882  * [[VUID-vkCmdDrawIndirect-buffer-00474]]
883    If pname:buffer is non-sparse then it must: be bound completely and
884    contiguously to a single sname:VkDeviceMemory object
885  * [[VUID-vkCmdDrawIndirect-buffer-01660]]
886    pname:buffer must: have been created with the
887    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
888  * [[VUID-vkCmdDrawIndirect-offset-00475]]
889    pname:offset must: be a multiple of `4`
890  * [[VUID-vkCmdDrawIndirect-drawCount-00476]]
891    If pname:drawCount is greater than `1`, pname:stride must: be a multiple
892    of `4` and must: be greater than or equal to
893    code:sizeof(sname:VkDrawIndirectCommand)
894  * [[VUID-vkCmdDrawIndirect-drawCount-00477]]
895    If the <<features-features-multiDrawIndirect,multi-draw indirect>>
896    feature is not enabled, pname:drawCount must: be `0` or `1`
897  * [[VUID-vkCmdDrawIndirect-firstInstance-00478]]
898    If the
899    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
900    feature is not enabled, all the pname:firstInstance members of the
901    sname:VkDrawIndirectCommand structures accessed by this command must: be
902    code:0
903  * [[VUID-vkCmdDrawIndirect-renderPass-00479]]
904    The current render pass must: be <<renderpass-compatibility,compatible>>
905    with the pname:renderPass member of the
906    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
907    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
908  * [[VUID-vkCmdDrawIndirect-subpass-00480]]
909    The subpass index of the current render pass must: be equal to the
910    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
911    specified when creating the sname:VkPipeline bound to
912    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
913  * [[VUID-vkCmdDrawIndirect-None-00481]]
914    For each set _n_ that is statically used by the sname:VkPipeline bound
915    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
916    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
917    sname:VkPipelineLayout that is compatible for set _n_, with the
918    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
919    described in <<descriptorsets-compatibility>>
920  * [[VUID-vkCmdDrawIndirect-None-00482]]
921    For each push constant that is statically used by the sname:VkPipeline
922    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
923    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
924    sname:VkPipelineLayout that is compatible for push constants, with the
925    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
926    described in <<descriptorsets-compatibility>>
927  * [[VUID-vkCmdDrawIndirect-None-00483]]
928    Descriptors in each bound descriptor set, specified via
929    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
930    used by the bound sname:VkPipeline object, specified via
931    fname:vkCmdBindPipeline
932  * [[VUID-vkCmdDrawIndirect-None-00484]]
933    All vertex input bindings accessed via vertex input variables declared
934    in the vertex shader entry point's interface must: have valid buffers
935    bound
936  * [[VUID-vkCmdDrawIndirect-None-00485]]
937    A valid graphics pipeline must: be bound to the current command buffer
938    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
939  * [[VUID-vkCmdDrawIndirect-None-00486]]
940    If the sname:VkPipeline object bound to
941    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
942    state must: have been set on the current command buffer
943  * [[VUID-vkCmdDrawIndirect-drawCount-00487]]
944    If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus}
945    code:sizeof(slink:VkDrawIndirectCommand))# must: be less than or equal
946    to the size of pname:buffer
947  * [[VUID-vkCmdDrawIndirect-drawCount-00488]]
948    If pname:drawCount is greater than `1`, [eq]#(pname:stride {times}
949    (pname:drawCount - 1) {plus} pname:offset {plus}
950    code:sizeof(slink:VkDrawIndirectCommand))# must: be less than or equal
951    to the size of pname:buffer
952  * [[VUID-vkCmdDrawIndirect-drawCount-00489]]
953    pname:drawCount must: be less than or equal to
954    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
955  * [[VUID-vkCmdDrawIndirect-None-00490]]
956    Every input attachment used by the current subpass must: be bound to the
957    pipeline via a descriptor set
958  * [[VUID-vkCmdDrawIndirect-None-00491]]
959    If any sname:VkSampler object that is accessed from a shader by the
960    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
961    unnormalized coordinates, it must: not be used to sample from any
962    sname:VkImage with a sname:VkImageView of the type
963    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
964    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
965    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
966  * [[VUID-vkCmdDrawIndirect-None-00492]]
967    If any sname:VkSampler object that is accessed from a shader by the
968    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
969    unnormalized coordinates, it must: not be used with any of the SPIR-V
970    `OpImageSample*` or `OpImageSparseSample*` instructions with
971    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
972    stage
973  * [[VUID-vkCmdDrawIndirect-None-00493]]
974    If any sname:VkSampler object that is accessed from a shader by the
975    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
976    unnormalized coordinates, it must: not be used with any of the SPIR-V
977    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
978    LOD bias or any offset values, in any shader stage
979  * [[VUID-vkCmdDrawIndirect-None-00494]]
980    If the <<features-features-robustBufferAccess,robust buffer access>>
981    feature is not enabled, and any shader stage in the sname:VkPipeline
982    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
983    buffer, it must: not access values outside of the range of that buffer
984    specified in the bound descriptor set
985  * [[VUID-vkCmdDrawIndirect-None-00495]]
986    If the <<features-features-robustBufferAccess,robust buffer access>>
987    feature is not enabled, and any shader stage in the sname:VkPipeline
988    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
989    buffer, it must: not access values outside of the range of that buffer
990    specified in the bound descriptor set
991  * [[VUID-vkCmdDrawIndirect-None-02013]]
992    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
993    result of this command, then the image view's
994    <<resources-image-view-format-features,format features>> must: contain
995    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
996  * [[VUID-vkCmdDrawIndirect-None-01501]]
997    Image subresources used as attachments in the current render pass must:
998    not be accessed in any way other than as an attachment by this command.
999ifdef::VK_IMG_filter_cubic[]
1000  * [[VUID-vkCmdDrawIndirect-None-02014]]
1001    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
1002    result of this command, then the image view's
1003    <<resources-image-view-format-features,format features>> must: contain
1004    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
1005  * [[VUID-vkCmdDrawIndirect-None-00498]]
1006    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
1007    result of this command must: not have a elink:VkImageViewType of
1008    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
1009    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
1010endif::VK_IMG_filter_cubic[]
1011ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
1012  * [[VUID-vkCmdDrawIndirect-maxMultiviewInstanceIndex-00499]]
1013    If the draw is recorded in a render pass instance with multiview
1014    enabled, the maximum instance index must: be less than or equal to
1015    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
1016endif::VK_VERSION_1_1,VK_KHR_multiview[]
1017ifdef::VK_VERSION_1_1[]
1018  * [[VUID-vkCmdDrawIndirect-commandBuffer-01856]]
1019    If pname:commandBuffer is an unprotected command buffer, and any
1020    pipeline stage in the sname:VkPipeline object bound to
1021    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
1022    or buffer, that image or buffer must: not be a protected image or
1023    protected buffer.
1024  * [[VUID-vkCmdDrawIndirect-commandBuffer-01857]]
1025    If pname:commandBuffer is a protected command buffer, and any pipeline
1026    stage in the sname:VkPipeline object bound to
1027    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
1028    that image or buffer must: not be an unprotected image or unprotected
1029    buffer.
1030  * [[VUID-vkCmdDrawIndirect-commandBuffer-01858]]
1031    If pname:commandBuffer is a protected command buffer, and any pipeline
1032    stage other than the framebuffer-space pipeline stages in the
1033    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1034    reads from or writes to any image or buffer, the image or buffer must:
1035    not be a protected image or protected buffer.
1036endif::VK_VERSION_1_1[]
1037ifdef::VK_EXT_sample_locations[]
1038  * [[VUID-vkCmdDrawIndirect-sampleLocationsEnable-01514]]
1039    If the bound graphics pipeline was created with
1040    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
1041    set to ename:VK_TRUE and the current subpass has a depth/stencil
1042    attachment, then that attachment must: have been created with the
1043    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
1044endif::VK_EXT_sample_locations[]
1045****
1046
1047include::../validity/protos/vkCmdDrawIndirect.txt[]
1048--
1049
1050[open,refpage='VkDrawIndirectCommand',desc='Structure specifying a draw indirect command',type='structs',xrefs='vkCmdDrawIndirect']
1051--
1052
1053The sname:VkDrawIndirectCommand structure is defined as:
1054
1055include::../api/structs/VkDrawIndirectCommand.txt[]
1056
1057  * pname:vertexCount is the number of vertices to draw.
1058  * pname:instanceCount is the number of instances to draw.
1059  * pname:firstVertex is the index of the first vertex to draw.
1060  * pname:firstInstance is the instance ID of the first instance to draw.
1061
1062The members of sname:VkDrawIndirectCommand have the same meaning as the
1063similarly named parameters of flink:vkCmdDraw.
1064
1065.Valid Usage
1066****
1067  * [[VUID-VkDrawIndirectCommand-None-00500]]
1068    For a given vertex buffer binding, any attribute data fetched must: be
1069    entirely contained within the corresponding vertex buffer binding, as
1070    described in <<fxvertex-input>>
1071  * [[VUID-VkDrawIndirectCommand-firstInstance-00501]]
1072    If the
1073    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1074    feature is not enabled, pname:firstInstance must: be code:0
1075****
1076
1077include::../validity/structs/VkDrawIndirectCommand.txt[]
1078
1079--
1080
1081ifdef::VK_KHR_draw_indirect_count[]
1082[open,refpage='vkCmdDrawIndirectCountKHR',desc='Perform an indirect draw with the draw count sourced from a buffer',type='protos']
1083--
1084
1085To record a non-indexed draw call with a draw call count sourced from a
1086buffer, call:
1087
1088include::../api/protos/vkCmdDrawIndirectCountKHR.txt[]
1089
1090  * pname:commandBuffer is the command buffer into which the command is
1091    recorded.
1092  * pname:buffer is the buffer containing draw parameters.
1093  * pname:offset is the byte offset into pname:buffer where parameters
1094    begin.
1095  * pname:countBuffer is the buffer containing the draw count.
1096  * pname:countBufferOffset is the byte offset into pname:countBuffer where
1097    the draw count begins.
1098  * pname:maxDrawCount specifies the maximum number of draws that will be
1099    executed.
1100    The actual number of executed draw calls is the minimum of the count
1101    specified in pname:countBuffer and pname:maxDrawCount.
1102  * pname:stride is the byte stride between successive sets of draw
1103    parameters.
1104
1105fname:vkCmdDrawIndirectCountKHR behaves similarly to flink:vkCmdDrawIndirect
1106except that the draw count is read by the device from a buffer during
1107execution.
1108The command will read an unsigned 32-bit integer from pname:countBuffer
1109located at pname:countBufferOffset and use this as the draw count.
1110
1111.Valid Usage
1112****
1113  * [[VUID-vkCmdDrawIndirectCountKHR-buffer-03104]]
1114    If pname:buffer is non-sparse then it must: be bound completely and
1115    contiguously to a single sname:VkDeviceMemory object
1116  * [[VUID-vkCmdDrawIndirectCountKHR-buffer-03105]]
1117    pname:buffer must: have been created with the
1118    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1119  * [[VUID-vkCmdDrawIndirectCountKHR-countBuffer-03106]]
1120    If pname:countBuffer is non-sparse then it must: be bound completely and
1121    contiguously to a single sname:VkDeviceMemory object
1122  * [[VUID-vkCmdDrawIndirectCountKHR-countBuffer-03107]]
1123    pname:countBuffer must: have been created with the
1124    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1125  * [[VUID-vkCmdDrawIndirectCountKHR-offset-03108]]
1126    pname:offset must: be a multiple of `4`
1127  * [[VUID-vkCmdDrawIndirectCountKHR-countBufferOffset-03109]]
1128    pname:countBufferOffset must: be a multiple of `4`
1129  * [[VUID-vkCmdDrawIndirectCountKHR-stride-03110]]
1130    pname:stride must: be a multiple of `4` and must: be greater than or
1131    equal to sizeof(sname:VkDrawIndirectCommand)
1132  * [[VUID-vkCmdDrawIndirectCountKHR-maxDrawCount-03111]]
1133    If pname:maxDrawCount is greater than or equal to `1`,
1134    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
1135    {plus} sizeof(sname:VkDrawIndirectCommand))# must: be less than or equal
1136    to the size of pname:buffer
1137  * [[VUID-vkCmdDrawIndirectCountKHR-firstInstance-03112]]
1138    If the
1139    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1140    feature is not enabled, all the pname:firstInstance members of the
1141    sname:VkDrawIndirectCommand structures accessed by this command must: be
1142    code:0
1143  * [[VUID-vkCmdDrawIndirectCountKHR-renderPass-03113]]
1144    The current render pass must: be <<renderpass-compatibility,compatible>>
1145    with the pname:renderPass member of the
1146    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
1147    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1148  * [[VUID-vkCmdDrawIndirectCountKHR-subpass-03114]]
1149    The subpass index of the current render pass must: be equal to the
1150    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
1151    specified when creating the sname:VkPipeline bound to
1152    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1153  * [[VUID-vkCmdDrawIndirectCountKHR-None-03115]]
1154    For each set _n_ that is statically used by the sname:VkPipeline bound
1155    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
1156    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1157    sname:VkPipelineLayout that is compatible for set _n_, with the
1158    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1159    described in <<descriptorsets-compatibility>>
1160  * [[VUID-vkCmdDrawIndirectCountKHR-None-03116]]
1161    For each push constant that is statically used by the sname:VkPipeline
1162    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
1163    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1164    sname:VkPipelineLayout that is compatible for push constants, with the
1165    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1166    described in <<descriptorsets-compatibility>>
1167  * [[VUID-vkCmdDrawIndirectCountKHR-None-03117]]
1168    Descriptors in each bound descriptor set, specified via
1169    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
1170    used by the bound sname:VkPipeline object, specified via
1171    fname:vkCmdBindPipeline
1172  * [[VUID-vkCmdDrawIndirectCountKHR-None-03118]]
1173    All vertex input bindings accessed via vertex input variables declared
1174    in the vertex shader entry point's interface must: have valid buffers
1175    bound
1176  * [[VUID-vkCmdDrawIndirectCountKHR-None-03119]]
1177    A valid graphics pipeline must: be bound to the current command buffer
1178    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1179  * [[VUID-vkCmdDrawIndirectCountKHR-None-03120]]
1180    If the sname:VkPipeline object bound to
1181    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
1182    state must: have been set on the current command buffer
1183  * [[VUID-vkCmdDrawIndirectCountKHR-countBuffer-03121]]
1184    If the count stored in pname:countBuffer is equal to `1`,
1185    [eq]#(pname:offset {plus} sizeof(sname:VkDrawIndirectCommand))# must: be
1186    less than or equal to the size of pname:buffer
1187  * [[VUID-vkCmdDrawIndirectCountKHR-countBuffer-03122]]
1188    If the count stored in pname:countBuffer is greater than `1`,
1189    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
1190    {plus} sizeof(sname:VkDrawIndirectCommand))# must: be less than or equal
1191    to the size of pname:buffer
1192  * [[VUID-vkCmdDrawIndirectCountKHR-countBuffer-03123]]
1193    The count stored in pname:countBuffer must: be less than or equal to
1194    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
1195  * [[VUID-vkCmdDrawIndirectCountKHR-None-03124]]
1196    Every input attachment used by the current subpass must: be bound to the
1197    pipeline via a descriptor set
1198  * [[VUID-vkCmdDrawIndirectCountKHR-None-03125]]
1199    If any sname:VkSampler object that is accessed from a shader by the
1200    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1201    unnormalized coordinates, it must: not be used to sample from any
1202    sname:VkImage with a sname:VkImageView of the type
1203    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
1204    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
1205    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
1206  * [[VUID-vkCmdDrawIndirectCountKHR-None-03126]]
1207    If any sname:VkSampler object that is accessed from a shader by the
1208    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1209    unnormalized coordinates, it must: not be used with any of the SPIR-V
1210    `OpImageSample*` or `OpImageSparseSample*` instructions with
1211    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
1212    stage
1213  * [[VUID-vkCmdDrawIndirectCountKHR-None-03127]]
1214    If any sname:VkSampler object that is accessed from a shader by the
1215    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1216    unnormalized coordinates, it must: not be used with any of the SPIR-V
1217    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
1218    LOD bias or any offset values, in any shader stage
1219  * [[VUID-vkCmdDrawIndirectCountKHR-None-03128]]
1220    If the <<features-features-robustBufferAccess,robust buffer access>>
1221    feature is not enabled, and any shader stage in the sname:VkPipeline
1222    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
1223    buffer, it must: not access values outside of the range of that buffer
1224    specified in the bound descriptor set
1225  * [[VUID-vkCmdDrawIndirectCountKHR-None-03129]]
1226    If the <<features-features-robustBufferAccess,robust buffer access>>
1227    feature is not enabled, and any shader stage in the sname:VkPipeline
1228    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
1229    buffer, it must: not access values outside of the range of that buffer
1230    specified in the bound descriptor set
1231  * [[VUID-vkCmdDrawIndirectCountKHR-None-02015]]
1232    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
1233    result of this command, then the image view's
1234    <<resources-image-view-format-features,format features>> must: contain
1235    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
1236  * [[VUID-vkCmdDrawIndirectCountKHR-None-03131]]
1237    Image subresources used as attachments in the current render pass must:
1238    not be accessed in any way other than as an attachment by this command.
1239ifdef::VK_IMG_filter_cubic[]
1240  * [[VUID-vkCmdDrawIndirectCountKHR-None-02016]]
1241    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
1242    result of this command, then the image view's
1243    <<resources-image-view-format-features,format features>> must: contain
1244    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
1245  * [[VUID-vkCmdDrawIndirectCountKHR-None-03170]]
1246    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
1247    result of this command must: not have a elink:VkImageViewType of
1248    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
1249    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
1250endif::VK_IMG_filter_cubic[]
1251ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
1252  * [[VUID-vkCmdDrawIndirectCountKHR-maxMultiviewInstanceIndex-03132]]
1253    If the draw is recorded in a render pass instance with multiview
1254    enabled, the maximum instance index must: be less than or equal to
1255    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
1256endif::VK_VERSION_1_1,VK_KHR_multiview[]
1257ifdef::VK_VERSION_1_1[]
1258  * [[VUID-vkCmdDrawIndirectCountKHR-commandBuffer-03133]]
1259    If pname:commandBuffer is an unprotected command buffer, and any
1260    pipeline stage in the sname:VkPipeline object bound to
1261    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
1262    or buffer, that image or buffer must: not be a protected image or
1263    protected buffer.
1264  * [[VUID-vkCmdDrawIndirectCountKHR-commandBuffer-03134]]
1265    If pname:commandBuffer is a protected command buffer, and any pipeline
1266    stage in the sname:VkPipeline object bound to
1267    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
1268    that image or buffer must: not be an unprotected image or unprotected
1269    buffer.
1270  * [[VUID-vkCmdDrawIndirectCountKHR-commandBuffer-03135]]
1271    If pname:commandBuffer is a protected command buffer, and any pipeline
1272    stage other than the framebuffer-space pipeline stages in the
1273    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1274    reads from or writes to any image or buffer, the image or buffer must:
1275    not be a protected image or protected buffer.
1276endif::VK_VERSION_1_1[]
1277ifdef::VK_EXT_sample_locations[]
1278  * [[VUID-vkCmdDrawIndirectCountKHR-sampleLocationsEnable-03171]]
1279    If the bound graphics pipeline was created with
1280    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
1281    set to ename:VK_TRUE and the current subpass has a depth/stencil
1282    attachment, then that attachment must: have been created with the
1283    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
1284endif::VK_EXT_sample_locations[]
1285****
1286
1287include::../validity/protos/vkCmdDrawIndirectCountKHR.txt[]
1288
1289--
1290endif::VK_KHR_draw_indirect_count[]
1291
1292ifdef::VK_AMD_draw_indirect_count[]
1293[open,refpage='vkCmdDrawIndirectCountAMD',desc='Perform an indirect draw with the draw count sourced from a buffer',type='protos']
1294--
1295
1296To record a non-indexed draw call with a draw call count sourced from a
1297buffer, call:
1298
1299include::../api/protos/vkCmdDrawIndirectCountAMD.txt[]
1300
1301  * pname:commandBuffer is the command buffer into which the command is
1302    recorded.
1303  * pname:buffer is the buffer containing draw parameters.
1304  * pname:offset is the byte offset into pname:buffer where parameters
1305    begin.
1306  * pname:countBuffer is the buffer containing the draw count.
1307  * pname:countBufferOffset is the byte offset into pname:countBuffer where
1308    the draw count begins.
1309  * pname:maxDrawCount specifies the maximum number of draws that will be
1310    executed.
1311    The actual number of executed draw calls is the minimum of the count
1312    specified in pname:countBuffer and pname:maxDrawCount.
1313  * pname:stride is the byte stride between successive sets of draw
1314    parameters.
1315
1316fname:vkCmdDrawIndirectCountAMD behaves similarly to flink:vkCmdDrawIndirect
1317except that the draw count is read by the device from a buffer during
1318execution.
1319The command will read an unsigned 32-bit integer from pname:countBuffer
1320located at pname:countBufferOffset and use this as the draw count.
1321
1322.Valid Usage
1323****
1324  * [[VUID-vkCmdDrawIndirectCountAMD-buffer-01661]]
1325    If pname:buffer is non-sparse then it must: be bound completely and
1326    contiguously to a single sname:VkDeviceMemory object
1327  * [[VUID-vkCmdDrawIndirectCountAMD-buffer-01662]]
1328    pname:buffer must: have been created with the
1329    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1330  * [[VUID-vkCmdDrawIndirectCountAMD-countBuffer-01663]]
1331    If pname:countBuffer is non-sparse then it must: be bound completely and
1332    contiguously to a single sname:VkDeviceMemory object
1333  * [[VUID-vkCmdDrawIndirectCountAMD-countBuffer-01664]]
1334    pname:countBuffer must: have been created with the
1335    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1336  * [[VUID-vkCmdDrawIndirectCountAMD-offset-00502]]
1337    pname:offset must: be a multiple of `4`
1338  * [[VUID-vkCmdDrawIndirectCountAMD-countBufferOffset-00503]]
1339    pname:countBufferOffset must: be a multiple of `4`
1340  * [[VUID-vkCmdDrawIndirectCountAMD-stride-00504]]
1341    pname:stride must: be a multiple of `4` and must: be greater than or
1342    equal to code:sizeof(sname:VkDrawIndirectCommand)
1343  * [[VUID-vkCmdDrawIndirectCountAMD-maxDrawCount-00505]]
1344    If pname:maxDrawCount is greater than or equal to `1`,
1345    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
1346    {plus} code:sizeof(sname:VkDrawIndirectCommand))# must: be less than or
1347    equal to the size of pname:buffer
1348  * [[VUID-vkCmdDrawIndirectCountAMD-firstInstance-00506]]
1349    If the
1350    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1351    feature is not enabled, all the pname:firstInstance members of the
1352    sname:VkDrawIndirectCommand structures accessed by this command must: be
1353    code:0
1354  * [[VUID-vkCmdDrawIndirectCountAMD-renderPass-00507]]
1355    The current render pass must: be <<renderpass-compatibility,compatible>>
1356    with the pname:renderPass member of the
1357    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
1358    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1359  * [[VUID-vkCmdDrawIndirectCountAMD-subpass-00508]]
1360    The subpass index of the current render pass must: be equal to the
1361    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
1362    specified when creating the sname:VkPipeline bound to
1363    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1364  * [[VUID-vkCmdDrawIndirectCountAMD-None-00509]]
1365    For each set _n_ that is statically used by the sname:VkPipeline bound
1366    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
1367    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1368    sname:VkPipelineLayout that is compatible for set _n_, with the
1369    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1370    described in <<descriptorsets-compatibility>>
1371  * [[VUID-vkCmdDrawIndirectCountAMD-None-00510]]
1372    For each push constant that is statically used by the sname:VkPipeline
1373    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
1374    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1375    sname:VkPipelineLayout that is compatible for push constants, with the
1376    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1377    described in <<descriptorsets-compatibility>>
1378  * [[VUID-vkCmdDrawIndirectCountAMD-None-00511]]
1379    Descriptors in each bound descriptor set, specified via
1380    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
1381    used by the bound sname:VkPipeline object, specified via
1382    fname:vkCmdBindPipeline
1383  * [[VUID-vkCmdDrawIndirectCountAMD-None-00512]]
1384    All vertex input bindings accessed via vertex input variables declared
1385    in the vertex shader entry point's interface must: have valid buffers
1386    bound
1387  * [[VUID-vkCmdDrawIndirectCountAMD-None-00513]]
1388    A valid graphics pipeline must: be bound to the current command buffer
1389    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1390  * [[VUID-vkCmdDrawIndirectCountAMD-None-00514]]
1391    If the sname:VkPipeline object bound to
1392    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
1393    state must: have been set on the current command buffer
1394  * [[VUID-vkCmdDrawIndirectCountAMD-countBuffer-00515]]
1395    If the count stored in pname:countBuffer is equal to `1`,
1396    [eq]#(pname:offset {plus} code:sizeof(sname:VkDrawIndirectCommand))#
1397    must: be less than or equal to the size of pname:buffer
1398  * [[VUID-vkCmdDrawIndirectCountAMD-countBuffer-00516]]
1399    If the count stored in pname:countBuffer is greater than `1`,
1400    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
1401    {plus} code:sizeof(sname:VkDrawIndirectCommand))# must: be less than or
1402    equal to the size of pname:buffer
1403  * [[VUID-vkCmdDrawIndirectCountAMD-countBuffer-00517]]
1404    The count stored in pname:countBuffer must: be less than or equal to
1405    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
1406  * [[VUID-vkCmdDrawIndirectCountAMD-None-00518]]
1407    Every input attachment used by the current subpass must: be bound to the
1408    pipeline via a descriptor set
1409  * [[VUID-vkCmdDrawIndirectCountAMD-None-00519]]
1410    If any sname:VkSampler object that is accessed from a shader by the
1411    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1412    unnormalized coordinates, it must: not be used to sample from any
1413    sname:VkImage with a sname:VkImageView of the type
1414    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
1415    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
1416    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
1417  * [[VUID-vkCmdDrawIndirectCountAMD-None-00520]]
1418    If any sname:VkSampler object that is accessed from a shader by the
1419    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1420    unnormalized coordinates, it must: not be used with any of the SPIR-V
1421    `OpImageSample*` or `OpImageSparseSample*` instructions with
1422    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
1423    stage
1424  * [[VUID-vkCmdDrawIndirectCountAMD-None-00521]]
1425    If any sname:VkSampler object that is accessed from a shader by the
1426    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1427    unnormalized coordinates, it must: not be used with any of the SPIR-V
1428    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
1429    LOD bias or any offset values, in any shader stage
1430  * [[VUID-vkCmdDrawIndirectCountAMD-None-00522]]
1431    If the <<features-features-robustBufferAccess,robust buffer access>>
1432    feature is not enabled, and any shader stage in the sname:VkPipeline
1433    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
1434    buffer, it must: not access values outside of the range of that buffer
1435    specified in the bound descriptor set
1436  * [[VUID-vkCmdDrawIndirectCountAMD-None-00523]]
1437    If the <<features-features-robustBufferAccess,robust buffer access>>
1438    feature is not enabled, and any shader stage in the sname:VkPipeline
1439    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
1440    buffer, it must: not access values outside of the range of that buffer
1441    specified in the bound descriptor set
1442  * [[VUID-vkCmdDrawIndirectCountAMD-None-02017]]
1443    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
1444    result of this command, then the image view's
1445    <<resources-image-view-format-features,format features>> must: contain
1446    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
1447  * [[VUID-vkCmdDrawIndirectCountAMD-None-01502]]
1448    Image subresources used as attachments in the current render pass must:
1449    not be accessed in any way other than as an attachment by this command.
1450ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
1451  * [[VUID-vkCmdDrawIndirectCountAMD-maxMultiviewInstanceIndex-00525]]
1452    If the draw is recorded in a render pass instance with multiview
1453    enabled, the maximum instance index must: be less than or equal to
1454    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
1455endif::VK_VERSION_1_1,VK_KHR_multiview[]
1456ifdef::VK_VERSION_1_1[]
1457  * [[VUID-vkCmdDrawIndirectCountAMD-commandBuffer-01859]]
1458    If pname:commandBuffer is an unprotected command buffer, and any
1459    pipeline stage in the sname:VkPipeline object bound to
1460    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
1461    or buffer, that image or buffer must: not be a protected image or
1462    protected buffer.
1463  * [[VUID-vkCmdDrawIndirectCountAMD-commandBuffer-01860]]
1464    If pname:commandBuffer is a protected command buffer, and any pipeline
1465    stage in the sname:VkPipeline object bound to
1466    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
1467    that image or buffer must: not be an unprotected image or unprotected
1468    buffer.
1469  * [[VUID-vkCmdDrawIndirectCountAMD-commandBuffer-01861]]
1470    If pname:commandBuffer is a protected command buffer, and any pipeline
1471    stage other than the framebuffer-space pipeline stages in the
1472    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1473    reads from or writes to any image or buffer, the image or buffer must:
1474    not be a protected image or protected buffer.
1475endif::VK_VERSION_1_1[]
1476ifdef::VK_EXT_sample_locations[]
1477  * [[VUID-vkCmdDrawIndirectCountAMD-sampleLocationsEnable-01515]]
1478    If the bound graphics pipeline was created with
1479    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
1480    set to ename:VK_TRUE and the current subpass has a depth/stencil
1481    attachment, then that attachment must: have been created with the
1482    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
1483endif::VK_EXT_sample_locations[]
1484****
1485
1486include::../validity/protos/vkCmdDrawIndirectCountAMD.txt[]
1487
1488--
1489endif::VK_AMD_draw_indirect_count[]
1490
1491[open,refpage='vkCmdDrawIndexedIndirect',desc='Perform an indexed indirect draw',type='protos']
1492--
1493
1494To record an indexed indirect draw, call:
1495
1496include::../api/protos/vkCmdDrawIndexedIndirect.txt[]
1497
1498  * pname:commandBuffer is the command buffer into which the command is
1499    recorded.
1500  * pname:buffer is the buffer containing draw parameters.
1501  * pname:offset is the byte offset into pname:buffer where parameters
1502    begin.
1503  * pname:drawCount is the number of draws to execute, and can: be zero.
1504  * pname:stride is the byte stride between successive sets of draw
1505    parameters.
1506
1507fname:vkCmdDrawIndexedIndirect behaves similarly to flink:vkCmdDrawIndexed
1508except that the parameters are read by the device from a buffer during
1509execution.
1510pname:drawCount draws are executed by the command, with parameters taken
1511from pname:buffer starting at pname:offset and increasing by pname:stride
1512bytes for each successive draw.
1513The parameters of each draw are encoded in an array of
1514slink:VkDrawIndexedIndirectCommand structures.
1515If pname:drawCount is less than or equal to one, pname:stride is ignored.
1516
1517.Valid Usage
1518****
1519  * [[VUID-vkCmdDrawIndexedIndirect-buffer-00526]]
1520    If pname:buffer is non-sparse then it must: be bound completely and
1521    contiguously to a single sname:VkDeviceMemory object
1522  * [[VUID-vkCmdDrawIndexedIndirect-buffer-01665]]
1523    pname:buffer must: have been created with the
1524    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1525  * [[VUID-vkCmdDrawIndexedIndirect-offset-00527]]
1526    pname:offset must: be a multiple of `4`
1527  * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00528]]
1528    If pname:drawCount is greater than `1`, pname:stride must: be a multiple
1529    of `4` and must: be greater than or equal to
1530    code:sizeof(sname:VkDrawIndexedIndirectCommand)
1531  * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00529]]
1532    If the <<features-features-multiDrawIndirect,multi-draw indirect>>
1533    feature is not enabled, pname:drawCount must: be `0` or `1`
1534  * [[VUID-vkCmdDrawIndexedIndirect-firstInstance-00530]]
1535    If the
1536    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1537    feature is not enabled, all the pname:firstInstance members of the
1538    sname:VkDrawIndexedIndirectCommand structures accessed by this command
1539    must: be code:0
1540  * [[VUID-vkCmdDrawIndexedIndirect-renderPass-00531]]
1541    The current render pass must: be <<renderpass-compatibility,compatible>>
1542    with the pname:renderPass member of the
1543    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
1544    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1545  * [[VUID-vkCmdDrawIndexedIndirect-subpass-00532]]
1546    The subpass index of the current render pass must: be equal to the
1547    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
1548    specified when creating the sname:VkPipeline bound to
1549    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1550  * [[VUID-vkCmdDrawIndexedIndirect-None-00533]]
1551    For each set _n_ that is statically used by the sname:VkPipeline bound
1552    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
1553    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1554    sname:VkPipelineLayout that is compatible for set _n_, with the
1555    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1556    described in <<descriptorsets-compatibility>>
1557  * [[VUID-vkCmdDrawIndexedIndirect-None-00534]]
1558    For each push constant that is statically used by the sname:VkPipeline
1559    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
1560    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1561    sname:VkPipelineLayout that is compatible for push constants, with the
1562    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1563    described in <<descriptorsets-compatibility>>
1564  * [[VUID-vkCmdDrawIndexedIndirect-None-00535]]
1565    Descriptors in each bound descriptor set, specified via
1566    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
1567    used by the bound sname:VkPipeline object, specified via
1568    fname:vkCmdBindPipeline
1569  * [[VUID-vkCmdDrawIndexedIndirect-None-00536]]
1570    All vertex input bindings accessed via vertex input variables declared
1571    in the vertex shader entry point's interface must: have valid buffers
1572    bound
1573  * [[VUID-vkCmdDrawIndexedIndirect-None-00537]]
1574    A valid graphics pipeline must: be bound to the current command buffer
1575    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1576  * [[VUID-vkCmdDrawIndexedIndirect-None-00538]]
1577    If the sname:VkPipeline object bound to
1578    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
1579    state must: have been set on the current command buffer
1580  * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00539]]
1581    If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus}
1582    code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than or
1583    equal to the size of pname:buffer
1584  * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00540]]
1585    If pname:drawCount is greater than `1`, [eq]#(pname:stride {times}
1586    (pname:drawCount - 1) {plus} pname:offset {plus}
1587    code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than or
1588    equal to the size of pname:buffer
1589  * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00541]]
1590    pname:drawCount must: be less than or equal to
1591    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
1592  * [[VUID-vkCmdDrawIndexedIndirect-None-00542]]
1593    Every input attachment used by the current subpass must: be bound to the
1594    pipeline via a descriptor set
1595  * [[VUID-vkCmdDrawIndexedIndirect-None-00543]]
1596    If any sname:VkSampler object that is accessed from a shader by the
1597    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1598    unnormalized coordinates, it must: not be used to sample from any
1599    sname:VkImage with a sname:VkImageView of the type
1600    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
1601    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
1602    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
1603  * [[VUID-vkCmdDrawIndexedIndirect-None-00544]]
1604    If any sname:VkSampler object that is accessed from a shader by the
1605    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1606    unnormalized coordinates, it must: not be used with any of the SPIR-V
1607    `OpImageSample*` or `OpImageSparseSample*` instructions with
1608    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
1609    stage
1610  * [[VUID-vkCmdDrawIndexedIndirect-None-00545]]
1611    If any sname:VkSampler object that is accessed from a shader by the
1612    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1613    unnormalized coordinates, it must: not be used with any of the SPIR-V
1614    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
1615    LOD bias or any offset values, in any shader stage
1616  * [[VUID-vkCmdDrawIndexedIndirect-None-00546]]
1617    If the <<features-features-robustBufferAccess,robust buffer access>>
1618    feature is not enabled, and any shader stage in the sname:VkPipeline
1619    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
1620    buffer, it must: not access values outside of the range of that buffer
1621    specified in the bound descriptor set
1622  * [[VUID-vkCmdDrawIndexedIndirect-None-00547]]
1623    If the <<features-features-robustBufferAccess,robust buffer access>>
1624    feature is not enabled, and any shader stage in the sname:VkPipeline
1625    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
1626    buffer, it must: not access values outside of the range of that buffer
1627    specified in the bound descriptor set
1628  * [[VUID-vkCmdDrawIndexedIndirect-None-02018]]
1629    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
1630    result of this command, then the image view's
1631    <<resources-image-view-format-features,format features>> must: contain
1632    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
1633  * [[VUID-vkCmdDrawIndexedIndirect-None-01503]]
1634    Image subresources used as attachments in the current render pass must:
1635    not be accessed in any way other than as an attachment by this command.
1636ifdef::VK_IMG_filter_cubic[]
1637  * [[VUID-vkCmdDrawIndexedIndirect-None-02019]]
1638    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
1639    result of this command, then the image view's
1640    <<resources-image-view-format-features,format features>> must: contain
1641    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
1642  * [[VUID-vkCmdDrawIndexedIndirect-None-00550]]
1643    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
1644    result of this command must: not have a elink:VkImageViewType of
1645    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
1646    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
1647endif::VK_IMG_filter_cubic[]
1648ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
1649  * [[VUID-vkCmdDrawIndexedIndirect-maxMultiviewInstanceIndex-00551]]
1650    If the draw is recorded in a render pass instance with multiview
1651    enabled, the maximum instance index must: be less than or equal to
1652    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
1653endif::VK_VERSION_1_1,VK_KHR_multiview[]
1654ifdef::VK_VERSION_1_1[]
1655  * [[VUID-vkCmdDrawIndexedIndirect-commandBuffer-01862]]
1656    If pname:commandBuffer is an unprotected command buffer, and any
1657    pipeline stage in the sname:VkPipeline object bound to
1658    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
1659    or buffer, that image or buffer must: not be a protected image or
1660    protected buffer.
1661  * [[VUID-vkCmdDrawIndexedIndirect-commandBuffer-01863]]
1662    If pname:commandBuffer is a protected command buffer, and any pipeline
1663    stage in the sname:VkPipeline object bound to
1664    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
1665    that image or buffer must: not be an unprotected image or unprotected
1666    buffer.
1667  * [[VUID-vkCmdDrawIndexedIndirect-commandBuffer-01864]]
1668    If pname:commandBuffer is a protected command buffer, and any pipeline
1669    stage other than the framebuffer-space pipeline stages in the
1670    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1671    reads from or writes to any image or buffer, the image or buffer must:
1672    not be a protected image or protected buffer.
1673endif::VK_VERSION_1_1[]
1674ifdef::VK_EXT_sample_locations[]
1675  * [[VUID-vkCmdDrawIndexedIndirect-sampleLocationsEnable-01516]]
1676    If the bound graphics pipeline was created with
1677    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
1678    set to ename:VK_TRUE and the current subpass has a depth/stencil
1679    attachment, then that attachment must: have been created with the
1680    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
1681endif::VK_EXT_sample_locations[]
1682****
1683
1684include::../validity/protos/vkCmdDrawIndexedIndirect.txt[]
1685--
1686
1687[open,refpage='VkDrawIndexedIndirectCommand',desc='Structure specifying a draw indexed indirect command',type='structs',xrefs='vkCmdDrawIndexedIndirect']
1688--
1689
1690The sname:VkDrawIndexedIndirectCommand structure is defined as:
1691
1692include::../api/structs/VkDrawIndexedIndirectCommand.txt[]
1693
1694  * pname:indexCount is the number of vertices to draw.
1695  * pname:instanceCount is the number of instances to draw.
1696  * pname:firstIndex is the base index within the index buffer.
1697  * pname:vertexOffset is the value added to the vertex index before
1698    indexing into the vertex buffer.
1699  * pname:firstInstance is the instance ID of the first instance to draw.
1700
1701The members of sname:VkDrawIndexedIndirectCommand have the same meaning as
1702the similarly named parameters of flink:vkCmdDrawIndexed.
1703
1704.Valid Usage
1705****
1706  * [[VUID-VkDrawIndexedIndirectCommand-None-00552]]
1707    For a given vertex buffer binding, any attribute data fetched must: be
1708    entirely contained within the corresponding vertex buffer binding, as
1709    described in <<fxvertex-input>>
1710  * [[VUID-VkDrawIndexedIndirectCommand-indexSize-00553]]
1711    [eq]#(pname:indexSize * (pname:firstIndex {plus} pname:indexCount)
1712    {plus} pname:offset)# must: be less than or equal to the size of the
1713    bound index buffer, with pname:indexSize being based on the type
1714    specified by pname:indexType, where the index buffer, pname:indexType,
1715    and pname:offset are specified via fname:vkCmdBindIndexBuffer
1716  * [[VUID-VkDrawIndexedIndirectCommand-firstInstance-00554]]
1717    If the
1718    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1719    feature is not enabled, pname:firstInstance must: be code:0
1720****
1721
1722include::../validity/structs/VkDrawIndexedIndirectCommand.txt[]
1723
1724--
1725
1726ifdef::VK_KHR_draw_indirect_count[]
1727[open,refpage='vkCmdDrawIndexedIndirectCountKHR',desc='Perform an indexed indirect draw with the draw count sourced from a buffer',type='protos']
1728--
1729
1730To record an indexed draw call with a draw call count sourced from a buffer,
1731call:
1732
1733include::../api/protos/vkCmdDrawIndexedIndirectCountKHR.txt[]
1734
1735  * pname:commandBuffer is the command buffer into which the command is
1736    recorded.
1737  * pname:buffer is the buffer containing draw parameters.
1738  * pname:offset is the byte offset into pname:buffer where parameters
1739    begin.
1740  * pname:countBuffer is the buffer containing the draw count.
1741  * pname:countBufferOffset is the byte offset into pname:countBuffer where
1742    the draw count begins.
1743  * pname:maxDrawCount specifies the maximum number of draws that will be
1744    executed.
1745    The actual number of executed draw calls is the minimum of the count
1746    specified in pname:countBuffer and pname:maxDrawCount.
1747  * pname:stride is the byte stride between successive sets of draw
1748    parameters.
1749
1750fname:vkCmdDrawIndexedIndirectCountKHR behaves similarly to
1751flink:vkCmdDrawIndexedIndirect except that the draw count is read by the
1752device from a buffer during execution.
1753The command will read an unsigned 32-bit integer from pname:countBuffer
1754located at pname:countBufferOffset and use this as the draw count.
1755
1756.Valid Usage
1757****
1758  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-buffer-03136]]
1759    If pname:buffer is non-sparse then it must: be bound completely and
1760    contiguously to a single sname:VkDeviceMemory object
1761  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-buffer-03137]]
1762    pname:buffer must: have been created with the
1763    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1764  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-countBuffer-03138]]
1765    If pname:countBuffer is non-sparse then it must: be bound completely and
1766    contiguously to a single sname:VkDeviceMemory object
1767  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-countBuffer-03139]]
1768    pname:countBuffer must: have been created with the
1769    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1770  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-offset-03140]]
1771    pname:offset must: be a multiple of `4`
1772  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-countBufferOffset-03141]]
1773    pname:countBufferOffset must: be a multiple of `4`
1774  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-stride-03142]]
1775    pname:stride must: be a multiple of `4` and must: be greater than or
1776    equal to sizeof(sname:VkDrawIndexedIndirectCommand)
1777  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-maxDrawCount-03143]]
1778    If pname:maxDrawCount is greater than or equal to `1`,
1779    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
1780    {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than
1781    or equal to the size of pname:buffer
1782  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-firstInstance-03144]]
1783    If the
1784    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1785    feature is not enabled, all the pname:firstInstance members of the
1786    sname:VkDrawIndexedIndirectCommand structures accessed by this command
1787    must: be code:0
1788  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-renderPass-03145]]
1789    The current render pass must: be <<renderpass-compatibility,compatible>>
1790    with the pname:renderPass member of the
1791    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
1792    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1793  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-subpass-03146]]
1794    The subpass index of the current render pass must: be equal to the
1795    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
1796    specified when creating the sname:VkPipeline bound to
1797    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
1798  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03147]]
1799    For each set _n_ that is statically used by the sname:VkPipeline bound
1800    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
1801    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1802    sname:VkPipelineLayout that is compatible for set _n_, with the
1803    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1804    described in <<descriptorsets-compatibility>>
1805  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03148]]
1806    For each push constant that is statically used by the sname:VkPipeline
1807    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
1808    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
1809    sname:VkPipelineLayout that is compatible for push constants, with the
1810    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
1811    described in <<descriptorsets-compatibility>>
1812  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03149]]
1813    Descriptors in each bound descriptor set, specified via
1814    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
1815    used by the bound sname:VkPipeline object, specified via
1816    fname:vkCmdBindPipeline
1817  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03150]]
1818    All vertex input bindings accessed via vertex input variables declared
1819    in the vertex shader entry point's interface must: have valid buffers
1820    bound
1821  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03151]]
1822    A valid graphics pipeline must: be bound to the current command buffer
1823    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1824  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03152]]
1825    If the sname:VkPipeline object bound to
1826    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
1827    state must: have been set on the current command buffer
1828  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-countBuffer-03153]]
1829    If count stored in pname:countBuffer is equal to `1`, [eq]#(pname:offset
1830    {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than
1831    or equal to the size of pname:buffer
1832  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-countBuffer-03154]]
1833    If count stored in pname:countBuffer is greater than `1`,
1834    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
1835    {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than
1836    or equal to the size of pname:buffer
1837  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-drawCount-03155]]
1838    pname:drawCount must: be less than or equal to
1839    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
1840  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03156]]
1841    Every input attachment used by the current subpass must: be bound to the
1842    pipeline via a descriptor set
1843  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03157]]
1844    If any sname:VkSampler object that is accessed from a shader by the
1845    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1846    unnormalized coordinates, it must: not be used to sample from any
1847    sname:VkImage with a sname:VkImageView of the type
1848    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
1849    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
1850    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
1851  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03158]]
1852    If any sname:VkSampler object that is accessed from a shader by the
1853    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1854    unnormalized coordinates, it must: not be used with any of the SPIR-V
1855    `OpImageSample*` or `OpImageSparseSample*` instructions with
1856    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
1857    stage
1858  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03159]]
1859    If any sname:VkSampler object that is accessed from a shader by the
1860    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
1861    unnormalized coordinates, it must: not be used with any of the SPIR-V
1862    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
1863    LOD bias or any offset values, in any shader stage
1864  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03160]]
1865    If the <<features-features-robustBufferAccess,robust buffer access>>
1866    feature is not enabled, and any shader stage in the sname:VkPipeline
1867    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
1868    buffer, it must: not access values outside of the range of that buffer
1869    specified in the bound descriptor set
1870  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03161]]
1871    If the <<features-features-robustBufferAccess,robust buffer access>>
1872    feature is not enabled, and any shader stage in the sname:VkPipeline
1873    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
1874    buffer, it must: not access values outside of the range of that buffer
1875    specified in the bound descriptor set
1876  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-02020]]
1877    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
1878    result of this command, then the image view's
1879    <<resources-image-view-format-features,format features>> must: contain
1880    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
1881  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03163]]
1882    Image subresources used as attachments in the current render pass must:
1883    not be accessed in any way other than as an attachment by this command.
1884ifdef::VK_IMG_filter_cubic[]
1885  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-02021]]
1886    If a sname:VkImageView is sampled with ename:VK_FILTER_CUBIC_IMG as a
1887    result of this command, then the image view's
1888    <<resources-image-view-format-features,format features>> must: contain
1889    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG.
1890  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-None-03173]]
1891    Any slink:VkImageView being sampled with ename:VK_FILTER_CUBIC_IMG as a
1892    result of this command must: not have a elink:VkImageViewType of
1893    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE, or
1894    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
1895endif::VK_IMG_filter_cubic[]
1896ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
1897  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-maxMultiviewInstanceIndex-03164]]
1898    If the draw is recorded in a render pass instance with multiview
1899    enabled, the maximum instance index must: be less than or equal to
1900    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
1901endif::VK_VERSION_1_1,VK_KHR_multiview[]
1902ifdef::VK_VERSION_1_1[]
1903  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-commandBuffer-03165]]
1904    If pname:commandBuffer is an unprotected command buffer, and any
1905    pipeline stage in the sname:VkPipeline object bound to
1906    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
1907    or buffer, that image or buffer must: not be a protected image or
1908    protected buffer.
1909  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-commandBuffer-03166]]
1910    If pname:commandBuffer is a protected command buffer, and any pipeline
1911    stage in the sname:VkPipeline object bound to
1912    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
1913    that image or buffer must: not be an unprotected image or unprotected
1914    buffer.
1915  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-commandBuffer-03167]]
1916    If pname:commandBuffer is a protected command buffer, and any pipeline
1917    stage other than the framebuffer-space pipeline stages in the
1918    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
1919    reads from or writes to any image or buffer, the image or buffer must:
1920    not be a protected image or protected buffer.
1921endif::VK_VERSION_1_1[]
1922ifdef::VK_EXT_sample_locations[]
1923  * [[VUID-vkCmdDrawIndexedIndirectCountKHR-sampleLocationsEnable-03174]]
1924    If the bound graphics pipeline was created with
1925    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
1926    set to ename:VK_TRUE and the current subpass has a depth/stencil
1927    attachment, then that attachment must: have been created with the
1928    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
1929endif::VK_EXT_sample_locations[]
1930****
1931
1932include::../validity/protos/vkCmdDrawIndexedIndirectCountKHR.txt[]
1933
1934--
1935endif::VK_KHR_draw_indirect_count[]
1936
1937
1938ifdef::VK_AMD_draw_indirect_count[]
1939[open,refpage='vkCmdDrawIndexedIndirectCountAMD',desc='Perform an indexed indirect draw with the draw count sourced from a buffer',type='protos']
1940--
1941
1942To record an indexed draw call with a draw call count sourced from a buffer,
1943call:
1944
1945include::../api/protos/vkCmdDrawIndexedIndirectCountAMD.txt[]
1946
1947  * pname:commandBuffer is the command buffer into which the command is
1948    recorded.
1949  * pname:buffer is the buffer containing draw parameters.
1950  * pname:offset is the byte offset into pname:buffer where parameters
1951    begin.
1952  * pname:countBuffer is the buffer containing the draw count.
1953  * pname:countBufferOffset is the byte offset into pname:countBuffer where
1954    the draw count begins.
1955  * pname:maxDrawCount specifies the maximum number of draws that will be
1956    executed.
1957    The actual number of executed draw calls is the minimum of the count
1958    specified in pname:countBuffer and pname:maxDrawCount.
1959  * pname:stride is the byte stride between successive sets of draw
1960    parameters.
1961
1962fname:vkCmdDrawIndexedIndirectCountAMD behaves similarly to
1963flink:vkCmdDrawIndexedIndirect except that the draw count is read by the
1964device from a buffer during execution.
1965The command will read an unsigned 32-bit integer from pname:countBuffer
1966located at pname:countBufferOffset and use this as the draw count.
1967
1968.Valid Usage
1969****
1970  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-buffer-01666]]
1971    If pname:buffer is non-sparse then it must: be bound completely and
1972    contiguously to a single sname:VkDeviceMemory object
1973  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-buffer-01667]]
1974    pname:buffer must: have been created with the
1975    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1976  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-countBuffer-01668]]
1977    If pname:countBuffer is non-sparse then it must: be bound completely and
1978    contiguously to a single sname:VkDeviceMemory object
1979  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-countBuffer-01669]]
1980    pname:countBuffer must: have been created with the
1981    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
1982  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-offset-00555]]
1983    pname:offset must: be a multiple of `4`
1984  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-countBufferOffset-00556]]
1985    pname:countBufferOffset must: be a multiple of `4`
1986  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-stride-00557]]
1987    pname:stride must: be a multiple of `4` and must: be greater than or
1988    equal to code:sizeof(sname:VkDrawIndexedIndirectCommand)
1989  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-maxDrawCount-00558]]
1990    If pname:maxDrawCount is greater than or equal to `1`,
1991    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
1992    {plus} code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less
1993    than or equal to the size of pname:buffer
1994  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-firstInstance-00559]]
1995    If the
1996    <<features-features-drawIndirectFirstInstance,drawIndirectFirstInstance>>
1997    feature is not enabled, all the pname:firstInstance members of the
1998    sname:VkDrawIndexedIndirectCommand structures accessed by this command
1999    must: be `0`
2000  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-renderPass-00560]]
2001    The current render pass must: be <<renderpass-compatibility,compatible>>
2002    with the pname:renderPass member of the
2003    sname:VkGraphicsPipelineCreateInfo structure specified when creating the
2004    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
2005  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-subpass-00561]]
2006    The subpass index of the current render pass must: be equal to the
2007    pname:subpass member of the sname:VkGraphicsPipelineCreateInfo structure
2008    specified when creating the sname:VkPipeline bound to
2009    ename:VK_PIPELINE_BIND_POINT_GRAPHICS.
2010  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00562]]
2011    For each set _n_ that is statically used by the sname:VkPipeline bound
2012    to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a descriptor set must: have
2013    been bound to _n_ at ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
2014    sname:VkPipelineLayout that is compatible for set _n_, with the
2015    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
2016    described in <<descriptorsets-compatibility>>
2017  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00563]]
2018    For each push constant that is statically used by the sname:VkPipeline
2019    bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS, a push constant value
2020    must: have been set for ename:VK_PIPELINE_BIND_POINT_GRAPHICS, with a
2021    sname:VkPipelineLayout that is compatible for push constants, with the
2022    sname:VkPipelineLayout used to create the current sname:VkPipeline, as
2023    described in <<descriptorsets-compatibility>>
2024  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00564]]
2025    Descriptors in each bound descriptor set, specified via
2026    fname:vkCmdBindDescriptorSets, must: be valid if they are statically
2027    used by the bound sname:VkPipeline object, specified via
2028    fname:vkCmdBindPipeline
2029  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00565]]
2030    All vertex input bindings accessed via vertex input variables declared
2031    in the vertex shader entry point's interface must: have valid buffers
2032    bound
2033  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00566]]
2034    A valid graphics pipeline must: be bound to the current command buffer
2035    with ename:VK_PIPELINE_BIND_POINT_GRAPHICS
2036  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00567]]
2037    If the sname:VkPipeline object bound to
2038    ename:VK_PIPELINE_BIND_POINT_GRAPHICS requires any dynamic state, that
2039    state must: have been set on the current command buffer
2040  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-countBuffer-00568]]
2041    If count stored in pname:countBuffer is equal to `1`, [eq]#(pname:offset
2042    {plus} code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less
2043    than or equal to the size of pname:buffer
2044  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-countBuffer-00569]]
2045    If count stored in pname:countBuffer is greater than `1`,
2046    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
2047    {plus} code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less
2048    than or equal to the size of pname:buffer
2049  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-drawCount-00570]]
2050    pname:drawCount must: be less than or equal to
2051    sname:VkPhysicalDeviceLimits::pname:maxDrawIndirectCount
2052  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00571]]
2053    Every input attachment used by the current subpass must: be bound to the
2054    pipeline via a descriptor set
2055  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00572]]
2056    If any sname:VkSampler object that is accessed from a shader by the
2057    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
2058    unnormalized coordinates, it must: not be used to sample from any
2059    sname:VkImage with a sname:VkImageView of the type
2060    ename:VK_IMAGE_VIEW_TYPE_3D, ename:VK_IMAGE_VIEW_TYPE_CUBE,
2061    ename:VK_IMAGE_VIEW_TYPE_1D_ARRAY, ename:VK_IMAGE_VIEW_TYPE_2D_ARRAY or
2062    ename:VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, in any shader stage
2063  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00573]]
2064    If any sname:VkSampler object that is accessed from a shader by the
2065    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
2066    unnormalized coordinates, it must: not be used with any of the SPIR-V
2067    `OpImageSample*` or `OpImageSparseSample*` instructions with
2068    code:ImplicitLod, code:Dref or code:Proj in their name, in any shader
2069    stage
2070  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00574]]
2071    If any sname:VkSampler object that is accessed from a shader by the
2072    sname:VkPipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS uses
2073    unnormalized coordinates, it must: not be used with any of the SPIR-V
2074    `OpImageSample*` or `OpImageSparseSample*` instructions that includes a
2075    LOD bias or any offset values, in any shader stage
2076  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00575]]
2077    If the <<features-features-robustBufferAccess,robust buffer access>>
2078    feature is not enabled, and any shader stage in the sname:VkPipeline
2079    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a uniform
2080    buffer, it must: not access values outside of the range of that buffer
2081    specified in the bound descriptor set
2082  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-00576]]
2083    If the <<features-features-robustBufferAccess,robust buffer access>>
2084    feature is not enabled, and any shader stage in the sname:VkPipeline
2085    object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS accesses a storage
2086    buffer, it must: not access values outside of the range of that buffer
2087    specified in the bound descriptor set
2088  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-02022]]
2089    If a sname:VkImageView is sampled with ename:VK_FILTER_LINEAR as a
2090    result of this command, then the image view's
2091    <<resources-image-view-format-features,format features>> must: contain
2092    ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT.
2093  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-None-01504]]
2094    Image subresources used as attachments in the current render pass must:
2095    not be accessed in any way other than as an attachment by this command.
2096ifdef::VK_VERSION_1_1,VK_KHR_multiview[]
2097  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-maxMultiviewInstanceIndex-00578]]
2098    If the draw is recorded in a render pass instance with multiview
2099    enabled, the maximum instance index must: be less than or equal to
2100    slink:VkPhysicalDeviceMultiviewProperties::pname:maxMultiviewInstanceIndex.
2101endif::VK_VERSION_1_1,VK_KHR_multiview[]
2102ifdef::VK_VERSION_1_1[]
2103  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-commandBuffer-01865]]
2104    If pname:commandBuffer is an unprotected command buffer, and any
2105    pipeline stage in the sname:VkPipeline object bound to
2106    ename:VK_PIPELINE_BIND_POINT_GRAPHICS reads from or writes to any image
2107    or buffer, that image or buffer must: not be a protected image or
2108    protected buffer.
2109  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-commandBuffer-01866]]
2110    If pname:commandBuffer is a protected command buffer, and any pipeline
2111    stage in the sname:VkPipeline object bound to
2112    ename:VK_PIPELINE_BIND_POINT_GRAPHICS writes to any image or buffer,
2113    that image or buffer must: not be an unprotected image or unprotected
2114    buffer.
2115  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-commandBuffer-01867]]
2116    If pname:commandBuffer is a protected command buffer, and any pipeline
2117    stage other than the framebuffer-space pipeline stages in the
2118    sname:VkPipeline object bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
2119    reads from or writes to any image or buffer, the image or buffer must:
2120    not be a protected image or protected buffer.
2121endif::VK_VERSION_1_1[]
2122ifdef::VK_EXT_sample_locations[]
2123  * [[VUID-vkCmdDrawIndexedIndirectCountAMD-sampleLocationsEnable-01517]]
2124    If the bound graphics pipeline was created with
2125    slink:VkPipelineSampleLocationsStateCreateInfoEXT::pname:sampleLocationsEnable
2126    set to ename:VK_TRUE and the current subpass has a depth/stencil
2127    attachment, then that attachment must: have been created with the
2128    ename:VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT bit set
2129endif::VK_EXT_sample_locations[]
2130****
2131
2132include::../validity/protos/vkCmdDrawIndexedIndirectCountAMD.txt[]
2133
2134--
2135endif::VK_AMD_draw_indirect_count[]
2136
2137ifdef::VK_EXT_conditional_rendering[]
2138
2139[[drawing-conditional-rendering]]
2140== Conditional Rendering
2141Certain rendering commands can: be executed conditionally based on a value
2142in buffer memory.
2143These rendering commands are limited to <<drawing,drawing commands>>,
2144<<dispatch,dispatching commands>>, and clearing attachments with
2145flink:vkCmdClearAttachments within a conditional rendering block which is
2146defined by commands flink:vkCmdBeginConditionalRenderingEXT and
2147flink:vkCmdEndConditionalRenderingEXT.
2148Other rendering commands remain unaffected by conditional rendering.
2149
2150[[active-conditional-rendering]]
2151After beginning conditional rendering, it is considered _active_ within the
2152command buffer it was called until it is ended with
2153flink:vkCmdEndConditionalRenderingEXT.
2154
2155Conditional rendering must: begin and end in the same command buffer.
2156When conditional rendering is active, a primary command buffer can: execute
2157secondary command buffers if the
2158<<features-features-inheritedConditionalRendering, inherited conditional
2159rendering>> feature is enabled.
2160For a secondary command buffer to be executed while conditional rendering is
2161active in the primary command buffer, it must: set the
2162pname:conditionalRenderingEnable flag of
2163slink:VkCommandBufferInheritanceConditionalRenderingInfoEXT, as described in
2164the <<commandbuffers-recording, Command Buffer Recording>> section.
2165
2166Conditional rendering must: also either begin and end inside the same
2167subpass of a render pass instance, or must: both begin and end outside of a
2168render pass instance (i.e. contain entire render pass instances).
2169
2170[open,refpage='vkCmdBeginConditionalRenderingEXT',desc='Define the beginning of a conditional rendering block',type='protos']
2171--
2172
2173To begin conditional rendering, call:
2174
2175include::../api/protos/vkCmdBeginConditionalRenderingEXT.txt[]
2176
2177  * pname:commandBuffer is the command buffer into which this command will
2178    be recorded.
2179  * pname:pConditionalRenderingBegin is a pointer to an instance of the
2180    slink:VkConditionalRenderingBeginInfoEXT structure specifying the
2181    parameters of conditional rendering.
2182
2183.Valid Usage
2184****
2185  * [[VUID-vkCmdBeginConditionalRenderingEXT-None-01980]]
2186    Conditional rendering must: not already be
2187    <<active-conditional-rendering,active>>
2188****
2189
2190include::../validity/protos/vkCmdBeginConditionalRenderingEXT.txt[]
2191--
2192
2193[open,refpage='VkConditionalRenderingBeginInfoEXT',desc='Structure specifying conditional rendering begin info',type='structs']
2194--
2195
2196The sname:VkConditionalRenderingBeginInfoEXT structure is defined as:
2197
2198include::../api/structs/VkConditionalRenderingBeginInfoEXT.txt[]
2199
2200  * pname:sType is the type of this structure.
2201  * pname:pNext is `NULL` or a pointer to an extension-specific structure.
2202  * pname:buffer is a buffer containing the predicate for conditional
2203    rendering.
2204  * pname:offset is the byte offset into pname:buffer where the predicate is
2205    located.
2206  * pname:flags is a bitmask of elink:VkConditionalRenderingFlagsEXT
2207    specifying the behavior of conditional rendering.
2208
2209If the 32-bit value at pname:offset in pname:buffer memory is zero, then the
2210rendering commands are discarded, otherwise they are executed as normal.
2211If the value of the predicate in buffer memory changes while conditional
2212rendering is active, the rendering commands may: be discarded in an
2213implementation-dependent way.
2214Some implementations may latch the value of the predicate upon beginning
2215conditional rendering while others may read it before every rendering
2216command.
2217
2218.Valid Usage
2219****
2220  * [[VUID-VkConditionalRenderingBeginInfoEXT-buffer-01981]]
2221    If pname:buffer is non-sparse then it must: be bound completely and
2222    contiguously to a single sname:VkDeviceMemory object
2223  * [[VUID-VkConditionalRenderingBeginInfoEXT-buffer-01982]]
2224    pname:buffer must: have been created with the
2225    ename:VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT bit set
2226  * [[VUID-VkConditionalRenderingBeginInfoEXT-offset-01983]]
2227    pname:offset must: be less than the size of pname:buffer by at least 32
2228    bits.
2229  * [[VUID-VkConditionalRenderingBeginInfoEXT-offset-01984]]
2230    pname:offset must: be a multiple of 4
2231****
2232
2233[open,refpage='VkConditionalRenderingFlagBitsEXT',desc='Specify the behavior of conditional rendering',type='enums']
2234--
2235
2236Bits which can: be set in
2237flink:vkCmdBeginConditionalRenderingEXT::pname:flags specifying the behavior
2238of conditional rendering are:
2239
2240include::../api/enums/VkConditionalRenderingFlagBitsEXT.txt[]
2241
2242  * ename:VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT specifies the condition
2243    used to determine whether to discard rendering commands or not.
2244    That is, if the 32-bit predicate read from pname:buffer memory at
2245    pname:offset is zero, the rendering commands are not discarded, and if
2246    non zero, then they are discarded.
2247
2248--
2249
2250[open,refpage='VkConditionalRenderingFlagsEXT',desc='Bitmask of VkConditionalRenderingFlagBitsEXT',type='enums']
2251--
2252include::../api/flags/VkConditionalRenderingFlagsEXT.txt[]
2253
2254sname:VkConditionalRenderingFlagsEXT is a bitmask type for setting a mask of
2255zero or more slink:VkConditionalRenderingFlagBitsEXT.
2256
2257[open,refpage='vkCmdEndConditionalRenderingEXT',desc='Define the end of a conditional rendering block',type='protos']
2258--
2259
2260To end conditional rendering, call:
2261
2262include::../api/protos/vkCmdEndConditionalRenderingEXT.txt[]
2263
2264  * pname:commandBuffer is the command buffer into which this command will
2265    be recorded.
2266
2267Once ended, conditional rendering becomes inactive.
2268
2269.Valid Usage
2270****
2271  * [[VUID-vkCmdEndConditionalRenderingEXT-None-01985]]
2272    Conditional rendering must: be <<active-conditional-rendering,active>>
2273  * [[VUID-vkCmdEndConditionalRenderingEXT-None-01986]]
2274    If conditional rendering was made
2275    <<active-conditional-rendering,active>> outside of a render pass
2276    instance, it must not be ended inside a render pass instance
2277  * [[VUID-vkCmdEndConditionalRenderingEXT-None-01987]]
2278    If conditional rendering was made
2279    <<active-conditional-rendering,active>> within a subpass it must be
2280    ended in the same subpass
2281****
2282
2283include::../validity/protos/vkCmdEndConditionalRenderingEXT.txt[]
2284--
2285
2286endif::VK_EXT_conditional_rendering[]
2287