svgadump: Dump the new depth format names.
[mesa.git] / src / glsl / linker.cpp
index 19eb9b5ff6f5a40383d92350f1177a9413449c7b..195f58f29c6bb191aaa4d1e73a9080343a6071c7 100644 (file)
@@ -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;
 }
 
@@ -395,7 +414,7 @@ cross_validate_globals(struct gl_shader_program *prog,
 
         /* Validate layout qualifiers for gl_FragDepth.
          *
-         * From the AMD_conservative_depth spec:
+         * From the AMD/ARB_conservative_depth specs:
          *    "If gl_FragDepth is redeclared in any fragment shader in
          *    a program, it must be redeclared in all fragment shaders in that
          *    program that have static assignments to gl_FragDepth. All
@@ -922,6 +941,14 @@ link_intrastage_shaders(void *mem_ctx,
 
    free(linking_shaders);
 
+#ifdef DEBUG
+   /* At this point linked should contain all of the linked IR, so
+    * validate it to make sure nothing went wrong.
+    */
+   if (linked)
+      validate_ir_tree(linked->ir);
+#endif
+
    /* Make a pass over all variable declarations to ensure that arrays with
     * unspecified sizes have a size specified.  The size is inferred from the
     * max_array_access field.