summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-12-18 18:42:06 -0800
committerEric Anholt <eric@anholt.net>2008-12-23 14:01:28 -0800
commit7e275eae46afb6281ff453fc05367403e01400fe (patch)
tree257d5c331ed0fb9b6366c3b4dcbb692869802ec6
parentc5b2549b3c3507c4d20bfe6261db0a3e1a91b4e6 (diff)
intel: Move copyteximage source clipping out of copytexsubimage.
glCopyTexSubImage already gets the (correct) clipping for us, so it doesn't need the path. While moving the clipping out, replace the code with the mesa path to do the same job. (cherry picked from commit 1e7785fe0721f66ca9523da0dc338d26256736bb)
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c109
1 files changed, 61 insertions, 48 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index 86ef2a9df3..4910713846 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -110,56 +110,47 @@ do_copy_texsubimage(struct intel_context *intel,
intelImage->level);
const GLint orig_x = x;
const GLint orig_y = y;
- const struct gl_framebuffer *fb = ctx->DrawBuffer;
-
- 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.
+ 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;
+ 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.
*/
- assert(intelImage->mt->region->tiling == I915_TILING_NONE);
-
- if (ctx->ReadBuffer->Name == 0) {
- /* reading from a window, adjust x, y */
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- 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, y is already oriented the way we like */
- src_pitch = src->pitch;
- }
-
- intelEmitCopyBlit(intel,
- intelImage->mt->cpp,
- src_pitch,
- src->buffer,
- 0,
- src->tiling,
- intelImage->mt->pitch,
- intelImage->mt->region->buffer,
- image_offset,
- intelImage->mt->region->tiling,
- x, y, dstx, dsty, width, height,
- GL_COPY);
+ src_pitch = -src->pitch;
+ } else {
+ /* reading from a FBO, y is already oriented the way we like */
+ src_pitch = src->pitch;
}
- }
+ intelEmitCopyBlit(intel,
+ intelImage->mt->cpp,
+ src_pitch,
+ src->buffer,
+ 0,
+ src->tiling,
+ intelImage->mt->pitch,
+ intelImage->mt->region->buffer,
+ image_offset,
+ intelImage->mt->region->tiling,
+ x, y, dstx, dsty, width, height,
+ GL_COPY);
+ }
UNLOCK_HARDWARE(intel);
@@ -186,6 +177,7 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
_mesa_select_tex_image(ctx, texObj, target, level);
+ int srcx, srcy, dstx, dsty, height;
if (border)
goto fail;
@@ -197,10 +189,20 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
width, border,
GL_RGBA, CHAN_TYPE, NULL,
&ctx->DefaultPacking, texObj, texImage);
+ srcx = x;
+ srcy = y;
+ dstx = 0;
+ dsty = 0;
+ height = 1;
+ if (!_mesa_clip_copytexsubimage(ctx,
+ &dstx, &dsty,
+ &srcx, &srcy,
+ &width, &height))
+ return;
if (!do_copy_texsubimage(intel_context(ctx), target,
intel_texture_image(texImage),
- internalFormat, 0, 0, x, y, width, 1))
+ internalFormat, 0, 0, x, y, width, height))
goto fail;
return;
@@ -222,10 +224,21 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
_mesa_select_tex_image(ctx, texObj, target, level);
+ int srcx, srcy, dstx, dsty;
if (border)
goto fail;
+ srcx = x;
+ srcy = y;
+ dstx = 0;
+ dsty = 0;
+ if (!_mesa_clip_copytexsubimage(ctx,
+ &dstx, &dsty,
+ &srcx, &srcy,
+ &width, &height))
+ return;
+
/* Setup or redefine the texture object, mipmap tree and texture
* image. Don't populate yet.
*/