[Mesa-dev] [PATCH 06/11] glsl: Cross-validate explicit binding points.
Kenneth Graunke
kenneth at whitecape.org
Wed Jul 17 18:24:06 PDT 2013
All compilation units need to agree on the binding point, if they
specify one at all.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/glsl/linker.cpp | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ba97ade..cca66f8 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -541,6 +541,28 @@ cross_validate_globals(struct gl_shader_program *prog,
existing->explicit_location = true;
}
+ /* From the GLSL 4.20 specification:
+ * "A link error will result if two compilation units in a program
+ * specify different integer-constant bindings for the same
+ * opaque-uniform name. However, it is not an error to specify a
+ * binding on some but not all declarations for the same name"
+ */
+ if (var->explicit_binding) {
+ assert(var->constant_value);
+ assert(!existing->explicit_binding || existing->constant_value);
+ if (existing->explicit_binding &&
+ var->constant_value->value.i[0] !=
+ existing->constant_value->value.i[0]) {
+ linker_error(prog, "explicit bindings for %s "
+ "`%s' have differing values\n",
+ mode_string(var), var->name);
+ return false;
+ }
+
+ existing->constant_value = var->constant_value;
+ existing->explicit_binding = true;
+ }
+
/* Validate layout qualifiers for gl_FragDepth.
*
* From the AMD/ARB_conservative_depth specs:
--
1.8.3.2
More information about the mesa-dev
mailing list