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;
}
{
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);
}
}
}
-#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 */
{
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);
xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+ buffer->refcount = 1;
return pipe_bo(buffer);
}
#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"
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;
}
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);
+ }
+}
+