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

Author: Paul Berry <stereotype...@gmail.com>
Date:   Thu Aug 11 18:10:22 2011 -0700

glsl: Make sure gl_ClipDistance and gl_ClipVertex are not both written.

>From section 7.1 (Vertex Shader Special Variables) of the GLSL 1.30
spec:

  "It is an error for a shader to statically write both
  gl_ClipVertex and gl_ClipDistance."

Fixes piglit test mixing-clip-distance-and-clip-vertex-disallowed.c.

Reviewed-by: Kenneth Graunke <kenn...@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>

---

 src/glsl/linker.cpp |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ba81c59..195f58f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -262,6 +262,25 @@ validate_vertex_shader_executable(struct gl_shader_program 
*prog,
       return false;
    }
 
+   if (prog->Version >= 130) {
+      /* From section 7.1 (Vertex Shader Special Variables) of the
+       * GLSL 1.30 spec:
+       *
+       *   "It is an error for a shader to statically write both
+       *   gl_ClipVertex and gl_ClipDistance."
+       */
+      find_assignment_visitor clip_vertex("gl_ClipVertex");
+      find_assignment_visitor clip_distance("gl_ClipDistance");
+
+      clip_vertex.run(shader->ir);
+      clip_distance.run(shader->ir);
+      if (clip_vertex.variable_found() && clip_distance.variable_found()) {
+         linker_error(prog, "vertex shader writes to both `gl_ClipVertex' "
+                      "and `gl_ClipDistance'\n");
+         return false;
+      }
+   }
+
    return true;
 }
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to