Mesa (gallium-array-textures): mesa/st: adapt to interface changes

Roland Scheidegger sroland at kemper.freedesktop.org
Mon Jun 14 03:40:42 PDT 2010


Module: Mesa
Branch: gallium-array-textures
Commit: 3232d11fe3ebf7686286013c357b404714853984
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3232d11fe3ebf7686286013c357b404714853984

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Mon Jun 14 11:40:04 2010 +0100

mesa/st: adapt to interface changes

still need to fix pipe_surface sharing
(as that is now per-context).
Also broken is depth0 handling - half the code assumes
this is also used for array textures (and hence by extension
of that cube maps would have depth 6), half the code does not...

---

 src/mesa/state_tracker/st_atom_framebuffer.c   |   14 ++--
 src/mesa/state_tracker/st_atom_pixeltransfer.c |    4 +-
 src/mesa/state_tracker/st_cb_accum.c           |   24 ++++----
 src/mesa/state_tracker/st_cb_bitmap.c          |   14 ++--
 src/mesa/state_tracker/st_cb_blit.c            |   27 +++------
 src/mesa/state_tracker/st_cb_drawpixels.c      |   45 +++++++--------
 src/mesa/state_tracker/st_cb_fbo.c             |   24 ++++----
 src/mesa/state_tracker/st_cb_readpixels.c      |   18 +++---
 src/mesa/state_tracker/st_cb_texture.c         |   74 +++++++++++-------------
 src/mesa/state_tracker/st_gen_mipmap.c         |   41 ++++++++-----
 src/mesa/state_tracker/st_manager.c            |   11 ++--
 src/mesa/state_tracker/st_texture.c            |   60 ++++++++++---------
 12 files changed, 175 insertions(+), 181 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 036bc60..5711999 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -51,7 +51,7 @@ static void
 update_renderbuffer_surface(struct st_context *st,
                             struct st_renderbuffer *strb)
 {
-   struct pipe_screen *screen = st->pipe->screen;
+   struct pipe_context *pipe = st->pipe;
    struct pipe_resource *resource = strb->rtt->pt;
    int rtt_width = strb->Base.Width;
    int rtt_height = strb->Base.Height;
@@ -68,12 +68,12 @@ update_renderbuffer_surface(struct st_context *st,
 
             pipe_surface_reference(&strb->surface, NULL);
 
-            strb->surface = screen->get_tex_surface(screen,
-						    resource,
-						    strb->rtt_face,
-						    level,
-						    strb->rtt_slice,
-						    PIPE_BIND_RENDER_TARGET);
+            strb->surface = pipe->create_surface(pipe,
+                                                 resource,
+                                                 level,
+                                                 strb->rtt_face + strb->rtt_slice,
+                                                 strb->rtt_face + strb->rtt_slice,
+                                                 PIPE_BIND_RENDER_TARGET);
 #if 0
             printf("-- alloc new surface %d x %d into tex %p\n",
                    strb->surface->width, strb->surface->height,
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index b8644fa..b214383 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -150,8 +150,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
    uint i, j;
 
    transfer = pipe_get_transfer(st_context(ctx)->pipe,
-					     pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
-					     0, 0, texSize, texSize);
+                                pt, 0, 0, PIPE_TRANSFER_WRITE,
+                                0, 0, texSize, texSize);
    dest = (uint *) pipe_transfer_map(pipe, transfer);
 
    /* Pack four 1D maps into a 2D texture:
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 425e798..099df0b 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -138,10 +138,10 @@ accum_accum(struct st_context *st, GLfloat value,
       debug_printf("%s: fallback processing\n", __FUNCTION__);
 
    color_trans = pipe_get_transfer(st->pipe,
-						color_strb->texture,
-						0, 0, 0,
-						PIPE_TRANSFER_READ, xpos, ypos,
-						width, height);
+                                   color_strb->texture,
+                                   0, 0,
+                                   PIPE_TRANSFER_READ, xpos, ypos,
+                                   width, height);
 
    buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
@@ -187,9 +187,9 @@ accum_load(struct st_context *st, GLfloat value,
       debug_printf("%s: fallback processing\n", __FUNCTION__);
 
    color_trans = pipe_get_transfer(st->pipe, color_strb->texture,
-						0, 0, 0,
-						PIPE_TRANSFER_READ, xpos, ypos,
-						width, height);
+                                   0, 0,
+                                   PIPE_TRANSFER_READ, xpos, ypos,
+                                   width, height);
 
    buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
@@ -241,12 +241,12 @@ accum_return(GLcontext *ctx, GLfloat value,
       usage = PIPE_TRANSFER_READ_WRITE;
    else
       usage = PIPE_TRANSFER_WRITE;
-   
+
    color_trans = pipe_get_transfer(st_context(ctx)->pipe,
-						color_strb->texture, 0, 0, 0,
-						usage,
-						xpos, ypos,
-						width, height);
+                                   color_strb->texture, 0, 0,
+                                   usage,
+                                   xpos, ypos,
+                                   width, height);
 
    if (usage & PIPE_TRANSFER_READ)
       pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 5aca110..c4e7738 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -282,9 +282,9 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
       return NULL;
    }
 
-   transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0,
-					   PIPE_TRANSFER_WRITE,
-					   0, 0, width, height);
+   transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
+                                PIPE_TRANSFER_WRITE,
+                                0, 0, width, height);
 
    dest = pipe_transfer_map(pipe, transfer);
 
@@ -579,10 +579,10 @@ create_cache_trans(struct st_context *st)
    /* Map the texture transfer.
     * Subsequent glBitmap calls will write into the texture image.
     */
-   cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, 0,
-					       PIPE_TRANSFER_WRITE, 0, 0,
-					       BITMAP_CACHE_WIDTH,
-					       BITMAP_CACHE_HEIGHT);
+   cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0,
+                                    PIPE_TRANSFER_WRITE, 0, 0,
+                                    BITMAP_CACHE_WIDTH,
+                                    BITMAP_CACHE_HEIGHT);
    cache->buffer = pipe_transfer_map(pipe, cache->trans);
 
    /* init image to all 0xff */
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 1f73f50..98870c1 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -114,17 +114,14 @@ st_BlitFramebuffer(GLcontext *ctx,
             st_texture_object(srcAtt->Texture);
          struct st_renderbuffer *dstRb =
             st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
-         struct pipe_subresource srcSub;
          struct pipe_surface *dstSurf = dstRb->surface;
 
          if (!srcObj->pt)
             return;
 
-         srcSub.face = srcAtt->CubeMapFace;
-         srcSub.level = srcAtt->TextureLevel;
-
-         util_blit_pixels(st->blit, srcObj->pt, srcSub,
-                          srcX0, srcY0, srcX1, srcY1, srcAtt->Zoffset,
+         util_blit_pixels(st->blit, srcObj->pt, srcAtt->TextureLevel,
+                          srcX0, srcY0, srcX1, srcY1,
+                          srcAtt->Zoffset + srcAtt->CubeMapFace,
                           dstSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
       }
@@ -135,14 +132,11 @@ st_BlitFramebuffer(GLcontext *ctx,
             st_renderbuffer(drawFB->_ColorDrawBuffers[0]);
          struct pipe_surface *srcSurf = srcRb->surface;
          struct pipe_surface *dstSurf = dstRb->surface;
-         struct pipe_subresource srcSub;
-
-         srcSub.face = srcSurf->face;
-         srcSub.level = srcSurf->level;
 
          util_blit_pixels(st->blit,
-                          srcRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
-                          srcSurf->zslice,
+                          srcRb->texture, srcSurf->level,
+                          srcX0, srcY0, srcX1, srcY1,
+                          srcSurf->first_layer,
                           dstSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
       }
@@ -174,17 +168,14 @@ st_BlitFramebuffer(GLcontext *ctx,
       if ((mask & depthStencil) == depthStencil &&
           srcDepthSurf == srcStencilSurf &&
           dstDepthSurf == dstStencilSurf) {
-         struct pipe_subresource srcSub;
-
-         srcSub.face = srcDepthRb->surface->face;
-         srcSub.level = srcDepthRb->surface->level;
 
          /* Blitting depth and stencil values between combined
           * depth/stencil buffers.  This is the ideal case for such buffers.
           */
          util_blit_pixels(st->blit,
-                          srcDepthRb->texture, srcSub, srcX0, srcY0, srcX1, srcY1,
-                          srcDepthRb->surface->zslice,
+                          srcDepthRb->texture, srcDepthRb->surface->level,
+                          srcX0, srcY0, srcX1, srcY1,
+                          srcDepthRb->surface->first_layer,
                           dstDepthSurf, dstX0, dstY0, dstX1, dstY1,
                           0.0, pFilter);
       }
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index f74d8cd..a0597db 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -385,9 +385,9 @@ make_texture(struct st_context *st,
       /* we'll do pixel transfer in a fragment shader */
       ctx->_ImageTransferState = 0x0;
 
-      transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0,
-					      PIPE_TRANSFER_WRITE, 0, 0,
-					      width, height);
+      transfer = pipe_get_transfer(st->pipe, pt, 0, 0,
+                                   PIPE_TRANSFER_WRITE, 0, 0,
+                                   width, height);
 
       /* map texture transfer */
       dest = pipe_transfer_map(pipe, transfer);
@@ -686,9 +686,9 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    else
       usage = PIPE_TRANSFER_WRITE;
 
-   pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0,
-				       usage, x, y,
-				       width, height);
+   pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0,
+                                     usage, x, y,
+                                     width, height);
 
    stmap = pipe_transfer_map(pipe, pt);
 
@@ -881,15 +881,15 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
       usage = PIPE_TRANSFER_READ_WRITE;
    else
       usage = PIPE_TRANSFER_WRITE;
-   
+
    if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
       dsty = rbDraw->Base.Height - dsty - height;
    }
 
    ptDraw = pipe_get_transfer(st_context(ctx)->pipe,
-					   rbDraw->texture, 0, 0, 0,
-					   usage, dstx, dsty,
-					   width, height);
+                              rbDraw->texture, 0, 0,
+                              usage, dstx, dsty,
+                              width, height);
 
    assert(util_format_get_blockwidth(ptDraw->resource->format) == 1);
    assert(util_format_get_blockheight(ptDraw->resource->format) == 1);
@@ -1056,27 +1056,24 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
    /* Make temporary texture which is a copy of the src region.
     */
    if (srcFormat == texFormat) {
-      struct pipe_subresource srcsub, dstsub;
-      srcsub.face = 0;
-      srcsub.level = 0;
-      dstsub.face = 0;
-      dstsub.level = 0;
-      /* copy source framebuffer surface into mipmap/texture */
+      struct pipe_box src_box;
+      u_box_2d(readX, readY, readW, readH, &src_box);
+    /* copy source framebuffer surface into mipmap/texture */
       pipe->resource_copy_region(pipe,
                                  pt,                                /* dest tex */
-                                 dstsub,
+                                 0,
                                  pack.SkipPixels, pack.SkipRows, 0, /* dest pos */
                                  rbRead->texture,                   /* src tex */
-                                 srcsub,
-                                 readX, readY, 0, readW, readH);    /* src region */
+                                 0,
+                                 &src_box);
 
    }
    else {
       /* CPU-based fallback/conversion */
       struct pipe_transfer *ptRead =
-         pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, 0,
-                                        PIPE_TRANSFER_READ,
-                                        readX, readY, readW, readH);
+         pipe_get_transfer(st->pipe, rbRead->texture, 0, 0,
+                           PIPE_TRANSFER_READ,
+                           readX, readY, readW, readH);
       struct pipe_transfer *ptTex;
       enum pipe_transfer_usage transfer_usage;
 
@@ -1088,8 +1085,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
 
-      ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, 0, transfer_usage,
-                                             0, 0, width, height);
+      ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, transfer_usage,
+                                0, 0, width, height);
 
       /* copy image from ptRead surface to ptTex surface */
       if (type == GL_COLOR) {
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 46f27ce..4a6b5db 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -65,6 +65,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
                               GLuint width, GLuint height)
 {
    struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = st->pipe->screen;
    struct st_renderbuffer *strb = st_renderbuffer(rb);
    enum pipe_format format;
@@ -120,7 +121,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       }
       else {
          template.bind = (PIPE_BIND_DISPLAY_TARGET |
-			  PIPE_BIND_RENDER_TARGET);
+                          PIPE_BIND_RENDER_TARGET);
       }
 
       strb->texture = screen->resource_create(screen, &template);
@@ -128,10 +129,10 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       if (!strb->texture) 
          return FALSE;
 
-      strb->surface = screen->get_tex_surface(screen,
-                                              strb->texture,
-                                              0, 0, 0,
-                                              template.bind);
+      strb->surface = pipe->create_surface(pipe,
+                                           strb->texture,
+                                           0, 0, 0,
+                                           template.bind);
       if (strb->surface) {
          assert(strb->surface->texture);
          assert(strb->surface->format);
@@ -315,7 +316,6 @@ st_render_texture(GLcontext *ctx,
 {
    struct st_context *st = st_context(ctx);
    struct pipe_context *pipe = st->pipe;
-   struct pipe_screen *screen = pipe->screen;
    struct st_renderbuffer *strb;
    struct gl_renderbuffer *rb;
    struct pipe_resource *pt = st_get_texobj_resource(att->Texture);
@@ -369,12 +369,12 @@ st_render_texture(GLcontext *ctx,
    assert(strb->rtt_level <= strb->texture->last_level);
 
    /* new surface for rendering into the texture */
-   strb->surface = screen->get_tex_surface(screen,
-                                           strb->texture,
-                                           strb->rtt_face,
-                                           strb->rtt_level,
-                                           strb->rtt_slice,
-                                           PIPE_BIND_RENDER_TARGET);
+   strb->surface = pipe->create_surface(pipe,
+                                        strb->texture,
+                                        strb->rtt_level,
+                                        strb->rtt_face + strb->rtt_slice,
+                                        strb->rtt_face + strb->rtt_slice,
+                                        PIPE_BIND_RENDER_TARGET);
 
    strb->format = pt->format;
 
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index b8493da..547d316 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -75,9 +75,9 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    /* Create a read transfer from the renderbuffer's texture */
 
    pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture,
-				       0, 0, 0,
-				       PIPE_TRANSFER_READ, x, y,
-				       width, height);
+                          0, 0,
+                          PIPE_TRANSFER_READ, x, y,
+                          width, height);
 
    /* map the stencil buffer */
    stmap = pipe_transfer_map(pipe, pt);
@@ -231,9 +231,9 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
       }
 
       trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture,
-					     0, 0, 0,
-					     PIPE_TRANSFER_READ, x, y,
-					     width, height);
+                                0, 0,
+                                PIPE_TRANSFER_READ, x, y,
+                                width, height);
       if (!trans) {
          return GL_FALSE;
       }
@@ -395,9 +395,9 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
 
    /* Create a read transfer from the renderbuffer's texture */
    trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture,
-					  0, 0, 0,
-					  PIPE_TRANSFER_READ, x, y,
-					  width, height);
+                             0, 0,
+                             PIPE_TRANSFER_READ, x, y,
+                             width, height);
 
    /* determine bottom-to-top vs. top-to-bottom order */
    if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 647898e..e4420d4 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -61,7 +61,7 @@
 #include "util/u_surface.h"
 #include "util/u_sampler.h"
 #include "util/u_math.h"
-
+#include "util/u_box.h"
 
 #define DBG if (0) printf
 
@@ -431,9 +431,9 @@ compress_with_blit(GLcontext * ctx,
    }
 
    /* get destination surface (in the compressed texture) */
-   dst_surface = screen->get_tex_surface(screen, stImage->pt,
-                                         stImage->face, stImage->level, 0,
-                                         0 /* flags */);
+   dst_surface = pipe->create_surface(pipe, stImage->pt, stImage->level,
+                                      stImage->face, stImage->face,
+                                      PIPE_BIND_RENDER_TARGET /* flags */);
    if (!dst_surface) {
       /* can't render into this format (or other problem) */
       return GL_FALSE;
@@ -465,9 +465,9 @@ compress_with_blit(GLcontext * ctx,
    /* Put user's tex data into the temporary texture
     */
    tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, src_tex,
-					     0, 0, 0, /* face, level are zero */
-					     PIPE_TRANSFER_WRITE,
-					     0, 0, width, height); /* x, y, w, h */
+                                0, 0, /* layer, level are zero */
+                                PIPE_TRANSFER_WRITE,
+                                0, 0, width, height); /* x, y, w, h */
    map = pipe_transfer_map(pipe, tex_xfer);
 
    _mesa_texstore(ctx, 2, GL_RGBA, mesa_format,
@@ -841,7 +841,6 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
 {
    struct st_context *st = st_context(ctx);
    struct pipe_context *pipe = st->pipe;
-   struct pipe_screen *screen = pipe->screen;
    struct st_texture_image *stImage = st_texture_image(texImage);
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct pipe_sampler_view *src_view =
@@ -855,7 +854,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
 		    PIPE_BIND_TRANSFER_READ);
 
    /* create temp / dest surface */
-   if (!util_create_rgba_surface(screen, width, height, bind,
+   if (!util_create_rgba_surface(pipe, width, height, bind,
                                  &dst_texture, &dst_surface)) {
       _mesa_problem(ctx, "util_create_rgba_surface() failed "
                     "in decompress_with_blit()");
@@ -875,9 +874,9 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
 
    /* map the dst_surface so we can read from it */
    tex_xfer = pipe_get_transfer(st_context(ctx)->pipe,
-					     dst_texture, 0, 0, 0,
-					     PIPE_TRANSFER_READ,
-					     0, 0, width, height);
+                                dst_texture, 0, 0,
+                                PIPE_TRANSFER_READ,
+                                0, 0, width, height);
 
    pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels);
 
@@ -1294,7 +1293,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
    struct pipe_transfer *src_trans;
    GLvoid *texDest;
    enum pipe_transfer_usage transfer_usage;
-   
+
    if (ST_DEBUG & DEBUG_FALLBACK)
       debug_printf("%s: fallback processing\n", __FUNCTION__);
 
@@ -1305,11 +1304,11 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
    }
 
    src_trans = pipe_get_transfer(st_context(ctx)->pipe,
-					       strb->texture,
-					       0, 0, 0,
-					       PIPE_TRANSFER_READ,
-					       srcX, srcY,
-					       width, height);
+                                 strb->texture,
+                                 0, 0,
+                                 PIPE_TRANSFER_READ,
+                                 srcX, srcY,
+                                 width, height);
 
    if ((baseFormat == GL_DEPTH_COMPONENT ||
         baseFormat == GL_DEPTH_STENCIL) &&
@@ -1318,7 +1317,8 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
    else
       transfer_usage = PIPE_TRANSFER_WRITE;
 
-   texDest = st_texture_image_map(st, stImage, 0, transfer_usage,
+   /* XXX this used to ignore destZ param */
+   texDest = st_texture_image_map(st, stImage, destZ, transfer_usage,
                                   destX, destY, width, height);
 
    if (baseFormat == GL_DEPTH_COMPONENT ||
@@ -1576,27 +1576,23 @@ st_copy_texsubimage(GLcontext *ctx,
 
       if (matching_base_formats &&
           src_format == dest_format &&
-          !do_flip) 
+          !do_flip)
       {
          /* use surface_copy() / blit */
-         struct pipe_subresource subdst, subsrc;
-         subdst.face = stImage->face;
-         subdst.level = stImage->level;
-         subsrc.face = strb->surface->face;
-         subsrc.level = strb->surface->level;
+         struct pipe_box src_box;
+         u_box_2d_zslice(srcX, srcY, strb->surface->first_layer,
+                         width, height, &src_box);
 
          /* for resource_copy_region(), y=0=top, always */
          pipe->resource_copy_region(pipe,
                                     /* dest */
                                     stImage->pt,
-                                    subdst,
-                                    destX, destY, destZ,
+                                    stImage->level,
+                                    destX, destY, destZ + stImage->face,
                                     /* src */
                                     strb->texture,
-                                    subsrc,
-                                    srcX, srcY, strb->surface->zslice,
-                                    /* size */
-                                    width, height);
+                                    strb->surface->level,
+                                    &src_box);
          use_fallback = GL_FALSE;
       }
       else if (format_writemask &&
@@ -1612,12 +1608,12 @@ st_copy_texsubimage(GLcontext *ctx,
                                            0)) {
          /* draw textured quad to do the copy */
          GLint srcY0, srcY1;
-         struct pipe_subresource subsrc;
 
-         dest_surface = screen->get_tex_surface(screen, stImage->pt,
-                                                stImage->face, stImage->level,
-                                                destZ,
-                                                PIPE_BIND_RENDER_TARGET);
+         dest_surface = pipe->create_surface(pipe, stImage->pt,
+                                             stImage->level,
+                                             stImage->face + destZ,
+                                             stImage->face + destZ,
+                                             PIPE_BIND_RENDER_TARGET);
 
          if (do_flip) {
             srcY1 = strb->Base.Height - srcY - height;
@@ -1627,15 +1623,13 @@ st_copy_texsubimage(GLcontext *ctx,
             srcY0 = srcY;
             srcY1 = srcY0 + height;
          }
-         subsrc.face = strb->surface->face;
-         subsrc.level = strb->surface->level;
 
          util_blit_pixels_writemask(st->blit,
                                     strb->texture,
-                                    subsrc,
+                                    strb->surface->level,
                                     srcX, srcY0,
                                     srcX + width, srcY1,
-                                    strb->surface->zslice,
+                                    strb->surface->first_layer,
                                     dest_surface,
                                     destX, destY,
                                     destX + width, destY + height,
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 2d587df..b06a8a3 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -80,11 +80,15 @@ st_render_mipmap(struct st_context *st,
    const uint face = _mesa_tex_target_to_face(target);
 
    assert(psv->texture == stObj->pt);
-   assert(target != GL_TEXTURE_3D); /* not done yet */
+#if 0
+   assert(target != GL_TEXTURE_3D); /* implemented but untested */
+#endif
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, psv->format, psv->texture->target, 0,
-                                    PIPE_BIND_RENDER_TARGET, 0)) {
+   /* XXX should probably kill this and always use util_gen_mipmap
+      since this implements a sw fallback as well */
+   if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
+                                    0, PIPE_BIND_RENDER_TARGET, 0)) {
       return FALSE;
    }
 
@@ -162,12 +166,12 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
    struct pipe_resource *pt = st_get_texobj_resource(texObj);
    const uint baseLevel = texObj->BaseLevel;
    const uint lastLevel = pt->last_level;
-   const uint face = _mesa_tex_target_to_face(target), zslice = 0;
+   const uint face = _mesa_tex_target_to_face(target);
    uint dstLevel;
    GLenum datatype;
    GLuint comps;
    GLboolean compressed;
-   
+
    if (ST_DEBUG & DEBUG_FALLBACK)
       debug_printf("%s: fallback processing\n", __FUNCTION__);
 
@@ -190,25 +194,26 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
       const uint srcLevel = dstLevel - 1;
       const uint srcWidth = u_minify(pt->width0, srcLevel);
       const uint srcHeight = u_minify(pt->height0, srcLevel);
-      const uint srcDepth = u_minify(pt->depth0, srcLevel);
+      const uint srcDepth = pt->target == PIPE_TEXTURE_3D ?
+                            u_minify(pt->depth0, srcLevel) : 1;
       const uint dstWidth = u_minify(pt->width0, dstLevel);
       const uint dstHeight = u_minify(pt->height0, dstLevel);
-      const uint dstDepth = u_minify(pt->depth0, dstLevel);
+      const uint dstDepth = pt->target == PIPE_TEXTURE_3D ?
+                            u_minify(pt->depth0, dstLevel) : 1;
       struct pipe_transfer *srcTrans, *dstTrans;
       const ubyte *srcData;
       ubyte *dstData;
       int srcStride, dstStride;
 
-      srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face,
-						srcLevel, zslice,
-						PIPE_TRANSFER_READ, 0, 0,
-                                                srcWidth, srcHeight);
-						
+      srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, srcLevel,
+                                   face,
+                                   PIPE_TRANSFER_READ, 0, 0,
+                                   srcWidth, srcHeight);
 
-      dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face,
-						dstLevel, zslice,
-						PIPE_TRANSFER_WRITE, 0, 0,
-						dstWidth, dstHeight);
+      dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, dstLevel,
+                                   face,
+                                   PIPE_TRANSFER_WRITE, 0, 0,
+                                   dstWidth, dstHeight);
 
       srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans);
       dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans);
@@ -216,6 +221,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
       srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format);
       dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format);
 
+     /* this cannot work correctly for 3d since it does
+        not respect layerStride. */
       if (compressed) {
          const enum pipe_format format = pt->format;
          const uint bw = util_format_get_blockwidth(format);
@@ -373,6 +380,8 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
     * use the software fallback.
     */
    if (!st_render_mipmap(st, target, stObj, baseLevel, lastLevel)) {
+      /* since the util code actually also has a fallback, should
+         probably make it never fail and kill this */
       fallback_generate_mipmap(ctx, target, texObj);
    }
 
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 8c3dfb3..2cd2ec5 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -149,7 +149,7 @@ buffer_index_to_attachment(gl_buffer_index index)
 static void
 st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
 {
-   struct pipe_screen *screen = st->pipe->screen;
+   struct pipe_context *pipe = st->pipe;
    struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
    uint width, height;
    unsigned i;
@@ -186,8 +186,8 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
          continue;
       }
 
-      ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0,
-				   PIPE_BIND_RENDER_TARGET);
+      ps = pipe->create_surface(pipe, textures[i], 0, 0, 0,
+                                PIPE_BIND_RENDER_TARGET);
       if (ps) {
          pipe_surface_reference(&strb->surface, ps);
          pipe_resource_reference(&strb->texture, ps->texture);
@@ -742,6 +742,7 @@ st_manager_flush_frontbuffer(struct st_context *st)
 
 /**
  * Return the surface of an EGLImage.
+ * FIXME: I think this should operate on resources, not surfaces
  */
 struct pipe_surface *
 st_manager_get_egl_image_surface(struct st_context *st,
@@ -759,8 +760,8 @@ st_manager_get_egl_image_surface(struct st_context *st,
    if (!smapi->get_egl_image(smapi, &st->iface, eglimg, &stimg))
       return NULL;
 
-   ps = smapi->screen->get_tex_surface(smapi->screen,
-         stimg.texture, stimg.face, stimg.level, stimg.zslice, usage);
+   ps = st->pipe->create_surface(st->pipe,
+         stimg.texture, stimg.level, stimg.layer, stimg.layer, usage);
    pipe_resource_reference(&stimg.texture, NULL);
 
    return ps;
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index dbdf1ea..927d1be 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -136,7 +136,7 @@ st_texture_match_image(const struct pipe_resource *pt,
  */
 GLubyte *
 st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
-		     GLuint zoffset, enum pipe_transfer_usage usage,
+                     GLuint zoffset, enum pipe_transfer_usage usage,
                      GLuint x, GLuint y, GLuint w, GLuint h)
 {
    struct pipe_context *pipe = st->pipe;
@@ -144,9 +144,9 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
 
    DBG("%s \n", __FUNCTION__);
 
-   stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face,
-						    stImage->level, zoffset,
-						    usage, x, y, w, h);
+   stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->level,
+                                         stImage->face + zoffset,
+                                         usage, x, y, w, h);
 
    if (stImage->transfer)
       return pipe_transfer_map(pipe, stImage->transfer);
@@ -211,7 +211,8 @@ st_texture_image_data(struct st_context *st,
                       GLuint src_row_stride, GLuint src_image_stride)
 {
    struct pipe_context *pipe = st->pipe;
-   GLuint depth = u_minify(dst->depth0, level);
+   GLuint depth = dst->target == PIPE_TEXTURE_3D ?
+                  u_minify(dst->depth0, level) : 1;
    GLuint i;
    const GLubyte *srcUB = src;
    struct pipe_transfer *dst_transfer;
@@ -219,10 +220,10 @@ st_texture_image_data(struct st_context *st,
    DBG("%s\n", __FUNCTION__);
 
    for (i = 0; i < depth; i++) {
-      dst_transfer = pipe_get_transfer(st->pipe, dst, face, level, i,
-						  PIPE_TRANSFER_WRITE, 0, 0,
-						  u_minify(dst->width0, level),
-                                                  u_minify(dst->height0, level));
+      dst_transfer = pipe_get_transfer(st->pipe, dst, level, face + i,
+                                       PIPE_TRANSFER_WRITE, 0, 0,
+                                       u_minify(dst->width0, level),
+                                       u_minify(dst->height0, level));
 
       st_surface_data(pipe, dst_transfer,
 		      0, 0,                             /* dstx, dsty */
@@ -245,14 +246,10 @@ st_texture_image_data(struct st_context *st,
 static void
 print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src)
 {
-   struct pipe_subresource rect;
    struct pipe_transfer *xfer;
    struct pipe_box region;
    ubyte *map;
 
-   rect.face = 0;
-   rect.level = 0;
-
    region.x = src->width0 / 2;
    region.y = src->height0 / 2;
    region.z = 0;
@@ -260,7 +257,7 @@ print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src)
    region.height = 1;
    region.depth = 1;
 
-   xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, &region);
+   xfer = pipe->get_transfer(pipe, src, 0, PIPE_TRANSFER_READ, &region);
    map = pipe->transfer_map(pipe, xfer);
 
    printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]);
@@ -282,22 +279,28 @@ st_texture_image_copy(struct pipe_context *pipe,
                       struct pipe_resource *src, GLuint srcLevel,
                       GLuint face)
 {
-   GLuint width = u_minify(dst->width0, dstLevel); 
-   GLuint height = u_minify(dst->height0, dstLevel); 
-   GLuint depth = u_minify(dst->depth0, dstLevel); 
-   struct pipe_subresource dstsub, srcsub;
+   GLuint width = u_minify(dst->width0, dstLevel);
+   GLuint height = u_minify(dst->height0, dstLevel);
+   GLuint depth = dst->target == PIPE_TEXTURE_3D ?
+                  u_minify(dst->depth0, dstLevel) : 1;
+   struct pipe_box src_box;
    GLuint i;
 
    assert(u_minify(src->width0, srcLevel) == width);
    assert(u_minify(src->height0, srcLevel) == height);
-   assert(u_minify(src->depth0, srcLevel) == depth);
-
-   dstsub.face = face;
-   dstsub.level = dstLevel;
-   srcsub.face = face;
-   srcsub.level = srcLevel;
+   assert((src->target == PIPE_TEXTURE_3D ?
+          u_minify(src->depth0, srcLevel) : 1) == depth);
+
+   src_box.x = 0;
+   src_box.y = 0;
+   src_box.width = width;
+   src_box.height = height;
+   src_box.depth = 1;
    /* Loop over 3D image slices */
-   for (i = 0; i < depth; i++) {
+   /* could (and probably should) use "true" 3d box here -
+      but drivers can't quite handle it yet */
+   for (i = face; i < face + depth; i++) {
+      src_box.z = i;
 
       if (0)  {
          print_center_pixel(pipe, src);
@@ -305,12 +308,11 @@ st_texture_image_copy(struct pipe_context *pipe,
 
       pipe->resource_copy_region(pipe,
                                  dst,
-                                 dstsub,
+                                 dstLevel,
                                  0, 0, i,/* destX, Y, Z */
                                  src,
-                                 srcsub,
-                                 0, 0, i,/* srcX, Y, Z */
-                                 width, height);
+                                 srcLevel,
+                                 &src_box);
    }
 }
 



More information about the mesa-commit mailing list