diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 330d571..12d6e3b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -336,6 +336,7 @@ struct brw_tracked_state { struct brw_state_flags dirty; void (*prepare)( struct brw_context *brw ); void (*emit)( struct brw_context *brw ); + void (*finish)( struct brw_context *brw ); }; /* Flags for brw->state.cache. diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c index 0a36001..bf35b9d 100644 --- a/src/mesa/drivers/dri/i965/brw_curbe.c +++ b/src/mesa/drivers/dri/i965/brw_curbe.c @@ -335,6 +335,9 @@ static void emit_constant_buffer(struct brw_context *brw) if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array))) intel_batchbuffer_flush(intel->batch); + if (sz && !brw->curbe.curbe_bo) + prepare_constant_buffer(brw); + BEGIN_BATCH(2, IGNORE_CLIPRECTS); if (sz == 0) { OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2)); diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 465239f..292cdda 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -300,6 +300,32 @@ copy_array_to_vbo_array( struct brw_context *brw, } } +static void brw_finish_vertices(struct brw_context *brw) +{ + GLuint tmp = brw->vs.prog_data->inputs_read; + struct brw_vertex_element *enabled[VERT_ATTRIB_MAX]; + GLuint i, nr_enabled = 0; + + /* Accumulate the list of enabled arrays. */ + while (tmp) { + i = _mesa_ffsll(tmp)-1; + struct brw_vertex_element *input = &brw->vb.inputs[i]; + + tmp &= ~(1<bo); + input->bo = NULL; + } +} + static void brw_prepare_vertices(struct brw_context *brw) { GLcontext *ctx = &brw->intel.ctx; @@ -365,8 +391,11 @@ static void brw_prepare_vertices(struct brw_context *brw) if (i == 0) { /* Position array not properly enabled: */ - if (input->glarray->StrideB == 0) - return; + if (input->glarray->StrideB == 0) { + intel->Fallback = 1; + brw_finish_vertices(brw); + return; + } interleave = input->glarray->StrideB; ptr = input->glarray->Ptr; @@ -455,12 +484,6 @@ static void brw_emit_vertices(struct brw_context *brw) input->offset); OUT_BATCH(brw->vb.max_index); OUT_BATCH(0); /* Instance data step rate */ - - /* Unreference the buffer so it can get freed, now that we won't - * touch it any more. - */ - dri_bo_unreference(input->bo); - input->bo = NULL; } ADVANCE_BATCH(); @@ -505,6 +528,7 @@ const struct brw_tracked_state brw_vertices = { }, .prepare = brw_prepare_vertices, .emit = brw_emit_vertices, + .finish = brw_finish_vertices, }; static void brw_prepare_indices(struct brw_context *brw) diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 7d4fd46..b7110f2 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -298,6 +298,16 @@ got_flushed: dri_bo_unreference(last_batch_bo); + for (i = 0; i < Elements(atoms); i++) { + const struct brw_tracked_state *atom = brw->state.atoms[i]; + + if (check_state(state, &atom->dirty)) { + if (atom->finish) { + atom->finish(brw); + } + } + } + if (!brw->intel.Fallback) memset(state, 0, sizeof(*state)); }