summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-09-23 15:53:29 -0700
committerEric Anholt <eric@anholt.net>2008-09-24 15:42:18 -0700
commitbba24c3ca7981e499fd95a6a793944f31f35bab2 (patch)
tree40d03ff32d9dc838705d2fc6aa34999763ebe858
parent1e96c8736cb077655db820954f4c7c2849513122 (diff)
i965: Cope with batch getting flushed in the middle of batchbuffer emits.
This isn't required for GEM (at least, yet), but the check_aperture code for non-GEM results in batch getting flushed during emit. brw_state_upload restarts state emits, but a bunch of the state emit functions were assuming that they would be called exactly once, after prepare and before new_batch. Bug #17179. (cherry picked from commit d533da2db873942b3f8676a754b8be3c9718bedf)
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h5
-rw-r--r--src/mesa/drivers/dri/i965/brw_curbe.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_vtbl.c3
5 files changed, 14 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 330d5714da..b0d4820629 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -557,6 +557,11 @@ struct brw_context
GLfloat *last_buf;
GLuint last_bufsz;
+ /**
+ * Whether we should create a new bo instead of reusing the old one
+ * (if we just dispatch the batch pointing at the old one.
+ */
+ GLboolean need_new_bo;
} curbe;
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index 0a3600193b..0de23a9667 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -282,7 +282,8 @@ static void prepare_constant_buffer(struct brw_context *brw)
brw->curbe.last_bufsz = bufsz;
if (brw->curbe.curbe_bo != NULL &&
- brw->curbe.curbe_next_offset + bufsz > brw->curbe.curbe_bo->size)
+ (brw->curbe.need_new_bo ||
+ brw->curbe.curbe_next_offset + bufsz > brw->curbe.curbe_bo->size))
{
dri_bo_unreference(brw->curbe.curbe_bo);
brw->curbe.curbe_bo = NULL;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 95d798238d..b7bbb18475 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -156,11 +156,13 @@ static void brw_emit_prim( struct brw_context *brw,
static void brw_merge_inputs( struct brw_context *brw,
const struct gl_client_array *arrays[])
{
- struct brw_vertex_element *inputs = brw->vb.inputs;
struct brw_vertex_info old = brw->vb.info;
GLuint i;
- memset(inputs, 0, sizeof(*inputs));
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ dri_bo_unreference(brw->vb.inputs[i].bo);
+
+ memset(&brw->vb.inputs, 0, sizeof(brw->vb.inputs));
memset(&brw->vb.info, 0, sizeof(brw->vb.info));
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
@@ -171,7 +173,8 @@ static void brw_merge_inputs( struct brw_context *brw,
if (arrays[i]->StrideB != 0)
brw->vb.info.varying |= 1 << i;
- brw->vb.info.sizes[i/16] |= (inputs[i].glarray->Size - 1) << ((i%16) * 2);
+ brw->vb.info.sizes[i/16] |= (brw->vb.inputs[i].glarray->Size - 1) <<
+ ((i%16) * 2);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 465239f195..f148b1038e 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -455,12 +455,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();
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index 31e96a250a..9fbdcdbaa2 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -97,8 +97,7 @@ static void brw_new_batch( struct intel_context *intel )
/* Check that we didn't just wrap our batchbuffer at a bad time. */
assert(!brw->no_batch_wrap);
- dri_bo_unreference(brw->curbe.curbe_bo);
- brw->curbe.curbe_bo = NULL;
+ brw->curbe.need_new_bo = GL_TRUE;
/* Mark all context state as needing to be re-emitted.
* This is probably not as severe as on 915, since almost all of our state