From 96f52f089f42b4bca8fa5fb573c687d233851126 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 May 2008 13:57:08 -0700 Subject: GEM: Don't emit an extra MI_FLUSH in the batch since GEM handles it. --- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/mesa/drivers/dri') diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index a95abd9ec9..ef66fd75ac 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -195,7 +195,7 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, int line) { struct intel_context *intel = batch->intel; - GLuint used = batch->ptr - batch->map; + GLuint used; GLboolean was_locked = intel->locked; if (used == 0) @@ -204,20 +204,20 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, if (INTEL_DEBUG & DEBUG_BATCH) fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line, used); - /* Add the MI_BATCH_BUFFER_END. Always add an MI_FLUSH - this is a - * performance drain that we would like to avoid. - */ - if (used & 4) { - ((int *) batch->ptr)[0] = intel->vtbl.flush_cmd(); - ((int *) batch->ptr)[1] = 0; - ((int *) batch->ptr)[2] = MI_BATCH_BUFFER_END; - used += 12; - } - else { - ((int *) batch->ptr)[0] = intel->vtbl.flush_cmd(); - ((int *) batch->ptr)[1] = MI_BATCH_BUFFER_END; - used += 8; - } + + /* Emit a flush if the bufmgr doesn't do it for us. */ + if (!intel->ttm) + intel_batchbuffer_emit_dword(intel->batch, intel->vtbl.flush_cmd()); + + /* Round batchbuffer usage to 2 DWORDs. */ + used = batch->ptr - batch->map; + if ((used & 4) == 0) + intel_batchbuffer_emit_dword(intel->batch, 0); /* noop */ + + /* Mark the end of the buffer. */ + intel_batchbuffer_emit_dword(intel->batch, MI_BATCH_BUFFER_END); + + used = batch->ptr - batch->map; /* Workaround for recursive batchbuffer flushing: If the window is * moved, we can get into a case where we try to flush during a -- cgit v1.2.3 From 42d4f89264f193e8beae7ba975df3507b81b6da0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 6 May 2008 15:25:51 -0700 Subject: GEM: Fix previous commit to avoid asserting when we run into reserved space. These are the dwords that the reserved space is for. --- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/mesa/drivers/dri') diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index ef66fd75ac..bab8e645d4 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -206,16 +206,21 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, used); /* Emit a flush if the bufmgr doesn't do it for us. */ - if (!intel->ttm) - intel_batchbuffer_emit_dword(intel->batch, intel->vtbl.flush_cmd()); + if (!intel->ttm) { + *(GLuint *) (batch->ptr) = intel->vtbl.flush_cmd(); + batch->ptr += 4; + } /* Round batchbuffer usage to 2 DWORDs. */ used = batch->ptr - batch->map; - if ((used & 4) == 0) - intel_batchbuffer_emit_dword(intel->batch, 0); /* noop */ + if ((used & 4) == 0) { + *(GLuint *) (batch->ptr) = 0; /* noop */ + batch->ptr += 4; + } /* Mark the end of the buffer. */ - intel_batchbuffer_emit_dword(intel->batch, MI_BATCH_BUFFER_END); + *(GLuint *) (batch->ptr) = MI_BATCH_BUFFER_END; /* noop */ + batch->ptr += 4; used = batch->ptr - batch->map; -- cgit v1.2.3