summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2008-01-10 13:24:14 -0800
committerEric Anholt <[email protected]>2008-01-10 13:24:14 -0800
commitab2933df65628d8f1f0a3f49129442bc8d2c3a2b (patch)
tree88c19afcfd9c9b8cd24e6edb8c93e203aa855117
parenta04b632350e5d0e9994fc667afc59407a39da0ba (diff)
[intel] Only flush batch when changing draw buffers, not every cliprect update.
The previous code would reference freed memory on window moves.
-rw-r--r--src/mesa/drivers/dri/i965/intel_ioctl.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h6
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c15
4 files changed, 17 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.c b/src/mesa/drivers/dri/i965/intel_ioctl.c
index d55a19ff3b6..f0ba59dcb25 100644
--- a/src/mesa/drivers/dri/i965/intel_ioctl.c
+++ b/src/mesa/drivers/dri/i965/intel_ioctl.c
@@ -156,6 +156,7 @@ intel_exec_ioctl(struct intel_context *intel,
{
struct drm_i915_execbuffer execbuf;
dri_fence *fo;
+ int i;
assert(intel->locked);
assert(used);
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index ff2045dabe8..cff15d253de 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -188,7 +188,8 @@ do_flush_locked(struct intel_batchbuffer *batch,
}
void
-intel_batchbuffer_flush(struct intel_batchbuffer *batch)
+_intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
+ int line)
{
struct intel_context *intel = batch->intel;
GLuint used = batch->ptr - batch->map;
@@ -197,6 +198,9 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch)
if (used == 0)
return;
+ 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.
*/
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index a3058bc6e6a..23d4e0fad55 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -61,7 +61,11 @@ void intel_batchbuffer_free(struct intel_batchbuffer *batch);
void intel_batchbuffer_finish(struct intel_batchbuffer *batch);
-void intel_batchbuffer_flush(struct intel_batchbuffer *batch);
+void _intel_batchbuffer_flush(struct intel_batchbuffer *batch,
+ const char *file, int line);
+
+#define intel_batchbuffer_flush(batch) \
+ _intel_batchbuffer_flush(batch, __FILE__, __LINE__)
void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index ceb30583519..dc54c18f40f 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -135,9 +135,6 @@ intel_readbuf_region(struct intel_context *intel)
static void
intelSetRenderbufferClipRects(struct intel_context *intel)
{
- /* flush batch since pClipRects may change */
- intel_batchbuffer_flush(intel->batch);
-
assert(intel->ctx.DrawBuffer->Width > 0);
assert(intel->ctx.DrawBuffer->Height > 0);
intel->fboRect.x1 = 0;
@@ -163,9 +160,6 @@ intelSetFrontClipRects(struct intel_context *intel)
if (!dPriv)
return;
- /* flush batch since pClipRects may change */
- intel_batchbuffer_flush(intel->batch);
-
intel->numClipRects = dPriv->numClipRects;
intel->pClipRects = dPriv->pClipRects;
intel->drawX = dPriv->x;
@@ -185,9 +179,6 @@ intelSetBackClipRects(struct intel_context *intel)
if (!dPriv)
return;
- /* flush batch since pClipRects may change */
- intel_batchbuffer_flush(intel->batch);
-
intel_fb = dPriv->driverPrivate;
if (intel_fb->pf_active || dPriv->numBackClipRects == 0) {
@@ -933,6 +924,12 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
if (fb->Name)
intel_validate_paired_depth_stencil(ctx, fb);
+ /* If the batch contents require looping over cliprects, flush them before
+ * we go changing which cliprects get referenced when that happens.
+ */
+ if (intel->batch->cliprect_mode == LOOP_CLIPRECTS)
+ intel_batchbuffer_flush(intel->batch);
+
/*
* How many color buffers are we drawing into?
*/