diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 08fdc54..3ba8a12 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -463,7 +463,7 @@ struct brw_context struct gl_buffer_object *vbo[BRW_NR_UPLOAD_BUFS]; GLuint buf; GLuint offset; - GLuint size; + GLuint max_size; GLuint wrap; } upload; diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index f796472..f0231bc 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -415,6 +415,25 @@ static GLboolean brw_need_rebase( GLcontext *ctx, return GL_FALSE; } } + +static GLboolean brw_need_split(GLcontext *ctx, + const struct gl_client_array *arrays[], + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) +{ + struct brw_context *brw = brw_context(ctx); + + if (vbo_all_varyings_in_vbos(arrays) && + (!ib || ib->obj->Name)) + return GL_FALSE; + + if ((max_index + 1 - min_index > brw->vb.upload.max_size) || + (ib && !ib->obj->Name && ib->count > brw->vb.upload.max_size)) + return GL_TRUE; + + return GL_FALSE; +} void brw_draw_prims( GLcontext *ctx, @@ -438,9 +457,22 @@ void brw_draw_prims( GLcontext *ctx, brw_draw_prims ); return; + } else if (brw_need_split(ctx, arrays, ib, min_index, max_index)) { + struct brw_context *brw = brw_context(ctx); + struct split_limits limits; + limits.max_verts = brw->vb.upload.max_size; + limits.max_vb_size = ~0; + limits.max_indices = brw->vb.upload.max_size; + + /* This will split the buffers one way or another and + * recursively call back into this function. + */ + vbo_split_prims(ctx, arrays, prim, nr_prims, ib, + 0, max_index, + brw_draw_prims, + &limits ); } - /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); @@ -491,7 +523,7 @@ void brw_draw_init( struct brw_context *brw ) */ vbo->draw_prims = brw_draw_prims; - brw->vb.upload.size = BRW_UPLOAD_INIT_SIZE; + brw->vb.upload.max_size = brw->intel.intelScreen->tex.size >> 4; for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) { brw->vb.upload.vbo[i] = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index bc4211d..b2b43df 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -78,7 +78,8 @@ GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] ) GLuint i; for (i = 0; i < VERT_ATTRIB_MAX; i++) - if (arrays[i]->StrideB && + if (arrays[i] && + arrays[i]->StrideB && arrays[i]->BufferObj->Name == 0) return GL_FALSE;