aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_exec_array.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-04-16 03:34:22 +0200
committerMarek Olšák <[email protected]>2012-04-19 14:47:21 +0200
commit784dd51198433e5c299da4a7742c68d21d68d1c1 (patch)
tree82bfb55116d13e2738114f321a33bd69d60892a2 /src/mesa/vbo/vbo_exec_array.c
parent0de5a21470b3bff9b7c8714e5d960d5ed9d01b9c (diff)
mesa,vbo: properly detect when vertex arrays need to be recalculated
This moves the RebindArrays flag into the vbo module, consolidates the code, and adds missing vbo_draw_method calls. Also with this change, the vertex arrays are not needlessly recalculated twice. The issue with the old code was: - If recalculate_input_bindings updates vp_varying_inputs, _NEW_ARRAY is set. - _mesa_update_state is called and the vp_varying_inputs change causes regeneration of the fixed-function shaders, which also sets _NEW_PROGRAM. - The occurence of either _NEW_ARRAY or _NEW_PROGRAM sets the recalculate_inputs flag to TRUE again. - The new code sets the flag to FALSE after the second _mesa_update_state, because there can't possibly be any change which would require recalculating the arrays. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_exec_array.c')
-rw-r--r--src/mesa/vbo/vbo_exec_array.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index b0a4261e764..d9003c243b1 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -529,12 +529,25 @@ recalculate_input_bindings(struct gl_context *ctx)
void
vbo_bind_arrays(struct gl_context *ctx)
{
- if (!ctx->Array.RebindArrays) {
- return;
- }
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_exec_context *exec = &vbo->exec;
+
+ vbo_draw_method(exec, DRAW_ARRAYS);
- recalculate_input_bindings(ctx);
- ctx->Array.RebindArrays = GL_FALSE;
+ if (exec->array.recalculate_inputs) {
+ recalculate_input_bindings(ctx);
+
+ /* Again... because we may have changed the bitmask of per-vertex varying
+ * attributes. If we regenerate the fixed-function vertex program now
+ * we may be able to prune down the number of vertex attributes which we
+ * need in the shader.
+ */
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ exec->array.recalculate_inputs = GL_FALSE;
+ }
}
@@ -554,16 +567,6 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
vbo_bind_arrays(ctx);
- vbo_draw_method(exec, DRAW_ARRAYS);
-
- /* Again... because we may have changed the bitmask of per-vertex varying
- * attributes. If we regenerate the fixed-function vertex program now
- * we may be able to prune down the number of vertex attributes which we
- * need in the shader.
- */
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
prim[0].begin = 1;
@@ -771,13 +774,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
return;
}
- vbo_bind_arrays( ctx );
-
- vbo_draw_method(exec, DRAW_ARRAYS);
-
- /* check for dirty state again */
- if (ctx->NewState)
- _mesa_update_state( ctx );
+ vbo_bind_arrays(ctx);
ib.count = count;
ib.type = type;
@@ -1063,15 +1060,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
return;
}
- /* Decide if we can do this all as one set of primitives sharing the
- * same index buffer, or if we have to reset the index pointer per
- * primitive.
- */
- vbo_bind_arrays( ctx );
-
- /* check for dirty state again */
- if (ctx->NewState)
- _mesa_update_state( ctx );
+ vbo_bind_arrays(ctx);
min_index_ptr = (uintptr_t)indices[0];
max_index_ptr = 0;
@@ -1217,14 +1206,6 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
vbo_bind_arrays(ctx);
- /* Again... because we may have changed the bitmask of per-vertex varying
- * attributes. If we regenerate the fixed-function vertex program now
- * we may be able to prune down the number of vertex attributes which we
- * need in the shader.
- */
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
prim[0].begin = 1;