diff options
author | Eric Anholt <eric@anholt.net> | 2008-01-10 13:24:14 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-01-10 13:24:14 -0800 |
commit | ab2933df65628d8f1f0a3f49129442bc8d2c3a2b (patch) | |
tree | 88c19afcfd9c9b8cd24e6edb8c93e203aa855117 | |
parent | a04b632350e5d0e9994fc667afc59407a39da0ba (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.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_batchbuffer.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_batchbuffer.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_buffers.c | 15 |
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 d55a19ff3b..f0ba59dcb2 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 ff2045dabe..cff15d253d 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 a3058bc6e6..23d4e0fad5 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 ceb3058351..dc54c18f40 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? */ |