summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/x11
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-11 21:21:12 +0100
committerBrian <brian.paul@tungstengraphics.com>2007-08-11 21:21:12 +0100
commit0095be534d633848bc12d73ed9dcc1b9aa41f00a (patch)
tree82c15888aceec77a526f2828db87f91253f4a886 /src/mesa/drivers/x11
parent5d42fdb9b70a53938cd29d7ebeaa4b9cedd2e8e3 (diff)
Change/fix surface allocation functions.
Use xmesa_new_color_surface() for front/back renderbuffer surfaces. Use xmesa_surface_alloc() for everything else (textures, other renderbuffers)
Diffstat (limited to 'src/mesa/drivers/x11')
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c7
-rw-r--r--src/mesa/drivers/x11/xm_softpipe.c2
-rw-r--r--src/mesa/drivers/x11/xm_surface.c80
-rw-r--r--src/mesa/drivers/x11/xmesaP.h6
4 files changed, 45 insertions, 50 deletions
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index 4cd2ab7c6b..52629aca18 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -252,10 +252,6 @@ static void
finish_surface_init(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
{
struct pipe_context *pipe = ctx->st->pipe;
-
- if (!xrb->St.surface) {
- xrb->St.surface = xmesa_new_surface(ctx, xrb);
- }
if (!xrb->St.surface->region) {
xrb->St.surface->region = pipe->region_alloc(pipe, 1, 0, 0, 0x0);
}
@@ -391,10 +387,9 @@ xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
}
/* only need to set Red/Green/EtcBits fields for user-created RBs */
- xrb->St.surface = xmesa_surface_alloc(pipe, pipeFormat);
+ xrb->St.surface = xmesa_new_color_surface(pipe, pipeFormat);
xms = (struct xmesa_surface *) xrb->St.surface;
xms->xrb = xrb;
-
}
return xrb;
}
diff --git a/src/mesa/drivers/x11/xm_softpipe.c b/src/mesa/drivers/x11/xm_softpipe.c
index 2f93ff3309..a08673444f 100644
--- a/src/mesa/drivers/x11/xm_softpipe.c
+++ b/src/mesa/drivers/x11/xm_softpipe.c
@@ -130,6 +130,8 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
struct xm_buffer *xm_buf = xm_bo(buf);
assert(!xm_buf->data);
xm_buf->data = malloc(size);
+ if (data)
+ memcpy(xm_buf->data, data, size);
}
static void
diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c
index c6057e5154..6f6c549c07 100644
--- a/src/mesa/drivers/x11/xm_surface.c
+++ b/src/mesa/drivers/x11/xm_surface.c
@@ -172,7 +172,18 @@ static void
get_tile(struct pipe_surface *ps,
GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p)
{
-
+ struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps);
+ GLubyte tmp[MAX_WIDTH * 4];
+ GLuint i, j;
+ GET_CURRENT_CONTEXT(ctx);
+ FLIP(y);
+ for (i = 0; i < h; i++) {
+ xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp);
+ for (j = 0; j < w * 4; j++) {
+ p[j] = UBYTE_TO_FLOAT(tmp[j]);
+ }
+ p += w * 4;
+ }
}
@@ -180,7 +191,7 @@ static void
put_tile(struct pipe_surface *ps,
GLuint x, GLuint y, GLuint w, GLuint h, const GLfloat *p)
{
-
+ assert(0);
}
@@ -191,45 +202,7 @@ put_tile(struct pipe_surface *ps,
* have special/unique quad read/write functions for X.
*/
struct pipe_surface *
-xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
-{
- struct pipe_context *pipe = ctx->st->pipe;
- struct softpipe_surface *sps;
-
- sps = CALLOC_STRUCT(softpipe_surface);
- if (!sps)
- return NULL;
-
-#if 0
- sps->surface.rb = xrb; /* XXX only needed for quad funcs above */
-#endif
- sps->surface.refcount = 1;
-
- sps->surface.width = xrb->St.Base.Width;
- sps->surface.height = xrb->St.Base.Height;
-
- sps->read_quad_f = read_quad_f;
- sps->read_quad_f_swz = read_quad_f_swz;
- sps->read_quad_ub = read_quad_ub;
- sps->write_quad_f = write_quad_f;
- sps->write_quad_f_swz = write_quad_f_swz;
- sps->write_quad_ub = write_quad_ub;
- sps->surface.get_tile = get_tile;
- sps->surface.put_tile = put_tile;
-
- /* Note, the region we allocate doesn't actually have any storage
- * since we're drawing into an XImage or Pixmap.
- * The region's size will get set in the xmesa_alloc_front/back_storage()
- * functions.
- */
- sps->surface.region = pipe->region_alloc(pipe, 0, 0, 0, 0x0);
-
- return &sps->surface;
-}
-
-
-struct pipe_surface *
-xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
+xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat)
{
struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
@@ -273,6 +246,31 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
}
+/**
+ * Called via pipe->surface_alloc() to create new surfaces (textures,
+ * renderbuffers, etc.
+ */
+struct pipe_surface *
+xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
+{
+ struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
+
+ assert(pipeFormat);
+
+ xms->surface.surface.format = pipeFormat;
+ xms->surface.surface.refcount = 1;
+ /*
+ * This is really just a softpipe surface, not an XImage/Pixmap surface.
+ */
+ softpipe_init_surface_funcs(&xms->surface);
+
+ assert(pipe);
+ xms->surface.surface.region = pipe->region_alloc(pipe, 1, 0, 0, 0x0);
+
+ return &xms->surface.surface;
+}
+
+
const GLuint *
xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats)
{
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 361c657354..9cbe8670f9 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -603,9 +603,6 @@ struct xmesa_surface
};
-extern struct pipe_surface *
-xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb);
-
extern void
xmesa_clear(struct pipe_context *pipe, struct pipe_surface *ps, GLuint value);
@@ -618,6 +615,9 @@ xmesa_create_softpipe(XMesaContext xm);
extern struct pipe_surface *
xmesa_surface_alloc(struct pipe_context *pipe, GLuint format);
+extern struct pipe_surface *
+xmesa_new_color_surface(struct pipe_context *pipe, GLuint format);
+
extern const GLuint *
xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats);