summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel/intel_tex_copy.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-11-21 17:09:47 +0800
committerEric Anholt <eric@anholt.net>2008-11-21 17:35:33 +0800
commit3e0164aabb48a99fce58964cad99fd3978ee84f6 (patch)
tree351bf921dd35ee641a601ee67cfdc5b4183f2bc1 /src/mesa/drivers/dri/intel/intel_tex_copy.c
parenta6aa926e3f0b6237679db0d3331690d2a96adbc2 (diff)
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.
Diffstat (limited to 'src/mesa/drivers/dri/intel/intel_tex_copy.c')
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c38
1 files changed, 22 insertions, 16 deletions
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);
}
}