switch (ib->type) {
case GL_UNSIGNED_BYTE:
- cut_index_will_work = (ctx->Array.RestartIndex & 0xff) == 0xff;
+ cut_index_will_work = (ctx->Array._RestartIndex & 0xff) == 0xff;
break;
case GL_UNSIGNED_SHORT:
- cut_index_will_work = (ctx->Array.RestartIndex & 0xffff) == 0xffff;
+ cut_index_will_work = (ctx->Array._RestartIndex & 0xffff) == 0xffff;
break;
case GL_UNSIGNED_INT:
- cut_index_will_work = ctx->Array.RestartIndex == 0xffffffff;
+ cut_index_will_work = ctx->Array._RestartIndex == 0xffffffff;
break;
default:
cut_index_will_work = false;
/* If PrimitiveRestart is not enabled, then we aren't concerned about
* handling this draw.
*/
- if (!(ctx->Array.PrimitiveRestart)) {
+ if (!(ctx->Array._PrimitiveRestart)) {
return GL_FALSE;
}
/* 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;
}
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 */
}
+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.
*/
*var = state;
+ update_derived_primitive_restart_state(ctx);
+
if (state)
arrayObj->_Enabled |= flag;
else
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;
}
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))
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;
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;
}
}
/* The VBO module handles restart for the non-indexed GLDrawArrays
* so we only set these fields for indexed drawing:
*/
- info.primitive_restart = ctx->Array.PrimitiveRestart;
- info.restart_index = ctx->Array.RestartIndex;
+ info.primitive_restart = ctx->Array._PrimitiveRestart;
+ info.restart_index = ctx->Array._RestartIndex;
}
else {
/* Transform feedback drawing is always non-indexed. */
GLuint *min_index, GLuint *max_index,
const GLuint count)
{
- const GLboolean restart = ctx->Array.PrimitiveRestart;
- const GLuint restartIndex = ctx->Array.RestartIndex;
+ const GLboolean restart = ctx->Array._PrimitiveRestart;
+ const GLuint restartIndex = ctx->Array._RestartIndex;
const int index_size = vbo_sizeof_ib_type(ib->type);
const char *indices;
GLuint i;
if ((ib != NULL) &&
ctx->Const.PrimitiveRestartInSoftware &&
- ctx->Array.PrimitiveRestart) {
+ ctx->Array._PrimitiveRestart) {
/* Handle primitive restart in software */
vbo_sw_primitive_restart(ctx, prim, nr_prims, ib);
} else {
prim[0].base_instance = baseInstance;
/* Implement the primitive restart index */
- if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) {
+ if (ctx->Array._PrimitiveRestart && ctx->Array._RestartIndex < count) {
GLuint primCount = 0;
- if (ctx->Array.RestartIndex == start) {
+ if (ctx->Array._RestartIndex == start) {
/* special case: RestartIndex at beginning */
if (count > 1) {
prim[0].start = start + 1;
primCount = 1;
}
}
- else if (ctx->Array.RestartIndex == start + count - 1) {
+ else if (ctx->Array._RestartIndex == start + count - 1) {
/* special case: RestartIndex at end */
if (count > 1) {
prim[0].start = start;
else {
/* general case: RestartIndex in middle, split into two prims */
prim[0].start = start;
- prim[0].count = ctx->Array.RestartIndex - start;
+ prim[0].count = ctx->Array._RestartIndex - start;
prim[1] = prim[0];
- prim[1].start = ctx->Array.RestartIndex + 1;
+ prim[1].start = ctx->Array._RestartIndex + 1;
prim[1].count = count - prim[1].start;
primCount = 2;
GLuint sub_prim_num;
GLuint end_index;
GLuint sub_end_index;
- GLuint restart_index = ctx->Array.RestartIndex;
+ GLuint restart_index = ctx->Array._RestartIndex;
struct _mesa_prim temp_prim;
struct vbo_context *vbo = vbo_context(ctx);
vbo_draw_func draw_prims_func = vbo->draw_prims;