/ appendices / VK_KHR_shader_draw_parameters.txt
VK_KHR_shader_draw_parameters.txt
  1  // Copyright (c) 2016-2019 Khronos Group. This work is licensed under a
  2  // Creative Commons Attribution 4.0 International License; see
  3  // http://creativecommons.org/licenses/by/4.0/
  4  
  5  include::meta/VK_KHR_shader_draw_parameters.txt[]
  6  
  7  *Last Modified Date*::
  8      2017-09-05
  9  *IP Status*::
 10      No known IP claims.
 11  *Interactions and External Dependencies*::
 12    - Requires the
 13      https://www.khronos.org/registry/spir-v/extensions/KHR/SPV_KHR_shader_draw_parameters.html[`SPV_KHR_shader_draw_parameters`]
 14      SPIR-V extension.
 15    - Requires
 16      https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shader_draw_parameters.txt[`GL_ARB_shader_draw_parameters`]
 17      for GLSL source languages.
 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  This extension adds support for the following SPIR-V extension in Vulkan:
 28  
 29    * `SPV_KHR_shader_draw_parameters`
 30  
 31  The extension provides access to three additional built-in shader variables
 32  in Vulkan:
 33  
 34    * code:BaseInstance, which contains the pname:firstInstance parameter
 35      passed to draw commands,
 36    * code:BaseVertex, which contains the pname:firstVertex/pname:vertexOffset
 37      parameter passed to draw commands, and
 38    * code:DrawIndex, which contains the index of the draw call currently
 39      being processed from an indirect draw call.
 40  
 41  When using GLSL source-based shader languages, the following variables from
 42  `GL_ARB_shader_draw_parameters` can map to these SPIR-V built-in
 43  decorations:
 44  
 45    * `in int gl_BaseInstanceARB;` -> code:BaseInstance,
 46    * `in int gl_BaseVertexARB;` -> code:BaseVertex, and
 47    * `in int gl_DrawIDARB;` -> code:DrawIndex.
 48  
 49  === New Object Types
 50  
 51  None.
 52  
 53  === New Enum Constants
 54  
 55  None.
 56  
 57  === New Enums
 58  
 59  None.
 60  
 61  === New Structures
 62  
 63  None.
 64  
 65  === New Functions
 66  
 67  None.
 68  
 69  === New Built-In Variables
 70  
 71    * <<interfaces-builtin-variables-baseinstance,code:BaseInstance>>
 72    * <<interfaces-builtin-variables-basevertex,code:BaseVertex>>
 73    * <<interfaces-builtin-variables-drawindex,code:DrawIndex>>
 74  
 75  === New SPIR-V Capabilities
 76  
 77    * <<spirvenv-capabilities,DrawParameters>>
 78  
 79  === Promotion to Vulkan 1.1
 80  
 81  All functionality in this extension is included in core Vulkan 1.1, however
 82  a <<features-shaderDrawParameters,feature bit was added>> to distinguish
 83  whether it is actually available or not.
 84  
 85  === Issues
 86  
 87  1) Is this the same functionality as `GL_ARB_shader_draw_parameters`?
 88  
 89  *RESOLVED*: It's actually a superset as it also adds in support for arrayed
 90  drawing commands.
 91  
 92  In GL for `GL_ARB_shader_draw_parameters`, code:gl_BaseVertexARB holds the
 93  integer value passed to the parameter to the command that resulted in the
 94  current shader invocation.
 95  In the case where the command has no code:baseVertex parameter, the value of
 96  code:gl_BaseVertexARB is zero.
 97  This means that code:gl_BaseVertexARB = code:baseVertex (for
 98  code:glDrawElements commands with code:baseVertex) or 0.
 99  In particular there are no code:glDrawArrays commands that take a
100  code:baseVertex parameter.
101  
102  Now in Vulkan, we have code:BaseVertex = pname:vertexOffset (for indexed
103  drawing commands) or pname:firstVertex (for arrayed drawing commands), and
104  so Vulkan's version is really a superset of GL functionality.
105  
106  === Version History
107  
108    * Revision 1, 2016-10-05 (Daniel Koch)
109      - Internal revisions