fix buffer clearing problems

This commit is contained in:
Brian 2007-08-17 10:28:20 +01:00
parent 93efcf50fa
commit ae64d5c173
5 changed files with 32 additions and 42 deletions

View file

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

View file

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

View file

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

View file

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

View file

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