From b60aa251e4fb4dd32db3fe167e078bf0092cb726 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 10:42:22 -0700 Subject: [PATCH] st/mesa: fix incorrect glCopyPixels between window/FBO There was a DrawBuffer/ReadBuffer typo and we were neglecting to invert the texture coords when copying from a window to an FBO. Plus, add some surface dump/debug code (disabled). (cherry picked from commit 34f02071618624263eba839b5aeb930d0e794078) --- src/mesa/state_tracker/st_cb_drawpixels.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 5278309e32d..43dc8d1b836 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -937,6 +937,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, GLfloat *color; enum pipe_format srcFormat, texFormat; int ptw, pth; + GLboolean invertTex = GL_FALSE; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); @@ -1012,8 +1013,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - srcy = ctx->DrawBuffer->Height - srcy - height; + if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { + srcy = ctx->ReadBuffer->Height - srcy - height; if (srcy < 0) { height -= -srcy; @@ -1022,6 +1023,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (height < 0) return; + + invertTex = !invertTex; } /* Need to use POT texture? */ @@ -1051,7 +1054,9 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (!pt) return; - + /* Make temporary texture which is a copy of the src region. + * We'll draw a quad with this texture to draw the dest image. + */ if (srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ struct pipe_surface *psRead = screen->get_tex_surface(screen, @@ -1072,6 +1077,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, psRead, srcx, srcy, width, height); } + + if (0) { + /* debug */ + debug_dump_surface("copypixsrcsurf", psRead); + debug_dump_surface("copypixtemptex", psTex); + } + pipe_surface_reference(&psRead, NULL); pipe_surface_reference(&psTex, NULL); } @@ -1122,7 +1134,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, pt, driver_vp, driver_fp, - color, GL_TRUE); + color, invertTex); pipe_texture_reference(&pt, NULL); } -- 2.30.2