gallium: Remove the standalone surfaces.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 20 Jan 2009 12:22:49 +0000 (12:22 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 20 Jan 2009 12:22:49 +0000 (12:22 +0000)
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.

25 files changed:
src/gallium/auxiliary/util/u_timed_winsys.c
src/gallium/drivers/i915simple/i915_texture.c
src/gallium/drivers/i965simple/brw_tex_layout.c
src/gallium/drivers/nv04/nv04_miptree.c
src/gallium/drivers/nv10/nv10_miptree.c
src/gallium/drivers/nv20/nv20_miptree.c
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv40/nv40_miptree.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/trace/tr_texture.c
src/gallium/drivers/trace/tr_winsys.c
src/gallium/include/pipe/p_inlines.h
src/gallium/include/pipe/p_state.h
src/gallium/include/pipe/p_winsys.h
src/gallium/state_trackers/python/st_softpipe_winsys.c
src/gallium/winsys/drm/intel/common/intel_be_device.c
src/gallium/winsys/egl_xlib/sw_winsys.c
src/gallium/winsys/g3dvl/nouveau/nouveau_winsys_pipe.c
src/gallium/winsys/g3dvl/xsp_winsys.c
src/gallium/winsys/gdi/gdi_softpipe_winsys.c
src/gallium/winsys/xlib/xlib_brw_screen.c
src/gallium/winsys/xlib/xlib_cell.c
src/gallium/winsys/xlib/xlib_softpipe.c

index 8beb3b4c885b526203b9f3532cb8fa7ca4e5387d..dc3c9be5952dacf8ec690176e8c679271a87a416 100644 (file)
@@ -205,34 +205,18 @@ timed_flush_frontbuffer( struct pipe_winsys *winsys,
 
 
 
-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__);
    
@@ -240,19 +224,6 @@ timed_surface_alloc_storage(struct pipe_winsys *winsys,
 }
 
 
-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 )
 {
@@ -331,9 +302,7 @@ struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend )
    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;
index 2f5459af67f70aad34fd1adde23791bc95345f62..af823f2d3c5d142e8a150769119db15e462eafed 100644 (file)
@@ -683,7 +683,6 @@ i915_get_tex_surface(struct pipe_screen *screen,
    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;
index cc0c665e021099a1d6ca9c04cabf750cb4dd99a2..12e2e02cfdc168044b64c2767cbcbcc4323285d4 100644 (file)
@@ -365,10 +365,10 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
       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];
@@ -378,6 +378,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
       ps->nblocksy = pt->nblocksy[level];
       ps->stride = tex->stride;
       ps->offset = offset;
+      ps->status = PIPE_SURFACE_STATUS_DEFINED;
    }
    return ps;
 }
index 0cbb91e187bfb3b505314a82b807153b072ce91f..094c38256b417dd676b85ab5ba24cdeb33a57280 100644 (file)
@@ -96,13 +96,12 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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];
@@ -110,7 +109,6 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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];
index 943f9e21e98173179f18df49a9903003e2d0663f..f8c021261bc9995a0b2aac47bf15c407997a3007 100644 (file)
@@ -110,9 +110,10 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
        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];
@@ -122,7 +123,6 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
        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];
index c6106d58c434dcc2492b7191b33c5bc3840cd891..d2038c391d69e35cb8f6b6294244932f6b456db7 100644 (file)
@@ -117,7 +117,6 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
        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];
index 37d297cc0f48ec8fb019852066ed3ec0099bd40a..54fb3585f8ade410510ce633b79a3b96ccf598d7 100644 (file)
@@ -154,7 +154,6 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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;
index 00ce6be985a71f11b00eeb9d5a90c5f3bdd6e643..ba912ddcbbf9f4728bf0398d5c5e2bee141e3ee9 100644 (file)
@@ -155,7 +155,6 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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;
index 63a23d06b89774e232274d9eca931b3c49fdfc36..7770fcc3f2aaa904f6feb129544317ecd71650a9 100644 (file)
@@ -217,7 +217,6 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
 {
        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;
 
@@ -229,13 +228,11 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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];
@@ -245,6 +242,10 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
        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));
index a64dc89f4325dfd158d82d2bc601d0f892eb7f9d..faf9e871f932939c99606069c1c36227c907a139 100644 (file)
@@ -94,49 +94,23 @@ softpipe_texture_layout(struct pipe_screen *screen,
    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;
 }
@@ -231,7 +205,6 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
                          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;
 
index bf437a7c61842ebed4d80c27ca3282d1fb045bbf..c1636920cd60affef7d10f273aa9d1e56079dbb8 100644 (file)
@@ -42,7 +42,7 @@ struct softpipe_texture
    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:
     */
index 440a78704abb5c988864eb87cf9465ccbe219b6c..1cc4f0bd43686f9ed84e0f225737915a11603ca0 100644 (file)
@@ -87,7 +87,6 @@ trace_surface_create(struct trace_texture *tr_tex,
    
    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;
index 177835854e19624d96caad54ef0e263b999ac48c..c4148fe81041d9d793511d60ce081a6e94eec7e3 100644 (file)
@@ -98,86 +98,41 @@ trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
 }
 
 
-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;
 }
 
 
@@ -465,9 +420,7 @@ trace_winsys_create(struct pipe_winsys *winsys)
    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;
index 5e79b7f485a38a60fd41caca73c6f92b51d797a6..73783926169224d60c9eeb3d9e841411448f837c 100644 (file)
@@ -45,30 +45,19 @@ extern "C" {
 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 );
 }
 
 
@@ -88,20 +77,11 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *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);
    }
 
index 317121c64a813501997fb11180dfadbd2717d4b5..abe7cbe9e7cd143f9c983e3787da1de3cab95a73 100644 (file)
@@ -292,9 +292,7 @@ struct pipe_surface
    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;
index 5d18291dc6cd3b1ebd386870f51295b881911ba0..3ae83e8105d30b3191f28c6be28a4ab721719230 100644 (file)
@@ -76,24 +76,6 @@ struct pipe_winsys
                               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.
     *
@@ -138,6 +120,24 @@ struct pipe_winsys
                                                     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. 
index f62113a4691bb8b4a2a01a8f1a57361a788b3f9e..01d88ee499d39556592279b1e8468661d352c436 100644 (file)
@@ -168,63 +168,25 @@ round_up(unsigned n, unsigned multiple)
 }
 
 
-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);
 }
 
 
@@ -279,9 +241,7 @@ st_softpipe_screen_create(void)
    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;
index 019ee5cbd2eb91407be6b6028e79e0a372d4c118..14aeaf61dbfa2670679e25e0efe121e1f2a9f11b 100644 (file)
@@ -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;
index 2fd190da52e9210a247377c2ee11d746ab8f0cfb..a09ad5e8e90c93e0fc7094ad3d61735871144004 100644 (file)
@@ -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;
index 17c409e1ce51379a486f70e080794b4fbfd1ac9b..2d8463037f72aeea8ebe607785cba83bf1a93ed6 100644 (file)
@@ -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;
index 68be2c2ea3afca16a8d6b81ab2fc68d3302b6cb1..40d683234fc6e8c2fd8980d3bf369079b1855b45 100644 (file)
@@ -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;
index bd5aa10a20f8f23174d73e55b23abe8a7f611d11..cc120071937bfb047a80f17ca922497bc18a4c62 100644 (file)
@@ -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;
index 030cd66bd90932fb5616ab1a634bce2f8d1390b8..1fd7da8a2f57270ad9e7fc8479638e2bac6a80f5 100644 (file)
@@ -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;
index 93bc8ecd81349e04dd016d54a6d63835baa006fa..5af9ee3bb50b739749e64b9edab700901f3d4bd2 100644 (file)
@@ -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;
index 0c3097c42e512597f5af04ccb9ddda396e2ac216..c0bf37050a4450d4f8bf19f869dc9f1bdb13fccf 100644 (file)
@@ -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;