summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-01-20 12:22:49 +0000
committerJosé Fonseca <jfonseca@vmware.com>2009-01-20 12:22:49 +0000
commit5897383344da3320d158c26adae05de35480471f (patch)
tree33519f45f1309b273e4b5a92d5c06dd171b29191 /src/gallium/winsys
parentecc563b17f810399ddf74a68fca1e903ba49a0d6 (diff)
gallium: Remove the standalone surfaces.
This commit is mostly just a cosmetic change that cleans-up the interfaces, replacing pipe_winsys::surface_* calls by /** * Allocate storage for a display target surface. * * Often surfaces which are meant to be blitted to the front screen (i.e., * display targets) must be allocated with special characteristics, memory * pools, or obtained directly from the windowing system. * * This callback is invoked by the pipe_screenwhen creating a texture marked * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying * buffer storage. */ struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws, unsigned width, unsigned height, enum pipe_format format, unsigned usage, unsigned *stride); Most drivers were updated but not all were tested. Use the softpipe pipe driver and the xlib winsys changes as a reference when fixing other drivers.
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.c46
-rw-r--r--src/gallium/winsys/egl_xlib/sw_winsys.c70
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c35
-rw-r--r--src/gallium/winsys/g3dvl/xsp_winsys.c67
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c68
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_screen.c63
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c80
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c80
8 files changed, 122 insertions, 387 deletions
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_device.c b/src/gallium/winsys/drm/intel/common/intel_be_device.c
index 019ee5cbd2..14aeaf61db 100644
--- a/src/gallium/winsys/drm/intel/common/intel_be_device.c
+++ b/src/gallium/winsys/drm/intel/common/intel_be_device.c
@@ -157,35 +157,25 @@ err:
}
-/*
- * Surface functions.
- *
- * Deprecated!
- */
-
-static struct pipe_surface *
-intel_i915_surface_alloc(struct pipe_winsys *winsys)
-{
- assert((size_t)"intel_i915_surface_alloc is deprecated" & 0);
- return NULL;
-}
-
-static int
-intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+intel_i915_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
-{
- assert((size_t)"intel_i915_surface_alloc_storage is deprecated" & 0);
- return -1;
-}
-
-static void
-intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
+ unsigned usage,
+ unsigned *stride)
{
- assert((size_t)"intel_i915_surface_release is deprecated" & 0);
+ const unsigned alignment = 64;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
+
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, alignment);
+
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ *stride * nblocksy);
}
@@ -238,9 +228,7 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
dev->base.buffer_map = intel_be_buffer_map;
dev->base.buffer_unmap = intel_be_buffer_unmap;
dev->base.buffer_destroy = intel_be_buffer_destroy;
- dev->base.surface_alloc = intel_i915_surface_alloc;
- dev->base.surface_alloc_storage = intel_i915_surface_alloc_storage;
- dev->base.surface_release = intel_i915_surface_release;
+ dev->base.surface_buffer_create = intel_i915_surface_buffer_create;
dev->base.fence_reference = intel_be_fence_reference;
dev->base.fence_signalled = intel_be_fence_signalled;
dev->base.fence_finish = intel_be_fence_finish;
diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c
index 2fd190da52..a09ad5e8e9 100644
--- a/src/gallium/winsys/egl_xlib/sw_winsys.c
+++ b/src/gallium/winsys/egl_xlib/sw_winsys.c
@@ -161,65 +161,25 @@ buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buf)
}
-/**
- * Called via winsys->surface_alloc() to create new surfaces.
- */
-static struct pipe_surface *
-surface_alloc(struct pipe_winsys *ws)
-{
- struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface);
- if (!surf)
- return NULL;
-
- surf->refcount = 1;
- surf->winsys = ws;
-
- return surf;
-}
-
-
-static int
-surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ unsigned usage,
+ unsigned *stride)
{
const unsigned alignment = 64;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
- surf->width = width;
- surf->height = height;
- surf->format = format;
- pf_get_block(surf->format, &surf->block);
- surf->nblocksx = pf_get_nblocksx(&surf->block, width);
- surf->nblocksy = pf_get_nblocksy(&surf->block, height);
- surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
- surf->usage = flags;
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->stride * height);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, alignment);
-static void
-surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- assert(!surf->texture);
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- winsys_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ *stride * nblocksy);
}
@@ -268,9 +228,7 @@ create_sw_winsys(void)
ws->Base.buffer_unmap = buffer_unmap;
ws->Base.buffer_destroy = buffer_destroy;
- ws->Base.surface_alloc = surface_alloc;
- ws->Base.surface_alloc_storage = surface_alloc_storage;
- ws->Base.surface_release = surface_release;
+ ws->Base.surface_buffer_create = surface_buffer_create;
ws->Base.fence_reference = fence_reference;
ws->Base.fence_signalled = fence_signalled;
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c
index 17c409e1ce..2d8463037f 100644
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c
+++ b/src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c
@@ -46,34 +46,29 @@ round_up(unsigned n, unsigned multiple)
return (n + multiple - 1) & ~(multiple - 1);
}
-static int
-nouveau_surface_alloc_storage
+static struct pipe_buffer *
+nouveau_surface_buffer_create
(
struct pipe_winsys *pws,
- struct pipe_surface *surface,
unsigned width,
unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage
+ unsigned usage,
+ unsigned *stride
)
{
const unsigned int ALIGNMENT = 256;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
- assert(pws);
- assert(surface);
-
- surface->width = width;
- surface->height = height;
- surface->format = format;
- pf_get_block(format, &surface->block);
- surface->nblocksx = pf_get_nblocksx(&surface->block, width);
- surface->nblocksy = pf_get_nblocksy(&surface->block, height);
- 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);
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, ALIGNMENT);
- return 0;
+ return winsys->buffer_create(winsys, ALIGNMENT,
+ usage,
+ *stride * nblocksy);
}
static void
@@ -269,9 +264,7 @@ nouveau_create_pipe_winsys(struct nouveau_context *nv)
pws->flush_frontbuffer = nouveau_flush_frontbuffer;
- pws->surface_alloc = nouveau_surface_alloc;
- pws->surface_alloc_storage = nouveau_surface_alloc_storage;
- pws->surface_release = nouveau_surface_release;
+ pws->surface_buffer_create = nouveau_surface_buffer_create;
pws->buffer_create = nouveau_pipe_bo_create;
pws->buffer_destroy = nouveau_pipe_bo_del;
diff --git a/src/gallium/winsys/g3dvl/xsp_winsys.c b/src/gallium/winsys/g3dvl/xsp_winsys.c
index 68be2c2ea3..40d683234f 100644
--- a/src/gallium/winsys/g3dvl/xsp_winsys.c
+++ b/src/gallium/winsys/g3dvl/xsp_winsys.c
@@ -96,73 +96,34 @@ static void xsp_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buff
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;
-}
-
/* Borrowed from Mesa's xm_winsys */
static unsigned int round_up(unsigned n, unsigned multiple)
{
return (n + multiple - 1) & ~(multiple - 1);
}
-static int xsp_surface_alloc_storage
+static struct pipe_buffer* xsp_surface_buffer_create
(
struct pipe_winsys *pws,
- struct pipe_surface *surface,
unsigned width,
unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage
+ unsigned usage,
+ unsigned *stride
)
{
const unsigned int ALIGNMENT = 1;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
- assert(pws);
- assert(surface);
-
- surface->width = width;
- surface->height = height;
- surface->format = format;
- pf_get_block(format, &surface->block);
- surface->nblocksx = pf_get_nblocksx(&surface->block, width);
- surface->nblocksy = pf_get_nblocksy(&surface->block, height);
- 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)
- {
- winsys_buffer_reference(pws, &s->buffer, NULL);
- free(s);
- }
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, ALIGNMENT);
- *surface = NULL;
+ return winsys->buffer_create(winsys, ALIGNMENT,
+ usage,
+ *stride * nblocksy);
}
static void xsp_fence_reference(struct pipe_winsys *pws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence)
@@ -273,9 +234,7 @@ struct pipe_context* create_pipe_context(Display *display, int screen)
xsp_winsys->base.buffer_map = xsp_buffer_map;
xsp_winsys->base.buffer_unmap = xsp_buffer_unmap;
xsp_winsys->base.buffer_destroy = xsp_buffer_destroy;
- xsp_winsys->base.surface_alloc = xsp_surface_alloc;
- xsp_winsys->base.surface_alloc_storage = xsp_surface_alloc_storage;
- xsp_winsys->base.surface_release = xsp_surface_release;
+ xsp_winsys->base.surface_buffer_create = xsp_surface_buffer_create;
xsp_winsys->base.fence_reference = xsp_fence_reference;
xsp_winsys->base.fence_signalled = xsp_fence_signalled;
xsp_winsys->base.fence_finish = xsp_fence_finish;
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index bd5aa10a20..cc12007193 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -161,63 +161,25 @@ round_up(unsigned n, unsigned multiple)
}
-static int
-gdi_softpipe_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ unsigned usage,
+ unsigned *stride)
{
const unsigned alignment = 64;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
- surf->width = width;
- surf->height = height;
- surf->format = format;
- pf_get_block(format, &surf->block);
- surf->nblocksx = pf_get_nblocksx(&surf->block, width);
- surf->nblocksy = pf_get_nblocksy(&surf->block, height);
- surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
- surf->usage = flags;
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->stride * surf->nblocksy);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-
-static struct pipe_surface *
-gdi_softpipe_surface_alloc(struct pipe_winsys *winsys)
-{
- struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
-
- assert(winsys);
-
- surface->refcount = 1;
- surface->winsys = winsys;
-
- return surface;
-}
-
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, alignment);
-static void
-gdi_softpipe_surface_release(struct pipe_winsys *winsys,
- struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- assert(!surf->texture);
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- winsys_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ *stride * nblocksy);
}
@@ -281,9 +243,7 @@ gdi_softpipe_screen_create(void)
winsys->buffer_unmap = gdi_softpipe_buffer_unmap;
winsys->buffer_destroy = gdi_softpipe_buffer_destroy;
- winsys->surface_alloc = gdi_softpipe_surface_alloc;
- winsys->surface_alloc_storage = gdi_softpipe_surface_alloc_storage;
- winsys->surface_release = gdi_softpipe_surface_release;
+ winsys->surface_buffer_create = gdi_softpipe_surface_buffer_create;
winsys->fence_reference = gdi_softpipe_fence_reference;
winsys->fence_signalled = gdi_softpipe_fence_signalled;
diff --git a/src/gallium/winsys/xlib/xlib_brw_screen.c b/src/gallium/winsys/xlib/xlib_brw_screen.c
index 030cd66bd9..1fd7da8a2f 100644
--- a/src/gallium/winsys/xlib/xlib_brw_screen.c
+++ b/src/gallium/winsys/xlib/xlib_brw_screen.c
@@ -229,17 +229,6 @@ aub_flush_frontbuffer( struct pipe_winsys *winsys,
aub_bo(surface->buffer)->offset );
}
-static struct pipe_surface *
-aub_i915_surface_alloc(struct pipe_winsys *winsys)
-{
- struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface);
- if (surf) {
- surf->refcount = 1;
- surf->winsys = winsys;
- }
- return surf;
-}
-
/**
* Round n up to next multiple.
@@ -250,50 +239,28 @@ round_up(unsigned n, unsigned multiple)
return (n + multiple - 1) & ~(multiple - 1);
}
-static int
-aub_i915_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+aub_i915_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ unsigned usage,
+ unsigned *stride)
{
const unsigned alignment = 64;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
- surf->width = width;
- surf->height = height;
- surf->format = format;
- pf_get_block(format, &surf->block);
- surf->nblocksx = pf_get_nblocksx(&surf->block, width);
- surf->nblocksy = pf_get_nblocksy(&surf->block, height);
- surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
- surf->usage = flags;
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->stride * surf->nblocksy);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, alignment);
-static void
-aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- winsys_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ *stride * nblocksy);
}
-
static const char *
aub_get_name( struct pipe_winsys *winsys )
{
@@ -333,9 +300,7 @@ xlib_create_brw_winsys( void )
iws->winsys.get_name = aub_get_name;
iws->winsys.destroy = xlib_brw_destroy_pipe_winsys_aub;
- iws->winsys.surface_alloc = aub_i915_surface_alloc;
- iws->winsys.surface_alloc_storage = aub_i915_surface_alloc_storage;
- iws->winsys.surface_release = aub_i915_surface_release;
+ iws->winsys.surface_buffer_create = aub_i915_surface_buffer_create;
iws->aubfile = brw_aubfile_create();
iws->size = AUB_BUF_SIZE;
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 93bc8ecd81..5af9ee3bb5 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -284,68 +284,26 @@ round_up(unsigned n, unsigned multiple)
return (n + multiple - 1) & ~(multiple - 1);
}
-static int
-xm_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ enum pipe_format format,
+ unsigned usage,
+ unsigned *stride)
{
const unsigned alignment = 64;
-
- surf->width = width;
- surf->height = height;
- surf->format = format;
- pf_get_block(format, &surf->block);
- surf->nblocksx = pf_get_nblocksx(&surf->block, width);
- surf->nblocksy = pf_get_nblocksy(&surf->block, height);
- surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
- surf->usage = flags;
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- /* XXX a bit of a hack */
- surf->stride * round_up(surf->nblocksy, TILE_SIZE));
-
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-
-/**
- * Called via winsys->surface_alloc() to create new surfaces.
- */
-static struct pipe_surface *
-xm_surface_alloc(struct pipe_winsys *ws)
-{
- struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
-
- assert(ws);
-
- surface->refcount = 1;
- surface->winsys = ws;
-
- return surface;
-}
-
-
-
-static void
-xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- assert(!surf->texture);
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- winsys_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
+
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = round_up(nblocksx * block.size, alignment);
+
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ /* XXX a bit of a hack */
+ *stride * round_up(nblocksy, TILE_SIZE));
}
@@ -395,9 +353,7 @@ xlib_create_cell_winsys( void )
ws->base.buffer_unmap = xm_buffer_unmap;
ws->base.buffer_destroy = xm_buffer_destroy;
- ws->base.surface_alloc = xm_surface_alloc;
- ws->base.surface_alloc_storage = xm_surface_alloc_storage;
- ws->base.surface_release = xm_surface_release;
+ ws->base.surface_buffer_create = xm_surface_buffer_create;
ws->base.fence_reference = xm_fence_reference;
ws->base.fence_signalled = xm_fence_signalled;
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index 0c3097c42e..c0bf37050a 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -344,67 +344,25 @@ xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
}
-static int
-xm_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+xm_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
-{
- const int alignment = 64;
-
- surf->width = width;
- surf->height = height;
- surf->format = format;
- pf_get_block(format, &surf->block);
- surf->nblocksx = pf_get_nblocksx(&surf->block, width);
- surf->nblocksy = pf_get_nblocksy(&surf->block, height);
- surf->stride = align(surf->nblocksx * surf->block.size, alignment);
- surf->usage = flags;
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->stride * surf->nblocksy);
-
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-
-/**
- * Called via winsys->surface_alloc() to create new surfaces.
- */
-static struct pipe_surface *
-xm_surface_alloc(struct pipe_winsys *ws)
+ enum pipe_format format,
+ unsigned usage,
+ unsigned *stride)
{
- struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
-
- assert(ws);
-
- surface->refcount = 1;
- surface->winsys = ws;
-
- return surface;
-}
-
-
-
-static void
-xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- assert(!surf->texture);
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- winsys_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
+ const unsigned alignment = 64;
+ struct pipe_format_block block;
+ unsigned nblocksx, nblocksy;
+
+ pf_get_block(format, &block);
+ nblocksx = pf_get_nblocksx(&block, width);
+ nblocksy = pf_get_nblocksy(&block, height);
+ *stride = align(nblocksx * block.size, alignment);
+
+ return winsys->buffer_create(winsys, alignment,
+ usage,
+ *stride * nblocksy);
}
@@ -454,9 +412,7 @@ xlib_create_softpipe_winsys( void )
ws->base.buffer_unmap = xm_buffer_unmap;
ws->base.buffer_destroy = xm_buffer_destroy;
- ws->base.surface_alloc = xm_surface_alloc;
- ws->base.surface_alloc_storage = xm_surface_alloc_storage;
- ws->base.surface_release = xm_surface_release;
+ ws->base.surface_buffer_create = xm_surface_buffer_create;
ws->base.fence_reference = xm_fence_reference;
ws->base.fence_signalled = xm_fence_signalled;