st/mesa: fix incorrect texture level/face/slice accesses
authorBrian Paul <brianp@vmware.com>
Thu, 26 May 2011 00:07:33 +0000 (18:07 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 26 May 2011 00:07:35 +0000 (18:07 -0600)
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.

src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_readpixels.c

index 9948f8d2bc526133b2f20acb0afd5ee0cdfc2e78..94bede73daf2b3dcece5e3b11f4aac9f3db0169b 100644 (file)
@@ -793,9 +793,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);
 
@@ -1131,7 +1132,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);
 
@@ -1291,8 +1294,10 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
          u_box_2d(readX, readY, readW, readH, &srcBox);
 
          pipe->resource_copy_region(pipe,
-                                    rbDraw->texture, 0, drawX, drawY, 0,
-                                    rbRead->texture, 0, &srcBox);
+                                    rbDraw->texture,
+                                    rbDraw->rtt_level, drawX, drawY, 0,
+                                    rbRead->texture,
+                                    rbRead->rtt_level, &srcBox);
          return GL_TRUE;
       }
    }
@@ -1444,10 +1449,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);
 
    }
@@ -1455,7 +1460,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;
index 2a63799bdbc3235277c3fea268642d2b5c1ea5d5..67926e39297f37881c2327fc133e5f90c17314a2 100644 (file)
@@ -82,7 +82,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);
 
@@ -250,7 +251,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) {
@@ -445,7 +447,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);