From 0c4acfe15a0555a6f3da02ab17e58cc379df11fd Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 15:11:59 -0600 Subject: [PATCH] Re-implement intelClear() in terms of softpipe_clear(). Pretty simple/small now. Note: softpipe_clear() should really be renamed to something like pipe_clear_with_blits() and put into a driver-indepedent module... --- src/mesa/drivers/dri/i915pipe/intel_blit.c | 4 +++ src/mesa/drivers/dri/i915pipe/intel_buffers.c | 34 ++++++++++++++++-- src/mesa/drivers/dri/i915pipe/intel_context.c | 1 + src/mesa/pipe/softpipe/sp_clear.c | 35 ++++++++++++++----- 4 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i915pipe/intel_blit.c b/src/mesa/drivers/dri/i915pipe/intel_blit.c index 109d4face26..4a5f58ed9e0 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_blit.c +++ b/src/mesa/drivers/dri/i915pipe/intel_blit.c @@ -216,6 +216,10 @@ intelEmitFillBlit(struct intel_context *intel, GLboolean badMask = GL_FALSE; BATCH_LOCALS; + /* + printf("Emit fill blit value=0x%x mask=0x%x\n", value, mask); + */ + dst_pitch *= cpp; switch (cpp) { diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.c b/src/mesa/drivers/dri/i915pipe/intel_buffers.c index fb931514302..e39220fe47e 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_buffers.c +++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.c @@ -295,16 +295,16 @@ intelWindowMoved(struct intel_context *intel) - /** * Called by ctx->Driver.Clear. + * XXX NO LONGER USED - REMOVE IN NEAR FUTURE */ #if 0 static void intelClear(GLcontext *ctx, GLbitfield mask) #else -void -intelClear(struct pipe_context *pipe, +static void +OLD_intelClear(struct pipe_context *pipe, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) #endif @@ -396,6 +396,34 @@ intelClear(struct pipe_context *pipe, } +/** + * Clear buffers. Called via pipe->clear(). + */ +void +intelClear(struct pipe_context *pipe, + GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum) +{ + GLcontext *ctx = (GLcontext *) pipe->glctx; + struct intel_context *intel = intel_context(ctx); + + /* XXX + * Examine stencil and color writemasks to determine if we can clear + * with blits. + */ + + intelFlush(&intel->ctx); + LOCK_HARDWARE(intel); + + softpipe_clear(pipe, color, depth, stencil, accum); + + intel_batchbuffer_flush(intel->batch); + + UNLOCK_HARDWARE(intel); +} + + + /* Emit wait for pending flips */ void intel_wait_flips(struct intel_context *intel, GLuint batch_flags) diff --git a/src/mesa/drivers/dri/i915pipe/intel_context.c b/src/mesa/drivers/dri/i915pipe/intel_context.c index 6121f6bc608..be8235d7d11 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_context.c +++ b/src/mesa/drivers/dri/i915pipe/intel_context.c @@ -763,6 +763,7 @@ void LOCK_HARDWARE( struct intel_context *intel ) */ void UNLOCK_HARDWARE( struct intel_context *intel ) { + assert(intel->locked); intel->locked = 0; DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext); diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index aa7601ab8cb..b3bbc96f307 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -90,7 +90,8 @@ color_mask(GLuint format, GLuint pipeMask) /** - * XXX maybe this belongs in the GL state tracker... + * XXX This should probaby be renamed to something like pipe_clear_with_blits() + * and moved into a device-independent pipe file. */ void softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, @@ -157,16 +158,32 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, if (stencil) { struct pipe_surface *ps = softpipe->framebuffer.sbuf; GLuint clearVal = softpipe->stencil.clear_value; - GLuint mask = 0xff; - if (softpipe->stencil.write_mask[0] /*== 0xff*/) { - /* no masking */ - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); - } - else if (softpipe->stencil.write_mask[0] != 0x0) { - /* masking */ - /* fill with quad funcs */ + GLuint mask = softpipe->stencil.write_mask[0]; + + switch (ps->format) { + case PIPE_FORMAT_S8_Z24: + clearVal = clearVal << 24; + mask = mask << 24; + break; + case PIPE_FORMAT_U_S8: + /* nothing */ + break; + default: assert(0); } + + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); } } + + if (accum) { + /* XXX there might be no notion of accum buffers in 'pipe'. + * Just implement them with a deep RGBA surface format... + */ + struct pipe_surface *ps = softpipe->framebuffer.abuf; + GLuint clearVal = 0x0; /* XXX FIX */ + GLuint mask = !0; + assert(ps); + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); + } } -- 2.30.2