Mesa (master): draw: fix clipvertex trouble if position comes from gs

Roland Scheidegger sroland at kemper.freedesktop.org
Wed Aug 6 16:02:28 UTC 2014


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

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Wed Aug  6 03:40:31 2014 +0200

draw: fix clipvertex trouble if position comes from gs

If the vertex shader has no position but the gs has, the clipvertex output
was -1 (because it's the same as vs position in this case if there's no
explicit clipvertex output). This caused crashes (or assertion failures) in
clipping since in the end position (which came from gs) was different from
cv (-1) and we then tried to use the bogus cv input.
Rather than just test for -1 cv value in clipping, make it explicitly return
the position output of the gs instead which seems cleaner (since we really
don't want to use the clipvertex value from the vs (it could be a valid value
in the (unsupported) case of vs writing clipvertex but still using a gs).
This fixes piglit shader_runner clip-distance-out-values.shader_test.

Reviewed-by: Zack Rusin <zackr at vmware.com>

---

 src/gallium/auxiliary/draw/draw_context.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index d7197fd..001446f 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -818,11 +818,15 @@ draw_current_shader_uses_viewport_index(const struct draw_context *draw)
 
 /**
  * Return the index of the shader output which will contain the
- * vertex position.
+ * clip vertex position.
+ * Note we don't support clipvertex output in the gs. For clipping
+ * to work correctly hence we return ordinary position output instead.
  */
 uint
 draw_current_shader_clipvertex_output(const struct draw_context *draw)
 {
+   if (draw->gs.geometry_shader)
+      return draw->gs.position_output;
    return draw->vs.clipvertex_output;
 }
 




More information about the mesa-commit mailing list