summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-11 17:04:12 +0100
committerBrian <[email protected]>2007-08-11 17:04:12 +0100
commitbf383d1f5496f6c2ce318bbe1c02e7c7953a9153 (patch)
tree00865a8d14cef90a770a6761892045ae1eccbced /src
parent37fdc69a99a7692d337fb4efaea97df842490f21 (diff)
repair breakage from recent pipe_winsys re-org
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c26
-rw-r--r--src/mesa/drivers/x11/xm_softpipe.c127
-rw-r--r--src/mesa/drivers/x11/xm_surface.c34
3 files changed, 149 insertions, 38 deletions
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index fb6815ae1eb..4cd2ab7c6bd 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -248,6 +248,20 @@ xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
}
+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);
+ }
+}
+
+
/**
* Reallocate renderbuffer storage for front color buffer.
* Called via gl_renderbuffer::AllocStorage()
@@ -271,8 +285,9 @@ xmesa_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->Height = height;
rb->InternalFormat = internalFormat;
- if (!xrb->St.surface)
- xrb->St.surface = xmesa_new_surface(ctx, xrb);
+ if (!xrb->St.surface || !xrb->St.surface->region)
+ finish_surface_init(ctx, xrb);
+
xrb->St.surface->width = width;
xrb->St.surface->height = height;
@@ -325,8 +340,9 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
xrb->origin4 = NULL;
}
- if (!xrb->St.surface)
- xrb->St.surface = xmesa_new_surface(ctx, xrb);
+ if (!xrb->St.surface || !xrb->St.surface->region)
+ finish_surface_init(ctx, xrb);
+
xrb->St.surface->width = width;
xrb->St.surface->height = height;
@@ -340,7 +356,7 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
*/
struct xmesa_renderbuffer *
xmesa_create_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
- GLboolean backBuffer)
+ GLboolean backBuffer)
{
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
struct pipe_context *pipe = NULL;/*ctx->st->pipe;*/
diff --git a/src/mesa/drivers/x11/xm_softpipe.c b/src/mesa/drivers/x11/xm_softpipe.c
index 6e8ef21b507..2f93ff33097 100644
--- a/src/mesa/drivers/x11/xm_softpipe.c
+++ b/src/mesa/drivers/x11/xm_softpipe.c
@@ -37,6 +37,7 @@
#include "xmesaP.h"
#include "main/macros.h"
+#include "pipe/p_winsys.h"
#include "pipe/softpipe/sp_winsys.h"
@@ -62,36 +63,37 @@ struct xm_buffer
static inline struct xm_buffer *
xm_bo( struct pipe_buffer_handle *bo )
{
- return (struct xm_buffer *)bo;
+ return (struct xm_buffer *) bo;
}
static inline struct pipe_buffer_handle *
pipe_bo( struct xm_buffer *bo )
{
- return (struct pipe_buffer_handle *)bo;
+ return (struct pipe_buffer_handle *) bo;
}
/* Turn a softpipe winsys into an xm/softpipe winsys:
*/
static inline struct xm_softpipe_winsys *
-xm_softpipe_winsys( struct softpipe_winsys *sws )
+xm_softpipe_winsys(struct softpipe_winsys *sws)
{
- return (struct xm_softpipe_winsys *)sws;
+ return (struct xm_softpipe_winsys *) sws;
}
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
-static void *xm_buffer_map(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf )
+static void *
+xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+ unsigned flags)
{
struct xm_buffer *xm_buf = xm_bo(buf);
xm_buf->mapped = xm_buf->data;
return xm_buf->mapped;
}
-static void xm_buffer_unmap(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf)
+static void
+xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
{
struct xm_buffer *xm_buf = xm_bo(buf);
xm_buf->mapped = NULL;
@@ -99,16 +101,15 @@ static void xm_buffer_unmap(struct softpipe_winsys *sws,
static struct pipe_buffer_handle *
-xm_buffer_reference(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf)
+xm_buffer_reference(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
{
struct xm_buffer *xm_buf = xm_bo(buf);
xm_buf->refcount++;
return buf;
}
-static void xm_buffer_unreference(struct softpipe_winsys *sws,
- struct pipe_buffer_handle **buf)
+static void
+xm_buffer_unreference(struct pipe_winsys *pws, struct pipe_buffer_handle **buf)
{
struct xm_buffer *xm_buf = xm_bo(*buf);
xm_buf->refcount--;
@@ -122,21 +123,18 @@ static void xm_buffer_unreference(struct softpipe_winsys *sws,
*buf = NULL;
}
-
-static void xm_buffer_data(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
+static void
+xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+ unsigned size, const void *data )
{
struct xm_buffer *xm_buf = xm_bo(buf);
assert(!xm_buf->data);
xm_buf->data = malloc(size);
}
-static void xm_buffer_subdata(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
+static void
+xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+ unsigned long offset, unsigned long size, const void *data)
{
struct xm_buffer *xm_buf = xm_bo(buf);
GLubyte *b = (GLubyte *) xm_buf->data;
@@ -144,11 +142,9 @@ static void xm_buffer_subdata(struct softpipe_winsys *sws,
memcpy(b + offset, data, size);
}
-static void xm_buffer_get_subdata(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
+static void
+xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+ unsigned long offset, unsigned long size, void *data)
{
const struct xm_buffer *xm_buf = xm_bo(buf);
const GLubyte *b = (GLubyte *) xm_buf->data;
@@ -156,21 +152,86 @@ static void xm_buffer_get_subdata(struct softpipe_winsys *sws,
memcpy(data, b + offset, size);
}
+static void
+xm_flush_frontbuffer(struct pipe_winsys *pws)
+{
+ /*
+ struct intel_context *intel = intel_pipe_winsys(sws)->intel;
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+ intelCopyBuffer(dPriv, NULL);
+ */
+}
+
+static void
+xm_wait_idle(struct pipe_winsys *pws)
+{
+ /* no-op */
+}
+
+static void
+xm_printf(struct pipe_winsys *pws, const char *fmtString, ...)
+{
+ va_list args;
+ va_start( args, fmtString );
+ vfprintf(stderr, fmtString, args);
+ va_end( args );
+}
+
+static const char *
+xm_get_name(struct pipe_winsys *pws)
+{
+ return "Xlib";
+}
+
/* Softpipe has no concept of pools. We choose the tex/region pool
* for all buffers.
*/
static struct pipe_buffer_handle *
-xm_create_buffer(struct softpipe_winsys *sws,
- unsigned alignment)
+xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
{
- struct xm_buffer *buffer;
-
- buffer = CALLOC_STRUCT(xm_buffer);
+ struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
return pipe_bo(buffer);
}
+struct xmesa_pipe_winsys
+{
+ struct pipe_winsys winsys;
+ XMesaContext xmesa;
+};
+
+static struct pipe_winsys *
+xmesa_create_pipe_winsys( XMesaContext xmesa )
+{
+ struct xmesa_pipe_winsys *xws = CALLOC_STRUCT(xmesa_pipe_winsys);
+
+ /* Fill in this struct with callbacks that pipe will need to
+ * communicate with the window system, buffer manager, etc.
+ *
+ * Pipe would be happy with a malloc based memory manager, but
+ * the SwapBuffers implementation in this winsys driver requires
+ * that rendering be done to an appropriate _DriBufferObject.
+ */
+ xws->winsys.buffer_create = xm_buffer_create;
+ xws->winsys.buffer_map = xm_buffer_map;
+ xws->winsys.buffer_unmap = xm_buffer_unmap;
+ xws->winsys.buffer_reference = xm_buffer_reference;
+ xws->winsys.buffer_unreference = xm_buffer_unreference;
+ xws->winsys.buffer_data = xm_buffer_data;
+ xws->winsys.buffer_subdata = xm_buffer_subdata;
+ xws->winsys.buffer_get_subdata = xm_buffer_get_subdata;
+ xws->winsys.flush_frontbuffer = xm_flush_frontbuffer;
+ xws->winsys.wait_idle = xm_wait_idle;
+ xws->winsys.printf = xm_printf;
+ xws->winsys.get_name = xm_get_name;
+ xws->xmesa = xmesa;
+
+ return &xws->winsys;
+}
+
+
struct pipe_context *
xmesa_create_softpipe(XMesaContext xmesa)
{
@@ -183,6 +244,7 @@ xmesa_create_softpipe(XMesaContext xmesa)
* the SwapBuffers implementation in this winsys driver requires
* that rendering be done to an appropriate xm_buffer.
*/
+#if 0
isws->sws.create_buffer = xm_create_buffer;
isws->sws.buffer_map = xm_buffer_map;
isws->sws.buffer_unmap = xm_buffer_unmap;
@@ -191,8 +253,9 @@ xmesa_create_softpipe(XMesaContext xmesa)
isws->sws.buffer_data = xm_buffer_data;
isws->sws.buffer_subdata = xm_buffer_subdata;
isws->sws.buffer_get_subdata = xm_buffer_get_subdata;
+#endif
/* Create the softpipe context:
*/
- return softpipe_create( &isws->sws );
+ return softpipe_create( xmesa_create_pipe_winsys(xmesa), &isws->sws );
}
diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c
index 1915151ba48..c6057e5154f 100644
--- a/src/mesa/drivers/x11/xm_surface.c
+++ b/src/mesa/drivers/x11/xm_surface.c
@@ -168,6 +168,23 @@ write_quad_ub(struct softpipe_surface *sps, GLint x, GLint y,
}
+static void
+get_tile(struct pipe_surface *ps,
+ GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p)
+{
+
+}
+
+
+static void
+put_tile(struct pipe_surface *ps,
+ GLuint x, GLuint y, GLuint w, GLuint h, const GLfloat *p)
+{
+
+}
+
+
+
/**
* Called to create a pipe_surface for each X renderbuffer.
* Note: this is being used instead of pipe->surface_alloc() since we
@@ -186,6 +203,8 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
#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;
@@ -195,13 +214,15 @@ xmesa_new_surface(GLcontext *ctx, struct xmesa_renderbuffer *xrb)
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);
+ sps->surface.region = pipe->region_alloc(pipe, 0, 0, 0, 0x0);
return &sps->surface;
}
@@ -215,6 +236,7 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
assert(pipeFormat);
xms->surface.surface.format = pipeFormat;
+ xms->surface.surface.refcount = 1;
switch (pipeFormat) {
case PIPE_FORMAT_U_A8_R8_G8_B8:
@@ -225,6 +247,8 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
xms->surface.write_quad_f = write_quad_f;
xms->surface.write_quad_f_swz = write_quad_f_swz;
xms->surface.write_quad_ub = write_quad_ub;
+ xms->surface.surface.get_tile = get_tile;
+ xms->surface.surface.put_tile = put_tile;
break;
case PIPE_FORMAT_S8_Z24:
softpipe_init_surface_funcs(&xms->surface);
@@ -237,6 +261,14 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
abort();
}
+ /* 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.
+ */
+ if (pipe)
+ xms->surface.surface.region = pipe->region_alloc(pipe, 1, 0, 0, 0x0);
+
return &xms->surface.surface;
}