surface_alloc() is now a winsys function.
authorBrian <brian.paul@tungstengraphics.com>
Fri, 26 Oct 2007 16:45:42 +0000 (10:45 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 26 Oct 2007 16:45:42 +0000 (10:45 -0600)
This allows surfaces to be allocated without a rendering context.
A few loose ends to resolve, but in working condition.

12 files changed:
src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
src/mesa/drivers/x11/xm_api.c
src/mesa/drivers/x11/xm_surface.c
src/mesa/drivers/x11/xm_winsys.c
src/mesa/drivers/x11/xmesaP.h
src/mesa/pipe/failover/fo_context.c
src/mesa/pipe/i915simple/i915_surface.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_winsys.h
src/mesa/pipe/softpipe/sp_surface.c
src/mesa/pipe/softpipe/sp_surface.h
src/mesa/state_tracker/st_cb_fbo.c

index 6f244e110013eb261484d879225bf135fbe509bb..4569b1e3bf6b9e0b90322bfe537037b48eebb6f8 100644 (file)
@@ -253,6 +253,18 @@ intel_i915_region_release(struct pipe_winsys *winsys,
 }
 
 
+static struct pipe_surface *
+intel_i915_surface_alloc(struct pipe_winsys *winsys, unsigned format)
+{
+   struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface);
+   if (surf) {
+      surf->format = format;
+      surf->refcount = 1;
+   }
+   return surf;
+}
+
+
 static void
 intel_printf( struct pipe_winsys *sws, const char *fmtString, ... )
 {
@@ -298,5 +310,7 @@ intel_create_pipe_winsys( struct intel_context *intel )
    iws->winsys.region_alloc = intel_i915_region_alloc;
    iws->winsys.region_release = intel_i915_region_release;
 
+   iws->winsys.surface_alloc = intel_i915_surface_alloc;
+
    return &iws->winsys;
 }
index 187663e66ca1af3c004036170465411faf459d05..1d2b93d100bea0dd5204478db2128f7b95d05ed7 100644 (file)
@@ -1610,8 +1610,15 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
    st_create_context( mesaCtx,
                       xmesa_create_softpipe( c ) );
 
+   /* override these functions, as if the xlib driver were derived from
+    * the softpipe driver.
+    */
+#if 0
    mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc;
+#endif
    mesaCtx->st->pipe->supported_formats = xmesa_supported_formats;
+   mesaCtx->st->pipe->get_tile_rgba = xmesa_get_tile_rgba;
+   mesaCtx->st->pipe->put_tile_rgba = xmesa_put_tile_rgba;
 
    mesaCtx->st->haveFramebufferRegions = GL_FALSE;
 
index 337033f8ad6f2f8e555c751b9ca5f5137ea6c645..3655a55e4eca6839f291766d0b5959de76f7ee5b 100644 (file)
@@ -48,6 +48,7 @@
 #include "pipe/softpipe/sp_context.h"
 #include "pipe/softpipe/sp_clear.h"
 #include "pipe/softpipe/sp_tile_cache.h"
+#include "pipe/softpipe/sp_surface.h"
 #include "state_tracker/st_context.h"
 
 
@@ -67,6 +68,13 @@ xmesa_surf(struct softpipe_surface *sps)
 }
 
 
+static INLINE struct xmesa_surface *
+xmesa_surface(struct pipe_surface *ps)
+{
+   return (struct xmesa_surface *) ps;
+}
+
+
 static INLINE struct xmesa_renderbuffer *
 xmesa_rb(struct softpipe_surface *sps)
 {
@@ -78,53 +86,71 @@ xmesa_rb(struct softpipe_surface *sps)
 #define FLIP(Y) Y = xrb->St.Base.Height - (Y) - 1;
 
 
-static void
-get_tile(struct pipe_surface *ps,
-         uint x, uint y, uint w, uint h, float *p)
+void
+xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
+                    uint x, uint y, uint w, uint h, float *p)
 {
-   struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps);
-   GLubyte tmp[MAX_WIDTH * 4];
-   GLuint i, j;
-   uint w0 = w;
-   GET_CURRENT_CONTEXT(ctx);
-
-   CLIP_TILE;
-
-   FLIP(y);
-   for (i = 0; i < h; i++) {
-      xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp);
-      for (j = 0; j < w * 4; j++) {
-         p[j] = UBYTE_TO_FLOAT(tmp[j]);
+   struct xmesa_surface *xms = xmesa_surface(ps);
+   struct xmesa_renderbuffer *xrb = xms->xrb;
+
+   if (xrb) {
+      /* this is a front/back color buffer */
+      GLubyte tmp[MAX_WIDTH * 4];
+      GLuint i, j;
+      uint w0 = w;
+      GET_CURRENT_CONTEXT(ctx);
+
+      CLIP_TILE;
+
+      FLIP(y);
+      for (i = 0; i < h; i++) {
+         xrb->St.Base.GetRow(ctx, &xrb->St.Base, w, x, y - i, tmp);
+         for (j = 0; j < w * 4; j++) {
+            p[j] = UBYTE_TO_FLOAT(tmp[j]);
+         }
+         p += w0 * 4;
       }
-      p += w0 * 4;
+   }
+   else {
+      /* other softpipe surface */
+      softpipe_get_tile_rgba(pipe, ps, x, y, w, h, p);
    }
 }
 
 
-static void
-put_tile(struct pipe_surface *ps,
-         uint x, uint y, uint w, uint h, const float *p)
+void
+xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
+                    uint x, uint y, uint w, uint h, const float *p)
 {
-   struct xmesa_renderbuffer *xrb = xmesa_rb((struct softpipe_surface *) ps);
-   GLubyte tmp[MAX_WIDTH * 4];
-   GLuint i, j;
-   uint w0 = w;
-   GET_CURRENT_CONTEXT(ctx);
-   CLIP_TILE;
-   FLIP(y);
-   for (i = 0; i < h; i++) {
-      for (j = 0; j < w * 4; j++) {
-         UNCLAMPED_FLOAT_TO_UBYTE(tmp[j], p[j]);
+   struct xmesa_surface *xms = xmesa_surface(ps);
+   struct xmesa_renderbuffer *xrb = xms->xrb;
+
+   if (xrb) {
+      /* this is a front/back color buffer */
+      GLubyte tmp[MAX_WIDTH * 4];
+      GLuint i, j;
+      uint w0 = w;
+      GET_CURRENT_CONTEXT(ctx);
+      CLIP_TILE;
+      FLIP(y);
+      for (i = 0; i < h; i++) {
+         for (j = 0; j < w * 4; j++) {
+            UNCLAMPED_FLOAT_TO_UBYTE(tmp[j], p[j]);
+         }
+         xrb->St.Base.PutRow(ctx, &xrb->St.Base, w, x, y - i, tmp, NULL);
+         p += w0 * 4;
       }
-      xrb->St.Base.PutRow(ctx, &xrb->St.Base, w, x, y - i, tmp, NULL);
-      p += w0 * 4;
-   }
 #if 0 /* debug: flush */
-   {
-      XMesaContext xm = XMESA_CONTEXT(ctx);
-      XSync(xm->display, 0);
-   }
+      {
+         XMesaContext xm = XMESA_CONTEXT(ctx);
+         XSync(xm->display, 0);
+      }
 #endif
+   }
+   else {
+      /* other softpipe surface */
+      softpipe_put_tile_rgba(pipe, ps, x, y, w, h, p);
+   }
 }
 
 
@@ -141,12 +167,15 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat)
 
    assert(pipeFormat);
 
-   xms->surface.surface.format = pipeFormat;
-   xms->surface.surface.refcount = 1;
+   xms->surface.format = pipeFormat;
+   xms->surface.refcount = 1;
 
+#if 0
    /* some of the functions plugged in by this call will get overridden */
    softpipe_init_surface_funcs(&xms->surface);
+#endif
 
+#if 0
    switch (pipeFormat) {
    case PIPE_FORMAT_U_A8_R8_G8_B8:
       xms->surface.get_tile = get_tile;
@@ -157,6 +186,7 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat)
    default:
       abort();
    }
+#endif
 
    /* Note, the region we allocate doesn't actually have any storage
     * since we're drawing into an XImage or Pixmap.
@@ -164,10 +194,10 @@ xmesa_new_color_surface(struct pipe_context *pipe, GLuint pipeFormat)
     * functions.
     */
    if (pipe)
-      xms->surface.surface.region = pipe->winsys->region_alloc(pipe->winsys,
-                                                               1, 0, 0, 0x0);
+      xms->surface.region = pipe->winsys->region_alloc(pipe->winsys,
+                                                       1, 0, 0, 0x0);
 
-   return &xms->surface.surface;
+   return &xms->surface;
 }
 
 
@@ -183,14 +213,15 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat)
    assert(pipe);
    assert(pipeFormat);
 
-   xms->surface.surface.format = pipeFormat;
-   xms->surface.surface.refcount = 1;
+   xms->surface.format = pipeFormat;
+   xms->surface.refcount = 1;
+#if 0
    /*
     * This is really just a softpipe surface, not an XImage/Pixmap surface.
     */
    softpipe_init_surface_funcs(&xms->surface);
-
-   return &xms->surface.surface;
+#endif
+   return &xms->surface;
 }
 
 
index 624d28dd018bb3f944d2f5167c0855880f1f6c32..36805437f0156b62e2c5230cec6246e6542046b0 100644 (file)
@@ -289,6 +289,31 @@ xm_region_release(struct pipe_winsys *winsys, struct pipe_region **region)
 }
 
 
+/**
+ * Called via pipe->surface_alloc() to create new surfaces (textures,
+ * renderbuffers, etc.
+ */
+static struct pipe_surface *
+xm_surface_alloc(struct pipe_winsys *ws, GLuint pipeFormat)
+{
+   struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
+
+   assert(ws);
+   assert(pipeFormat);
+
+   xms->surface.format = pipeFormat;
+   xms->surface.refcount = 1;
+#if 0
+   /*
+    * This is really just a softpipe surface, not an XImage/Pixmap surface.
+    */
+   softpipe_init_surface_funcs(&xms->surface);
+#endif
+   return &xms->surface;
+}
+
+
+
 
 struct xmesa_pipe_winsys
 {
@@ -320,6 +345,8 @@ xmesa_create_pipe_winsys( XMesaContext xmesa )
    xws->winsys.region_alloc = xm_region_alloc;
    xws->winsys.region_release = xm_region_release;
 
+   xws->winsys.surface_alloc = xm_surface_alloc;
+
    xws->winsys.flush_frontbuffer = xm_flush_frontbuffer;
    xws->winsys.wait_idle = xm_wait_idle;
    xws->winsys.printf = xm_printf;
index 9cbe8670f92c14d3dfe7350b6f745ab35a9147de..8af95504fb67525cb0c6fed4a2081f5bee7db504 100644 (file)
@@ -598,7 +598,7 @@ struct pipe_context;
 
 struct xmesa_surface
 {
-   struct softpipe_surface surface;
+   struct pipe_surface surface;
    struct xmesa_renderbuffer *xrb;
 };
 
@@ -618,8 +618,15 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint format);
 extern struct pipe_surface *
 xmesa_new_color_surface(struct pipe_context *pipe, GLuint format);
 
-extern const GLuint *
-xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats);
+extern const uint *
+xmesa_supported_formats(struct pipe_context *pipe, uint *numFormats);
 
+extern void
+xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
+                    uint x, uint y, uint w, uint h, float *p);
+
+extern void
+xmesa_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps,
+                    uint x, uint y, uint w, uint h, const float *p);
 
 #endif
index a3a0296598ce8751dcb78c191d046cf51b887358..7e02b751bb3f19b33494f82e90fb6cfd99fdcc71 100644 (file)
@@ -134,7 +134,9 @@ struct pipe_context *failover_create( struct pipe_context *hw,
 
    failover_init_state_functions( failover );
 
+#if 0
    failover->pipe.surface_alloc = hw->surface_alloc;
+#endif
    failover->pipe.get_tex_surface = hw->get_tex_surface;
 
    failover->pipe.region_map = hw->region_map;
index a07a21c13b1cdfb089d2425fb1ecb3ddeaf60099..b4b5bd1ce575b5a84492eaae3310e78e08ab9a14 100644 (file)
 #include "i915_state.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_util.h"
+#include "pipe/p_winsys.h"
 
 
-struct i915_surface
-{
-   struct pipe_surface surface;
-   /* anything else? */
-};
+#define CLIP_TILE \
+   do { \
+      if (x >= ps->width) \
+         return; \
+      if (y >= ps->height) \
+         return; \
+      if (x + w > ps->width) \
+         w = ps->width - x; \
+      if (y + h > ps->height) \
+         h = ps->height -y; \
+   } while(0)
 
 
 /**
@@ -53,30 +60,44 @@ i915_get_tile_rgba(struct pipe_context *pipe,
    unsigned i, j;
    unsigned w0 = w;
 
-   assert(ps->format == PIPE_FORMAT_U_A8_R8_G8_B8);
-
-#if 0
-   assert(x + w <= ps->width);
-   assert(y + h <= ps->height);
-#else
-   /* temp clipping hack */
-   if (x + w > ps->width)
-      w = ps->width - x;
-   if (y + h > ps->height)
-      h = ps->height -y;
-#endif
-   for (i = 0; i < h; i++) {
-      float *pRow = p;
-      for (j = 0; j < w; j++) {
-         const unsigned pixel = src[j];
-         pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
-         pRow[1] = UBYTE_TO_FLOAT((pixel >>  8) & 0xff);
-         pRow[2] = UBYTE_TO_FLOAT((pixel >>  0) & 0xff);
-         pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
-         pRow += 4;
+   CLIP_TILE;
+
+   switch (ps->format) {
+   case PIPE_FORMAT_U_A8_R8_G8_B8:
+      for (i = 0; i < h; i++) {
+         float *pRow = p;
+         for (j = 0; j < w; j++) {
+            const unsigned pixel = src[j];
+            pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
+            pRow[1] = UBYTE_TO_FLOAT((pixel >>  8) & 0xff);
+            pRow[2] = UBYTE_TO_FLOAT((pixel >>  0) & 0xff);
+            pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
+            pRow += 4;
+         }
+         src += ps->region->pitch;
+         p += w0 * 4;
+      }
+      break;
+   case PIPE_FORMAT_S8_Z24:
+      {
+         const float scale = 1.0 / (float) 0xffffff;
+         for (i = 0; i < h; i++) {
+            float *pRow = p;
+            for (j = 0; j < w; j++) {
+               const unsigned pixel = src[j];
+               pRow[0] =
+               pRow[1] =
+               pRow[2] =
+               pRow[3] = (pixel & 0xffffff) * scale;
+               pRow += 4;
+            }
+            src += ps->region->pitch;
+            p += w0 * 4;
+         }
       }
-      src += ps->region->pitch;
-      p += w0 * 4;
+      break;
+   default:
+      assert(0);
    }
 }
 
@@ -86,34 +107,122 @@ i915_put_tile_rgba(struct pipe_context *pipe,
                    struct pipe_surface *ps,
                    uint x, uint y, uint w, uint h, const float *p)
 {
-   /* any need to put tiles into i915 surfaces? */
+   /* TODO */
    assert(0);
 }
 
 
+/*
+ * XXX note: same as code in sp_surface.c
+ */
+static void
+i915_get_tile(struct pipe_context *pipe,
+              struct pipe_surface *ps,
+              uint x, uint y, uint w, uint h,
+              void *p, int dst_stride)
+{
+   const uint cpp = ps->region->cpp;
+   const uint w0 = w;
+   const ubyte *pSrc;
+   ubyte *pDest;
+   uint i;
 
-static struct pipe_surface *
-i915_surface_alloc(struct pipe_context *pipe, unsigned format)
+   assert(ps->region->map);
+
+   CLIP_TILE;
+
+   if (dst_stride == 0) {
+      dst_stride = w0 * cpp;
+   }
+
+   pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+   pDest = (ubyte *) p;
+
+   for (i = 0; i < h; i++) {
+      memcpy(pDest, pSrc, w0 * cpp);
+      pDest += dst_stride;
+      pSrc += ps->region->pitch * cpp;
+   }
+}
+
+
+/*
+ * XXX note: same as code in sp_surface.c
+ */
+static void
+i915_put_tile(struct pipe_context *pipe,
+              struct pipe_surface *ps,
+              uint x, uint y, uint w, uint h,
+              const void *p, int src_stride)
 {
-   struct i915_surface *surf = CALLOC_STRUCT(i915_surface);
+   const uint cpp = ps->region->cpp;
+   const uint w0 = w;
+   const ubyte *pSrc;
+   ubyte *pDest;
+   uint i;
+
+   assert(ps->region->map);
+
+   CLIP_TILE;
+
+   if (src_stride == 0) {
+      src_stride = w0 * cpp;
+   }
+
+   pSrc = (const ubyte *) p;
+   pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+
+   for (i = 0; i < h; i++) {
+      memcpy(pDest, pSrc, w0 * cpp);
+      pDest += ps->region->pitch * cpp;
+      pSrc += src_stride;
+   }
+}
 
-   if (!surf)
-      return NULL;
 
-   surf->surface.format = format;
-   surf->surface.refcount = 1;
+/*
+ * XXX note: same as code in sp_surface.c
+ */
+static struct pipe_surface *
+i915_get_tex_surface(struct pipe_context *pipe,
+                     struct pipe_mipmap_tree *mt,
+                     unsigned face, unsigned level, unsigned zslice)
+{
+   struct pipe_surface *ps;
+   unsigned offset;  /* in bytes */
 
-   //   surf->surface.get_tile = i915_get_tile;
-   //   surf->surface.put_tile = i915_put_tile;
+   offset = mt->level[level].level_offset;
 
-   return &surf->surface;
+   if (mt->target == PIPE_TEXTURE_CUBE) {
+      offset += mt->level[level].image_offset[face] * mt->cpp;
+   }
+   else if (mt->target == PIPE_TEXTURE_3D) {
+      offset += mt->level[level].image_offset[zslice] * mt->cpp;
+   }
+   else {
+      assert(face == 0);
+      assert(zslice == 0);
+   }
+
+   ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
+   if (ps) {
+      assert(ps->format);
+      assert(ps->refcount);
+      pipe_region_reference(&ps->region, mt->region);
+      ps->width = mt->level[level].width;
+      ps->height = mt->level[level].height;
+      ps->offset = offset;
+   }
+   return ps;
 }
 
 
 void
 i915_init_surface_functions(struct i915_context *i915)
 {
-   i915->pipe.surface_alloc = i915_surface_alloc;
+   i915->pipe.get_tex_surface = i915_get_tex_surface;
+   i915->pipe.get_tile = i915_get_tile;
+   i915->pipe.put_tile = i915_put_tile;
    i915->pipe.get_tile_rgba = i915_get_tile_rgba;
    i915->pipe.put_tile_rgba = i915_put_tile_rgba;
 }
index b9de3667e5126c52181196eec7df959d32450f1f..3a041f158b0e1b653f52c476f4e8bcb048f42a48 100644 (file)
@@ -176,13 +176,7 @@ struct pipe_context {
                                unsigned index,
                                const struct pipe_feedback_buffer *);
 
-   /*
-    * Surface functions
-    * This might go away...
-    */
-   struct pipe_surface *(*surface_alloc)(struct pipe_context *pipe,
-                                         unsigned format);
-
+   /** Get a surface which is a "view" into a texture */
    struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
                                            struct pipe_mipmap_tree *texture,
                                            unsigned face, unsigned level,
@@ -198,7 +192,6 @@ struct pipe_context {
                     struct pipe_surface *ps,
                     uint x, uint y, uint w, uint h,
                     const void *p, int src_stride);
-
    /* XXX temporary here, move these to softpipe */
    void (*get_tile_rgba)(struct pipe_context *pipe, struct pipe_surface *ps,
                          uint x, uint y, uint w, uint h, float *p);
index 3b04c44733c0640a5a08aa13de682ba9e216f305..10a2caf1a242c6de3c22707355fc61a2f1cb670e 100644 (file)
@@ -77,6 +77,10 @@ struct pipe_winsys
    void (*region_release)(struct pipe_winsys *ws, struct pipe_region **r);
 
 
+   /** allocate a new surface (no context dependency) */
+   struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws,
+                                         unsigned format);
+
    /**
     * The buffer manager is modeled after the dri_bufmgr interface, which 
     * in turn is modeled after the ARB_vertex_buffer_object extension,  
index 4accafa38458e94c33330e8de0f09eda06fc1997..d1aa2aba97ac878c138e86dd00fdce70521c7757 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "pipe/p_defines.h"
 #include "pipe/p_util.h"
+#include "pipe/p_winsys.h"
 #include "sp_context.h"
 #include "sp_state.h"
 #include "sp_surface.h"
@@ -361,7 +362,7 @@ i8_get_tile(struct pipe_surface *ps,
 
 static void
 a8_l8_get_tile(struct pipe_surface *ps,
-            unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+               unsigned x, unsigned y, unsigned w, unsigned h, float *p)
 {
    const ushort *src
       = ((const ushort *) (ps->region->map + ps->offset))
@@ -466,7 +467,7 @@ void
 softpipe_init_surface_funcs(struct softpipe_surface *sps)
 {
    assert(sps->surface.format);
-
+#if 0
    switch (sps->surface.format) {
    case PIPE_FORMAT_U_A8_R8_G8_B8:
       sps->get_tile = a8r8g8b8_get_tile;
@@ -507,6 +508,7 @@ softpipe_init_surface_funcs(struct softpipe_surface *sps)
    default:
       assert(0);
    }
+#endif
 }
 
 
@@ -555,7 +557,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
       assert(zslice == 0);
    }
 
-   ps = pipe->surface_alloc(pipe, mt->format);
+   ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
    if (ps) {
       assert(ps->format);
       assert(ps->refcount);
@@ -637,26 +639,90 @@ softpipe_put_tile(struct pipe_context *pipe,
 
 
 /* XXX TEMPORARY */
-static void
-get_tile_rgba_generic(struct pipe_context *pipe,
-                      struct pipe_surface *ps,
-                      uint x, uint y, uint w, uint h,
-                      float *p)
+void
+softpipe_get_tile_rgba(struct pipe_context *pipe,
+                       struct pipe_surface *ps,
+                       uint x, uint y, uint w, uint h,
+                       float *p)
 {
-   struct softpipe_surface *sps = softpipe_surface(ps);
-   sps->get_tile(ps, x, y, w, h, p);
+   switch (ps->format) {
+   case PIPE_FORMAT_U_A8_R8_G8_B8:
+      a8r8g8b8_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_A1_R5_G5_B5:
+      a1r5g5b5_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_L8:
+      l8_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_A8:
+      a8_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_I8:
+      i8_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_A8_L8:
+      a8_l8_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_S_R16_G16_B16_A16:
+      r16g16b16a16_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_Z16:
+      z16_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_Z32:
+      z32_get_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_S8_Z24:
+      s8z24_get_tile(ps, x, y, w, h, p);
+      break;
+   default:
+      assert(0);
+   }
 }
 
 
 /* XXX TEMPORARY */
-static void
-put_tile_rgba_generic(struct pipe_context *pipe,
-                      struct pipe_surface *ps,
-                      uint x, uint y, uint w, uint h,
-                      const float *p)
+void
+softpipe_put_tile_rgba(struct pipe_context *pipe,
+                       struct pipe_surface *ps,
+                       uint x, uint y, uint w, uint h,
+                       const float *p)
 {
-   struct softpipe_surface *sps = softpipe_surface(ps);
-   sps->put_tile(ps, x, y, w, h, p);
+   switch (ps->format) {
+   case PIPE_FORMAT_U_A8_R8_G8_B8:
+      a8r8g8b8_put_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_A1_R5_G5_B5:
+      /*a1r5g5b5_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_U_L8:
+      /*l8_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_U_A8:
+      /*a8_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_U_I8:
+      /*i8_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_U_A8_L8:
+      /*a8_l8_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_S_R16_G16_B16_A16:
+      r16g16b16a16_put_tile(ps, x, y, w, h, p);
+      break;
+   case PIPE_FORMAT_U_Z16:
+      /*z16_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_U_Z32:
+      /*z32_put_tile(ps, x, y, w, h, p);*/
+      break;
+   case PIPE_FORMAT_S8_Z24:
+      /*s8z24_put_tile(ps, x, y, w, h, p);*/
+      break;
+   default:
+      assert(0);
+   }
 }
 
 
@@ -664,11 +730,12 @@ put_tile_rgba_generic(struct pipe_context *pipe,
 void
 sp_init_surface_functions(struct softpipe_context *sp)
 {
+#if 0
    sp->pipe.surface_alloc = softpipe_surface_alloc;
-
+#endif
    sp->pipe.get_tile = softpipe_get_tile;
    sp->pipe.put_tile = softpipe_put_tile;
 
-   sp->pipe.get_tile_rgba = get_tile_rgba_generic;
-   sp->pipe.put_tile_rgba = put_tile_rgba_generic;
+   sp->pipe.get_tile_rgba = softpipe_get_tile_rgba;
+   sp->pipe.put_tile_rgba = softpipe_put_tile_rgba;
 }
index af6533d4f072805ae41a420b3d3a5f41683e3d1e..359a438c869f176479a540532e3ef0d958ef4ec5 100644 (file)
@@ -46,20 +46,33 @@ struct softpipe_tile_cache;
 struct softpipe_surface {
    struct pipe_surface surface;
 
+#if 0
    /* XXX these are temporary here */
    void (*get_tile)(struct pipe_surface *ps,
                     uint x, uint y, uint w, uint h, float *p);
    void (*put_tile)(struct pipe_surface *ps,
                     uint x, uint y, uint w, uint h, const float *p);
+#endif
 };
 
-
 extern struct pipe_surface *
 softpipe_get_tex_surface(struct pipe_context *pipe,
                          struct pipe_mipmap_tree *mt,
                          unsigned face, unsigned level, unsigned zslice);
 
 
+extern void
+softpipe_get_tile_rgba(struct pipe_context *pipe,
+                       struct pipe_surface *ps,
+                       uint x, uint y, uint w, uint h,
+                       float *p);
+
+extern void
+softpipe_put_tile_rgba(struct pipe_context *pipe,
+                       struct pipe_surface *ps,
+                       uint x, uint y, uint w, uint h,
+                       const float *p);
+
 extern void
 softpipe_init_surface_funcs(struct softpipe_surface *sps);
 
index f22132b3cf5f48c9c838802eaef04964b14c06b7..160edc427485fe6da56192f4c58e6e36650b4535 100644 (file)
@@ -84,7 +84,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    cpp = info->size;
 
    if (!strb->surface) {
-      strb->surface = pipe->surface_alloc(pipe, pipeFormat);
+      strb->surface = pipe->winsys->surface_alloc(pipe->winsys, pipeFormat);
       assert(strb->surface);
       if (!strb->surface)
          return GL_FALSE;