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