• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2016-2024 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5include::{generated}/meta/{refprefix}VK_KHR_shader_draw_parameters.adoc[]
6
7=== Other Extension Metadata
8
9*Last Modified Date*::
10    2017-09-05
11*IP Status*::
12    No known IP claims.
13*Interactions and External Dependencies*::
14  - This extension provides API support for
15    {GLregistry}/ARB/ARB_shader_draw_parameters.txt[`GL_ARB_shader_draw_parameters`]
16*Contributors*::
17  - Daniel Koch, NVIDIA Corporation
18  - Jeff Bolz, NVIDIA
19  - Daniel Rakos, AMD
20  - Jan-Harald Fredriksen, ARM
21  - John Kessenich, Google
22  - Stuart Smith, IMG
23
24=== Description
25
26This extension adds support for the following SPIR-V extension in Vulkan:
27
28  * `SPV_KHR_shader_draw_parameters`
29
30The extension provides access to three additional built-in shader variables
31in Vulkan:
32
33  * code:BaseInstance, containing the pname:firstInstance parameter passed
34    to drawing commands,
35  * code:BaseVertex, containing the pname:firstVertex or pname:vertexOffset
36    parameter passed to drawing commands, and
37  * code:DrawIndex, containing the index of the draw call currently being
38    processed from an indirect drawing call.
39
40When using GLSL source-based shader languages, the following variables from
41`GL_ARB_shader_draw_parameters` can map to these SPIR-V built-in
42decorations:
43
44  * `in int gl_BaseInstanceARB;` -> code:BaseInstance,
45  * `in int gl_BaseVertexARB;` -> code:BaseVertex, and
46  * `in int gl_DrawIDARB;` -> code:DrawIndex.
47
48=== Promotion to Vulkan 1.1
49
50All functionality in this extension is included in core Vulkan 1.1.
51However, the <<features-shaderDrawParameters, pname:shaderDrawParameters>>
52feature bit was added to distinguish whether it is actually available or
53not.
54
55include::{generated}/interfaces/VK_KHR_shader_draw_parameters.adoc[]
56
57=== New Built-In Variables
58
59  * <<interfaces-builtin-variables-baseinstance,code:BaseInstance>>
60  * <<interfaces-builtin-variables-basevertex,code:BaseVertex>>
61  * <<interfaces-builtin-variables-drawindex,code:DrawIndex>>
62
63=== New SPIR-V Capabilities
64
65  * <<spirvenv-capabilities-table-DrawParameters, code:DrawParameters>>
66
67=== Issues
68
691) Is this the same functionality as `GL_ARB_shader_draw_parameters`?
70
71*RESOLVED*: It is actually a superset, as it also adds in support for
72arrayed drawing commands.
73
74In GL for `GL_ARB_shader_draw_parameters`, code:gl_BaseVertexARB holds the
75integer value passed to the parameter to the command that resulted in the
76current shader invocation.
77In the case where the command has no code:baseVertex parameter, the value of
78code:gl_BaseVertexARB is zero.
79This means that code:gl_BaseVertexARB = code:baseVertex (for
80code:glDrawElements commands with code:baseVertex) or 0.
81In particular there are no code:glDrawArrays commands that take a
82code:baseVertex parameter.
83
84Now in Vulkan, we have code:BaseVertex = pname:vertexOffset (for indexed
85drawing commands) or pname:firstVertex (for arrayed drawing commands), and
86so Vulkan's version is really a superset of GL functionality.
87
88=== Version History
89
90  * Revision 1, 2016-10-05 (Daniel Koch)
91  ** Internal revisions
92