diff options
author | Brian <[email protected]> | 2007-08-17 10:28:20 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-17 10:28:20 +0100 |
commit | ae64d5c173a4525800383668cc91c176a1bd7a15 (patch) | |
tree | 8b29d0922354be0728182d532764f32b6aa99b77 /src/mesa/drivers/x11 | |
parent | 93efcf50fae7bdd9ee9468f4f4049ecb4c06e2df (diff) |
fix buffer clearing problems
Diffstat (limited to 'src/mesa/drivers/x11')
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_buffer.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_softpipe.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_surface.c | 28 |
5 files changed, 32 insertions, 42 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index cea790dc608..69b7277c1b4 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1591,12 +1591,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; -#if 1 - mesaCtx->Driver.Clear = xmesa_clear_buffers; -#endif -#if 0 + /* special pipe->clear function */ mesaCtx->st->pipe->clear = xmesa_clear; -#endif return c; } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 52629aca182..b8d3df1379a 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -253,7 +253,8 @@ finish_surface_init(GLcontext *ctx, struct xmesa_renderbuffer *xrb) { struct pipe_context *pipe = ctx->st->pipe; if (!xrb->St.surface->region) { - xrb->St.surface->region = pipe->region_alloc(pipe, 1, 0, 0, 0x0); + int w = 1, h = 1; + xrb->St.surface->region = pipe->region_alloc(pipe, 1, w, h, 0x0); } } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 22eae51ca91..d7fb3e6e03f 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -425,41 +425,6 @@ xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers) } -#if 0 -void -xmesa_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, - GLboolean stencil, GLboolean accum) -{ - struct softpipe_context *sp = (struct softpipe_context *) pipe; - - /* Clear non-color buffers first. This will cause softpipe to - * re-validate the scissor/surface bounds. - */ - softpipe_clear(pipe, GL_FALSE, depth, stencil, accum); - - if (color) { - GET_CURRENT_CONTEXT(ctx); - GLuint i; - for (i = 0; i < sp->framebuffer.num_cbufs; i++) { - struct pipe_surface *ps = sp->framebuffer.cbufs[i]; - struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) ps->rb; - const GLint x = sp->cliprect.minx; - const GLint y = sp->cliprect.miny; - const GLint w = sp->cliprect.maxx - x; - const GLint h = sp->cliprect.maxy - y; - xrb->clearFunc(ctx, xrb, x, y, w, h); - } - } -} -#endif - -void -xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value) -{ - -} - - #ifndef XFree86Server /* XXX this was never tested in the Xserver environment */ diff --git a/src/mesa/drivers/x11/xm_softpipe.c b/src/mesa/drivers/x11/xm_softpipe.c index a08673444f7..09edea6265e 100644 --- a/src/mesa/drivers/x11/xm_softpipe.c +++ b/src/mesa/drivers/x11/xm_softpipe.c @@ -113,6 +113,7 @@ xm_buffer_unreference(struct pipe_winsys *pws, struct pipe_buffer_handle **buf) { struct xm_buffer *xm_buf = xm_bo(*buf); xm_buf->refcount--; + assert(xm_buf->refcount >= 0); if (xm_buf->refcount == 0) { if (xm_buf->data) { free(xm_buf->data); @@ -194,6 +195,7 @@ static struct pipe_buffer_handle * xm_buffer_create(struct pipe_winsys *pws, unsigned alignment) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); + buffer->refcount = 1; return pipe_bo(buffer); } diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 6f6c549c071..a751b0868cf 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -45,6 +45,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/softpipe/sp_context.h" +#include "pipe/softpipe/sp_clear.h" #include "state_tracker/st_context.h" @@ -265,7 +266,7 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) softpipe_init_surface_funcs(&xms->surface); assert(pipe); - xms->surface.surface.region = pipe->region_alloc(pipe, 1, 0, 0, 0x0); + xms->surface.surface.region = pipe->region_alloc(pipe, 1, 1, 1, 0x0); return &xms->surface.surface; } @@ -284,3 +285,28 @@ xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) return formats; } + +/** + * Called via pipe->clear() + */ +void +xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value) +{ + struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps); + assert(xrb); + if (xrb->ximage) { + /* clearing back color buffer */ + GET_CURRENT_CONTEXT(ctx); + xmesa_clear_buffers(ctx, BUFFER_BIT_BACK_LEFT); + } + else if (xrb->pixmap) { + /* clearing front color buffer */ + GET_CURRENT_CONTEXT(ctx); + xmesa_clear_buffers(ctx, BUFFER_BIT_FRONT_LEFT); + } + else { + /* clearing other buffer */ + softpipe_clear(pipe, ps, value); + } +} + |