diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 213b845c9ca..059bd0b7114 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1153,6 +1153,30 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) } +unsigned +_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type) +{ + /* From the OpenGL 4.3 core specification, page 302: + * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are + * enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX + * is used." + */ + if (ctx->Array.PrimitiveRestartFixedIndex) { + switch (ib_type) { + case GL_UNSIGNED_BYTE: + return 0xff; + case GL_UNSIGNED_SHORT: + return 0xffff; + case GL_UNSIGNED_INT: + return 0xffffffff; + default: + assert(!"_mesa_primitive_restart_index: Invalid index buffer type."); + } + } + + return ctx->Array.RestartIndex; +} + /** * Copy one client vertex array to another. diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 904fa1bea8f..46e9dc49568 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -248,6 +248,8 @@ _mesa_PrimitiveRestartIndex(GLuint index); extern void GLAPIENTRY _mesa_VertexAttribDivisor(GLuint index, GLuint divisor); +extern unsigned +_mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type); extern void _mesa_copy_client_array(struct gl_context *ctx,