[Mesa-dev] [PATCH 2/2] glsl: match unnamed record types across stages

Grigori Goronzy greg at chown.ath.cx
Tue Nov 26 15:15:06 PST 2013


Unnamed record types are assigned to separate types per stage, e.g.

uniform struct { ... } a;

if defined in both vertex and fragment shader, will result in two
separate types of different name. When linking the shader, this
results in a type conflict. However, there is no reason why this
should not be allowed according to GLSL specifications. Compare and
match record types when linking shader stages to avoid this conflict.
---
 src/glsl/linker.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1366077..c60753c 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -609,6 +609,10 @@ cross_validate_globals(struct gl_shader_program *prog,
 		  if (var->type->length != 0) {
 		     existing->type = var->type;
 		  }
+               } else if (var->type->is_record()
+		   && existing->type->is_record()
+		   && existing->type->record_compare(var->type)) {
+		  existing->type = var->type;
 	       } else {
 		  linker_error(prog, "%s `%s' declared as type "
 			       "`%s' and type `%s'\n",
-- 
1.8.1.2



More information about the mesa-dev mailing list