Mesa (10.1): draw: (trivial) fix clamping of viewport index

Carl Worth cworth at kemper.freedesktop.org
Tue Jun 24 20:32:26 UTC 2014


Module: Mesa
Branch: 10.1
Commit: 04ca4cef977f7bfed9be9ee4046fed7e52ddafeb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=04ca4cef977f7bfed9be9ee4046fed7e52ddafeb

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Mon Jun 23 22:06:15 2014 +0200

draw: (trivial) fix clamping of viewport index

The old logic would let all negative values go through unclamped, with
potentially disastrous results (probably trying to fetch viewport values
from random memory locations). GL has undefined rendering for vp indices
outside valid range but that's a bit too undefined...
(The logic is now the same as in llvmpipe.)

CC: "10.1 10.2" <mesa-stable at lists.freedesktop.org>

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
Tested-by: Ilia Mirkin <imirkin at alum.mit.edu>
(cherry picked from commit 604e54de78aa00430b1d61d030656e387866e840)

---

 src/gallium/auxiliary/draw/draw_private.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 801d009..4fe3682 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -495,7 +495,7 @@ draw_stats_clipper_primitives(struct draw_context *draw,
 static INLINE unsigned
 draw_clamp_viewport_idx(int idx)
 {
-   return ((PIPE_MAX_VIEWPORTS > idx || idx < 0) ? idx : 0);
+   return ((PIPE_MAX_VIEWPORTS > idx && idx >= 0) ? idx : 0);
 }
 
 /**




More information about the mesa-commit mailing list