diff options
author | Antia Puentes <[email protected]> | 2018-01-25 19:15:38 +0100 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2018-04-19 15:57:45 -0700 |
commit | 5ff848df7be34bdc4c2e0ad509ad43b4ae1fc3b9 (patch) | |
tree | 96fb43b88f02fa5447031abf2bd6a89e6e02c8e1 /src/compiler/shader_enums.h | |
parent | 051fddb4a9e6abb6f2cf9c892e34c8739983c794 (diff) |
compiler: Add SYSTEM_VALUE_FIRST_VERTEX and instrinsics
This VS system value will contain the value passed as <basevertex> for
indexed draw calls or the value passed as <first> for non-indexed draw
calls. It can be used to calculate the gl_VertexID as
SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus SYSTEM_VALUE_FIRST_VERTEX.
From the OpenGL 4.6 spec, 10.4 "Drawing Commands Using Vertex Arrays":
- Page 352:
"The index of any element transferred to the GL by DrawArraysOneInstance
is referred to as its vertex ID, and may be read by a vertex shader as
gl_VertexID. The vertex ID of the ith element transferred is first +
i."
- Page 355:
"The index of any element transferred to the GL by
DrawElementsOneInstance is referred to as its vertex ID, and may be read
by a vertex shader as gl_VertexID. The vertex ID of the ith element
transferred is the sum of basevertex and the value stored in the
currently bound element array buffer at offset indices + i."
Currently the gl_VertexID calculation uses SYSTEM_VALUE_BASE_VERTEX but
this will have to change when the value of gl_BaseVertex is
fixed. Currently its value is broken for non-indexed draw calls because
it must be zero but we are setting it to <first>.
v2: use SYSTEM_VALUE_FIRST_VERTEX as name for the value, instead of
SYSTEM_VALUE_BASE_VERTEX_ID (Kenneth).
v3 (idr): Rebase on Rob Clark converting nir_intrinsics.h to be
generated. Reformat commit message to 72 columns.
Reviewed-by: Neil Roberts <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/shader_enums.h')
-rw-r--r-- | src/compiler/shader_enums.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 2aedbb9b3fa..8a277a14f21 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -504,6 +504,20 @@ typedef enum SYSTEM_VALUE_BASE_VERTEX, /** + * Depending on the type of the draw call (indexed or non-indexed), + * is the value of \c basevertex passed to \c glDrawElementsBaseVertex and + * similar, or is the value of \c first passed to \c glDrawArrays and + * similar. + * + * \note + * It can be used to calculate the \c SYSTEM_VALUE_VERTEX_ID as + * \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus \c SYSTEM_VALUE_FIRST_VERTEX. + * + * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_VERTEX_ID + */ + SYSTEM_VALUE_FIRST_VERTEX, + + /** * Value of \c baseinstance passed to instanced draw entry points * * \sa SYSTEM_VALUE_INSTANCE_ID |