-static struct pipe_surface *
-timed_surface_alloc(struct pipe_winsys *winsys)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- uint64_t start = time_start();
-
- struct pipe_surface *surf = backend->surface_alloc( backend );
-
- time_finish(winsys, start, 6, __FUNCTION__);
-
- return surf;
-}
-
-
-
-static int
-timed_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+timed_surface_buffer_create(struct pipe_winsys *winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ unsigned usage,
+ unsigned *stride)
{
struct pipe_winsys *backend = timed_winsys(winsys)->backend;
uint64_t start = time_start();
- int ret = backend->surface_alloc_storage( backend, surf, width, height,
- format, flags, tex_usage );
+ struct pipe_buffer *ret = backend->surface_buffer_create( backend, width, height,
+ format, usage, stride );
time_finish(winsys, start, 7, __FUNCTION__);
}
-static void
-timed_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- uint64_t start = time_start();
-
- backend->surface_release( backend, s );
-
- time_finish(winsys, start, 8, __FUNCTION__);
-}
-
-
-
static const char *
timed_get_name( struct pipe_winsys *winsys )
{
ws->base.buffer_create = timed_buffer_create;
ws->base.flush_frontbuffer = timed_flush_frontbuffer;
ws->base.get_name = timed_get_name;
- ws->base.surface_alloc = timed_surface_alloc;
- ws->base.surface_alloc_storage = timed_surface_alloc_storage;
- ws->base.surface_release = timed_surface_release;
+ ws->base.surface_buffer_create = timed_surface_buffer_create;
ws->base.fence_reference = timed_fence_reference;
ws->base.fence_signalled = timed_fence_signalled;
ws->base.fence_finish = timed_fence_finish;
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
ps->refcount = 1;
- ps->winsys = ws;
pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(screen, &ps->buffer, tex->buffer);
ps->format = pt->format;
assert(zslice == 0);
}
- ps = ws->surface_alloc(ws);
+ ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- assert(ps->format);
- assert(ps->refcount);
+ ps->refcount = 1;
+ pipe_texture_reference(&ps->texture, pt);
winsys_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->nblocksy = pt->nblocksy[level];
ps->stride = tex->stride;
ps->offset = offset;
+ ps->status = PIPE_SURFACE_STATUS_DEFINED;
}
return ps;
}
struct nv04_miptree *nv04mt = (struct nv04_miptree *)pt;
struct pipe_surface *ps;
- ps = ws->surface_alloc(ws);
+ ps = CALLOC_STRUCT(pipe_surface);
if (!ps)
return NULL;
+ pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(pscreen, &ps->buffer, nv04mt->buffer);
ps->format = pt->format;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
ps->block = pt->block;
ps->width = pt->width[level];
ps->height = pt->height[level];
ps->nblocksy = pt->nblocksy[level];
ps->stride = nv04mt->level[level].pitch;
ps->refcount = 1;
- ps->winsys = pscreen->winsys;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv04mt->level[level].image_offset[face];
struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
struct pipe_surface *ps;
- ps = ws->surface_alloc(ws);
+ ps = CALLOC_STRUCT(pipe_surface);
if (!ps)
return NULL;
+ pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(screen, &ps->buffer, nv10mt->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->nblocksy = pt->nblocksy[level];
ps->stride = nv10mt->level[level].pitch;
ps->refcount = 1;
- ps->winsys = screen->winsys;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv10mt->level[level].image_offset[face];
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
ps->refcount = 1;
- ps->winsys = screen->winsys;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv20mt->level[level].image_offset[face];
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
ps->refcount = 1;
- ps->winsys = pscreen->winsys;
ps->face = face;
ps->level = level;
ps->zslice = zslice;
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
ps->refcount = 1;
- ps->winsys = pscreen->winsys;
ps->face = face;
ps->level = level;
ps->zslice = zslice;
{
struct nv50_miptree *mt = nv50_miptree(pt);
struct nv50_miptree_level *lvl = &mt->level[level];
- struct nv50_surface *s;
struct pipe_surface *ps;
int img;
else
img = 0;
- s = CALLOC_STRUCT(nv50_surface);
- if (!s)
+ ps = CALLOC_STRUCT(pipe_surface);
+ if (!ps)
return NULL;
- ps = &s->base;
-
- ps->refcount = 1;
- ps->winsys = pscreen->winsys;
+ pipe_texture_reference(&ps->texture, pt);
+ pipe_buffer_reference(pscreen, &ps->buffer, mt->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
ps->stride = ps->width * ps->block.size;
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
+ ps->refcount = 1;
+ ps->face = face;
+ ps->level = level;
+ ps->zslice = zslice;
if (flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
return spt->buffer != NULL;
}
-/* Hack it up to use the old winsys->surface_alloc_storage()
- * method for now:
- */
static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
struct pipe_winsys *ws = screen->winsys;
- struct pipe_surface surf;
- unsigned flags = (PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
- int ret;
-
-
- memset(&surf, 0, sizeof(surf));
-
- ret =ws->surface_alloc_storage( ws,
- &surf,
- spt->base.width[0],
- spt->base.height[0],
- spt->base.format,
- flags,
- spt->base.tex_usage);
- if(ret != 0)
- return FALSE;
-
- if (!surf.buffer) {
- /* allocation failed */
- return FALSE;
- }
+ unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE |
+ PIPE_BUFFER_USAGE_GPU_READ_WRITE);
- /* Now extract the goodies:
- */
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
- spt->stride[0] = surf.stride;
- /* Transfer the reference:
- */
- spt->buffer = surf.buffer;
- surf.buffer = NULL;
+ spt->buffer = ws->surface_buffer_create( ws,
+ spt->base.width[0],
+ spt->base.height[0],
+ spt->base.format,
+ usage,
+ &spt->stride[0]);
return spt->buffer != NULL;
}
unsigned face, unsigned level, unsigned zslice,
unsigned usage)
{
- struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = softpipe_texture(pt);
struct pipe_surface *ps;
struct pipe_texture base;
unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
- unsigned long stride[PIPE_MAX_TEXTURE_LEVELS];
+ unsigned stride[PIPE_MAX_TEXTURE_LEVELS];
/* The data is held here:
*/
memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
- tr_surf->base.winsys = tr_tex->base.screen->winsys;
tr_surf->base.texture = NULL;
pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
}
-static struct pipe_surface *
-trace_winsys_surface_alloc(struct pipe_winsys *_winsys)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- struct pipe_surface *result;
-
- trace_dump_call_begin("pipe_winsys", "surface_alloc");
-
- trace_dump_arg(ptr, winsys);
-
- result = winsys->surface_alloc(winsys);
-
- trace_dump_ret(ptr, result);
-
- trace_dump_call_end();
-
- assert(!result || !result->texture);
-
- return result;
-}
-
-
-static int
-trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
- struct pipe_surface *surface,
+static struct pipe_buffer *
+trace_winsys_surface_buffer_create(struct pipe_winsys *_winsys,
unsigned width, unsigned height,
enum pipe_format format,
- unsigned flags,
- unsigned tex_usage)
+ unsigned usage,
+ unsigned *pstride)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
struct pipe_winsys *winsys = tr_ws->winsys;
- int result;
+ unsigned stride;
+ struct pipe_buffer *result;
- assert(surface && !surface->texture);
-
- trace_dump_call_begin("pipe_winsys", "surface_alloc_storage");
+ trace_dump_call_begin("pipe_winsys", "surface_buffer_create");
trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, surface);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
trace_dump_arg(format, format);
- trace_dump_arg(uint, flags);
- trace_dump_arg(uint, tex_usage);
+ trace_dump_arg(uint, usage);
- result = winsys->surface_alloc_storage(winsys,
- surface,
+ result = winsys->surface_buffer_create(winsys,
width, height,
format,
- flags,
- tex_usage);
+ usage,
+ pstride);
- trace_dump_ret(int, result);
+ stride = *pstride;
- trace_dump_call_end();
+ trace_dump_arg(uint, stride);
- return result;
-}
-
-
-static void
-trace_winsys_surface_release(struct pipe_winsys *_winsys,
- struct pipe_surface **psurface)
-{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
- struct pipe_surface *surface = *psurface;
-
- assert(psurface && *psurface && !(*psurface)->texture);
-
- trace_dump_call_begin("pipe_winsys", "surface_release");
-
- trace_dump_arg(ptr, winsys);
- trace_dump_arg(ptr, surface);
-
- winsys->surface_release(winsys, psurface);
+ trace_dump_ret(ptr, result);
trace_dump_call_end();
+
+ return result;
}
tr_ws->base.destroy = trace_winsys_destroy;
tr_ws->base.get_name = trace_winsys_get_name;
tr_ws->base.flush_frontbuffer = trace_winsys_flush_frontbuffer;
- tr_ws->base.surface_alloc = trace_winsys_surface_alloc;
- tr_ws->base.surface_alloc_storage = trace_winsys_surface_alloc_storage;
- tr_ws->base.surface_release = trace_winsys_surface_release;
+ tr_ws->base.surface_buffer_create = trace_winsys_surface_buffer_create;
tr_ws->base.buffer_create = trace_winsys_buffer_create;
tr_ws->base.user_buffer_create = trace_winsys_user_buffer_create;
tr_ws->base.buffer_map = trace_winsys_buffer_map;
static INLINE void *
pipe_surface_map( struct pipe_surface *surf, unsigned flags )
{
- if (surf->texture) {
- struct pipe_screen *screen = surf->texture->screen;
- return surf->texture->screen->surface_map( screen, surf, flags );
- }
- else {
- struct pipe_winsys *winsys = surf->winsys;
- char *map = (char *)winsys->buffer_map( winsys, surf->buffer, flags );
- if (map == NULL)
- return NULL;
- return (void *)(map + surf->offset);
- }
+ struct pipe_screen *screen;
+ assert(surf->texture);
+ screen = surf->texture->screen;
+ return screen->surface_map( screen, surf, flags );
}
static INLINE void
pipe_surface_unmap( struct pipe_surface *surf )
{
- if (surf->texture) {
- struct pipe_screen *screen = surf->texture->screen;
- surf->texture->screen->surface_unmap( screen, surf );
- }
- else {
- struct pipe_winsys *winsys = surf->winsys;
- winsys->buffer_unmap( winsys, surf->buffer );
- }
+ struct pipe_screen *screen;
+ assert(surf->texture);
+ screen = surf->texture->screen;
+ screen->surface_unmap( screen, surf );
}
}
if (*ptr) {
+ struct pipe_screen *screen;
assert((*ptr)->refcount);
-
- /* There are currently two sorts of surfaces... This needs to be
- * fixed so that all surfaces are views into a texture.
- */
- if ((*ptr)->texture) {
- struct pipe_screen *screen = (*ptr)->texture->screen;
- screen->tex_surface_release( screen, ptr );
- }
- else {
- struct pipe_winsys *winsys = (*ptr)->winsys;
- winsys->surface_release(winsys, ptr);
- }
-
+ assert((*ptr)->texture);
+ screen = (*ptr)->texture->screen;
+ screen->tex_surface_release( screen, ptr );
assert(!*ptr);
}
unsigned refcount;
unsigned usage; /**< PIPE_BUFFER_USAGE_* */
- struct pipe_winsys *winsys; /**< winsys which owns/created the surface */
-
- struct pipe_texture *texture; /**< optional texture into which this is a view */
+ struct pipe_texture *texture; /**< texture into which this is a view */
unsigned face;
unsigned level;
unsigned zslice;
void *context_private );
- /** allocate a new surface (no context dependency) */
- struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws);
-
- /**
- * Allocate storage for a pipe_surface.
- * \param flags XXX unused, remove someday
- * \return 0 if succeeds.
- */
- int (*surface_alloc_storage)(struct pipe_winsys *ws,
- struct pipe_surface *surf,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags,
- unsigned tex_usage);
-
- void (*surface_release)(struct pipe_winsys *ws, struct pipe_surface **s);
-
-
/**
* Buffer management. Buffer attributes are mostly fixed over its lifetime.
*
void *ptr,
unsigned bytes);
+ /**
+ * 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);
+
+
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
}
-static int
-st_softpipe_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
+static struct pipe_buffer *
+st_softpipe_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;
+ 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 *
-st_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
-st_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);
}
winsys->buffer_unmap = st_softpipe_buffer_unmap;
winsys->buffer_destroy = st_softpipe_buffer_destroy;
- winsys->surface_alloc = st_softpipe_surface_alloc;
- winsys->surface_alloc_storage = st_softpipe_surface_alloc_storage;
- winsys->surface_release = st_softpipe_surface_release;
+ winsys->surface_buffer_create = st_softpipe_surface_buffer_create;
winsys->fence_reference = st_softpipe_fence_reference;
winsys->fence_signalled = st_softpipe_fence_signalled;
}
-/*
- * 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);
}
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;
}
-/**
- * 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);
}
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;
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
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;
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)
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;
}
-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);
}
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;
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.
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 )
{
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;
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));
}
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;
}
-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);
}
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;