From 3e0164aabb48a99fce58964cad99fd3978ee84f6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 21 Nov 2008 17:09:47 +0800 Subject: i965: Add support for accelerated CopyTexSubImage. There were hacks in EmitCopyBlit before to adjust offsets so that y=0 after the offsets had been adjusted for a negative pitch. It appears that those hacks were due to an unclear and surprising aspect of the hardware: inverting the pitch results in the blit into the specified rectangle being inverted, without the user needing to adjust y and base offset. Tested with piglit copytexsubimage test on 915GM and GM965. Should fix serious performance issues with ETQW and other applications. --- src/mesa/drivers/dri/intel/intel_tex_copy.c | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/mesa/drivers/dri/intel/intel_tex_copy.c') diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index f4cb4a781c..36446efde7 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -114,43 +114,49 @@ do_copy_texsubimage(struct intel_context *intel, if (_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax, &x, &y, &width, &height)) { + GLshort src_pitch; + /* Update dst for clipped src. Need to also clip the source rect. */ dstx += x - orig_x; dsty += y - orig_y; + /* image_offset may be non-page-aligned, but that's illegal for tiling. + */ + assert(intelImage->mt->region->tiling == I915_TILING_NONE); + if (ctx->ReadBuffer->Name == 0) { /* reading from a window, adjust x, y */ __DRIdrawablePrivate *dPriv = intel->driDrawable; - GLuint window_y; - /* window_y = position of window on screen if y=0=bottom */ - window_y = intel->intelScreen->height - (dPriv->y + dPriv->h); - y = window_y + y; + y = dPriv->y + (dPriv->h - (y + height)); x += dPriv->x; + + /* Invert the data coming from the source rectangle due to GL + * and hardware disagreeing on where y=0 is. + * + * It appears that our offsets and pitches get mangled + * appropriately by the hardware, and we don't need to adjust them + * on our own. + */ + src_pitch = -src->pitch; } else { - /* reading from a FBO */ - /* invert Y */ - y = ctx->ReadBuffer->Height - y - 1; + /* reading from a FBO, y is already oriented the way we like */ + src_pitch = src->pitch; } - - /* A bit of fiddling to get the blitter to work with -ve - * pitches. But we get a nice inverted blit this way, so it's - * worth it: - */ intelEmitCopyBlit(intel, intelImage->mt->cpp, - -src->pitch, + src_pitch, src->buffer, - src->height * src->pitch * src->cpp, + 0, src->tiling, intelImage->mt->pitch, intelImage->mt->region->buffer, image_offset, intelImage->mt->region->tiling, - x, y + height, dstx, dsty, width, height, - GL_COPY); /* ? */ + x, y, dstx, dsty, width, height, + GL_COPY); } } -- cgit v1.2.3