diff options
author | Marek Olšák <[email protected]> | 2012-04-16 03:34:22 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-04-19 14:47:21 +0200 |
commit | 784dd51198433e5c299da4a7742c68d21d68d1c1 (patch) | |
tree | 82bfb55116d13e2738114f321a33bd69d60892a2 /src/mesa/vbo | |
parent | 0de5a21470b3bff9b7c8714e5d960d5ed9d01b9c (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')
-rw-r--r-- | src/mesa/vbo/vbo_exec.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec.h | 1 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_array.c | 59 |
3 files changed, 25 insertions, 39 deletions
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 05c3ec1ae9d..fd5e0f8911b 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -85,6 +85,10 @@ void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + if (new_state & (_NEW_PROGRAM|_NEW_ARRAY)) { + exec->array.recalculate_inputs = GL_TRUE; + } + if (new_state & (_NEW_PROGRAM|_NEW_EVAL)) exec->eval.recalculate_maps = 1; diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index f6ede99cd75..5cdf5ced912 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -141,6 +141,7 @@ struct vbo_exec_context * programs: */ const struct gl_client_array *inputs[VERT_ATTRIB_MAX]; + GLboolean recalculate_inputs; } array; /* Which flags to set in vbo_exec_BeginVertices() */ 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; |