From: Brian Paul Date: Wed, 17 Mar 2010 16:13:51 +0000 (-0600) Subject: Merge branch '7.8' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef92fe85de114cb50ca4b3070d0594aade54526c;p=mesa.git Merge branch '7.8' Conflicts: src/mesa/state_tracker/st_cb_drawpixels.c --- ef92fe85de114cb50ca4b3070d0594aade54526c diff --cc src/mesa/state_tracker/st_cb_drawpixels.c index 75be79fd4b0,7c611cb4ec9..72a2ddb379b --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@@ -964,10 -934,12 +964,12 @@@ st_CopyPixels(GLcontext *ctx, GLint src struct st_renderbuffer *rbRead; void *driver_vp, *driver_fp; struct pipe_texture *pt; + struct pipe_sampler_view *sv; GLfloat *color; enum pipe_format srcFormat, texFormat; - int ptw, pth; GLboolean invertTex = GL_FALSE; + GLint readX, readY, readW, readH; + struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); @@@ -1048,28 -993,48 +1023,32 @@@ invertTex = !invertTex; } + /* Clip the read region against the src buffer bounds. + * We'll still allocate a temporary buffer/texture for the original + * src region size but we'll only read the region which is on-screen. + * This may mean that we draw garbage pixels into the dest region, but + * that's expected. + */ + readX = srcx; + readY = srcy; + readW = width; + readH = height; + _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &unpack); + readW = MAX2(0, readW); + readH = MAX2(0, readH); + - /* Need to use POT texture? */ - ptw = width; - pth = height; - if (!screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) { - int l2pt, maxSize; - - l2pt = util_logbase2(width); - if (1<screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1); - assert(ptw <= maxSize); - assert(pth <= maxSize); - } - - pt = st_texture_create(st, PIPE_TEXTURE_2D, texFormat, 0, - ptw, pth, 1, - PIPE_TEXTURE_USAGE_SAMPLER); + /* alloc temporary texture */ + pt = alloc_texture(st, width, height, texFormat); if (!pt) return; + sv = st_sampler_view_from_texture(st->pipe, pt); + if (!sv) { + pipe_texture_reference(&pt, NULL); + 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 */ @@@ -1124,28 -1090,30 +1104,30 @@@ if (type == GL_COLOR) { /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, ptRead, 0, 0, width, height, buf); - pipe_put_tile_rgba(pipe, ptTex, 0, 0, width, height, buf); - - pipe_get_tile_rgba(ptRead, readX, readY, readW, readH, buf); - pipe_put_tile_rgba(ptTex, unpack.SkipPixels, unpack.SkipRows, ++ pipe_get_tile_rgba(pipe, ptRead, readX, readY, readW, readH, buf); ++ pipe_put_tile_rgba(pipe, ptTex, unpack.SkipPixels, unpack.SkipRows, + readW, readH, buf); free(buf); } else { /* GL_DEPTH */ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); - pipe_get_tile_z(pipe, ptRead, 0, 0, width, height, buf); - pipe_put_tile_z(pipe, ptTex, 0, 0, width, height, buf); - pipe_get_tile_z(ptRead, readX, readY, readW, readH, buf); - pipe_put_tile_z(ptTex, unpack.SkipPixels, unpack.SkipRows, - readW, readH, buf); ++ pipe_get_tile_z(pipe, ptRead, readX, readY, readW, readH, buf); ++ pipe_put_tile_z(pipe, ptTex, unpack.SkipPixels, unpack.SkipRows, ++ readW, readH, buf); free(buf); } - screen->tex_transfer_destroy(ptRead); - screen->tex_transfer_destroy(ptTex); + pipe->tex_transfer_destroy(pipe, ptRead); + pipe->tex_transfer_destroy(pipe, ptTex); } - /* draw textured quad */ + /* OK, the texture 'pt' contains the src image/pixels. Now draw a + * textured quad with that texture. + */ draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2], width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, - pt, + sv, driver_vp, driver_fp, color, invertTex);