[Mesa-dev] [PATCH 1/2] vbo: do FLUSH_CURRENT before validating and updating state

Marek Olšák maraeo at gmail.com
Sun Apr 22 10:50:34 PDT 2012


This fixes an assertion failure since:
   commit 81afdd20f3f574ce29559d8ad77df5c77652009e
   vbo: don't check twice whether it's valid to render

FLUSH_CURRENT may set _NEW_CURRENT_ATTRIB.
---
 src/mesa/vbo/vbo_exec_array.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index f95e062..28019af 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -640,11 +640,11 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
       _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n",
                   _mesa_lookup_enum_by_nr(mode), start, count);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
       return;
 
-   FLUSH_CURRENT( ctx, 0 );
-
    if (0)
       check_draw_arrays_data(ctx, start, count);
 
@@ -669,11 +669,11 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
       _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
                   _mesa_lookup_enum_by_nr(mode), start, count, numInstances);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances))
       return;
 
-   FLUSH_CURRENT( ctx, 0 );
-
    if (0)
       check_draw_arrays_data(ctx, start, count);
 
@@ -761,8 +761,6 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
    struct _mesa_index_buffer ib;
    struct _mesa_prim prim[1];
 
-   FLUSH_CURRENT( ctx, 0 );
-
    vbo_bind_arrays(ctx);
 
    ib.count = count;
@@ -838,6 +836,8 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
                 _mesa_lookup_enum_by_nr(mode), start, end, count,
                 _mesa_lookup_enum_by_nr(type), indices, basevertex);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
                                           type, indices, basevertex ))
       return;
@@ -936,6 +936,8 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
                   _mesa_lookup_enum_by_nr(mode), count,
                   _mesa_lookup_enum_by_nr(type), indices);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 ))
       return;
 
@@ -958,6 +960,8 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
                   _mesa_lookup_enum_by_nr(mode), count,
                   _mesa_lookup_enum_by_nr(type), indices, basevertex);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices,
 				     basevertex ))
       return;
@@ -981,6 +985,8 @@ vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
                   _mesa_lookup_enum_by_nr(mode), count,
                   _mesa_lookup_enum_by_nr(type), indices, numInstances);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
                                              numInstances, 0))
       return;
@@ -1005,6 +1011,8 @@ vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type
                   _mesa_lookup_enum_by_nr(type), indices,
                   numInstances, basevertex);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
                                              numInstances, basevertex))
       return;
@@ -1037,8 +1045,6 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
    if (primcount == 0)
       return;
 
-   FLUSH_CURRENT( ctx, 0 );
-
    prim = calloc(1, primcount * sizeof(*prim));
    if (prim == NULL) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
@@ -1226,12 +1232,12 @@ vbo_exec_DrawTransformFeedback(GLenum mode, GLuint name)
       _mesa_debug(ctx, "glDrawTransformFeedback(%s, %d)\n",
                   _mesa_lookup_enum_by_nr(mode), name);
 
+   FLUSH_CURRENT(ctx, 0);
+
    if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj)) {
       return;
    }
 
-   FLUSH_CURRENT(ctx, 0);
-
    vbo_draw_transform_feedback(ctx, mode, obj, 1);
 }
 
-- 
1.7.5.4



More information about the mesa-dev mailing list