summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2014-06-19 12:06:42 -0700
committerKenneth Graunke <[email protected]>2014-09-10 11:05:08 -0700
commitec08b5e768271aa100be87c1ca6dd2b0109049d9 (patch)
treeb76c8e82a5c3fe2cc5180586b815a3bbcd218b18 /src/mesa/main
parent04d3323d4b7b7cae4954d80946f0ca202770dd14 (diff)
glsl: Add a lowering pass for gl_VertexID
Converts gl_VertexID to (gl_VertexIDMESA + gl_BaseVertex). gl_VertexIDMESA is backed by SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, and gl_BaseVertex is backed by SYSTEM_VALUE_BASE_VERTEX. v2: Put the enum in struct gl_constants and propoerly resolve the scope in C++ code. Fix suggested by Marek. v3: Reabase on Matt's foreach_in_list changes (was using foreach_list). v4 (Ken): Use a systemvalue instead of a uniform because STATE_BASE_VERTEX has been removed. v5: Use a boolean to select lowering, and only allow one lowering method. Suggested by Ken. v6 (Ken): Replace strcmp against literal "gl_BaseVertex"/"gl_VertexID" with SYSTEM_VALUE enum checks, for efficiency. v7: Rebase on context constant initialization work. Signed-off-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c6
-rw-r--r--src/mesa/main/mtypes.h9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8b5693e3771..8208a50b3e6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -622,6 +622,12 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES;
consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
+ /* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
+ * gl_VertexID is implemented using a native hardware register with OpenGL
+ * semantics.
+ */
+ consts->VertexID_is_zero_based = false;
+
/* CheckArrayBounds is overriden by drivers/x11 for X server */
consts->CheckArrayBounds = GL_FALSE;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 05534dba288..0d50be842fb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3488,6 +3488,15 @@ struct gl_constants
GLboolean NativeIntegers;
/**
+ * Does VertexID count from zero or from base vertex?
+ *
+ * \note
+ * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
+ * ignored and need not be set.
+ */
+ bool VertexID_is_zero_based;
+
+ /**
* If the driver supports real 32-bit integers, what integer value should be
* used for boolean true in uniform uploads? (Usually 1 or ~0.)
*/