Mesa (7.8): i965: Fix scissoring when width or height is 0.

Eric Anholt anholt at kemper.freedesktop.org
Thu May 13 21:12:53 UTC 2010


Module: Mesa
Branch: 7.8
Commit: 533b76638362e03d3a8b90402f8f16e5738d6516
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=533b76638362e03d3a8b90402f8f16e5738d6516

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Apr 20 13:40:28 2010 -0700

i965: Fix scissoring when width or height is 0.

We would run into trouble due to the hardware using inclusive numbers
and the subtraction to handle that producing negative (meaning large
positive) coordinates.

Bug #27643.
(cherry picked from commit 64516430be1cbe4904613903887a8178f4b4fc60)

---

 src/mesa/drivers/dri/i965/brw_sf_state.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 9712c31..1a6c821 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -76,7 +76,20 @@ static void upload_sf_vp(struct brw_context *brw)
     * Note that the hardware's coordinates are inclusive, while Mesa's min is
     * inclusive but max is exclusive.
     */
-   if (render_to_fbo) {
+
+   if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax ||
+       ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) {
+      /* If the scissor was out of bounds and got clamped to 0
+       * width/height at the bounds, the subtraction of 1 from
+       * maximums could produce a negative number and thus not clip
+       * anything.  Instead, just provide a min > max scissor inside
+       * the bounds, which produces the expected no rendering.
+       */
+      sfv.scissor.xmin = 1;
+      sfv.scissor.xmax = 0;
+      sfv.scissor.ymin = 1;
+      sfv.scissor.ymax = 0;
+   } else if (render_to_fbo) {
       /* texmemory: Y=0=bottom */
       sfv.scissor.xmin = ctx->DrawBuffer->_Xmin;
       sfv.scissor.xmax = ctx->DrawBuffer->_Xmax - 1;




More information about the mesa-commit mailing list