vbo: fix missing state validation bugs

Commit 2708ddfb06 caused a few regressions.
We need to check/validate state after calling bind_arrays() because
it might set the _NEW_ARRAYS flag if the varying VP inputs change.

The symptom of this problem was some attribute arrays being ignored
(or interpreted as constant-valued) in glDrawRangeElements or
glMultiDrawElements.

A follow-on patch will add some additional asserts to try to catch
this kind of thing in the future.

(cherry picked from commit 3cba779e16935f7c3a0bfd8af48bd5e015068e96)
This commit is contained in:
Brian Paul
2010-01-29 08:38:21 -07:00
parent a38859569d
commit 5ce9183c1c
+14 -14
View File
@@ -443,6 +443,13 @@ recalculate_input_bindings(GLcontext *ctx)
}
/**
* Examine the enabled vertex arrays to set the exec->array.inputs[] values.
* These will point to the arrays to actually use for drawing. Some will
* be user-provided arrays, other will be zero-stride const-valued arrays.
* Note that this might set the _NEW_ARRAY dirty flag so state validation
* must be done after this call.
*/
static void
bind_arrays(GLcontext *ctx)
{
@@ -484,9 +491,6 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
FLUSH_CURRENT( ctx, 0 );
if (ctx->NewState)
_mesa_update_state( ctx );
if (!_mesa_valid_to_render(ctx, "glDrawArrays")) {
return;
}
@@ -600,18 +604,16 @@ vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode,
FLUSH_CURRENT( ctx, 0 );
if (ctx->NewState)
_mesa_update_state( ctx );
if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) {
return;
}
bind_arrays( ctx );
/* check for dirty state again */
if (ctx->NewState)
_mesa_update_state( ctx );
bind_arrays( ctx );
ib.count = count;
ib.type = type;
ib.obj = ctx->Array.ElementArrayBufferObj;
@@ -848,16 +850,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
FLUSH_CURRENT( ctx, 0 );
if (ctx->NewState)
_mesa_update_state( ctx );
if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) {
return;
}
if (ctx->NewState)
_mesa_update_state( ctx );
prim = _mesa_calloc(primcount * sizeof(*prim));
if (prim == NULL) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements");
@@ -869,6 +865,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode,
*/
bind_arrays( ctx );
/* check for dirty state again */
if (ctx->NewState)
_mesa_update_state( ctx );
switch (type) {
case GL_UNSIGNED_INT:
index_type_size = 4;