summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_arrayelt.c2
-rw-r--r--src/mesa/main/attrib.c3
-rw-r--r--src/mesa/main/enable.c33
-rw-r--r--src/mesa/main/mtypes.h13
-rw-r--r--src/mesa/main/varray.c5
5 files changed, 52 insertions, 4 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 0fa2429976b..ea3361488ce 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -1636,7 +1636,7 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
/* If PrimitiveRestart is enabled and the index is the RestartIndex
* then we call PrimitiveRestartNV and return.
*/
- if (ctx->Array.PrimitiveRestart && (elt == ctx->Array.RestartIndex)) {
+ if (ctx->Array._PrimitiveRestart && (elt == ctx->Array._RestartIndex)) {
CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
return;
}
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index a19d610545d..d6f298d93c6 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1377,7 +1377,10 @@ copy_array_attrib(struct gl_context *ctx,
dest->LockFirst = src->LockFirst;
dest->LockCount = src->LockCount;
dest->PrimitiveRestart = src->PrimitiveRestart;
+ dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex;
+ dest->_PrimitiveRestart = src->_PrimitiveRestart;
dest->RestartIndex = src->RestartIndex;
+ dest->_RestartIndex = src->_RestartIndex;
/* skip NewState */
/* skip RebindArrays */
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index b48794f950b..73257290ed8 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -48,6 +48,20 @@
}
+static void
+update_derived_primitive_restart_state(struct gl_context *ctx)
+{
+ /* Update derived primitive restart state.
+ */
+ if (ctx->Array.PrimitiveRestart)
+ ctx->Array._RestartIndex = ctx->Array.RestartIndex;
+ else
+ ctx->Array._RestartIndex = ~0;
+
+ ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart
+ || ctx->Array.PrimitiveRestartFixedIndex;
+}
+
/**
* Helper to enable/disable client-side state.
*/
@@ -119,6 +133,8 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
*var = state;
+ update_derived_primitive_restart_state(ctx);
+
if (state)
arrayObj->_Enabled |= flag;
else
@@ -967,6 +983,17 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
if (ctx->Array.PrimitiveRestart != state) {
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
ctx->Array.PrimitiveRestart = state;
+ update_derived_primitive_restart_state(ctx);
+ }
+ break;
+
+ case GL_PRIMITIVE_RESTART_FIXED_INDEX:
+ if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility)
+ goto invalid_enum_error;
+ if (ctx->Array.PrimitiveRestartFixedIndex != state) {
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Array.PrimitiveRestartFixedIndex = state;
+ update_derived_primitive_restart_state(ctx);
}
break;
@@ -1542,6 +1569,12 @@ _mesa_IsEnabled( GLenum cap )
}
return ctx->Array.PrimitiveRestart;
+ case GL_PRIMITIVE_RESTART_FIXED_INDEX:
+ if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) {
+ goto invalid_enum_error;
+ }
+ return ctx->Array.PrimitiveRestartFixedIndex;
+
/* GL3.0 - GL_framebuffer_sRGB */
case GL_FRAMEBUFFER_SRGB_EXT:
if (!_mesa_is_desktop_gl(ctx))
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 318dcb548d8..f44ec4947ed 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1634,9 +1634,20 @@ struct gl_array_attrib
GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
- /** GL 3.1 (slightly different from GL_NV_primitive_restart) */
+ /**
+ * \name Primitive restart controls
+ *
+ * Primitive restart is enabled if either \c PrimitiveRestart or
+ * \c PrimitiveRestart is set. If \c PrimitiveRestart is set, then
+ * \c RestartIndex is used as the cut vertex. Otherwise ~0 is used.
+ */
+ /*@{*/
GLboolean PrimitiveRestart;
+ GLboolean PrimitiveRestartFixedIndex;
+ GLboolean _PrimitiveRestart;
GLuint RestartIndex;
+ GLuint _RestartIndex;
+ /*@}*/
/* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 5e4d6c3e638..e453b3b0e64 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1113,9 +1113,10 @@ _mesa_PrimitiveRestartIndex(GLuint index)
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (ctx->Array.RestartIndex != index) {
+ ctx->Array.RestartIndex = index;
+ if (ctx->Array.PrimitiveRestart && ctx->Array._RestartIndex != index) {
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
- ctx->Array.RestartIndex = index;
+ ctx->Array._RestartIndex = index;
}
}