Mesa (7.10): st/mesa: fix incorrect texture level/face/slice accesses

Brian Paul brianp at kemper.freedesktop.org
Fri Jun 10 14:26:27 PDT 2011


Module: Mesa
Branch: 7.10
Commit: 59b147c6a35414f37e010b262f6feaccccb7960d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=59b147c6a35414f37e010b262f6feaccccb7960d

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jun  2 12:44:10 2011 -0600

st/mesa: fix incorrect texture level/face/slice accesses

If we use FBOs to access mipmap levels with glRead/Draw/CopyPixels()
we need to be sure to access the correct mipmap level/face/slice.
Before, we were just passing zero in quite a few places.

This fixes the new piglit fbo-mipmap-copypix test.

NOTE: This is a candidate for the 7.10 branch.
(cherry picked from commit bf14ab417c6638afd19206e11ee69bdb9fb93d9e)

Conflicts:

	src/mesa/state_tracker/st_cb_drawpixels.c

---

 src/mesa/state_tracker/st_cb_drawpixels.c |   18 +++++++++++-------
 src/mesa/state_tracker/st_cb_readpixels.c |    9 ++++++---
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index f7c9198..4c2b7e7 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -763,9 +763,10 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
    else
       usage = PIPE_TRANSFER_WRITE;
 
-   pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0,
-                                     usage, x, y,
-                                     width, height);
+   pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture,
+                          strb->rtt_level, strb->rtt_face + strb->rtt_slice,
+                          usage, x, y,
+                          width, height);
 
    stmap = pipe_transfer_map(pipe, pt);
 
@@ -1031,7 +1032,9 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    }
 
    ptDraw = pipe_get_transfer(st_context(ctx)->pipe,
-                              rbDraw->texture, 0, 0,
+                              rbDraw->texture,
+                              rbDraw->rtt_level,
+                              rbDraw->rtt_face + rbDraw->rtt_slice,
                               usage, dstx, dsty,
                               width, height);
 
@@ -1214,10 +1217,10 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
     /* copy source framebuffer surface into mipmap/texture */
       pipe->resource_copy_region(pipe,
                                  pt,                                /* dest tex */
-                                 0,
+                                 0,                                 /* dest lvl */
                                  pack.SkipPixels, pack.SkipRows, 0, /* dest pos */
                                  rbRead->texture,                   /* src tex */
-                                 0,
+                                 rbRead->rtt_level,                 /* src lvl */
                                  &src_box);
 
    }
@@ -1225,7 +1228,8 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       /* CPU-based fallback/conversion */
       struct pipe_transfer *ptRead =
          pipe_get_transfer(st->pipe, rbRead->texture,
-                           0, 0, /* level, layer */
+                           rbRead->rtt_level,
+                           rbRead->rtt_face + rbRead->rtt_slice,
                            PIPE_TRANSFER_READ,
                            readX, readY, readW, readH);
       struct pipe_transfer *ptTex;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 0507be7..616baa3 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -80,7 +80,8 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
    /* Create a read transfer from the renderbuffer's texture */
 
    pt = pipe_get_transfer(pipe, strb->texture,
-                          0, 0,
+                          strb->rtt_level,
+                          strb->rtt_face + strb->rtt_slice,
                           PIPE_TRANSFER_READ,
                           x, y, width, height);
 
@@ -236,7 +237,8 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
       }
 
       trans = pipe_get_transfer(pipe, strb->texture,
-                                0, 0,
+                                strb->rtt_level,
+                                strb->rtt_face + strb->rtt_slice,
                                 PIPE_TRANSFER_READ,
                                 x, y, width, height);
       if (!trans) {
@@ -407,7 +409,8 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
 
    /* Create a read transfer from the renderbuffer's texture */
    trans = pipe_get_transfer(pipe, strb->texture,
-                             0, 0,
+                             strb->rtt_level, /* level */
+                             strb->rtt_face + strb->rtt_slice, /* layer */
                              PIPE_TRANSFER_READ,
                              x, y, width, height);
 



More information about the mesa-commit mailing list