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 <nroberts@igalia.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:

committed by
Ian Romanick

parent
051fddb4a9
commit
5ff848df7b
@@ -1991,6 +1991,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
|
||||
return nir_intrinsic_load_base_instance;
|
||||
case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
|
||||
return nir_intrinsic_load_vertex_id_zero_base;
|
||||
case SYSTEM_VALUE_FIRST_VERTEX:
|
||||
return nir_intrinsic_load_first_vertex;
|
||||
case SYSTEM_VALUE_BASE_VERTEX:
|
||||
return nir_intrinsic_load_base_vertex;
|
||||
case SYSTEM_VALUE_INVOCATION_ID:
|
||||
@@ -2066,6 +2068,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
|
||||
return SYSTEM_VALUE_BASE_INSTANCE;
|
||||
case nir_intrinsic_load_vertex_id_zero_base:
|
||||
return SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
|
||||
case nir_intrinsic_load_first_vertex:
|
||||
return SYSTEM_VALUE_FIRST_VERTEX;
|
||||
case nir_intrinsic_load_base_vertex:
|
||||
return SYSTEM_VALUE_BASE_VERTEX;
|
||||
case nir_intrinsic_load_invocation_id:
|
||||
|
@@ -265,6 +265,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
|
||||
case nir_intrinsic_load_vertex_id:
|
||||
case nir_intrinsic_load_vertex_id_zero_base:
|
||||
case nir_intrinsic_load_base_vertex:
|
||||
case nir_intrinsic_load_first_vertex:
|
||||
case nir_intrinsic_load_base_instance:
|
||||
case nir_intrinsic_load_instance_id:
|
||||
case nir_intrinsic_load_sample_id:
|
||||
|
@@ -413,6 +413,7 @@ system_value("frag_coord", 4)
|
||||
system_value("front_face", 1)
|
||||
system_value("vertex_id", 1)
|
||||
system_value("vertex_id_zero_base", 1)
|
||||
system_value("first_vertex", 1)
|
||||
system_value("base_vertex", 1)
|
||||
system_value("instance_id", 1)
|
||||
system_value("base_instance", 1)
|
||||
|
@@ -216,6 +216,7 @@ gl_system_value_name(gl_system_value sysval)
|
||||
ENUM(SYSTEM_VALUE_INSTANCE_ID),
|
||||
ENUM(SYSTEM_VALUE_INSTANCE_INDEX),
|
||||
ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE),
|
||||
ENUM(SYSTEM_VALUE_FIRST_VERTEX),
|
||||
ENUM(SYSTEM_VALUE_BASE_VERTEX),
|
||||
ENUM(SYSTEM_VALUE_BASE_INSTANCE),
|
||||
ENUM(SYSTEM_VALUE_DRAW_ID),
|
||||
|
@@ -503,6 +503,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
|
||||
*
|
||||
|
Reference in New Issue
Block a user