1// Copyright 2015-2021 The Khronos Group, Inc. 2// 3// SPDX-License-Identifier: CC-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-- 18ifdef::VK_NV_mesh_shader[] 19Drawing can be achieved in two modes: 20 21 * <<drawing-mesh-shading,Programmable Mesh Shading>>, the mesh shader 22 assembles primitives, or 23 * <<drawing-primitive-shading,Programmable Primitive Shading>>, the input 24 primitives are assembled 25 26as follows. 27endif::VK_NV_mesh_shader[] 28 29Each draw is made up of zero or more vertices and zero or more instances, 30which are processed by the device and result in the assembly of primitives. 31Primitives are assembled according to the pname:pInputAssemblyState member 32of the slink:VkGraphicsPipelineCreateInfo structure, which is of type 33sname:VkPipelineInputAssemblyStateCreateInfo: 34 35include::{generated}/api/structs/VkPipelineInputAssemblyStateCreateInfo.txt[] 36 37 * pname:sType is the type of this structure. 38 * pname:pNext is `NULL` or a pointer to a structure extending this 39 structure. 40 * pname:flags is reserved for future use. 41 * pname:topology is a elink:VkPrimitiveTopology defining the primitive 42 topology, as described below. 43 * pname:primitiveRestartEnable controls whether a special vertex index 44 value is treated as restarting the assembly of primitives. 45 This enable only applies to indexed draws (flink:vkCmdDrawIndexed, 46ifdef::VK_EXT_multi_draw[] 47 flink:vkCmdDrawMultiIndexedEXT, 48endif::VK_EXT_multi_draw[] 49 and flink:vkCmdDrawIndexedIndirect), and the special index value is 50 either 0xFFFFFFFF when the pname:indexType parameter of 51 fname:vkCmdBindIndexBuffer is equal to ename:VK_INDEX_TYPE_UINT32, 52ifdef::VK_EXT_index_type_uint8[] 53 0xFF when pname:indexType is equal to ename:VK_INDEX_TYPE_UINT8_EXT, 54endif::VK_EXT_index_type_uint8[] 55 or 0xFFFF when pname:indexType is equal to ename:VK_INDEX_TYPE_UINT16. 56ifndef::VK_EXT_primitive_topology_list_restart[] 57 Primitive restart is not allowed for "`list`" topologies. 58endif::VK_EXT_primitive_topology_list_restart[] 59ifdef::VK_EXT_primitive_topology_list_restart[] 60 Primitive restart is not allowed for "`list`" topologies, unless one of 61 the features 62 <<features-primitiveTopologyPatchListRestart,pname:primitiveTopologyPatchListRestart>> 63 (for ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) or 64 <<features-primitiveTopologyListRestart,pname:primitiveTopologyListRestart>> 65 (for all other list topologies) is enabled. 66endif::VK_EXT_primitive_topology_list_restart[] 67 68Restarting the assembly of primitives discards the most recent index values 69if those elements formed an incomplete primitive, and restarts the primitive 70assembly using the subsequent indices, but only assembling the immediately 71following element through the end of the originally specified elements. 72The primitive restart index value comparison is performed before adding the 73pname:vertexOffset value to the index value. 74 75.Valid Usage 76**** 77ifndef::VK_EXT_primitive_topology_list_restart[] 78 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428]] 79 If pname:topology is ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST, 80 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST, 81 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 82 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, 83 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY or 84 ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, pname:primitiveRestartEnable 85 must: be ename:VK_FALSE 86endif::VK_EXT_primitive_topology_list_restart[] 87ifdef::VK_EXT_primitive_topology_list_restart[] 88 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-06252]] 89 If pname:topology is ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST, 90 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST, 91 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 92 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY or 93 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, and 94 pname:primitiveRestartEnable is ename:VK_TRUE, the 95 <<features-primitiveTopologyListRestart,pname:primitiveTopologyListRestart>> 96 feature must: be enabled 97 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-06253]] 98 If pname:topology is ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, and 99 pname:primitiveRestartEnable is ename:VK_TRUE, the 100 <<features-primitiveTopologyPatchListRestart,pname:primitiveTopologyPatchListRestart>> 101 feature must: be enabled 102endif::VK_EXT_primitive_topology_list_restart[] 103 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00429]] 104 If the <<features-geometryShader,geometry shaders>> feature is not 105 enabled, pname:topology must: not be any of 106 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, 107 ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, 108 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY or 109 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY 110 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00430]] 111 If the <<features-tessellationShader,tessellation shaders>> feature is 112 not enabled, pname:topology must: not be 113 ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST 114ifdef::VK_KHR_portability_subset[] 115 * [[VUID-VkPipelineInputAssemblyStateCreateInfo-triangleFans-04452]] 116 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 117 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:triangleFans 118 is ename:VK_FALSE, pname:topology must: not be 119 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN 120endif::VK_KHR_portability_subset[] 121**** 122 123include::{generated}/validity/structs/VkPipelineInputAssemblyStateCreateInfo.txt[] 124-- 125 126[open,refpage='VkPipelineInputAssemblyStateCreateFlags',desc='Reserved for future use',type='flags'] 127-- 128include::{generated}/api/flags/VkPipelineInputAssemblyStateCreateFlags.txt[] 129 130tname:VkPipelineInputAssemblyStateCreateFlags is a bitmask type for setting 131a mask, but is currently reserved for future use. 132-- 133 134ifdef::VK_EXT_extended_dynamic_state2[] 135[open,refpage='vkCmdSetPrimitiveRestartEnableEXT',desc='Set primitive assembly restart state dynamically for a command buffer',type='protos'] 136-- 137To <<pipelines-dynamic-state, dynamically control>> whether a special vertex 138index value is treated as restarting the assembly of primitives, call: 139 140include::{generated}/api/protos/vkCmdSetPrimitiveRestartEnableEXT.txt[] 141 142 * pname:commandBuffer is the command buffer into which the command will be 143 recorded. 144 * pname:primitiveRestartEnable controls whether a special vertex index 145 value is treated as restarting the assembly of primitives. 146 It behaves in the same way as 147 sname:VkPipelineInputAssemblyStateCreateInfo::pname:primitiveRestartEnable 148 149This command sets the primitive restart enable for subsequent drawing 150commands when the graphics pipeline is created with 151ename:VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT set in 152slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 153Otherwise, this state is specified by the 154slink:VkPipelineInputAssemblyStateCreateInfo::pname:primitiveRestartEnable 155value used to create the currently active pipeline. 156 157.Valid Usage 158**** 159 * [[VUID-vkCmdSetPrimitiveRestartEnableEXT-None-04866]] 160 The <<features-extendedDynamicState2, extendedDynamicState2>> feature 161 must: be enabled 162**** 163 164include::{generated}/validity/protos/vkCmdSetPrimitiveRestartEnableEXT.txt[] 165-- 166endif::VK_EXT_extended_dynamic_state2[] 167 168 169[[drawing-primitive-topologies]] 170== Primitive Topologies 171 172_Primitive topology_ determines how consecutive vertices are organized into 173primitives, and determines the type of primitive that is used at the 174beginning of the graphics pipeline. 175The effective topology for later stages of the pipeline is altered by 176tessellation or geometry shading (if either is in use) and depends on the 177execution modes of those shaders. 178ifdef::VK_NV_mesh_shader[] 179In the case of mesh shading the only effective topology is defined by the 180execution mode of the mesh shader. 181endif::VK_NV_mesh_shader[] 182 183[open,refpage='VkPrimitiveTopology',desc='Supported primitive topologies',type='enums'] 184-- 185The primitive topologies defined by elink:VkPrimitiveTopology are: 186 187include::{generated}/api/enums/VkPrimitiveTopology.txt[] 188 189 * ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST specifies a series of 190 <<drawing-point-lists,separate point primitives>>. 191 * ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST specifies a series of 192 <<drawing-line-lists,separate line primitives>>. 193 * ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP specifies a series of 194 <<drawing-line-strips,connected line primitives>> with consecutive lines 195 sharing a vertex. 196 * ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST specifies a series of 197 <<drawing-triangle-lists,separate triangle primitives>>. 198 * ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP specifies a series of 199 <<drawing-triangle-strips,connected triangle primitives>> with 200 consecutive triangles sharing an edge. 201 * ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN specifies a series of 202 <<drawing-triangle-fans,connected triangle primitives>> with all 203 triangles sharing a common vertex. 204ifdef::VK_KHR_portability_subset[] 205 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 206 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:triangleFans 207 is ename:VK_FALSE, then triangle fans are not supported by the 208 implementation, and ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN must: not 209 be used. 210endif::VK_KHR_portability_subset[] 211 * ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY specifies a series 212 of <<drawing-line-lists-with-adjacency,separate line primitives with 213 adjacency>>. 214 * ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY specifies a series 215 of <<drawing-line-strips-with-adjacency,connected line primitives with 216 adjacency>>, with consecutive primitives sharing three vertices. 217 * ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY specifies a 218 series of <<drawing-triangle-lists-with-adjacency,separate triangle 219 primitives with adjacency>>. 220 * ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY specifies 221 <<drawing-triangle-strips-with-adjacency,connected triangle primitives 222 with adjacency>>, with consecutive triangles sharing an edge. 223 * ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST specifies 224 <<drawing-patch-lists,separate patch primitives>>. 225 226Each primitive topology, and its construction from a list of vertices, is 227described in detail below with a supporting diagram, according to the 228following key: 229 230[cols="1,2,9"] 231|==== 232^.^| image:{images}/primitive_topology_key_vertex.svg[pdfwidth=6pt,align="center",opts="{imageopts}"] 233.^| Vertex 234| A point in 3-dimensional space. 235 Positions chosen within the diagrams are arbitrary and for 236 illustration only. 237 238^.^| image:{images}/primitive_topology_key_vertex_number.svg[pdfwidth=6pt,align="center",opts="{imageopts}"] 239.^| Vertex Number 240| Sequence position of a vertex within the provided vertex data. 241 242^.^| image:{images}/primitive_topology_key_provoking_vertex.svg[pdfwidth=30pt,align="center",opts="{imageopts}"] 243.^| Provoking Vertex 244| Provoking vertex within the main primitive. 245 The tail is angled towards the relevant primitive. 246 Used in <<vertexpostproc-flatshading, flat shading>>. 247 248^.^| image:{images}/primitive_topology_key_edge.svg[pdfwidth=30pt,align="center",opts="{imageopts}"] 249.^| Primitive Edge 250| An edge connecting the points of a main primitive. 251 252^.^| image:{images}/primitive_topology_key_adjacency_edge.svg[pdfwidth=30pt,align="center",opts="{imageopts}"] 253.^| Adjacency Edge 254| Points connected by these lines do not contribute to a main primitive, 255 and are only accessible in a <<geometry,geometry shader>>. 256 257^.^| image:{images}/primitive_topology_key_winding_order.svg[pdfwidth=30pt,align="center",opts="{imageopts}"] 258.^| Winding Order 259| The relative order in which vertices are defined within a primitive, 260 used in the <<primsrast-polygons-basic,facing determination>>. 261 This ordering has no specific start or end point. 262|==== 263 264The diagrams are supported with mathematical definitions where the vertices 265([eq]#v#) and primitives ([eq]#p#) are numbered starting from [eq]#0#; 266[eq]#v~0~# is the first vertex in the provided data and [eq]#p~0~# is the 267first primitive in the set of primitives defined by the vertices and 268topology. 269-- 270 271ifdef::VK_EXT_extended_dynamic_state[] 272[open,refpage='vkCmdSetPrimitiveTopologyEXT',desc='Set primitive topology state dynamically for a command buffer',type='protos'] 273-- 274To <<pipelines-dynamic-state, dynamically set>> primitive topology, call: 275 276include::{generated}/api/protos/vkCmdSetPrimitiveTopologyEXT.txt[] 277 278 * pname:commandBuffer is the command buffer into which the command will be 279 recorded. 280 * pname:primitiveTopology specifies the primitive topology to use for 281 drawing. 282 283This command sets the primitive topology for subsequent drawing commands 284when the graphics pipeline is created with 285ename:VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT set in 286slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 287Otherwise, this state is specified by the 288slink:VkPipelineInputAssemblyStateCreateInfo::pname:topology value used to 289create the currently active pipeline. 290 291.Valid Usage 292**** 293 * [[VUID-vkCmdSetPrimitiveTopologyEXT-None-03347]] 294 The <<features-extendedDynamicState, extendedDynamicState>> feature 295 must: be enabled 296**** 297 298include::{generated}/validity/protos/vkCmdSetPrimitiveTopologyEXT.txt[] 299-- 300 301 302[[drawing-primitive-topology-class]] 303=== Topology Class 304 305The primitive topologies are grouped into the following topology classes: 306 307[[topology-classes]] 308.Topology classes 309[options="header"] 310|=== 311| Topology Class | Primitive Topology 312| Point | ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST 313| Line | ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST, 314 ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, 315 ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, 316 ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY 317| Triangle | ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 318 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, 319 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN, 320 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, 321 ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY 322| Patch | ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST 323|=== 324endif::VK_EXT_extended_dynamic_state[] 325 326 327[[drawing-point-lists]] 328=== Point Lists 329 330When the topology is ename:VK_PRIMITIVE_TOPOLOGY_POINT_LIST, each 331consecutive vertex defines a single point primitive, according to the 332equation: 333 334 {empty}:: [eq]#p~i~ = {v~i~}# 335 336As there is only one vertex, that vertex is the provoking vertex. 337The number of primitives generated is equal to [eq]#pname:vertexCount#. 338 339image::{images}/primitive_topology_point_list.svg[align="center",opts="{imageopts}"] 340 341 342[[drawing-line-lists]] 343=== Line Lists 344 345When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST, each 346consecutive pair of vertices defines a single line primitive, according to 347the equation: 348 349 {empty}:: [eq]#p~i~ = {v~2i~, v~2i+1~}# 350 351The number of primitives generated is equal to 352[eq]#{lfloor}pname:vertexCount/2{rfloor}#. 353 354ifdef::VK_EXT_provoking_vertex[] 355When the pname:provokingVertexMode is 356ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 357endif::VK_EXT_provoking_vertex[] 358ifndef::VK_EXT_provoking_vertex[] 359The 360endif::VK_EXT_provoking_vertex[] 361provoking vertex for [eq]#p~i~# is [eq]#v~2i~#. 362 363image::{images}/primitive_topology_line_list.svg[align="center",opts="{imageopts}"] 364 365ifdef::VK_EXT_provoking_vertex[] 366When the pname:provokingVertexMode is 367ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 368[eq]#p~i~# is [eq]#v~2i+1~#. 369 370image::{images}/primitive_topology_line_list_last.svg[align="center",opts="{imageopts}"] 371endif::VK_EXT_provoking_vertex[] 372 373 374[[drawing-line-strips]] 375=== Line Strips 376 377When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, one 378line primitive is defined by each vertex and the following vertex, according 379to the equation: 380 381 {empty}:: [eq]#p~i~ = {v~i~, v~i+1~}# 382 383The number of primitives generated is equal to 384[eq]#max(0,pname:vertexCount-1)#. 385 386ifdef::VK_EXT_provoking_vertex[] 387When the pname:provokingVertexMode is 388ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 389endif::VK_EXT_provoking_vertex[] 390ifndef::VK_EXT_provoking_vertex[] 391The 392endif::VK_EXT_provoking_vertex[] 393provoking vertex for [eq]#p~i~# is [eq]#v~i~#. 394 395image::{images}/primitive_topology_line_strip.svg[align="center",opts="{imageopts}"] 396 397ifdef::VK_EXT_provoking_vertex[] 398When the pname:provokingVertexMode is 399ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 400[eq]#p~i~# is [eq]#v~i+1~#. 401 402image::{images}/primitive_topology_line_strip_last.svg[align="center",opts="{imageopts}"] 403endif::VK_EXT_provoking_vertex[] 404 405 406[[drawing-triangle-lists]] 407=== Triangle Lists 408 409When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 410each consecutive set of three vertices defines a single triangle primitive, 411according to the equation: 412 413 {empty}:: [eq]#p~i~ = {v~3i~, v~3i+1~, v~3i+2~}# 414 415The number of primitives generated is equal to 416[eq]#{lfloor}pname:vertexCount/3{rfloor}#. 417 418ifdef::VK_EXT_provoking_vertex[] 419When the pname:provokingVertexMode is 420ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 421endif::VK_EXT_provoking_vertex[] 422ifndef::VK_EXT_provoking_vertex[] 423The 424endif::VK_EXT_provoking_vertex[] 425provoking vertex for [eq]#p~i~# is [eq]#v~3i~#. 426 427image::{images}/primitive_topology_triangle_list.svg[align="center",opts="{imageopts}"] 428 429ifdef::VK_EXT_provoking_vertex[] 430When the pname:provokingVertexMode is 431ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 432[eq]#p~i~# is [eq]#v~3i+2~#. 433 434image::{images}/primitive_topology_triangle_list_last.svg[align="center",opts="{imageopts}"] 435endif::VK_EXT_provoking_vertex[] 436 437 438[[drawing-triangle-strips]] 439=== Triangle Strips 440 441When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, 442one triangle primitive is defined by each vertex and the two vertices that 443follow it, according to the equation: 444 445 {empty}:: [eq]#p~i~ = {v~i~, v~i+(1+i%2)~, v~i+(2-i%2)~}# 446 447The number of primitives generated is equal to 448[eq]#max(0,pname:vertexCount-2)#. 449 450ifdef::VK_EXT_provoking_vertex[] 451When the pname:provokingVertexMode is 452ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 453endif::VK_EXT_provoking_vertex[] 454ifndef::VK_EXT_provoking_vertex[] 455The 456endif::VK_EXT_provoking_vertex[] 457provoking vertex for [eq]#p~i~# is [eq]#v~i~#. 458 459image::{images}/primitive_topology_triangle_strip.svg[align="center",opts="{imageopts}"] 460 461ifdef::VK_EXT_provoking_vertex[] 462When the pname:provokingVertexMode is 463ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 464[eq]#p~i~# is [eq]#v~i+2~#. 465 466image::{images}/primitive_topology_triangle_strip_last.svg[align="center",opts="{imageopts}"] 467endif::VK_EXT_provoking_vertex[] 468 469[NOTE] 470.Note 471==== 472The ordering of the vertices in each successive triangle is reversed, so 473that the winding order is consistent throughout the strip. 474==== 475 476 477[[drawing-triangle-fans]] 478=== Triangle Fans 479 480When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN, 481triangle primitives are defined around a shared common vertex, according to 482the equation: 483 484 {empty}:: [eq]#p~i~ = {v~i+1~, v~i+2~, v~0~}# 485 486The number of primitives generated is equal to 487[eq]#max(0,pname:vertexCount-2)#. 488 489ifdef::VK_EXT_provoking_vertex[] 490When the pname:provokingVertexMode is 491ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 492endif::VK_EXT_provoking_vertex[] 493ifndef::VK_EXT_provoking_vertex[] 494The 495endif::VK_EXT_provoking_vertex[] 496provoking vertex for [eq]#p~i~# is [eq]#v~i+1~#. 497 498image::{images}/primitive_topology_triangle_fan.svg[align="center",opts="{imageopts}"] 499 500ifdef::VK_EXT_provoking_vertex[] 501When the pname:provokingVertexMode is 502ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 503[eq]#p~i~# is [eq]#v~i+2~#. 504 505image::{images}/primitive_topology_triangle_fan_last.svg[align="center",opts="{imageopts}"] 506endif::VK_EXT_provoking_vertex[] 507 508ifdef::VK_KHR_portability_subset[] 509[NOTE] 510.Note 511==== 512If the `apiext:VK_KHR_portability_subset` extension is enabled, and 513slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:triangleFans is 514ename:VK_FALSE, then triangle fans are not supported by the implementation, 515and ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN must: not be used. 516==== 517endif::VK_KHR_portability_subset[] 518 519 520[[drawing-line-lists-with-adjacency]] 521=== Line Lists With Adjacency 522 523When the primitive topology is 524ename:VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, each consecutive set 525of four vertices defines a single line primitive with adjacency, according 526to the equation: 527 528 {empty}:: [eq]#p~i~ = {v~4i~, v~4i+1~, v~4i+2~,v~4i+3~}# 529 530A line primitive is described by the second and third vertices of the total 531primitive, with the remaining two vertices only accessible in a 532<<geometry,geometry shader>>. 533 534The number of primitives generated is equal to 535[eq]#{lfloor}pname:vertexCount/4{rfloor}#. 536 537ifdef::VK_EXT_provoking_vertex[] 538When the pname:provokingVertexMode is 539ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 540endif::VK_EXT_provoking_vertex[] 541ifndef::VK_EXT_provoking_vertex[] 542The 543endif::VK_EXT_provoking_vertex[] 544provoking vertex for [eq]#p~i~# is [eq]#v~4i+1~#. 545 546image::{images}/primitive_topology_line_list_with_adjacency.svg[align="center",opts="{imageopts}"] 547 548ifdef::VK_EXT_provoking_vertex[] 549When the pname:provokingVertexMode is 550ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 551[eq]#p~i~# is [eq]#v~4i+2~#. 552 553image::{images}/primitive_topology_line_list_with_adjacency_last.svg[align="center",opts="{imageopts}"] 554endif::VK_EXT_provoking_vertex[] 555 556 557[[drawing-line-strips-with-adjacency]] 558=== Line Strips With Adjacency 559 560When the primitive topology is 561ename:VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, one line primitive 562with adjacency is defined by each vertex and the following vertex, according 563to the equation: 564 565 {empty}:: [eq]#p~i~ = {v~i~, v~i+1~, v~i+2~, v~i+3~}# 566 567A line primitive is described by the second and third vertices of the total 568primitive, with the remaining two vertices only accessible in a 569<<geometry,geometry shader>>. 570 571The number of primitives generated is equal to 572[eq]#max(0,pname:vertexCount-3)#. 573 574ifdef::VK_EXT_provoking_vertex[] 575When the pname:provokingVertexMode is 576ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 577endif::VK_EXT_provoking_vertex[] 578ifndef::VK_EXT_provoking_vertex[] 579The 580endif::VK_EXT_provoking_vertex[] 581provoking vertex for [eq]#p~i~# is [eq]#v~i+1~#. 582 583image::{images}/primitive_topology_line_strip_with_adjacency.svg[align="center",opts="{imageopts}"] 584 585ifdef::VK_EXT_provoking_vertex[] 586When the pname:provokingVertexMode is 587ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 588[eq]#p~i~# is [eq]#v~i+2~#. 589 590image::{images}/primitive_topology_line_strip_with_adjacency_last.svg[align="center",opts="{imageopts}"] 591endif::VK_EXT_provoking_vertex[] 592 593 594[[drawing-triangle-lists-with-adjacency]] 595=== Triangle Lists With Adjacency 596 597When the primitive topology is 598ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, each consecutive 599set of six vertices defines a single triangle primitive with adjacency, 600according to the equations: 601 602 {empty}:: [eq]#p~i~ = {v~6i~, v~6i+1~, v~6i+2~, v~6i+3~, v~6i+4~, 603 v~6i+5~}# 604 605A triangle primitive is described by the first, third, and fifth vertices of 606the total primitive, with the remaining three vertices only accessible in a 607<<geometry,geometry shader>>. 608 609The number of primitives generated is equal to 610[eq]#{lfloor}pname:vertexCount/6{rfloor}#. 611 612ifdef::VK_EXT_provoking_vertex[] 613When the pname:provokingVertexMode is 614ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 615endif::VK_EXT_provoking_vertex[] 616ifndef::VK_EXT_provoking_vertex[] 617The 618endif::VK_EXT_provoking_vertex[] 619provoking vertex for [eq]#p~i~# is [eq]#v~6i~#. 620 621image::{images}/primitive_topology_triangle_list_with_adjacency.svg[align="center",opts="{imageopts}"] 622 623ifdef::VK_EXT_provoking_vertex[] 624When the pname:provokingVertexMode is 625ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 626[eq]#p~i~# is [eq]#v~6i+4~#. 627 628image::{images}/primitive_topology_triangle_list_with_adjacency_last.svg[align="center",opts="{imageopts}"] 629endif::VK_EXT_provoking_vertex[] 630 631 632[[drawing-triangle-strips-with-adjacency]] 633=== Triangle Strips With Adjacency 634 635When the primitive topology is 636ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, one triangle 637primitive with adjacency is defined by each vertex and the following 5 638vertices. 639 640The number of primitives generated, [eq]#n#, is equal to [eq]#{lfloor}max(0, 641pname:vertexCount - 4)/2{rfloor}#. 642 643If [eq]#n=1#, the primitive is defined as: 644 645 {empty}:: [eq]#p = {v~0~, v~1~, v~2~, v~5~, v~4~, v~3~}# 646 647If [eq]#n>1#, the total primitive consists of different vertices according 648to where it is in the strip: 649 650 {empty}:: [eq]#p~i~ = {v~2i~, v~2i+1~, v~2i+2~, v~2i+6~, v~2i+4~, 651 v~2i+3~}# when [eq]#i=0# 652 {empty}:: [eq]#p~i~ = {v~2i~, v~2i+3~, v~2i+4~, v~2i+6~, v~2i+2~, 653 v~2i-2~}# when [eq]#i>0#, [eq]#i<n-1#, and [eq]#i%2=1# 654 {empty}:: [eq]#p~i~ = {v~2i~, v~2i-2~, v~2i+2~, v~2i+6~, v~2i+4~, 655 v~2i+3~}# when [eq]#i>0#, [eq]#i<n-1#, and [eq]#i%2=0# 656 {empty}:: [eq]#p~i~ = {v~2i~, v~2i+3~, v~2i+4~, v~2i+5~, v~2i+2~, 657 v~2i-2~}# when [eq]#i=n-1# and [eq]#i%2=1# 658 {empty}:: [eq]#p~i~ = {v~2i~, v~2i-2~, v~2i+2~, v~2i+5~, v~2i+4~, 659 v~2i+3~}# when [eq]#i=n-1# and [eq]#i%2=0# 660 661A triangle primitive is described by the first, third, and fifth vertices of 662the total primitive in all cases, with the remaining three vertices only 663accessible in a <<geometry,geometry shader>>. 664 665[NOTE] 666.Note 667==== 668The ordering of the vertices in each successive triangle is altered so that 669the winding order is consistent throughout the strip. 670==== 671 672ifdef::VK_EXT_provoking_vertex[] 673When the pname:provokingVertexMode is 674ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the 675endif::VK_EXT_provoking_vertex[] 676ifndef::VK_EXT_provoking_vertex[] 677The 678endif::VK_EXT_provoking_vertex[] 679provoking vertex for [eq]#p~i~# is always [eq]#v~2i~#. 680 681image::{images}/primitive_topology_triangle_strip_with_adjacency.svg[align="center",opts="{imageopts}"] 682 683ifdef::VK_EXT_provoking_vertex[] 684When the pname:provokingVertexMode is 685ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the provoking vertex for 686[eq]#p~i~# is always [eq]#v~2i+4~#. 687 688image::{images}/primitive_topology_triangle_strip_with_adjacency_last.svg[align="center",opts="{imageopts}"] 689endif::VK_EXT_provoking_vertex[] 690 691 692[[drawing-patch-lists]] 693=== Patch Lists 694 695When the primitive topology is ename:VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, each 696consecutive set of [eq]#m# vertices defines a single patch primitive, 697according to the equation: 698 699 {empty}:: [eq]#p~i~ = {v~mi~, v~mi+1~, ..., v~mi+(m-2)~, v~mi+(m-1)~}# 700 701where [eq]#m# is equal to 702slink:VkPipelineTessellationStateCreateInfo::pname:patchControlPoints. 703 704Patch lists are never passed to <<vertexpostproc, vertex post-processing>>, 705and as such no provoking vertex is defined for patch primitives. 706The number of primitives generated is equal to 707[eq]#{lfloor}pname:vertexCount/m{rfloor}#. 708 709The vertices comprising a patch have no implied geometry, and are used as 710inputs to tessellation shaders and the fixed-function tessellator to 711generate new point, line, or triangle primitives. 712 713 714[[drawing-primitive-order]] 715== Primitive Order 716 717Primitives generated by <<drawing, drawing commands>> progress through the 718stages of the <<synchronization-pipeline-graphics, graphics pipeline>> in 719_primitive order_. 720Primitive order is initially determined in the following way: 721 722 . Submission order determines the initial ordering 723 . For indirect drawing commands, the order in which accessed instances of 724 the slink:VkDrawIndirectCommand are stored in pname:buffer, from lower 725 indirect buffer addresses to higher addresses. 726 . If a drawing command includes multiple instances, the order in which 727 instances are executed, from lower numbered instances to higher. 728 . The order in which primitives are specified by a drawing command: 729 ** For non-indexed draws, from vertices with a lower numbered 730 code:vertexIndex to a higher numbered code:vertexIndex. 731 ** For indexed draws, vertices sourced from a lower index buffer addresses 732 to higher addresses. 733ifdef::VK_NV_mesh_shader[] 734 ** For draws using mesh shaders, the order is provided by <<mesh-ordering, 735 mesh shading>>. 736endif::VK_NV_mesh_shader[] 737 738Within this order implementations further sort primitives: 739 740[start=5] 741 . If tessellation shading is active, by an implementation-dependent order 742 of new primitives generated by <<tessellation-primitive-order, 743 tessellation>>. 744 . If geometry shading is active, by the order new primitives are generated 745 by <<geometry-ordering, geometry shading>>. 746 . If the <<primsrast-polygonmode,polygon mode>> is not 747 ename:VK_POLYGON_MODE_FILL, 748ifdef::VK_NV_fill_rectangle[] 749 or ename:VK_POLYGON_MODE_FILL_RECTANGLE_NV, 750endif::VK_NV_fill_rectangle[] 751 by an implementation-dependent ordering of the new primitives generated 752 within the original primitive. 753 754Primitive order is later used to define <<primsrast-order, rasterization 755order>>, which determines the order in which fragments output results to a 756framebuffer. 757 758 759[[drawing-primitive-shading]] 760== Programmable Primitive Shading 761 762Once primitives are assembled, they proceed to the vertex shading stage of 763the pipeline. 764If the draw includes multiple instances, then the set of primitives is sent 765to the vertex shading stage multiple times, once for each instance. 766 767It is implementation-dependent whether vertex shading occurs on vertices 768that are discarded as part of incomplete primitives, but if it does occur 769then it operates as if they were vertices in complete primitives and such 770invocations can: have side effects. 771 772Vertex shading receives two per-vertex inputs from the primitive assembly 773stage - the code:vertexIndex and the code:instanceIndex. 774How these values are generated is defined below, with each command. 775 776Drawing commands fall roughly into two categories: 777 778 * Non-indexed drawing commands present a sequential code:vertexIndex to 779 the vertex shader. 780 The sequential index is generated automatically by the device (see 781 <<fxvertex,Fixed-Function Vertex Processing>> for details on both 782 specifying the vertex attributes indexed by code:vertexIndex, as well as 783 binding vertex buffers containing those attributes to a command buffer). 784 These commands are: 785 ** flink:vkCmdDraw 786 ** flink:vkCmdDrawIndirect 787ifdef::VK_VERSION_1_2[] 788 ** flink:vkCmdDrawIndirectCount 789endif::VK_VERSION_1_2[] 790ifdef::VK_KHR_draw_indirect_count[] 791 ** flink:vkCmdDrawIndirectCountKHR 792endif::VK_KHR_draw_indirect_count[] 793ifdef::VK_AMD_draw_indirect_count[] 794 ** flink:vkCmdDrawIndirectCountAMD 795endif::VK_AMD_draw_indirect_count[] 796ifdef::VK_EXT_multi_draw[] 797 ** flink:vkCmdDrawMultiEXT 798endif::VK_EXT_multi_draw[] 799 * Indexed drawing commands read index values from an _index buffer_ and 800 use this to compute the code:vertexIndex value for the vertex shader. 801 These commands are: 802 ** flink:vkCmdDrawIndexed 803 ** flink:vkCmdDrawIndexedIndirect 804ifdef::VK_VERSION_1_2[] 805 ** flink:vkCmdDrawIndexedIndirectCount 806endif::VK_VERSION_1_2[] 807ifdef::VK_KHR_draw_indirect_count[] 808 ** flink:vkCmdDrawIndexedIndirectCountKHR 809endif::VK_KHR_draw_indirect_count[] 810ifdef::VK_AMD_draw_indirect_count[] 811 ** flink:vkCmdDrawIndexedIndirectCountAMD 812endif::VK_AMD_draw_indirect_count[] 813ifdef::VK_EXT_multi_draw[] 814 ** flink:vkCmdDrawMultiIndexedEXT 815endif::VK_EXT_multi_draw[] 816 817 818[open,refpage='vkCmdBindIndexBuffer',desc='Bind an index buffer to a command buffer',type='protos'] 819-- 820To bind an index buffer to a command buffer, call: 821 822include::{generated}/api/protos/vkCmdBindIndexBuffer.txt[] 823 824 * pname:commandBuffer is the command buffer into which the command is 825 recorded. 826 * pname:buffer is the buffer being bound. 827 * pname:offset is the starting offset in bytes within pname:buffer used in 828 index buffer address calculations. 829 * pname:indexType is a elink:VkIndexType value specifying the size of the 830 indices. 831 832.Valid Usage 833**** 834 * [[VUID-vkCmdBindIndexBuffer-offset-00431]] 835 pname:offset must: be less than the size of pname:buffer 836 * [[VUID-vkCmdBindIndexBuffer-offset-00432]] 837 The sum of pname:offset and the address of the range of 838 sname:VkDeviceMemory object that is backing pname:buffer, must: be a 839 multiple of the type indicated by pname:indexType 840 * [[VUID-vkCmdBindIndexBuffer-buffer-00433]] 841 pname:buffer must: have been created with the 842 ename:VK_BUFFER_USAGE_INDEX_BUFFER_BIT flag 843 * [[VUID-vkCmdBindIndexBuffer-buffer-00434]] 844 If pname:buffer is non-sparse then it must: be bound completely and 845 contiguously to a single sname:VkDeviceMemory object 846ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 847 * [[VUID-vkCmdBindIndexBuffer-indexType-02507]] 848 pname:indexType must: not be ename:VK_INDEX_TYPE_NONE_KHR 849endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 850ifdef::VK_EXT_index_type_uint8[] 851 * [[VUID-vkCmdBindIndexBuffer-indexType-02765]] 852 If pname:indexType is ename:VK_INDEX_TYPE_UINT8_EXT, the 853 <<features-indexTypeUint8,indexTypeUint8>> feature must: be enabled 854endif::VK_EXT_index_type_uint8[] 855**** 856 857include::{generated}/validity/protos/vkCmdBindIndexBuffer.txt[] 858-- 859 860[open,refpage='VkIndexType',desc='Type of index buffer indices',type='enums'] 861-- 862Possible values of flink:vkCmdBindIndexBuffer::pname:indexType, specifying 863the size of indices, are: 864 865include::{generated}/api/enums/VkIndexType.txt[] 866 867 * ename:VK_INDEX_TYPE_UINT16 specifies that indices are 16-bit unsigned 868 integer values. 869 * ename:VK_INDEX_TYPE_UINT32 specifies that indices are 32-bit unsigned 870 integer values. 871ifdef::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 872 * ename:VK_INDEX_TYPE_NONE_KHR specifies that no indices are provided. 873endif::VK_NV_ray_tracing,VK_KHR_acceleration_structure[] 874ifdef::VK_EXT_index_type_uint8[] 875 * ename:VK_INDEX_TYPE_UINT8_EXT specifies that indices are 8-bit unsigned 876 integer values. 877endif::VK_EXT_index_type_uint8[] 878-- 879 880The parameters for each drawing command are specified directly in the 881command or read from buffer memory, depending on the command. 882Drawing commands that source their parameters from buffer memory are known 883as _indirect_ drawing commands. 884 885All drawing commands interact with the <<features-robustBufferAccess, Robust 886Buffer Access>> feature. 887 888[open,refpage='vkCmdDraw',desc='Draw primitives',type='protos'] 889-- 890:refpage: vkCmdDraw 891 892To record a non-indexed draw, call: 893 894include::{generated}/api/protos/vkCmdDraw.txt[] 895 896 * pname:commandBuffer is the command buffer into which the command is 897 recorded. 898 * pname:vertexCount is the number of vertices to draw. 899 * pname:instanceCount is the number of instances to draw. 900 * pname:firstVertex is the index of the first vertex to draw. 901 * pname:firstInstance is the instance ID of the first instance to draw. 902 903When the command is executed, primitives are assembled using the current 904primitive topology and pname:vertexCount consecutive vertex indices with the 905first code:vertexIndex value equal to pname:firstVertex. 906The primitives are drawn pname:instanceCount times with code:instanceIndex 907starting with pname:firstInstance and increasing sequentially for each 908instance. 909The assembled primitives execute the bound graphics pipeline. 910 911.Valid Usage 912**** 913include::{chapters}/commonvalidity/draw_common.txt[] 914include::{chapters}/commonvalidity/draw_dispatch_nonindirect_common.txt[] 915include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 916**** 917 918include::{generated}/validity/protos/vkCmdDraw.txt[] 919-- 920 921[open,refpage='vkCmdDrawIndexed',desc='Draw primitives with indexed vertices',type='protos'] 922-- 923:refpage: vkCmdDrawIndexed 924 925To record an indexed draw, call: 926 927include::{generated}/api/protos/vkCmdDrawIndexed.txt[] 928 929 * pname:commandBuffer is the command buffer into which the command is 930 recorded. 931 * pname:indexCount is the number of vertices to draw. 932 * pname:instanceCount is the number of instances to draw. 933 * pname:firstIndex is the base index within the index buffer. 934 * pname:vertexOffset is the value added to the vertex index before 935 indexing into the vertex buffer. 936 * pname:firstInstance is the instance ID of the first instance to draw. 937 938When the command is executed, primitives are assembled using the current 939primitive topology and pname:indexCount vertices whose indices are retrieved 940from the index buffer. 941The index buffer is treated as an array of tightly packed unsigned integers 942of size defined by the flink:vkCmdBindIndexBuffer::pname:indexType parameter 943with which the buffer was bound. 944 945The first vertex index is at an offset of [eq]#pname:firstIndex {times} 946code:indexSize {plus} pname:offset# within the bound index buffer, where 947pname:offset is the offset specified by fname:vkCmdBindIndexBuffer and 948code:indexSize is the byte size of the type specified by pname:indexType. 949Subsequent index values are retrieved from consecutive locations in the 950index buffer. 951Indices are first compared to the primitive restart value, then zero 952extended to 32 bits (if the code:indexType is 953ifdef::VK_EXT_index_type_uint8[] 954ename:VK_INDEX_TYPE_UINT8_EXT or 955endif::VK_EXT_index_type_uint8[] 956ename:VK_INDEX_TYPE_UINT16) and have pname:vertexOffset added to them, 957before being supplied as the code:vertexIndex value. 958 959The primitives are drawn pname:instanceCount times with code:instanceIndex 960starting with pname:firstInstance and increasing sequentially for each 961instance. 962The assembled primitives execute the bound graphics pipeline. 963 964.Valid Usage 965**** 966include::{chapters}/commonvalidity/draw_common.txt[] 967include::{chapters}/commonvalidity/draw_dispatch_nonindirect_common.txt[] 968include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 969 * [[VUID-vkCmdDrawIndexed-firstIndex-04932]] 970 [eq]#(code:indexSize {times} (pname:firstIndex {plus} pname:indexCount) 971 {plus} pname:offset)# must: be less than or equal to the size of the 972 bound index buffer, with code:indexSize being based on the type 973 specified by pname:indexType, where the index buffer, pname:indexType, 974 and pname:offset are specified via fname:vkCmdBindIndexBuffer 975**** 976 977include::{generated}/validity/protos/vkCmdDrawIndexed.txt[] 978-- 979 980ifdef::VK_EXT_multi_draw[] 981[open,refpage='vkCmdDrawMultiEXT',desc='Draw primitives',type='protos'] 982-- 983:refpage: vkCmdDrawMultiEXT 984 985To record an ordered sequence of drawing operations which have no state 986changes between them, call: 987 988include::{generated}/api/protos/vkCmdDrawMultiEXT.txt[] 989 990 * pname:commandBuffer is the command buffer into which the command is 991 recorded. 992 * pname:drawCount is the number of draws to execute, and can: be zero. 993 * pname:pVertexInfo is a pointer to an array of slink:VkMultiDrawInfoEXT 994 with vertex information to be drawn. 995 * pname:instanceCount is the number of instances to draw. 996 * pname:firstInstance is the instance ID of the first instance to draw. 997 * pname:stride is the byte stride between consecutive elements of 998 pname:pVertexInfo. 999 1000pname:drawCount draws are executed with parameters taken from 1001pname:pVertexInfo. 1002The number of draw commands recorded is pname:drawCount, with each command 1003reading, sequentially, a pname:firstVertex and a pname:vertexCount from 1004pname:pVertexInfo. 1005 1006.Valid Usage 1007**** 1008include::{chapters}/commonvalidity/draw_common.txt[] 1009include::{chapters}/commonvalidity/draw_dispatch_nonindirect_common.txt[] 1010include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1011 * [[VUID-vkCmdDrawMultiEXT-None-04933]] 1012 The <<features-multiDraw,multiDraw>> feature must: be enabled 1013 * [[VUID-vkCmdDrawMultiEXT-drawCount-04934]] 1014 pname:drawCount must: be less than 1015 sname:VkPhysicalDeviceMultiDrawPropertiesEXT::pname:maxMultiDrawCount 1016 * [[VUID-vkCmdDrawMultiEXT-drawCount-04935]] 1017 If pname:drawCount is greater than zero, pname:pVertexInfo must: be a 1018 valid pointer to memory containing one or more valid instances of 1019 slink:VkMultiDrawInfoEXT structures 1020 * [[VUID-vkCmdDrawMultiEXT-stride-04936]] 1021 pname:stride must be a multiple of 4 1022**** 1023 1024include::{generated}/validity/protos/vkCmdDrawMultiEXT.txt[] 1025-- 1026 1027[open,refpage='vkCmdDrawMultiIndexedEXT',desc='Draw primitives',type='protos'] 1028-- 1029:refpage: vkCmdDrawMultiIndexedEXT 1030 1031To record an ordered sequence of indexed drawing operations which have no 1032state changes between them, call: 1033 1034include::{generated}/api/protos/vkCmdDrawMultiIndexedEXT.txt[] 1035 1036 * pname:commandBuffer is the command buffer into which the command is 1037 recorded. 1038 * pname:drawCount is the number of draws to execute, and can: be zero. 1039 * pname:pIndexInfo is a pointer to an array of 1040 slink:VkMultiDrawIndexedInfoEXT with index information to be drawn. 1041 * pname:instanceCount is the number of instances to draw. 1042 * pname:firstInstance is the instance ID of the first instance to draw. 1043 * pname:stride is the byte stride between consecutive elements of 1044 pname:pIndexInfo. 1045 * pname:pVertexOffset is `NULL` or a pointer to the value added to the 1046 vertex index before indexing into the vertex buffer. 1047 When specified, sname:VkMultiDrawIndexedInfoEXT::pname:offset is 1048 ignored. 1049 1050pname:drawCount indexed draws are executed with parameters taken from 1051pname:pIndexInfo. 1052The number of draw commands recorded is pname:drawCount, with each command 1053reading, sequentially, a pname:firstIndex and an pname:indexCount from 1054pname:pIndexInfo. 1055If pname:pVertexOffset is `NULL`, a pname:vertexOffset is also read from 1056pname:pIndexInfo, otherwise the value from dereferencing pname:pVertexOffset 1057is used. 1058 1059.Valid Usage 1060**** 1061include::{chapters}/commonvalidity/draw_common.txt[] 1062include::{chapters}/commonvalidity/draw_dispatch_nonindirect_common.txt[] 1063include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1064 * [[VUID-vkCmdDrawMultiIndexedEXT-None-04937]] 1065 The <<features-multiDraw,multiDraw>> feature must: be enabled 1066 * [[VUID-vkCmdDrawMultiIndexedEXT-firstIndex-04938]] 1067 [eq]#(code:indexSize {times} (pname:firstIndex {plus} pname:indexCount) 1068 {plus} pname:offset)# must: be less than or equal to the size of the 1069 bound index buffer, with code:indexSize being based on the type 1070 specified by pname:indexType, where the index buffer, pname:indexType, 1071 and pname:offset are specified via fname:vkCmdBindIndexBuffer 1072 * [[VUID-vkCmdDrawMultiIndexedEXT-drawCount-04939]] 1073 pname:drawCount must: be less than 1074 sname:VkPhysicalDeviceMultiDrawPropertiesEXT::pname:maxMultiDrawCount 1075 * [[VUID-vkCmdDrawMultiIndexedEXT-drawCount-04940]] 1076 If pname:drawCount is greater than zero, pname:pIndexInfo must: be a 1077 valid pointer to memory containing one or more valid instances of 1078 slink:VkMultiDrawIndexedInfoEXT structures 1079 * [[VUID-vkCmdDrawMultiIndexedEXT-stride-04941]] 1080 pname:stride must be a multiple of 4 1081**** 1082 1083include::{generated}/validity/protos/vkCmdDrawMultiIndexedEXT.txt[] 1084-- 1085 1086[open,refpage='VkMultiDrawInfoEXT',desc='Structure specifying a multi-draw command',type='structs',xrefs='vkCmdDrawMultiEXT'] 1087-- 1088 1089The sname:VkMultiDrawInfoEXT structure is defined as: 1090 1091include::{generated}/api/structs/VkMultiDrawInfoEXT.txt[] 1092 1093 * pname:firstVertex is the first vertex to draw. 1094 * pname:vertexCount is the number of vertices to draw. 1095 1096The members of sname:VkMultiDrawInfoEXT have the same meaning as the 1097pname:firstVertex and pname:vertexCount parameters in flink:vkCmdDraw. 1098 1099include::{generated}/validity/structs/VkMultiDrawInfoEXT.txt[] 1100 1101-- 1102 1103[open,refpage='VkMultiDrawIndexedInfoEXT',desc='Structure specifying a multi-draw command',type='structs',xrefs='vkCmdDrawMultiIndexedEXT'] 1104-- 1105 1106The sname:VkMultiDrawIndexedInfoEXT structure is defined as: 1107 1108include::{generated}/api/structs/VkMultiDrawIndexedInfoEXT.txt[] 1109 1110 * pname:firstIndex is the first index to draw. 1111 * pname:indexCount is the number of vertices to draw. 1112 * pname:vertexOffset is the value added to the vertex index before 1113 indexing into the vertex buffer for indexed multidraws. 1114 1115The pname:firstIndex, pname:indexCount, and pname:vertexOffset members of 1116sname:VkMultiDrawIndexedInfoEXT have the same meaning as the 1117pname:firstIndex, pname:indexCount, and pname:vertexOffset parameters, 1118respectively, of flink:vkCmdDrawIndexed. 1119 1120include::{generated}/validity/structs/VkMultiDrawIndexedInfoEXT.txt[] 1121 1122-- 1123endif::VK_EXT_multi_draw[] 1124 1125[open,refpage='vkCmdDrawIndirect',desc='Draw primitives with indirect parameters',type='protos'] 1126-- 1127:refpage: vkCmdDrawIndirect 1128 1129To record a non-indexed indirect drawing command, call: 1130 1131include::{generated}/api/protos/vkCmdDrawIndirect.txt[] 1132 1133 * pname:commandBuffer is the command buffer into which the command is 1134 recorded. 1135 * pname:buffer is the buffer containing draw parameters. 1136 * pname:offset is the byte offset into pname:buffer where parameters 1137 begin. 1138 * pname:drawCount is the number of draws to execute, and can: be zero. 1139 * pname:stride is the byte stride between successive sets of draw 1140 parameters. 1141 1142fname:vkCmdDrawIndirect behaves similarly to flink:vkCmdDraw except that the 1143parameters are read by the device from a buffer during execution. 1144pname:drawCount draws are executed by the command, with parameters taken 1145from pname:buffer starting at pname:offset and increasing by pname:stride 1146bytes for each successive draw. 1147The parameters of each draw are encoded in an array of 1148slink:VkDrawIndirectCommand structures. 1149If pname:drawCount is less than or equal to one, pname:stride is ignored. 1150 1151.Valid Usage 1152**** 1153include::{chapters}/commonvalidity/draw_common.txt[] 1154include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1155include::{chapters}/commonvalidity/draw_dispatch_indirect_common.txt[] 1156include::{chapters}/commonvalidity/draw_indirect_drawcount.txt[] 1157 * [[VUID-vkCmdDrawIndirect-firstInstance-00478]] 1158 If the <<features-drawIndirectFirstInstance,drawIndirectFirstInstance>> 1159 feature is not enabled, all the pname:firstInstance members of the 1160 sname:VkDrawIndirectCommand structures accessed by this command must: be 1161 code:0 1162 * [[VUID-vkCmdDrawIndirect-drawCount-00476]] 1163 If pname:drawCount is greater than `1`, pname:stride must: be a multiple 1164 of `4` and must: be greater than or equal to 1165 code:sizeof(sname:VkDrawIndirectCommand) 1166 * [[VUID-vkCmdDrawIndirect-drawCount-00487]] 1167 If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus} 1168 code:sizeof(slink:VkDrawIndirectCommand))# must: be less than or equal 1169 to the size of pname:buffer 1170 * [[VUID-vkCmdDrawIndirect-drawCount-00488]] 1171 If pname:drawCount is greater than `1`, [eq]#(pname:stride {times} 1172 (pname:drawCount - 1) {plus} pname:offset {plus} 1173 code:sizeof(slink:VkDrawIndirectCommand))# must: be less than or equal 1174 to the size of pname:buffer 1175**** 1176 1177include::{generated}/validity/protos/vkCmdDrawIndirect.txt[] 1178-- 1179 1180[open,refpage='VkDrawIndirectCommand',desc='Structure specifying a indirect drawing command',type='structs',xrefs='vkCmdDrawIndirect'] 1181-- 1182The sname:VkDrawIndirectCommand structure is defined as: 1183 1184include::{generated}/api/structs/VkDrawIndirectCommand.txt[] 1185 1186 * pname:vertexCount is the number of vertices to draw. 1187 * pname:instanceCount is the number of instances to draw. 1188 * pname:firstVertex is the index of the first vertex to draw. 1189 * pname:firstInstance is the instance ID of the first instance to draw. 1190 1191The members of sname:VkDrawIndirectCommand have the same meaning as the 1192similarly named parameters of flink:vkCmdDraw. 1193 1194.Valid Usage 1195**** 1196 * [[VUID-VkDrawIndirectCommand-None-00500]] 1197 For a given vertex buffer binding, any attribute data fetched must: be 1198 entirely contained within the corresponding vertex buffer binding, as 1199 described in <<fxvertex-input>> 1200 * [[VUID-VkDrawIndirectCommand-firstInstance-00501]] 1201 If the <<features-drawIndirectFirstInstance,drawIndirectFirstInstance>> 1202 feature is not enabled, pname:firstInstance must: be code:0 1203**** 1204 1205include::{generated}/validity/structs/VkDrawIndirectCommand.txt[] 1206 1207-- 1208 1209ifdef::VK_VERSION_1_2,VK_KHR_draw_indirect_count[] 1210[open,refpage='vkCmdDrawIndirectCount',desc='Draw primitives with indirect parameters and draw count',type='protos',alias='vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountAMD'] 1211-- 1212:refpage: vkCmdDrawIndirectCount 1213 1214To record a non-indexed draw call with a draw call count sourced from a 1215buffer, call: 1216 1217ifdef::VK_VERSION_1_2[] 1218include::{generated}/api/protos/vkCmdDrawIndirectCount.txt[] 1219endif::VK_VERSION_1_2[] 1220 1221// Jon: conditional logic on connective clauses with 3 forms of the command including VK_VERSION_1_2 needs work. 1222ifdef::VK_VERSION_1_2+VK_KHR_draw_indirect_count[or the equivalent command] 1223 1224ifdef::VK_KHR_draw_indirect_count[] 1225include::{generated}/api/protos/vkCmdDrawIndirectCountKHR.txt[] 1226endif::VK_KHR_draw_indirect_count[] 1227 1228ifdef::VK_KHR_draw_indirect_count+VK_AMD_draw_indirect_count[or the equivalent command] 1229 1230ifdef::VK_AMD_draw_indirect_count[] 1231include::{generated}/api/protos/vkCmdDrawIndirectCountAMD.txt[] 1232endif::VK_AMD_draw_indirect_count[] 1233 1234 * pname:commandBuffer is the command buffer into which the command is 1235 recorded. 1236 * pname:buffer is the buffer containing draw parameters. 1237 * pname:offset is the byte offset into pname:buffer where parameters 1238 begin. 1239 * pname:countBuffer is the buffer containing the draw count. 1240 * pname:countBufferOffset is the byte offset into pname:countBuffer where 1241 the draw count begins. 1242 * pname:maxDrawCount specifies the maximum number of draws that will be 1243 executed. 1244 The actual number of executed draw calls is the minimum of the count 1245 specified in pname:countBuffer and pname:maxDrawCount. 1246 * pname:stride is the byte stride between successive sets of draw 1247 parameters. 1248 1249fname:vkCmdDrawIndirectCount behaves similarly to flink:vkCmdDrawIndirect 1250except that the draw count is read by the device from a buffer during 1251execution. 1252The command will read an unsigned 32-bit integer from pname:countBuffer 1253located at pname:countBufferOffset and use this as the draw count. 1254 1255.Valid Usage 1256**** 1257include::{chapters}/commonvalidity/draw_common.txt[] 1258include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1259include::{chapters}/commonvalidity/draw_dispatch_indirect_common.txt[] 1260include::{chapters}/commonvalidity/draw_indirect_count_common.txt[] 1261 * [[VUID-vkCmdDrawIndirectCount-stride-03110]] 1262 pname:stride must: be a multiple of `4` and must: be greater than or 1263 equal to sizeof(sname:VkDrawIndirectCommand) 1264 * [[VUID-vkCmdDrawIndirectCount-maxDrawCount-03111]] 1265 If pname:maxDrawCount is greater than or equal to `1`, 1266 [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset 1267 {plus} sizeof(sname:VkDrawIndirectCommand))# must: be less than or equal 1268 to the size of pname:buffer 1269 * [[VUID-vkCmdDrawIndirectCount-countBuffer-03121]] 1270 If the count stored in pname:countBuffer is equal to `1`, 1271 [eq]#(pname:offset {plus} sizeof(sname:VkDrawIndirectCommand))# must: be 1272 less than or equal to the size of pname:buffer 1273 * [[VUID-vkCmdDrawIndirectCount-countBuffer-03122]] 1274 If the count stored in pname:countBuffer is greater than `1`, 1275 [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset 1276 {plus} sizeof(sname:VkDrawIndirectCommand))# must: be less than or equal 1277 to the size of pname:buffer 1278**** 1279 1280include::{generated}/validity/protos/vkCmdDrawIndirectCount.txt[] 1281 1282-- 1283endif::VK_VERSION_1_2,VK_KHR_draw_indirect_count[] 1284 1285[open,refpage='vkCmdDrawIndexedIndirect',desc='Draw primitives with indirect parameters and indexed vertices',type='protos'] 1286-- 1287:refpage: vkCmdDrawIndexedIndirect 1288 1289To record an indexed indirect drawing command, call: 1290 1291include::{generated}/api/protos/vkCmdDrawIndexedIndirect.txt[] 1292 1293 * pname:commandBuffer is the command buffer into which the command is 1294 recorded. 1295 * pname:buffer is the buffer containing draw parameters. 1296 * pname:offset is the byte offset into pname:buffer where parameters 1297 begin. 1298 * pname:drawCount is the number of draws to execute, and can: be zero. 1299 * pname:stride is the byte stride between successive sets of draw 1300 parameters. 1301 1302fname:vkCmdDrawIndexedIndirect behaves similarly to flink:vkCmdDrawIndexed 1303except that the parameters are read by the device from a buffer during 1304execution. 1305pname:drawCount draws are executed by the command, with parameters taken 1306from pname:buffer starting at pname:offset and increasing by pname:stride 1307bytes for each successive draw. 1308The parameters of each draw are encoded in an array of 1309slink:VkDrawIndexedIndirectCommand structures. 1310If pname:drawCount is less than or equal to one, pname:stride is ignored. 1311 1312.Valid Usage 1313**** 1314include::{chapters}/commonvalidity/draw_common.txt[] 1315include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1316include::{chapters}/commonvalidity/draw_dispatch_indirect_common.txt[] 1317include::{chapters}/commonvalidity/draw_indirect_drawcount.txt[] 1318 * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00528]] 1319 If pname:drawCount is greater than `1`, pname:stride must: be a multiple 1320 of `4` and must: be greater than or equal to 1321 code:sizeof(sname:VkDrawIndexedIndirectCommand) 1322 * [[VUID-vkCmdDrawIndexedIndirect-firstInstance-00530]] 1323 If the <<features-drawIndirectFirstInstance,drawIndirectFirstInstance>> 1324 feature is not enabled, all the pname:firstInstance members of the 1325 sname:VkDrawIndexedIndirectCommand structures accessed by this command 1326 must: be code:0 1327 * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00539]] 1328 If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus} 1329 code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than or 1330 equal to the size of pname:buffer 1331 * [[VUID-vkCmdDrawIndexedIndirect-drawCount-00540]] 1332 If pname:drawCount is greater than `1`, [eq]#(pname:stride {times} 1333 (pname:drawCount - 1) {plus} pname:offset {plus} 1334 code:sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than or 1335 equal to the size of pname:buffer 1336**** 1337 1338include::{generated}/validity/protos/vkCmdDrawIndexedIndirect.txt[] 1339-- 1340 1341[open,refpage='VkDrawIndexedIndirectCommand',desc='Structure specifying a indexed indirect drawing command',type='structs',xrefs='vkCmdDrawIndexedIndirect'] 1342-- 1343The sname:VkDrawIndexedIndirectCommand structure is defined as: 1344 1345include::{generated}/api/structs/VkDrawIndexedIndirectCommand.txt[] 1346 1347 * pname:indexCount is the number of vertices to draw. 1348 * pname:instanceCount is the number of instances to draw. 1349 * pname:firstIndex is the base index within the index buffer. 1350 * pname:vertexOffset is the value added to the vertex index before 1351 indexing into the vertex buffer. 1352 * pname:firstInstance is the instance ID of the first instance to draw. 1353 1354The members of sname:VkDrawIndexedIndirectCommand have the same meaning as 1355the similarly named parameters of flink:vkCmdDrawIndexed. 1356 1357.Valid Usage 1358**** 1359 * [[VUID-VkDrawIndexedIndirectCommand-None-00552]] 1360 For a given vertex buffer binding, any attribute data fetched must: be 1361 entirely contained within the corresponding vertex buffer binding, as 1362 described in <<fxvertex-input>> 1363 * [[VUID-VkDrawIndexedIndirectCommand-indexSize-00553]] 1364 [eq]#(code:indexSize {times} (pname:firstIndex {plus} pname:indexCount) 1365 {plus} pname:offset)# must: be less than or equal to the size of the 1366 bound index buffer, with code:indexSize being based on the type 1367 specified by pname:indexType, where the index buffer, pname:indexType, 1368 and pname:offset are specified via fname:vkCmdBindIndexBuffer 1369 * [[VUID-VkDrawIndexedIndirectCommand-firstInstance-00554]] 1370 If the <<features-drawIndirectFirstInstance,drawIndirectFirstInstance>> 1371 feature is not enabled, pname:firstInstance must: be code:0 1372**** 1373 1374include::{generated}/validity/structs/VkDrawIndexedIndirectCommand.txt[] 1375-- 1376 1377ifdef::VK_VERSION_1_2,VK_KHR_draw_indirect_count[] 1378[open,refpage='vkCmdDrawIndexedIndirectCount',desc='Draw parameters with indirect parameters, indexed vertices, and draw count',type='protos',alias='vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountAMD'] 1379-- 1380:refpage: vkCmdDrawIndexedIndirectCount 1381 1382To record an indexed draw call with a draw call count sourced from a buffer, 1383call: 1384 1385ifdef::VK_VERSION_1_2[] 1386include::{generated}/api/protos/vkCmdDrawIndexedIndirectCount.txt[] 1387endif::VK_VERSION_1_2[] 1388 1389// Jon: conditional logic on connective clauses with 3 forms of the command including VK_VERSION_1_2 needs work. 1390ifdef::VK_VERSION_1_2+VK_KHR_draw_indirect_count[or the equivalent command] 1391 1392ifdef::VK_KHR_draw_indirect_count[] 1393include::{generated}/api/protos/vkCmdDrawIndexedIndirectCountKHR.txt[] 1394endif::VK_KHR_draw_indirect_count[] 1395 1396ifdef::VK_KHR_draw_indirect_count+VK_AMD_draw_indirect_count[or the equivalent command] 1397 1398ifdef::VK_AMD_draw_indirect_count[] 1399include::{generated}/api/protos/vkCmdDrawIndexedIndirectCountAMD.txt[] 1400endif::VK_AMD_draw_indirect_count[] 1401 1402 * pname:commandBuffer is the command buffer into which the command is 1403 recorded. 1404 * pname:buffer is the buffer containing draw parameters. 1405 * pname:offset is the byte offset into pname:buffer where parameters 1406 begin. 1407 * pname:countBuffer is the buffer containing the draw count. 1408 * pname:countBufferOffset is the byte offset into pname:countBuffer where 1409 the draw count begins. 1410 * pname:maxDrawCount specifies the maximum number of draws that will be 1411 executed. 1412 The actual number of executed draw calls is the minimum of the count 1413 specified in pname:countBuffer and pname:maxDrawCount. 1414 * pname:stride is the byte stride between successive sets of draw 1415 parameters. 1416 1417fname:vkCmdDrawIndexedIndirectCount behaves similarly to 1418flink:vkCmdDrawIndexedIndirect except that the draw count is read by the 1419device from a buffer during execution. 1420The command will read an unsigned 32-bit integer from pname:countBuffer 1421located at pname:countBufferOffset and use this as the draw count. 1422 1423.Valid Usage 1424**** 1425include::{chapters}/commonvalidity/draw_common.txt[] 1426include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1427include::{chapters}/commonvalidity/draw_dispatch_indirect_common.txt[] 1428include::{chapters}/commonvalidity/draw_indirect_count_common.txt[] 1429 * [[VUID-vkCmdDrawIndexedIndirectCount-stride-03142]] 1430 pname:stride must: be a multiple of `4` and must: be greater than or 1431 equal to sizeof(sname:VkDrawIndexedIndirectCommand) 1432 * [[VUID-vkCmdDrawIndexedIndirectCount-maxDrawCount-03143]] 1433 If pname:maxDrawCount is greater than or equal to `1`, 1434 [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset 1435 {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than 1436 or equal to the size of pname:buffer 1437 * [[VUID-vkCmdDrawIndexedIndirectCount-countBuffer-03153]] 1438 If count stored in pname:countBuffer is equal to `1`, [eq]#(pname:offset 1439 {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than 1440 or equal to the size of pname:buffer 1441 * [[VUID-vkCmdDrawIndexedIndirectCount-countBuffer-03154]] 1442 If count stored in pname:countBuffer is greater than `1`, 1443 [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset 1444 {plus} sizeof(sname:VkDrawIndexedIndirectCommand))# must: be less than 1445 or equal to the size of pname:buffer 1446**** 1447 1448include::{generated}/validity/protos/vkCmdDrawIndexedIndirectCount.txt[] 1449-- 1450endif::VK_VERSION_1_2,VK_KHR_draw_indirect_count[] 1451 1452 1453ifdef::VK_EXT_transform_feedback[] 1454[[drawing-transform-feedback]] 1455=== Drawing Transform Feedback 1456 1457It is possible to draw vertex data that was previously captured during 1458active <<vertexpostproc-transform-feedback,transform feedback>> by binding 1459one or more of the transform feedback buffers as vertex buffers. 1460A pipeline barrier is required between using the buffers as transform 1461feedback buffers and vertex buffers to ensure all writes to the transform 1462feedback buffers are visible when the data is read as vertex attributes. 1463The source access is ename:VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT and 1464the destination access is ename:VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT for the 1465pipeline stages ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT and 1466ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT respectively. 1467The value written to the counter buffer by 1468flink:vkCmdEndTransformFeedbackEXT can: be used to determine the vertex 1469count for the draw. 1470A pipeline barrier is required between using the counter buffer for 1471fname:vkCmdEndTransformFeedbackEXT and fname:vkCmdDrawIndirectByteCountEXT 1472where the source access is 1473ename:VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT and the destination 1474access is ename:VK_ACCESS_INDIRECT_COMMAND_READ_BIT for the pipeline stages 1475ename:VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT and 1476ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT respectively. 1477 1478[open,refpage='vkCmdDrawIndirectByteCountEXT',desc='Draw primitives with indirect parameters where the vertex count is derived from the counter byte value in the counter buffer',type='protos'] 1479-- 1480:refpage: vkCmdDrawIndirectByteCountEXT 1481 1482To record a non-indexed draw call, where the vertex count is based on a byte 1483count read from a buffer and the passed in vertex stride parameter, call: 1484 1485include::{generated}/api/protos/vkCmdDrawIndirectByteCountEXT.txt[] 1486 1487 * pname:commandBuffer is the command buffer into which the command is 1488 recorded. 1489 * pname:instanceCount is the number of instances to draw. 1490 * pname:firstInstance is the instance ID of the first instance to draw. 1491 * pname:counterBuffer is the buffer handle from where the byte count is 1492 read. 1493 * pname:counterBufferOffset is the offset into the buffer used to read the 1494 byte count, which is used to calculate the vertex count for this draw 1495 call. 1496 * pname:counterOffset is subtracted from the byte count read from the 1497 pname:counterBuffer at the pname:counterBufferOffset 1498 * pname:vertexStride is the stride in bytes between each element of the 1499 vertex data that is used to calculate the vertex count from the counter 1500 value. 1501 This value is typically the same value that was used in the graphics 1502 pipeline state when the transform feedback was captured as the 1503 code:XfbStride. 1504 1505When the command is executed, primitives are assembled in the same way as 1506done with flink:vkCmdDraw except the pname:vertexCount is calculated based 1507on the byte count read from pname:counterBuffer at offset 1508pname:counterBufferOffset. 1509The assembled primitives execute the bound graphics pipeline. 1510 1511The effective pname:vertexCount is calculated as follows: 1512 1513[source,c] 1514~~~~ 1515const uint32_t * counterBufferPtr = (const uint8_t *)counterBuffer.address + counterBufferOffset; 1516vertexCount = floor(max(0, (*counterBufferPtr - counterOffset)) / vertexStride); 1517~~~~ 1518 1519The effective pname:firstVertex is zero. 1520 1521.Valid Usage 1522**** 1523include::{chapters}/commonvalidity/draw_common.txt[] 1524include::{chapters}/commonvalidity/draw_vertex_binding.txt[] 1525 * [[VUID-vkCmdDrawIndirectByteCountEXT-transformFeedback-02287]] 1526 sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:transformFeedback 1527 must: be enabled 1528 * [[VUID-vkCmdDrawIndirectByteCountEXT-transformFeedbackDraw-02288]] 1529 The implementation must: support 1530 sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackDraw 1531 * [[VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289]] 1532 pname:vertexStride must: be greater than 0 and less than or equal to 1533 slink:VkPhysicalDeviceLimits::pname:maxTransformFeedbackBufferDataStride 1534 * [[VUID-vkCmdDrawIndirectByteCountEXT-counterBuffer-04567]] 1535 If pname:counterBuffer is non-sparse then it must: be bound completely 1536 and contiguously to a single sname:VkDeviceMemory object 1537 * [[VUID-vkCmdDrawIndirectByteCountEXT-counterBuffer-02290]] 1538 pname:counterBuffer must: have been created with the 1539 ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set 1540 * [[VUID-vkCmdDrawIndirectByteCountEXT-counterBufferOffset-04568]] 1541 pname:counterBufferOffset must: be a multiple of `4` 1542ifdef::VK_VERSION_1_1[] 1543 * [[VUID-vkCmdDrawIndirectByteCountEXT-commandBuffer-02646]] 1544 pname:commandBuffer must: not be a protected command buffer 1545endif::VK_VERSION_1_1[] 1546**** 1547 1548include::{generated}/validity/protos/vkCmdDrawIndirectByteCountEXT.txt[] 1549-- 1550endif::VK_EXT_transform_feedback[] 1551 1552 1553ifdef::VK_EXT_conditional_rendering[] 1554[[drawing-conditional-rendering]] 1555== Conditional Rendering 1556 1557Certain rendering commands can: be executed conditionally based on a value 1558in buffer memory. 1559These rendering commands are limited to <<drawing,drawing commands>>, 1560<<dispatch,dispatching commands>>, and clearing attachments with 1561flink:vkCmdClearAttachments within a conditional rendering block which is 1562defined by commands flink:vkCmdBeginConditionalRenderingEXT and 1563flink:vkCmdEndConditionalRenderingEXT. 1564Other rendering commands remain unaffected by conditional rendering. 1565 1566[[active-conditional-rendering]] 1567After beginning conditional rendering, it is considered _active_ within the 1568command buffer it was called until it is ended with 1569flink:vkCmdEndConditionalRenderingEXT. 1570 1571Conditional rendering must: begin and end in the same command buffer. 1572When conditional rendering is active, a primary command buffer can: execute 1573secondary command buffers if the <<features-inheritedConditionalRendering, 1574inherited conditional rendering>> feature is enabled. 1575For a secondary command buffer to be executed while conditional rendering is 1576active in the primary command buffer, it must: set the 1577pname:conditionalRenderingEnable flag of 1578slink:VkCommandBufferInheritanceConditionalRenderingInfoEXT, as described in 1579the <<commandbuffers-recording, Command Buffer Recording>> section. 1580 1581Conditional rendering must: also either begin and end inside the same 1582subpass of a render pass instance, or must: both begin and end outside of a 1583render pass instance (i.e. contain entire render pass instances). 1584 1585[open,refpage='vkCmdBeginConditionalRenderingEXT',desc='Define the beginning of a conditional rendering block',type='protos'] 1586-- 1587To begin conditional rendering, call: 1588 1589include::{generated}/api/protos/vkCmdBeginConditionalRenderingEXT.txt[] 1590 1591 * pname:commandBuffer is the command buffer into which this command will 1592 be recorded. 1593 * pname:pConditionalRenderingBegin is a pointer to a 1594 slink:VkConditionalRenderingBeginInfoEXT structure specifying parameters 1595 of conditional rendering. 1596 1597.Valid Usage 1598**** 1599 * [[VUID-vkCmdBeginConditionalRenderingEXT-None-01980]] 1600 Conditional rendering must: not already be 1601 <<active-conditional-rendering,active>> 1602**** 1603 1604include::{generated}/validity/protos/vkCmdBeginConditionalRenderingEXT.txt[] 1605-- 1606 1607[open,refpage='VkConditionalRenderingBeginInfoEXT',desc='Structure specifying conditional rendering begin information',type='structs'] 1608-- 1609The sname:VkConditionalRenderingBeginInfoEXT structure is defined as: 1610 1611include::{generated}/api/structs/VkConditionalRenderingBeginInfoEXT.txt[] 1612 1613 * pname:sType is the type of this structure. 1614 * pname:pNext is `NULL` or a pointer to a structure extending this 1615 structure. 1616 * pname:buffer is a buffer containing the predicate for conditional 1617 rendering. 1618 * pname:offset is the byte offset into pname:buffer where the predicate is 1619 located. 1620 * pname:flags is a bitmask of tlink:VkConditionalRenderingFlagsEXT 1621 specifying the behavior of conditional rendering. 1622 1623If the 32-bit value at pname:offset in pname:buffer memory is zero, then the 1624rendering commands are discarded, otherwise they are executed as normal. 1625If the value of the predicate in buffer memory changes while conditional 1626rendering is active, the rendering commands may: be discarded in an 1627implementation-dependent way. 1628Some implementations may latch the value of the predicate upon beginning 1629conditional rendering while others may read it before every rendering 1630command. 1631 1632.Valid Usage 1633**** 1634 * [[VUID-VkConditionalRenderingBeginInfoEXT-buffer-01981]] 1635 If pname:buffer is non-sparse then it must: be bound completely and 1636 contiguously to a single sname:VkDeviceMemory object 1637 * [[VUID-VkConditionalRenderingBeginInfoEXT-buffer-01982]] 1638 pname:buffer must: have been created with the 1639 ename:VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT bit set 1640 * [[VUID-VkConditionalRenderingBeginInfoEXT-offset-01983]] 1641 pname:offset must: be less than the size of pname:buffer by at least 32 1642 bits 1643 * [[VUID-VkConditionalRenderingBeginInfoEXT-offset-01984]] 1644 pname:offset must: be a multiple of 4 1645**** 1646 1647include::{generated}/validity/structs/VkConditionalRenderingBeginInfoEXT.txt[] 1648 1649-- 1650 1651[open,refpage='VkConditionalRenderingFlagBitsEXT',desc='Specify the behavior of conditional rendering',type='enums'] 1652-- 1653Bits which can: be set in 1654flink:vkCmdBeginConditionalRenderingEXT::pname:flags specifying the behavior 1655of conditional rendering are: 1656 1657include::{generated}/api/enums/VkConditionalRenderingFlagBitsEXT.txt[] 1658 1659 * ename:VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT specifies the condition 1660 used to determine whether to discard rendering commands or not. 1661 That is, if the 32-bit predicate read from pname:buffer memory at 1662 pname:offset is zero, the rendering commands are not discarded, and if 1663 non zero, then they are discarded. 1664-- 1665 1666[open,refpage='VkConditionalRenderingFlagsEXT',desc='Bitmask of VkConditionalRenderingFlagBitsEXT',type='flags'] 1667-- 1668include::{generated}/api/flags/VkConditionalRenderingFlagsEXT.txt[] 1669 1670tname:VkConditionalRenderingFlagsEXT is a bitmask type for setting a mask of 1671zero or more elink:VkConditionalRenderingFlagBitsEXT. 1672-- 1673 1674[open,refpage='vkCmdEndConditionalRenderingEXT',desc='Define the end of a conditional rendering block',type='protos'] 1675-- 1676To end conditional rendering, call: 1677 1678include::{generated}/api/protos/vkCmdEndConditionalRenderingEXT.txt[] 1679 1680 * pname:commandBuffer is the command buffer into which this command will 1681 be recorded. 1682 1683Once ended, conditional rendering becomes inactive. 1684 1685.Valid Usage 1686**** 1687 * [[VUID-vkCmdEndConditionalRenderingEXT-None-01985]] 1688 Conditional rendering must: be <<active-conditional-rendering,active>> 1689 * [[VUID-vkCmdEndConditionalRenderingEXT-None-01986]] 1690 If conditional rendering was made 1691 <<active-conditional-rendering,active>> outside of a render pass 1692 instance, it must: not be ended inside a render pass instance 1693 * [[VUID-vkCmdEndConditionalRenderingEXT-None-01987]] 1694 If conditional rendering was made 1695 <<active-conditional-rendering,active>> within a subpass it must: be 1696 ended in the same subpass 1697**** 1698 1699include::{generated}/validity/protos/vkCmdEndConditionalRenderingEXT.txt[] 1700-- 1701endif::VK_EXT_conditional_rendering[] 1702 1703ifdef::VK_NV_mesh_shader[] 1704include::{chapters}/VK_NV_mesh_shader/drawing.txt[] 1705endif::VK_NV_mesh_shader[] 1706