[intel] Only flush batch when changing draw buffers, not every cliprect update.

The previous code would reference freed memory on window moves.
This commit is contained in:
Eric Anholt 2008-01-10 13:24:14 -08:00
parent a04b632350
commit ab2933df65
4 changed files with 17 additions and 11 deletions

View file

@ -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);

View file

@ -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.
*/

View file

@ -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);

View file

@ -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?
*/