Mesa (master): swrast: be a bit smarter in clip_span()

Brian Paul brianp at kemper.freedesktop.org
Thu Oct 13 23:19:24 UTC 2011


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Oct 13 17:16:17 2011 -0600

swrast: be a bit smarter in clip_span()

If no pixels pass the clip test, return false.

---

 src/mesa/swrast/s_span.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 1aa20f9..e517c9a 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -707,11 +707,13 @@ clip_span( struct gl_context *ctx, SWspan *span )
       const GLint n = span->end;
       GLubyte *mask = span->array->mask;
       GLint i;
+      GLuint passed = 0;
       if (span->arrayMask & SPAN_MASK) {
          /* note: using & intead of && to reduce branches */
          for (i = 0; i < n; i++) {
             mask[i] &= (x[i] >= xmin) & (x[i] < xmax)
                      & (y[i] >= ymin) & (y[i] < ymax);
+            passed += mask[i];
          }
       }
       else {
@@ -719,9 +721,10 @@ clip_span( struct gl_context *ctx, SWspan *span )
          for (i = 0; i < n; i++) {
             mask[i] = (x[i] >= xmin) & (x[i] < xmax)
                     & (y[i] >= ymin) & (y[i] < ymax);
+            passed += mask[i];
          }
       }
-      return GL_TRUE;  /* some pixels visible */
+      return passed > 0;
    }
    else {
       /* horizontal span of pixels */




More information about the mesa-commit mailing list