From: Brian Paul Date: Thu, 26 May 2011 00:07:33 +0000 (-0600) Subject: st/mesa: fix incorrect texture level/face/slice accesses X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf14ab417c6638afd19206e11ee69bdb9fb93d9e;p=mesa.git 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. --- diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 9948f8d2bc5..94bede73daf 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 2a63799bdbc..67926e39297 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -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);