Mesa (master): draw: fix points with negative w coords for d3d style point clipping

Roland Scheidegger sroland at kemper.freedesktop.org
Tue Jan 21 16:49:24 UTC 2014


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

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Tue Jan 21 17:47:08 2014 +0100

draw: fix points with negative w coords for d3d style point clipping

Even with depth clipping disabled, vertices which have negative w coords
must be discarded. And since we don't have a proper guardband implementation
yet (relying on driver to handle all values except infs/nans in rasterization
for such points) we need to kill them off manually (as they can end up with
coordinates inside viewport otherwise).

v2: use 0.0f instead of 0 (spotted by Brian).

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/draw/draw_pipe_clip.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 8bdb882..de354e9 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -635,8 +635,13 @@ clip_point_guard_xy( struct draw_stage *stage,
          clipmask &= ~(1 << plane_idx);  /* turn off this plane's bit */
          /* TODO: this should really do proper guardband clipping,
           * currently just throw out infs/nans.
+          * Also note that vertices with negative w values MUST be tossed
+          * out (not sure if proper guardband clipping would do this
+          * automatically). These would usually be captured by depth clip
+          * too but this can be disabled.
           */
-         if (util_is_inf_or_nan(header->v[0]->clip[0]) ||
+         if (header->v[0]->clip[3] <= 0.0f ||
+             util_is_inf_or_nan(header->v[0]->clip[0]) ||
              util_is_inf_or_nan(header->v[0]->clip[1]))
             return;
       }
@@ -645,7 +650,6 @@ clip_point_guard_xy( struct draw_stage *stage,
 }
 
 
-
 static void
 clip_first_point( struct draw_stage *stage,
                   struct prim_header *header )




More information about the mesa-commit mailing list