draw: (trivial) fix clamping of viewport index
authorRoland Scheidegger <sroland@vmware.com>
Mon, 23 Jun 2014 20:06:15 +0000 (22:06 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 23 Jun 2014 22:37:52 +0000 (00:37 +0200)
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@lists.freedesktop.org>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/auxiliary/draw/draw_private.h

index 783c3efcc9bc2c7b14f0df6db1245f7912004ac6..d8dc2ab0bae9a1574143ffd289a427b4df9c143e 100644 (file)
@@ -493,7 +493,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);
 }
 
 /**