summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/g3dvl/xsp_winsys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/g3dvl/xsp_winsys.c')
-rw-r--r--src/gallium/winsys/g3dvl/xsp_winsys.c107
1 files changed, 53 insertions, 54 deletions
diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c
index 0100fe37bd..68be2c2ea3 100644
--- a/src/gallium/winsys/g3dvl/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xsp_winsys.c
@@ -2,8 +2,8 @@
#include <X11/Xutil.h>
#include <pipe/p_winsys.h>
#include <pipe/p_state.h>
-#include <pipe/p_util.h>
#include <pipe/p_inlines.h>
+#include <util/u_memory.h>
#include <softpipe/sp_winsys.h>
/* pipe_winsys implementation */
@@ -33,79 +33,79 @@ struct xsp_buffer
static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned usage, unsigned size)
{
struct xsp_buffer *buffer;
-
+
assert(pws);
-
+
buffer = calloc(1, sizeof(struct xsp_buffer));
buffer->base.refcount = 1;
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
buffer->data = align_malloc(size, alignment);
-
+
return (struct pipe_buffer*)buffer;
}
static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void *data, unsigned size)
{
struct xsp_buffer *buffer;
-
+
assert(pws);
-
+
buffer = calloc(1, sizeof(struct xsp_buffer));
buffer->base.refcount = 1;
buffer->base.size = size;
buffer->is_user_buffer = TRUE;
buffer->data = data;
-
+
return (struct pipe_buffer*)buffer;
}
static void* xsp_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buffer, unsigned flags)
{
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
+
assert(pws);
assert(buffer);
-
+
xsp_buf->mapped_data = xsp_buf->data;
-
+
return xsp_buf->mapped_data;
}
static void xsp_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buffer)
{
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
+
assert(pws);
assert(buffer);
-
+
xsp_buf->mapped_data = NULL;
}
static void xsp_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buffer)
{
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
+
assert(pws);
assert(buffer);
-
+
if (!xsp_buf->is_user_buffer)
align_free(xsp_buf->data);
-
+
free(xsp_buf);
}
static struct pipe_surface* xsp_surface_alloc(struct pipe_winsys *pws)
{
struct pipe_surface *surface;
-
+
assert(pws);
-
+
surface = calloc(1, sizeof(struct pipe_surface));
surface->refcount = 1;
surface->winsys = pws;
-
+
return surface;
}
@@ -127,10 +127,10 @@ static int xsp_surface_alloc_storage
)
{
const unsigned int ALIGNMENT = 1;
-
+
assert(pws);
assert(surface);
-
+
surface->width = width;
surface->height = height;
surface->format = format;
@@ -140,28 +140,28 @@ static int xsp_surface_alloc_storage
surface->stride = round_up(surface->nblocksx * surface->block.size, ALIGNMENT);
surface->usage = flags;
surface->buffer = pws->buffer_create(pws, ALIGNMENT, PIPE_BUFFER_USAGE_PIXEL, surface->stride * surface->nblocksy);
-
+
return 0;
}
static void xsp_surface_release(struct pipe_winsys *pws, struct pipe_surface **surface)
{
struct pipe_surface *s;
-
+
assert(pws);
assert(surface);
assert(*surface);
-
+
s = *surface;
-
+
s->refcount--;
-
+
if (s->refcount == 0)
{
- pipe_buffer_reference(pws, &s->buffer, NULL);
+ winsys_buffer_reference(pws, &s->buffer, NULL);
free(s);
}
-
+
*surface = NULL;
}
@@ -176,7 +176,7 @@ static int xsp_fence_signalled(struct pipe_winsys *pws, struct pipe_fence_handle
{
assert(pws);
assert(fence);
-
+
return 0;
}
@@ -184,30 +184,30 @@ static int xsp_fence_finish(struct pipe_winsys *pws, struct pipe_fence_handle *f
{
assert(pws);
assert(fence);
-
+
return 0;
}
static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surface, void *context_private)
-{
+{
struct xsp_pipe_winsys *xsp_winsys;
struct xsp_context *xsp_context;
-
+
assert(pws);
assert(surface);
assert(context_private);
-
+
xsp_winsys = (struct xsp_pipe_winsys*)pws;
xsp_context = (struct xsp_context*)context_private;
-
+
if (!xsp_context->drawable_bound)
return;
-
+
xsp_winsys->fbimage.width = surface->width;
xsp_winsys->fbimage.height = surface->height;
xsp_winsys->fbimage.bytes_per_line = surface->width * (xsp_winsys->fbimage.bits_per_pixel >> 3);
xsp_winsys->fbimage.data = pipe_surface_map(surface, 0);
-
+
XPutImage
(
xsp_context->display,
@@ -236,25 +236,25 @@ static const char* xsp_get_name(struct pipe_winsys *pws)
int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
{
struct xsp_context *xsp_context;
-
+
assert(pipe);
-
+
xsp_context = pipe->priv;
xsp_context->drawable = drawable;
xsp_context->drawable_bound = 1;
-
+
return 0;
}
int unbind_pipe_drawable(struct pipe_context *pipe)
{
struct xsp_context *xsp_context;
-
+
assert(pipe);
-
+
xsp_context = pipe->priv;
xsp_context->drawable_bound = 0;
-
+
return 0;
}
@@ -264,9 +264,9 @@ struct pipe_context* create_pipe_context(Display *display, int screen)
struct xsp_context *xsp_context;
struct pipe_screen *sp_screen;
struct pipe_context *sp_pipe;
-
+
assert(display);
-
+
xsp_winsys = calloc(1, sizeof(struct xsp_pipe_winsys));
xsp_winsys->base.buffer_create = xsp_buffer_create;
xsp_winsys->base.user_buffer_create = xsp_user_buffer_create;
@@ -281,7 +281,7 @@ struct pipe_context* create_pipe_context(Display *display, int screen)
xsp_winsys->base.fence_finish = xsp_fence_finish;
xsp_winsys->base.flush_frontbuffer = xsp_flush_frontbuffer;
xsp_winsys->base.get_name = xsp_get_name;
-
+
{
/* XXX: Can't use the returned XImage* directly,
since we don't have control over winsys destruction
@@ -299,22 +299,22 @@ struct pipe_context* create_pipe_context(Display *display, int screen)
32,
0
);
-
+
memcpy(&xsp_winsys->fbimage, template, sizeof(XImage));
XInitImage(&xsp_winsys->fbimage);
-
+
XDestroyImage(template);
}
-
+
sp_screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys);
sp_pipe = softpipe_create(sp_screen, (struct pipe_winsys*)xsp_winsys, NULL);
-
+
xsp_context = calloc(1, sizeof(struct xsp_context));
xsp_context->display = display;
xsp_context->screen = screen;
-
+
sp_pipe->priv = xsp_context;
-
+
return sp_pipe;
}
@@ -322,16 +322,15 @@ int destroy_pipe_context(struct pipe_context *pipe)
{
struct pipe_screen *screen;
struct pipe_winsys *winsys;
-
+
assert(pipe);
-
+
screen = pipe->screen;
winsys = pipe->winsys;
free(pipe->priv);
pipe->destroy(pipe);
screen->destroy(screen);
free(winsys);
-
+
return 0;
}
-