brw_batch_emit(brw, GENX(3DSTATE_VF), vf) {
if (ctx->Array._PrimitiveRestart && brw->ib.ib) {
vf.IndexedDrawCutIndexEnable = true;
- vf.CutIndex = _mesa_primitive_restart_index(ctx, brw->ib.index_size);
+ vf.CutIndex = ctx->Array._RestartIndex[brw->ib.index_size - 1];
}
}
}
dest->PrimitiveRestartFixedIndex = src->PrimitiveRestartFixedIndex;
dest->_PrimitiveRestart = src->_PrimitiveRestart;
dest->RestartIndex = src->RestartIndex;
+ memcpy(dest->_RestartIndex, src->_RestartIndex, sizeof(src->_RestartIndex));
/* skip NewState */
/* skip RebindArrays */
#include "varray.h"
-static void
-update_derived_primitive_restart_state(struct gl_context *ctx)
+void
+_mesa_update_derived_primitive_restart_state(struct gl_context *ctx)
{
- /* Update derived primitive restart state.
- */
- ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart
- || ctx->Array.PrimitiveRestartFixedIndex;
+ ctx->Array._PrimitiveRestart = ctx->Array.PrimitiveRestart ||
+ ctx->Array.PrimitiveRestartFixedIndex;
+ ctx->Array._RestartIndex[0] = _mesa_primitive_restart_index(ctx, 1);
+ ctx->Array._RestartIndex[1] = _mesa_primitive_restart_index(ctx, 2);
+ ctx->Array._RestartIndex[3] = _mesa_primitive_restart_index(ctx, 4);
}
FLUSH_VERTICES(ctx, 0);
ctx->Array.PrimitiveRestart = state;
- update_derived_primitive_restart_state(ctx);
+ _mesa_update_derived_primitive_restart_state(ctx);
return;
default:
if (ctx->Array.PrimitiveRestart != state) {
FLUSH_VERTICES(ctx, 0);
ctx->Array.PrimitiveRestart = state;
- update_derived_primitive_restart_state(ctx);
+ _mesa_update_derived_primitive_restart_state(ctx);
}
break;
if (ctx->Array.PrimitiveRestartFixedIndex != state) {
FLUSH_VERTICES(ctx, 0);
ctx->Array.PrimitiveRestartFixedIndex = state;
- update_derived_primitive_restart_state(ctx);
+ _mesa_update_derived_primitive_restart_state(ctx);
}
break;
struct gl_context;
+extern void
+_mesa_update_derived_primitive_restart_state(struct gl_context *ctx);
+
extern void
_mesa_set_enable( struct gl_context* ctx, GLenum cap, GLboolean state );
GLboolean PrimitiveRestartFixedIndex;
GLboolean _PrimitiveRestart;
GLuint RestartIndex;
+ GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */
/*@}*/
/* GL_ARB_vertex_buffer_object */
primitive_restart_index(struct gl_context *ctx, GLuint index)
{
ctx->Array.RestartIndex = index;
+ _mesa_update_derived_primitive_restart_state(ctx);
}
if (ctx->Array._PrimitiveRestart) {
unsigned index_size = info->index_size;
- info->restart_index =
- _mesa_primitive_restart_index(ctx, index_size);
+ info->restart_index = ctx->Array._RestartIndex[index_size - 1];
/* Enable primitive restart only when the restart index can have an
* effect. This is required for correctness in radeonsi GFX8 support.
if (ctx->Array._PrimitiveRestart) {
info.primitive_restart = true;
- info.restart_index = _mesa_primitive_restart_index(ctx, info.index_size);
+ info.restart_index = ctx->Array._RestartIndex[index_size - 1];
}
} else {
info.index_size = 0;
{
const GLboolean restart = ctx->Array._PrimitiveRestart;
const GLuint restartIndex =
- _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift);
+ ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1];
const char *indices;
GLuint i;
GLintptr offset = 0;
GLuint sub_prim_num;
GLuint end_index;
GLuint sub_end_index;
- GLuint restart_index = _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift);
+ GLuint restart_index = ctx->Array._RestartIndex[(1 << ib->index_size_shift) - 1];
struct _mesa_prim temp_prim;
GLboolean map_ib = ib->obj && !ib->obj->Mappings[MAP_INTERNAL].Pointer;
const void *ptr;
* then we call PrimitiveRestartNV and return.
*/
if (ctx->Array._PrimitiveRestart &&
- elt == _mesa_primitive_restart_index(ctx, index_size)) {
+ elt == ctx->Array._RestartIndex[index_size - 1]) {
CALL_PrimitiveRestartNV(GET_DISPATCH(), ());
return;
}