1// Copyright 2015-2023 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[fxvertex]] 6= Fixed-Function Vertex Processing 7 8Vertex fetching is controlled via configurable state, as a logically 9distinct graphics pipeline stage. 10 11 12[[fxvertex-attrib]] 13== Vertex Attributes 14 15Vertex shaders can: define input variables, which receive _vertex attribute_ 16data transferred from one or more sname:VkBuffer(s) by drawing commands. 17Vertex shader input variables are bound to buffers via an indirect binding 18where the vertex shader associates a _vertex input attribute_ number with 19each variable, vertex input attributes are associated to _vertex input 20bindings_ on a per-pipeline basis, and vertex input bindings are associated 21with specific buffers on a per-draw basis via the 22fname:vkCmdBindVertexBuffers command. 23Vertex input attribute and vertex input binding descriptions also contain 24format information controlling how data is extracted from buffer memory and 25converted to the format expected by the vertex shader. 26 27There are sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributes 28number of vertex input attributes and 29sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings number of vertex 30input bindings (each referred to by zero-based indices), where there are at 31least as many vertex input attributes as there are vertex input bindings. 32Applications can: store multiple vertex input attributes interleaved in a 33single buffer, and use a single vertex input binding to access those 34attributes. 35 36In GLSL, vertex shaders associate input variables with a vertex input 37attribute number using the code:location layout qualifier. 38The code:Component layout qualifier associates components of a vertex shader 39input variable with components of a vertex input attribute. 40 41.GLSL example 42[source,glsl] 43---- 44// Assign location M to variableName 45layout (location=M, component=2) in vec2 variableName; 46 47// Assign locations [N,N+L) to the array elements of variableNameArray 48layout (location=N) in vec4 variableNameArray[L]; 49---- 50 51In SPIR-V, vertex shaders associate input variables with a vertex input 52attribute number using the code:Location decoration. 53The code:Component decoration associates components of a vertex shader input 54variable with components of a vertex input attribute. 55The code:Location and code:Component decorations are specified via the 56code:OpDecorate instruction. 57 58.SPIR-V example 59[source,spirv] 60---- 61 ... 62 %1 = OpExtInstImport "GLSL.std.450" 63 ... 64 OpName %9 "variableName" 65 OpName %15 "variableNameArray" 66 OpDecorate %18 BuiltIn VertexIndex 67 OpDecorate %19 BuiltIn InstanceIndex 68 OpDecorate %9 Location M 69 OpDecorate %9 Component 2 70 OpDecorate %15 Location N 71 ... 72 %2 = OpTypeVoid 73 %3 = OpTypeFunction %2 74 %6 = OpTypeFloat 32 75 %7 = OpTypeVector %6 2 76 %8 = OpTypePointer Input %7 77 %9 = OpVariable %8 Input 78 %10 = OpTypeVector %6 4 79 %11 = OpTypeInt 32 0 80 %12 = OpConstant %11 L 81 %13 = OpTypeArray %10 %12 82 %14 = OpTypePointer Input %13 83 %15 = OpVariable %14 Input 84 ... 85---- 86 87 88[[fxvertex-attrib-location]] 89=== Attribute Location and Component Assignment 90 91The code:Location decoration specifies which vertex input attribute is used 92to read and interpret the data that a variable will consume. 93 94When a vertex shader input variable declared using a 16- or 32-bit scalar or 95vector data type is assigned a code:Location, its value(s) are taken from 96the components of the input attribute specified with the corresponding 97sname:VkVertexInputAttributeDescription::pname:location. 98The components used depend on the type of variable and the code:Component 99decoration specified in the variable declaration, as identified in 100<<fxvertex-attrib-components>>. 101Any 16-bit or 32-bit scalar or vector input will consume a single 102code:Location. 103For 16-bit and 32-bit data types, missing components are filled in with 104default values as described <<fxvertex-input-extraction,below>>. 105 106ifdef::VK_VERSION_1_1,VK_KHR_16bit_storage[] 107If an implementation supports <<features-storageInputOutput16, 108pname:storageInputOutput16>>, vertex shader input variables can: have a 109width of 16 bits. 110endif::VK_VERSION_1_1,VK_KHR_16bit_storage[] 111 112[[fxvertex-attrib-components]] 113.Input attribute components accessed by 16-bit and 32-bit input variables 114[width="65%",cols="<5,<3,<3",options="header"] 115|==== 116| 16-bit or 32-bit data type | code:Component decoration | Components consumed 117| scalar | 0 or unspecified | (x, o, o, o) 118| scalar | 1 | (o, y, o, o) 119| scalar | 2 | (o, o, z, o) 120| scalar | 3 | (o, o, o, w) 121| two-component vector | 0 or unspecified | (x, y, o, o) 122| two-component vector | 1 | (o, y, z, o) 123| two-component vector | 2 | (o, o, z, w) 124| three-component vector | 0 or unspecified | (x, y, z, o) 125| three-component vector | 1 | (o, y, z, w) 126| four-component vector | 0 or unspecified | (x, y, z, w) 127|==== 128 129Components indicated by "`o`" are available for use by other input variables 130which are sourced from the same attribute, and if used, are either filled 131with the corresponding component from the input format (if present), or the 132default value. 133 134When a vertex shader input variable declared using a 32-bit floating point 135matrix type is assigned a code:Location _i_, its values are taken from 136consecutive input attributes starting with the corresponding 137sname:VkVertexInputAttributeDescription::pname:location. 138Such matrices are treated as an array of column vectors with values taken 139from the input attributes identified in <<fxvertex-attrib-matrix>>. 140The sname:VkVertexInputAttributeDescription::pname:format must: be specified 141with a elink:VkFormat that corresponds to the appropriate type of column 142vector. 143The code:Component decoration must: not be used with matrix types. 144 145[[fxvertex-attrib-matrix]] 146.Input attributes accessed by 32-bit input matrix variables 147[width="100%",cols="<10%,<24%,<21%,<45%",options="header"] 148|==== 149| Data type | Column vector type | Locations consumed | Components consumed 150| mat2 | two-component vector | i, i+1 | (x, y, o, o), (x, y, o, o) 151| mat2x3 | three-component vector | i, i+1 | (x, y, z, o), (x, y, z, o) 152| mat2x4 | four-component vector | i, i+1 | (x, y, z, w), (x, y, z, w) 153| mat3x2 | two-component vector | i, i+1, i+2 | (x, y, o, o), (x, y, o, o), (x, y, o, o) 154| mat3 | three-component vector | i, i+1, i+2 | (x, y, z, o), (x, y, z, o), (x, y, z, o) 155| mat3x4 | four-component vector | i, i+1, i+2 | (x, y, z, w), (x, y, z, w), (x, y, z, w) 156| mat4x2 | two-component vector | i, i+1, i+2, i+3 | (x, y, o, o), (x, y, o, o), (x, y, o, o), (x, y, o, o) 157| mat4x3 | three-component vector | i, i+1, i+2, i+3 | (x, y, z, o), (x, y, z, o), (x, y, z, o), (x, y, z, o) 158| mat4 | four-component vector | i, i+1, i+2, i+3 | (x, y, z, w), (x, y, z, w), (x, y, z, w), (x, y, z, w) 159|==== 160 161Components indicated by "`o`" are available for use by other input variables 162which are sourced from the same attribute, and if used, are either filled 163with the corresponding component from the input (if present), or the default 164value. 165 166When a vertex shader input variable declared using a scalar or vector 64-bit 167data type is assigned a code:Location _i_, its values are taken from 168consecutive input attributes starting with the corresponding 169sname:VkVertexInputAttributeDescription::pname:location. 170The code:Location slots and code:Component words used depend on the type of 171variable and the code:Component decoration specified in the variable 172declaration, as identified in <<fxvertex-attrib-double>>. 173For 64-bit data types, no default attribute values are provided. 174Input variables must: not use more components than provided by the 175attribute. 176 177[[fxvertex-attrib-double]] 178.Input attribute locations and components accessed by 64-bit input variables 179[width="100%",cols="<18%,^12%,<25%,^14%,^18%,<13%",options="header"] 180|==== 181^.^| Input format | Locations consumed 182 ^.^| 64-bit data type |code:Location decoration |code:Component decoration ^| 32-bit components consumed 183| R64 | i 184 | scalar | i | 0 or unspecified | (x, y, -, -) 185.3+<.^| R64G64 .3+^.^| i 186 | scalar | i | 0 or unspecified | (x, y, o, o) 187 | scalar | i | 2 | (o, o, z, w) 188 | two-component vector | i | 0 or unspecified | (x, y, z, w) 189.5+<.^| R64G64B64 .5+^.^| i, i+1 190 | scalar | i | 0 or unspecified | (x, y, o, o), (o, o, -, -) 191 | scalar | i | 2 | (o, o, z, w), (o, o, -, -) 192 | scalar | i+1 | 0 or unspecified | (o, o, o, o), (x, y, -, -) 193 | two-component vector | i | 0 or unspecified | (x, y, z, w), (o, o, -, -) 194 | three-component vector | i | unspecified | (x, y, z, w), (x, y, -, -) 195.8+<.^| R64G64B64A64 .8+^.^| i, i+1 196 | scalar | i | 0 or unspecified | (x, y, o, o), (o, o, o, o) 197 | scalar | i | 2 | (o, o, z, w), (o, o, o, o) 198 | scalar | i+1 | 0 or unspecified | (o, o, o, o), (x, y, o, o) 199 | scalar | i+1 | 2 | (o, o, o, o), (o, o, z, w) 200 | two-component vector | i | 0 or unspecified | (x, y, z, w), (o, o, o, o) 201 | two-component vector | i+1 | 0 or unspecified | (o, o, o, o), (x, y, z, w) 202 | three-component vector | i | unspecified | (x, y, z, w), (x, y, o, o) 203 | four-component vector | i | unspecified | (x, y, z, w), (x, y, z, w) 204|==== 205 206Components indicated by "`o`" are available for use by other input variables 207which are sourced from the same attribute. 208Components indicated by "`-`" are not available for input variables as there 209are no default values provided for 64-bit data types, and there is no data 210provided by the input format. 211 212When a vertex shader input variable declared using a 64-bit floating-point 213matrix type is assigned a code:Location _i_, its values are taken from 214consecutive input attribute locations. 215Such matrices are treated as an array of column vectors with values taken 216from the input attributes as shown in <<fxvertex-attrib-double>>. 217Each column vector starts at the code:Location immediately following the 218last code:Location of the previous column vector. 219The number of attributes and components assigned to each matrix is 220determined by the matrix dimensions and ranges from two to eight locations. 221 222When a vertex shader input variable declared using an array type is assigned 223a location, its values are taken from consecutive input attributes starting 224with the corresponding 225sname:VkVertexInputAttributeDescription::pname:location. 226The number of attributes and components assigned to each element are 227determined according to the data type of the array elements and 228code:Component decoration (if any) specified in the declaration of the 229array, as described above. 230Each element of the array, in order, is assigned to consecutive locations, 231but all at the same specified component within each location. 232 233Only input variables declared with the data types and component decorations 234as specified above are supported. 235Two variables are allowed to share the same code:Location slot only if their 236code:Component words do not overlap. 237If multiple variables share the same code:Location slot, they must: all have 238the same SPIR-V floating-point component type or all have the same width 239scalar type components. 240 241[[fxvertex-input]] 242== Vertex Input Description 243 244Applications specify vertex input attribute and vertex input binding 245descriptions as part of graphics pipeline creation by setting the 246slink:VkGraphicsPipelineCreateInfo::pname:pVertexInputState pointer to a 247slink:VkPipelineVertexInputStateCreateInfo structure. 248ifdef::VK_EXT_vertex_input_dynamic_state[] 249Alternatively, if the graphics pipeline is created with the 250ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT dynamic state enabled, then the 251vertex input attribute and vertex input binding descriptions are specified 252dynamically with flink:vkCmdSetVertexInputEXT, and the 253slink:VkGraphicsPipelineCreateInfo::pname:pVertexInputState pointer is 254ignored. 255endif::VK_EXT_vertex_input_dynamic_state[] 256 257[open,refpage='VkPipelineVertexInputStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline vertex input state',type='structs'] 258-- 259The sname:VkPipelineVertexInputStateCreateInfo structure is defined as: 260 261include::{generated}/api/structs/VkPipelineVertexInputStateCreateInfo.adoc[] 262 263 * pname:sType is a elink:VkStructureType value identifying this structure. 264 * pname:pNext is `NULL` or a pointer to a structure extending this 265 structure. 266 * pname:flags is reserved for future use. 267 * pname:vertexBindingDescriptionCount is the number of vertex binding 268 descriptions provided in pname:pVertexBindingDescriptions. 269 * pname:pVertexBindingDescriptions is a pointer to an array of 270 sname:VkVertexInputBindingDescription structures. 271 * pname:vertexAttributeDescriptionCount is the number of vertex attribute 272 descriptions provided in pname:pVertexAttributeDescriptions. 273 * pname:pVertexAttributeDescriptions is a pointer to an array of 274 sname:VkVertexInputAttributeDescription structures. 275 276.Valid Usage 277**** 278 * [[VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613]] 279 pname:vertexBindingDescriptionCount must: be less than or equal to 280 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 281 * [[VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614]] 282 pname:vertexAttributeDescriptionCount must: be less than or equal to 283 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributes 284 * [[VUID-VkPipelineVertexInputStateCreateInfo-binding-00615]] 285 For every pname:binding specified by each element of 286 pname:pVertexAttributeDescriptions, a 287 sname:VkVertexInputBindingDescription must: exist in 288 pname:pVertexBindingDescriptions with the same value of pname:binding 289 * [[VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616]] 290 All elements of pname:pVertexBindingDescriptions must: describe distinct 291 binding numbers 292 * [[VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617]] 293 All elements of pname:pVertexAttributeDescriptions must: describe 294 distinct attribute locations 295**** 296 297include::{generated}/validity/structs/VkPipelineVertexInputStateCreateInfo.adoc[] 298-- 299 300[open,refpage='VkPipelineVertexInputStateCreateFlags',desc='Reserved for future use',type='flags'] 301-- 302include::{generated}/api/flags/VkPipelineVertexInputStateCreateFlags.adoc[] 303 304tname:VkPipelineVertexInputStateCreateFlags is a bitmask type for setting a 305mask, but is currently reserved for future use. 306-- 307 308[open,refpage='VkVertexInputBindingDescription',desc='Structure specifying vertex input binding description',type='structs'] 309-- 310Each vertex input binding is specified by the 311sname:VkVertexInputBindingDescription structure, defined as: 312 313include::{generated}/api/structs/VkVertexInputBindingDescription.adoc[] 314 315 * pname:binding is the binding number that this structure describes. 316 * pname:stride is the byte stride between consecutive elements within the 317 buffer. 318 * pname:inputRate is a elink:VkVertexInputRate value specifying whether 319 vertex attribute addressing is a function of the vertex index or of the 320 instance index. 321 322.Valid Usage 323**** 324 * [[VUID-VkVertexInputBindingDescription-binding-00618]] 325 pname:binding must: be less than 326 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 327 * [[VUID-VkVertexInputBindingDescription-stride-00619]] 328 pname:stride must: be less than or equal to 329 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindingStride 330ifdef::VK_KHR_portability_subset[] 331 * [[VUID-VkVertexInputBindingDescription-stride-04456]] 332 If the `apiext:VK_KHR_portability_subset` extension is enabled, 333 pname:stride must: be a multiple of, and at least as large as, 334 slink:VkPhysicalDevicePortabilitySubsetPropertiesKHR::pname:minVertexInputBindingStrideAlignment 335endif::VK_KHR_portability_subset[] 336**** 337 338include::{generated}/validity/structs/VkVertexInputBindingDescription.adoc[] 339-- 340 341[open,refpage='VkVertexInputRate',desc='Specify rate at which vertex attributes are pulled from buffers',type='enums'] 342-- 343Possible values of slink:VkVertexInputBindingDescription::pname:inputRate, 344specifying the rate at which vertex attributes are pulled from buffers, are: 345 346include::{generated}/api/enums/VkVertexInputRate.adoc[] 347 348 * ename:VK_VERTEX_INPUT_RATE_VERTEX specifies that vertex attribute 349 addressing is a function of the vertex index. 350 * ename:VK_VERTEX_INPUT_RATE_INSTANCE specifies that vertex attribute 351 addressing is a function of the instance index. 352-- 353 354[open,refpage='VkVertexInputAttributeDescription',desc='Structure specifying vertex input attribute description',type='structs'] 355-- 356Each vertex input attribute is specified by the 357sname:VkVertexInputAttributeDescription structure, defined as: 358 359include::{generated}/api/structs/VkVertexInputAttributeDescription.adoc[] 360 361 * pname:location is the shader input location number for this attribute. 362 * pname:binding is the binding number which this attribute takes its data 363 from. 364 * pname:format is the size and type of the vertex attribute data. 365 * pname:offset is a byte offset of this attribute relative to the start of 366 an element in the vertex input binding. 367 368.Valid Usage 369**** 370 * [[VUID-VkVertexInputAttributeDescription-location-00620]] 371 pname:location must: be less than 372 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributes 373 * [[VUID-VkVertexInputAttributeDescription-binding-00621]] 374 pname:binding must: be less than 375 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 376 * [[VUID-VkVertexInputAttributeDescription-offset-00622]] 377 pname:offset must: be less than or equal to 378 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributeOffset 379 * [[VUID-VkVertexInputAttributeDescription-format-00623]] 380 The <<resources-buffer-view-format-features,format features>> of 381 pname:format must: contain ename:VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT 382ifdef::VK_KHR_portability_subset[] 383 * [[VUID-VkVertexInputAttributeDescription-vertexAttributeAccessBeyondStride-04457]] 384 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 385 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:vertexAttributeAccessBeyondStride 386 is ename:VK_FALSE, the sum of pname:offset plus the size of the vertex 387 attribute data described by pname:format must: not be greater than 388 pname:stride in the slink:VkVertexInputBindingDescription referenced in 389 pname:binding 390endif::VK_KHR_portability_subset[] 391**** 392 393include::{generated}/validity/structs/VkVertexInputAttributeDescription.adoc[] 394-- 395 396ifdef::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 397[open,refpage='vkCmdSetVertexInputEXT',desc='Set the vertex input state dynamically for a command buffer',type='protos'] 398-- 399To <<pipelines-dynamic-state, dynamically set>> the vertex input attribute 400and vertex input binding descriptions, call: 401 402include::{generated}/api/protos/vkCmdSetVertexInputEXT.adoc[] 403 404 * pname:commandBuffer is the command buffer into which the command will be 405 recorded. 406 * pname:vertexBindingDescriptionCount is the number of vertex binding 407 descriptions provided in pname:pVertexBindingDescriptions. 408 * pname:pVertexBindingDescriptions is a pointer to an array of 409 sname:VkVertexInputBindingDescription2EXT structures. 410 * pname:vertexAttributeDescriptionCount is the number of vertex attribute 411 descriptions provided in pname:pVertexAttributeDescriptions. 412 * pname:pVertexAttributeDescriptions is a pointer to an array of 413 sname:VkVertexInputAttributeDescription2EXT structures. 414 415This command sets the vertex input attribute and vertex input binding 416descriptions state for subsequent drawing commands 417ifdef::VK_EXT_shader_object[] 418ifdef::VK_EXT_vertex_input_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or] 419ifndef::VK_EXT_vertex_input_dynamic_state[when drawing using <<shaders-objects, shader objects>>.] 420endif::VK_EXT_shader_object[] 421ifdef::VK_EXT_vertex_input_dynamic_state[] 422when the graphics pipeline is created with 423ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT set in 424slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 425endif::VK_EXT_vertex_input_dynamic_state[] 426Otherwise, this state is specified by the 427slink:VkGraphicsPipelineCreateInfo::pname:pVertexInputState values used to 428create the currently active pipeline. 429 430ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 431If 432ifdef::VK_EXT_shader_object[] 433drawing using <<shaders-objects, shader objects>>, 434ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[or if] 435endif::VK_EXT_shader_object[] 436ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 437the bound pipeline state object was also created with the 438ename:VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE dynamic state enabled, 439endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 440then flink:vkCmdBindVertexBuffers2 can be used instead of 441fname:vkCmdSetVertexInputEXT to dynamically set the stride. 442endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 443 444.Valid Usage 445**** 446ifdef::VK_EXT_shader_object[] 447ifdef::VK_EXT_vertex_input_dynamic_state[] 448 * [[VUID-vkCmdSetVertexInputEXT-None-08546]] 449 Either the <<features-vertexInputDynamicState, 450 pname:vertexInputDynamicState>> feature or the <<features-shaderObject, 451 pname:shaderObject>> feature or both must: be enabled 452endif::VK_EXT_vertex_input_dynamic_state[] 453ifndef::VK_EXT_vertex_input_dynamic_state[] 454 * [[VUID-vkCmdSetVertexInputEXT-None-08547]] 455 The <<features-shaderObject, pname:shaderObject>> feature must: be 456 enabled 457endif::VK_EXT_vertex_input_dynamic_state[] 458endif::VK_EXT_shader_object[] 459ifndef::VK_EXT_shader_object[] 460 * [[VUID-vkCmdSetVertexInputEXT-None-04790]] 461 The <<features-vertexInputDynamicState, pname:vertexInputDynamicState>> 462 feature must: be enabled 463endif::VK_EXT_shader_object[] 464 * [[VUID-vkCmdSetVertexInputEXT-vertexBindingDescriptionCount-04791]] 465 pname:vertexBindingDescriptionCount must: be less than or equal to 466 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 467 * [[VUID-vkCmdSetVertexInputEXT-vertexAttributeDescriptionCount-04792]] 468 pname:vertexAttributeDescriptionCount must: be less than or equal to 469 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributes 470 * [[VUID-vkCmdSetVertexInputEXT-binding-04793]] 471 For every pname:binding specified by each element of 472 pname:pVertexAttributeDescriptions, a 473 sname:VkVertexInputBindingDescription2EXT must: exist in 474 pname:pVertexBindingDescriptions with the same value of pname:binding 475 * [[VUID-vkCmdSetVertexInputEXT-pVertexBindingDescriptions-04794]] 476 All elements of pname:pVertexBindingDescriptions must: describe distinct 477 binding numbers 478 * [[VUID-vkCmdSetVertexInputEXT-pVertexAttributeDescriptions-04795]] 479 All elements of pname:pVertexAttributeDescriptions must: describe 480 distinct attribute locations 481**** 482 483include::{generated}/validity/protos/vkCmdSetVertexInputEXT.adoc[] 484-- 485 486[open,refpage='VkVertexInputBindingDescription2EXT',desc='Structure specifying the extended vertex input binding description',type='structs'] 487-- 488The sname:VkVertexInputBindingDescription2EXT structure is defined as: 489 490include::{generated}/api/structs/VkVertexInputBindingDescription2EXT.adoc[] 491 492 * pname:sType is a elink:VkStructureType value identifying this structure. 493 * pname:pNext is `NULL` or a pointer to a structure extending this 494 structure. 495 * pname:binding is the binding number that this structure describes. 496 * pname:stride is the byte stride between consecutive elements within the 497 buffer. 498 * pname:inputRate is a elink:VkVertexInputRate value specifying whether 499 vertex attribute addressing is a function of the vertex index or of the 500 instance index. 501ifdef::VK_EXT_vertex_attribute_divisor[] 502 * pname:divisor is the number of successive instances that will use the 503 same value of the vertex attribute when instanced rendering is enabled. 504 This member can: be set to a value other than `1` if the 505 <<features-vertexAttributeInstanceRateDivisor, 506 pname:vertexAttributeInstanceRateDivisor>> feature is enabled. 507 For example, if the divisor is N, the same vertex attribute will be 508 applied to N successive instances before moving on to the next vertex 509 attribute. 510 The maximum value of pname:divisor is implementation-dependent and can 511 be queried using 512 sname:VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT::pname:maxVertexAttribDivisor. 513 A value of `0` can: be used for the divisor if the 514 <<features-vertexAttributeInstanceRateZeroDivisor, 515 pname:vertexAttributeInstanceRateZeroDivisor>> feature is enabled. 516 In this case, the same vertex attribute will be applied to all 517 instances. 518endif::VK_EXT_vertex_attribute_divisor[] 519ifndef::VK_EXT_vertex_attribute_divisor[] 520 * pname:divisor must: be set to `1` 521endif::VK_EXT_vertex_attribute_divisor[] 522 523.Valid Usage 524**** 525 * [[VUID-VkVertexInputBindingDescription2EXT-binding-04796]] 526 pname:binding must: be less than 527 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 528 * [[VUID-VkVertexInputBindingDescription2EXT-stride-04797]] 529 pname:stride must: be less than or equal to 530 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindingStride 531 * [[VUID-VkVertexInputBindingDescription2EXT-divisor-04798]] 532 If the <<features-vertexAttributeInstanceRateZeroDivisor, 533 pname:vertexAttributeInstanceRateZeroDivisor>> feature is not enabled, 534 pname:divisor must: not be `0` 535 * [[VUID-VkVertexInputBindingDescription2EXT-divisor-04799]] 536 If the <<features-vertexAttributeInstanceRateDivisor, 537 pname:vertexAttributeInstanceRateDivisor>> feature is not enabled, 538 pname:divisor must: be `1` 539 * [[VUID-VkVertexInputBindingDescription2EXT-divisor-06226]] 540 pname:divisor must: be a value between `0` and 541 sname:VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT::pname:maxVertexAttribDivisor, 542 inclusive 543 * [[VUID-VkVertexInputBindingDescription2EXT-divisor-06227]] 544 If pname:divisor is not `1` then pname:inputRate must: be of type 545 ename:VK_VERTEX_INPUT_RATE_INSTANCE 546**** 547 548include::{generated}/validity/structs/VkVertexInputBindingDescription2EXT.adoc[] 549-- 550 551[open,refpage='VkVertexInputAttributeDescription2EXT',desc='Structure specifying the extended vertex input attribute description',type='structs'] 552-- 553The sname:VkVertexInputAttributeDescription2EXT structure is defined as: 554 555include::{generated}/api/structs/VkVertexInputAttributeDescription2EXT.adoc[] 556 557 * pname:sType is a elink:VkStructureType value identifying this structure. 558 * pname:pNext is `NULL` or a pointer to a structure extending this 559 structure. 560 * pname:location is the shader input location number for this attribute. 561 * pname:binding is the binding number which this attribute takes its data 562 from. 563 * pname:format is the size and type of the vertex attribute data. 564 * pname:offset is a byte offset of this attribute relative to the start of 565 an element in the vertex input binding. 566 567.Valid Usage 568**** 569 * [[VUID-VkVertexInputAttributeDescription2EXT-location-06228]] 570 pname:location must: be less than 571 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributes 572 * [[VUID-VkVertexInputAttributeDescription2EXT-binding-06229]] 573 pname:binding must: be less than 574 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 575 * [[VUID-VkVertexInputAttributeDescription2EXT-offset-06230]] 576 pname:offset must: be less than or equal to 577 sname:VkPhysicalDeviceLimits::pname:maxVertexInputAttributeOffset 578 * [[VUID-VkVertexInputAttributeDescription2EXT-format-04805]] 579 The <<resources-buffer-view-format-features,format features>> of 580 pname:format must: contain ename:VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT 581ifdef::VK_KHR_portability_subset[] 582 * [[VUID-VkVertexInputAttributeDescription2EXT-vertexAttributeAccessBeyondStride-04806]] 583 If the `apiext:VK_KHR_portability_subset` extension is enabled, and 584 slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:vertexAttributeAccessBeyondStride 585 is ename:VK_FALSE, the sum of pname:offset plus the size of the vertex 586 attribute data described by pname:format must: not be greater than 587 pname:stride in the slink:VkVertexInputBindingDescription2EXT referenced 588 in pname:binding 589endif::VK_KHR_portability_subset[] 590**** 591 592include::{generated}/validity/structs/VkVertexInputAttributeDescription2EXT.adoc[] 593-- 594endif::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 595 596[open,refpage='vkCmdBindVertexBuffers',desc='Bind vertex buffers to a command buffer',type='protos'] 597-- 598To bind vertex buffers to a command buffer for use in subsequent drawing 599commands, call: 600 601include::{generated}/api/protos/vkCmdBindVertexBuffers.adoc[] 602 603 * pname:commandBuffer is the command buffer into which the command is 604 recorded. 605 * pname:firstBinding is the index of the first vertex input binding whose 606 state is updated by the command. 607 * pname:bindingCount is the number of vertex input bindings whose state is 608 updated by the command. 609 * pname:pBuffers is a pointer to an array of buffer handles. 610 * pname:pOffsets is a pointer to an array of buffer offsets. 611 612The values taken from elements [eq]#i# of pname:pBuffers and pname:pOffsets 613replace the current state for the vertex input binding 614[eq]#pname:firstBinding {plus} i#, for [eq]#i# in [eq]#[0, 615pname:bindingCount)#. 616The vertex input binding is updated to start at the offset indicated by 617pname:pOffsets[i] from the start of the buffer pname:pBuffers[i]. 618All vertex input attributes that use each of these bindings will use these 619updated addresses in their address calculations for subsequent drawing 620commands. 621ifdef::VK_EXT_robustness2[] 622If the <<features-nullDescriptor, pname:nullDescriptor>> feature is enabled, 623elements of pname:pBuffers can: be dlink:VK_NULL_HANDLE, and can: be used by 624the vertex shader. 625If a vertex input attribute is bound to a vertex input binding that is 626dlink:VK_NULL_HANDLE, the values taken from memory are considered to be 627zero, and missing G, B, or A components are 628<<fxvertex-input-extraction,filled with [eq]#(0,0,1)#>>. 629endif::VK_EXT_robustness2[] 630 631.Valid Usage 632**** 633 * [[VUID-vkCmdBindVertexBuffers-firstBinding-00624]] 634 pname:firstBinding must: be less than 635 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 636 * [[VUID-vkCmdBindVertexBuffers-firstBinding-00625]] 637 The sum of pname:firstBinding and pname:bindingCount must: be less than 638 or equal to sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 639 * [[VUID-vkCmdBindVertexBuffers-pOffsets-00626]] 640 All elements of pname:pOffsets must: be less than the size of the 641 corresponding element in pname:pBuffers 642 * [[VUID-vkCmdBindVertexBuffers-pBuffers-00627]] 643 All elements of pname:pBuffers must: have been created with the 644 ename:VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag 645 * [[VUID-vkCmdBindVertexBuffers-pBuffers-00628]] 646 Each element of pname:pBuffers that is non-sparse must: be bound 647 completely and contiguously to a single sname:VkDeviceMemory object 648 * [[VUID-vkCmdBindVertexBuffers-pBuffers-04001]] 649 If the <<features-nullDescriptor, pname:nullDescriptor>> feature is not 650 enabled, all elements of pname:pBuffers must: not be 651 dlink:VK_NULL_HANDLE 652ifdef::VK_EXT_robustness2[] 653 * [[VUID-vkCmdBindVertexBuffers-pBuffers-04002]] 654 If an element of pname:pBuffers is dlink:VK_NULL_HANDLE, then the 655 corresponding element of pname:pOffsets must: be zero 656endif::VK_EXT_robustness2[] 657**** 658 659include::{generated}/validity/protos/vkCmdBindVertexBuffers.adoc[] 660-- 661 662ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 663[open,refpage='vkCmdBindVertexBuffers2',desc='Bind vertex buffers to a command buffer and dynamically set strides',type='protos',alias='vkCmdBindVertexBuffers2EXT'] 664-- 665Alternatively, to bind vertex buffers, along with their sizes and strides, 666to a command buffer for use in subsequent drawing commands, call: 667 668ifdef::VK_VERSION_1_3[] 669include::{generated}/api/protos/vkCmdBindVertexBuffers2.adoc[] 670 671ifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[or the equivalent command] 672endif::VK_VERSION_1_3[] 673 674ifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 675include::{generated}/api/protos/vkCmdBindVertexBuffers2EXT.adoc[] 676endif::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 677 678 * pname:commandBuffer is the command buffer into which the command is 679 recorded. 680 * pname:firstBinding is the index of the first vertex input binding whose 681 state is updated by the command. 682 * pname:bindingCount is the number of vertex input bindings whose state is 683 updated by the command. 684 * pname:pBuffers is a pointer to an array of buffer handles. 685 * pname:pOffsets is a pointer to an array of buffer offsets. 686 * pname:pSizes is `NULL` or a pointer to an array of the size in bytes of 687 vertex data bound from pname:pBuffers. 688 * pname:pStrides is `NULL` or a pointer to an array of buffer strides. 689 690The values taken from elements [eq]#i# of pname:pBuffers and pname:pOffsets 691replace the current state for the vertex input binding 692[eq]#pname:firstBinding {plus} i#, for [eq]#i# in [eq]#[0, 693pname:bindingCount)#. 694The vertex input binding is updated to start at the offset indicated by 695pname:pOffsets[i] from the start of the buffer pname:pBuffers[i]. 696If pname:pSizes is not `NULL` then pname:pSizes[i] specifies the bound size 697of the vertex buffer starting from the corresponding elements of 698pname:pBuffers[i] plus pname:pOffsets[i]. 699ifdef::VK_KHR_maintenance5[] 700If pname:pSizes[i] is ename:VK_WHOLE_SIZE then the bound size is from 701pname:pBuffers[i] plus pname:pOffsets[i] to the end of the buffer 702pname:pBuffers[i]. 703endif::VK_KHR_maintenance5[] 704All vertex input attributes that use each of these bindings will use these 705updated addresses in their address calculations for subsequent drawing 706commands. 707ifdef::VK_EXT_robustness2[] 708If the <<features-nullDescriptor, pname:nullDescriptor>> feature is enabled, 709elements of pname:pBuffers can: be dlink:VK_NULL_HANDLE, and can: be used by 710the vertex shader. 711If a vertex input attribute is bound to a vertex input binding that is 712dlink:VK_NULL_HANDLE, the values taken from memory are considered to be 713zero, and missing G, B, or A components are 714<<fxvertex-input-extraction,filled with [eq]#(0,0,1)#>>. 715endif::VK_EXT_robustness2[] 716 717This command also <<pipelines-dynamic-state, dynamically sets>> the byte 718strides between consecutive elements within buffer pname:pBuffers[i] to the 719corresponding pname:pStrides[i] value 720ifdef::VK_EXT_shader_object[] 721ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or] 722ifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>.] 723endif::VK_EXT_shader_object[] 724ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 725when the graphics pipeline is created with 726ename:VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE set in 727slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates. 728endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[] 729Otherwise, strides are specified by the 730sname:VkVertexInputBindingDescription::pname:stride values used to create 731the currently active pipeline. 732 733ifdef::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 734If 735ifdef::VK_EXT_shader_object[drawing using <<shaders-objects, shader objects>>] 736ifdef::VK_EXT_vertex_input_dynamic_state[] 737ifdef::VK_EXT_shader_object[or if] 738the bound pipeline state object was also created with the 739ename:VK_DYNAMIC_STATE_VERTEX_INPUT_EXT dynamic state enabled 740endif::VK_EXT_vertex_input_dynamic_state[] 741then flink:vkCmdSetVertexInputEXT can: be used instead of 742fname:vkCmdBindVertexBuffers2 to set the stride. 743endif::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 744 745[NOTE] 746.Note 747==== 748Unlike the static state to set the same, pname:pStrides must be between 0 749and the maximum extent of the attributes in the binding. 750ifdef::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 751flink:vkCmdSetVertexInputEXT does not have this restriction so can be used 752if other stride values are desired. 753endif::VK_EXT_vertex_input_dynamic_state,VK_EXT_shader_object[] 754==== 755 756.Valid Usage 757**** 758 * [[VUID-vkCmdBindVertexBuffers2-firstBinding-03355]] 759 pname:firstBinding must: be less than 760 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 761 * [[VUID-vkCmdBindVertexBuffers2-firstBinding-03356]] 762 The sum of pname:firstBinding and pname:bindingCount must: be less than 763 or equal to sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 764 * [[VUID-vkCmdBindVertexBuffers2-pOffsets-03357]] 765 If pname:pSizes is not `NULL`, all elements of pname:pOffsets must: be 766 less than the size of the corresponding element in pname:pBuffers 767 * [[VUID-vkCmdBindVertexBuffers2-pSizes-03358]] 768 If pname:pSizes is not `NULL`, all elements of pname:pOffsets plus 769 pname:pSizes 770ifdef::VK_KHR_maintenance5[] 771 , where pname:pSizes is not ename:VK_WHOLE_SIZE, 772endif::VK_KHR_maintenance5[] 773 must: be less than or equal to the size of the corresponding element in 774 pname:pBuffers 775 * [[VUID-vkCmdBindVertexBuffers2-pBuffers-03359]] 776 All elements of pname:pBuffers must: have been created with the 777 ename:VK_BUFFER_USAGE_VERTEX_BUFFER_BIT flag 778 * [[VUID-vkCmdBindVertexBuffers2-pBuffers-03360]] 779 Each element of pname:pBuffers that is non-sparse must: be bound 780 completely and contiguously to a single sname:VkDeviceMemory object 781 * [[VUID-vkCmdBindVertexBuffers2-pBuffers-04111]] 782 If the <<features-nullDescriptor, pname:nullDescriptor>> feature is not 783 enabled, all elements of pname:pBuffers must: not be 784 dlink:VK_NULL_HANDLE 785ifdef::VK_EXT_robustness2[] 786 * [[VUID-vkCmdBindVertexBuffers2-pBuffers-04112]] 787 If an element of pname:pBuffers is dlink:VK_NULL_HANDLE, then the 788 corresponding element of pname:pOffsets must: be zero 789endif::VK_EXT_robustness2[] 790 * [[VUID-vkCmdBindVertexBuffers2-pStrides-03362]] 791 If pname:pStrides is not `NULL` each element of pname:pStrides must: be 792 less than or equal to 793 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindingStride 794 * [[VUID-vkCmdBindVertexBuffers2-pStrides-06209]] 795 If pname:pStrides is not `NULL` each element of pname:pStrides must: be 796 either 0 or greater than or equal to the maximum extent of all vertex 797 input attributes fetched from the corresponding binding, where the 798 extent is calculated as the 799 slink:VkVertexInputAttributeDescription::pname:offset plus 800 slink:VkVertexInputAttributeDescription::pname:format size 801**** 802 803include::{generated}/validity/protos/vkCmdBindVertexBuffers2.adoc[] 804-- 805endif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[] 806 807 808ifdef::VK_EXT_vertex_attribute_divisor[] 809[[fxvertex-attribute_divisor]] 810== Vertex Attribute Divisor in Instanced Rendering 811 812[open,refpage='VkPipelineVertexInputDivisorStateCreateInfoEXT',desc='Structure specifying vertex attributes assignment during instanced rendering',type='structs'] 813-- 814If the <<features-vertexAttributeInstanceRateDivisor, 815pname:vertexAttributeInstanceRateDivisor>> feature is enabled and the 816pname:pNext chain of slink:VkPipelineVertexInputStateCreateInfo includes a 817sname:VkPipelineVertexInputDivisorStateCreateInfoEXT structure, then that 818structure controls how vertex attributes are assigned to an instance when 819instanced rendering is enabled. 820 821The sname:VkPipelineVertexInputDivisorStateCreateInfoEXT structure is 822defined as: 823 824include::{generated}/api/structs/VkPipelineVertexInputDivisorStateCreateInfoEXT.adoc[] 825 826 * pname:sType is a elink:VkStructureType value identifying this structure. 827 * pname:pNext is `NULL` or a pointer to a structure extending this 828 structure. 829 * pname:vertexBindingDivisorCount is the number of elements in the 830 pname:pVertexBindingDivisors array. 831 * pname:pVertexBindingDivisors is a pointer to an array of 832 sname:VkVertexInputBindingDivisorDescriptionEXT structures specifying 833 the divisor value for each binding. 834 835include::{generated}/validity/structs/VkPipelineVertexInputDivisorStateCreateInfoEXT.adoc[] 836-- 837 838[open,refpage='VkVertexInputBindingDivisorDescriptionEXT',desc='Structure specifying a divisor used in instanced rendering',type='structs'] 839-- 840The individual divisor values per binding are specified using the 841sname:VkVertexInputBindingDivisorDescriptionEXT structure which is defined 842as: 843 844include::{generated}/api/structs/VkVertexInputBindingDivisorDescriptionEXT.adoc[] 845 846 * pname:binding is the binding number for which the divisor is specified. 847 * pname:divisor is the number of successive instances that will use the 848 same value of the vertex attribute when instanced rendering is enabled. 849 For example, if the divisor is N, the same vertex attribute will be 850 applied to N successive instances before moving on to the next vertex 851 attribute. 852 The maximum value of pname:divisor is implementation-dependent and can 853 be queried using 854 sname:VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT::pname:maxVertexAttribDivisor. 855 A value of `0` can: be used for the divisor if the 856 <<features-vertexAttributeInstanceRateZeroDivisor, 857 pname:vertexAttributeInstanceRateZeroDivisor>> feature is enabled. 858 In this case, the same vertex attribute will be applied to all 859 instances. 860 861If this structure is not used to define a divisor value for an attribute, 862then the divisor has a logical default value of 1. 863 864.Valid Usage 865**** 866 * [[VUID-VkVertexInputBindingDivisorDescriptionEXT-binding-01869]] 867 pname:binding must: be less than 868 sname:VkPhysicalDeviceLimits::pname:maxVertexInputBindings 869 * [[VUID-VkVertexInputBindingDivisorDescriptionEXT-vertexAttributeInstanceRateZeroDivisor-02228]] 870 If the pname:vertexAttributeInstanceRateZeroDivisor feature is not 871 enabled, pname:divisor must: not be `0` 872 * [[VUID-VkVertexInputBindingDivisorDescriptionEXT-vertexAttributeInstanceRateDivisor-02229]] 873 If the pname:vertexAttributeInstanceRateDivisor feature is not enabled, 874 pname:divisor must: be `1` 875 * [[VUID-VkVertexInputBindingDivisorDescriptionEXT-divisor-01870]] 876 pname:divisor must: be a value between `0` and 877 sname:VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT::pname:maxVertexAttribDivisor, 878 inclusive 879 * [[VUID-VkVertexInputBindingDivisorDescriptionEXT-inputRate-01871]] 880 slink:VkVertexInputBindingDescription::pname:inputRate must: be of type 881 ename:VK_VERTEX_INPUT_RATE_INSTANCE for this pname:binding 882**** 883 884include::{generated}/validity/structs/VkVertexInputBindingDivisorDescriptionEXT.adoc[] 885-- 886endif::VK_EXT_vertex_attribute_divisor[] 887 888 889[[fxvertex-input-address-calculation]] 890== Vertex Input Address Calculation 891The address of each attribute for each code:vertexIndex and 892code:instanceIndex is calculated as follows: 893 894 * Let code:attribDesc be the member of 895 slink:VkPipelineVertexInputStateCreateInfo::pname:pVertexAttributeDescriptions 896 with sname:VkVertexInputAttributeDescription::pname:location equal to 897 the vertex input attribute number. 898 * Let code:bindingDesc be the member of 899 slink:VkPipelineVertexInputStateCreateInfo::pname:pVertexBindingDescriptions 900 with sname:VkVertexInputAttributeDescription::pname:binding equal to 901 code:attribDesc.binding. 902 * Let code:vertexIndex be the index of the vertex within the draw (a value 903 between pname:firstVertex and pname:firstVertex+pname:vertexCount for 904 fname:vkCmdDraw, or a value taken from the index buffer plus 905 pname:vertexOffset for fname:vkCmdDrawIndexed), and let 906 code:instanceIndex be the instance number of the draw (a value between 907 pname:firstInstance and pname:firstInstance+pname:instanceCount). 908 * Let code:offset be an array of offsets into the currently bound vertex 909 buffers specified during fname:vkCmdBindVertexBuffers 910ifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[or fname:vkCmdBindVertexBuffers2] 911 with pname:pOffsets. 912ifdef::VK_EXT_vertex_attribute_divisor[] 913 * Let code:divisor be the member of 914 slink:VkPipelineVertexInputDivisorStateCreateInfoEXT::pname:pVertexBindingDivisors 915 with sname:VkVertexInputBindingDivisorDescriptionEXT::pname:binding 916 equal to code:attribDesc.binding. 917endif::VK_EXT_vertex_attribute_divisor[] 918 919[source,c] 920---- 921bufferBindingAddress = buffer[binding].baseAddress + offset[binding]; 922 923if (bindingDesc.inputRate == VK_VERTEX_INPUT_RATE_VERTEX) 924 effectiveVertexOffset = vertexIndex * bindingDesc.stride; 925else 926ifndef::VK_EXT_vertex_attribute_divisor[] 927 effectiveVertexOffset = instanceIndex * bindingDesc.stride; 928endif::VK_EXT_vertex_attribute_divisor[] 929ifdef::VK_EXT_vertex_attribute_divisor[] 930 if (divisor == 0) 931 effectiveVertexOffset = firstInstance * bindingDesc.stride; 932 else 933 effectiveVertexOffset = (firstInstance + ((instanceIndex - firstInstance) / divisor)) * bindingDesc.stride; 934endif::VK_EXT_vertex_attribute_divisor[] 935 936attribAddress = bufferBindingAddress + effectiveVertexOffset + attribDesc.offset; 937---- 938 939 940[[fxvertex-input-extraction]] 941=== Vertex Input Extraction 942 943For each attribute, raw data is extracted starting at `attribAddress` and is 944converted from the sname:VkVertexInputAttributeDescription's pname:format to 945either floating-point, unsigned integer, or signed integer based on the 946<<formats-numericformat, numeric type>> of pname:format. 947The numeric type of pname:format must: match the numeric type of the input 948variable in the shader. 949The input variable in the shader must: be declared as a 64-bit data type if 950and only if pname:format is a 64-bit data type. 951If pname:format is a packed format, `attribAddress` must: be a multiple of 952the size in bytes of the whole attribute data type as described in 953<<formats-packed,Packed Formats>>. 954Otherwise, `attribAddress` must: be a multiple of the size in bytes of the 955component type indicated by pname:format (see <<formats,Formats>>). 956For attributes that are not 64-bit data types, each component is converted 957to the format of the input variable based on its type and size (as defined 958in the <<formats-definition,Format Definition>> section for each 959elink:VkFormat), using the appropriate equations in <<fundamentals-fp16, 96016-Bit Floating-Point Numbers>>, <<fundamentals-fp11,Unsigned 11-Bit 961Floating-Point Numbers>>, <<fundamentals-fp10,Unsigned 10-Bit Floating-Point 962Numbers>>, <<fundamentals-fixedconv,Fixed-Point Data Conversion>>, and 963<<textures-sexp-RGB,Shared Exponent to RGB>>. 964Signed integer components smaller than 32 bits are sign-extended. 965Attributes that are not 64-bit data types are expanded to four components in 966the same way as described in <<textures-conversion-to-rgba,conversion to 967RGBA>>. 968The number of components in the vertex shader input variable need not 969exactly match the number of components in the format. 970If the vertex shader has fewer components, the extra components are 971discarded. 972