[Mesa-dev] [PATCH 8/8] vbo: Fix GL_PRIMITIVE_RESTART_FIXED_INDEX in display list compiles.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Tue Mar 5 08:13:18 UTC 2019


From: Mathias Fröhlich <mathias.froehlich at web.de>

The maximum value primitive restart index is different for each index data
type. Use the appropriate fixed restart index value.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/vbo/vbo_save_api.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 7f8c06b630c..de0be4e3324 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1374,7 +1374,7 @@ _save_OBE_MultiDrawArrays(GLenum mode, const GLint *first,
 
 static void
 array_element(struct gl_context *ctx, struct _glapi_table *disp,
-              GLint basevertex, GLuint elt)
+              GLint basevertex, GLuint elt, unsigned index_size)
 {
    /* Section 10.3.5 Primitive Restart:
     * [...]
@@ -1385,7 +1385,8 @@ array_element(struct gl_context *ctx, struct _glapi_table *disp,
    /* 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 == _mesa_primitive_restart_index(ctx, index_size)) {
       CALL_PrimitiveRestartNV(disp, ());
       return;
    }
@@ -1439,15 +1440,18 @@ _save_OBE_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
    switch (type) {
    case GL_UNSIGNED_BYTE:
       for (i = 0; i < count; i++)
-         array_element(ctx, GET_DISPATCH(), basevertex, ((GLubyte *) indices)[i]);
+         array_element(ctx, GET_DISPATCH(), basevertex,
+                       ((GLubyte *) indices)[i], 1);
       break;
    case GL_UNSIGNED_SHORT:
       for (i = 0; i < count; i++)
-         array_element(ctx, GET_DISPATCH(), basevertex, ((GLushort *) indices)[i]);
+         array_element(ctx, GET_DISPATCH(), basevertex,
+                       ((GLushort *) indices)[i], 2);
       break;
    case GL_UNSIGNED_INT:
       for (i = 0; i < count; i++)
-         array_element(ctx, GET_DISPATCH(), basevertex, ((GLuint *) indices)[i]);
+         array_element(ctx, GET_DISPATCH(), basevertex,
+                       ((GLuint *) indices)[i], 4);
       break;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)");
-- 
2.20.1



More information about the mesa-dev mailing list