Mesa (master): st/mesa: no-op glCopyPixels if source region is out of bounds

Brian Paul brianp at kemper.freedesktop.org
Mon Apr 23 19:29:15 UTC 2012


Module: Mesa
Branch: master
Commit: 99ed0b2f9b95a484aa78aeee0277bb669611be5b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=99ed0b2f9b95a484aa78aeee0277bb669611be5b

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Apr 20 16:45:12 2012 -0600

st/mesa: no-op glCopyPixels if source region is out of bounds

If the source region for a glCopyPixels is completely outside the
source buffer bounds, no-op the copy.  Fixes a failed assertion.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/mesa/state_tracker/st_cb_drawpixels.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 5e078a8..9a3f224 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1509,7 +1509,15 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    readY = srcy;
    readW = width;
    readH = height;
-   _mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &pack);
+   if (!_mesa_clip_readpixels(ctx, &readX, &readY, &readW, &readH, &pack)) {
+      /* The source region is completely out of bounds.  Do nothing.
+       * The GL spec says "Results of copies from outside the window,
+       * or from regions of the window that are not exposed, are
+       * hardware dependent and undefined."
+       */
+      return;
+   }
+
    readW = MAX2(0, readW);
    readH = MAX2(0, readH);
 




More information about the mesa-commit mailing list