Mesa (master): draw: add new debug code and comments in clip code template

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 22 21:55:35 UTC 2013


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Jan 21 11:32:49 2013 -0700

draw: add new debug code and comments in clip code template

In debug builds, set clipped vertex window coordinates to NaN values
to help debugging.  Otherwise, we're just leaving the coordinate in clip
space and it's invalid to use it later expecting it to be a window coord.

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

---

 src/gallium/auxiliary/draw/draw_cliptest_tmp.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
index bff266b..8b2dcda 100644
--- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
+++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
@@ -129,6 +129,10 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
          need_pipeline |= out->clipmask;
       }
 
+      /*
+       * Transform the vertex position from clip coords to window coords,
+       * if the vertex is unclipped.
+       */
       if ((flags & DO_VIEWPORT) && mask == 0)
       {
 	 /* divide by w */
@@ -140,6 +144,17 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
 	 position[2] = position[2] * w * scale[2] + trans[2];
 	 position[3] = w;
       }
+#ifdef DEBUG
+      /* For debug builds, set the clipped vertex's window coordinate
+       * to NaN to help catch potential errors later.
+       */
+      else {
+         position[0] =
+         position[1] =
+         position[2] =
+         position[3] = 0.0f / 0.0f;
+      }
+#endif
 
       if ((flags & DO_EDGEFLAG) && ef) {
          const float *edgeflag = out->data[ef];




More information about the mesa-commit mailing list