Mesa (master): glsl: Raise linking error if gl_FragDepth layout is inconsistent

Chad Versace chadversary at kemper.freedesktop.org
Thu Jan 27 01:49:39 UTC 2011


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

Author: Chad Versace <chad.versace at intel.com>
Date:   Thu Jan 27 01:40:31 2011 -0800

glsl: Raise linking error if gl_FragDepth layout is inconsistent

>From the AMD_conservative_depth spec:
   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 redeclarations of gl_FragDepth in
   all fragment shaders in a single program must have the same set of
   qualifiers.

---

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

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bf7a563..4332338 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -382,6 +382,32 @@ cross_validate_globals(struct gl_shader_program *prog,
 	       existing->explicit_location = true;
 	    }
 
+        /* Validate layout qualifiers for gl_FragDepth.
+         *
+         * From the AMD_conservative_depth spec:
+         *    "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
+         *    redeclarations of gl_FragDepth in all fragment shaders in
+         *    a single program must have the same set of qualifiers."
+         */
+        if (strcmp(var->name, "gl_FragDepth") == 0) {
+           bool layout_declared = var->depth_layout != ir_depth_layout_none;
+           bool layout_differs = var->depth_layout != existing->depth_layout;
+           if (layout_declared && layout_differs) {
+              linker_error_printf(prog,
+                 "All redeclarations of gl_FragDepth in all fragment shaders "
+                 "in a single program must have the same set of qualifiers.");
+           }
+           if (var->used && layout_differs) {
+              linker_error_printf(prog,
+                    "If gl_FragDepth is redeclared with a layout qualifier in"
+                    "any fragment shader, it must be redeclared with the same"
+                    "layout qualifier in all fragment shaders that have"
+                    "assignments to gl_FragDepth");
+           }
+        }
+
 	    /* FINISHME: Handle non-constant initializers.
 	     */
 	    if (var->constant_value != NULL) {




More information about the mesa-commit mailing list