summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorNanley Chery <nanley.g.chery@intel.com>2016-02-05 16:21:33 -0800
committerNanley Chery <nanley.g.chery@intel.com>2016-02-09 15:13:07 -0800
commit605832736a6d9427ad894d403cceeb74a5b18dc1 (patch)
tree82eef6c48ec62dc165d3dc843007fc3dcc6e58e8 /src/mesa
parent55d56d34e0535baa2c7e1e1d8f1be11593a07fa8 (diff)
mesa/readpix: Clip ReadPixels() area to the ReadBuffer's
The fast path for Intel's ReadPixels() unintentionally omits clipping the specified area to a valid one. Rather than clip in various corner-cases, perform this operation in the API validation stage. The bug in intel_readpixels_tiled_memcpy() showed itself when the winsys ReadBuffer's height was smaller than the one specified by ReadPixels(). yoffset became negative, which was an invalid input for tiled_to_linear(). v2: Move clipping to validation stage (Jason) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193 Reported-by: Marta Löfstedt <marta.lofstedt@intel.com> Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org> Signed-off-by: Nanley Chery <nanley.g.chery@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/readpix.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 8cdc9fe1cb2..a5b74bcccfd 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -993,6 +993,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
{
GLenum err = GL_NO_ERROR;
struct gl_renderbuffer *rb;
+ struct gl_pixelstore_attrib clippedPacking;
GET_CURRENT_CONTEXT(ctx);
@@ -1094,7 +1095,9 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
}
}
- if (width == 0 || height == 0)
+ /* Do all needed clipping here, so that we can forget about it later */
+ clippedPacking = ctx->Pack;
+ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking))
return; /* nothing to do */
if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1,
@@ -1118,7 +1121,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
}
ctx->Driver.ReadPixels(ctx, x, y, width, height,
- format, type, &ctx->Pack, pixels);
+ format, type, &clippedPacking, pixels);
}
void GLAPIENTRY