]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.cpp
Avoid incorrectly matching interfaces in certain cases
[libs/gl.git] / source / glsl / generate.cpp
index 064d217e7da7b9b47f2c90dbab59a8f5006f9a77..952f1f0bfa4f1bddb2e1bc7585f3829fda9ce78b 100644 (file)
@@ -10,7 +10,7 @@ namespace SL {
 
 void DeclarationCombiner::apply(Stage &stage)
 {
-       visit(stage.content);
+       stage.content.visit(*this);
        NodeRemover().apply(stage, nodes_to_remove);
 }
 
@@ -52,8 +52,9 @@ void DeclarationCombiner::visit(VariableDeclaration &var)
                                {
                                        bool found = false;
                                        for(vector<Layout::Qualifier>::iterator j=ptr->layout->qualifiers.begin(); (!found && j!=ptr->layout->qualifiers.end()); ++j)
-                                               if(j->identifier==i->identifier)
+                                               if(j->name==i->name)
                                                {
+                                                       j->has_value = i->value;
                                                        j->value = i->value;
                                                        found = true;
                                                }
@@ -95,7 +96,7 @@ void VariableResolver::apply(Stage &stage)
 {
        Stage *builtin_stage = get_builtins(stage.type);
        builtins = (builtin_stage ? &builtin_stage->content : 0);
-       visit(stage.content);
+       stage.content.visit(*this);
 }
 
 Block *VariableResolver::next_block(Block &block)
@@ -284,7 +285,7 @@ void InterfaceGenerator::apply(Stage &s)
        if(stage->previous)
                in_prefix = get_out_prefix(stage->previous->type);
        out_prefix = get_out_prefix(stage->type);
-       visit(s.content);
+       s.content.visit(*this);
        NodeRemover().apply(s, nodes_to_remove);
 }
 
@@ -357,6 +358,10 @@ void InterfaceGenerator::visit(VariableReference &var)
 {
        if(var.declaration || !stage->previous)
                return;
+       /* Don't pull a variable from previous stage if we just generated an out
+       interface in this stage */
+       if(stage->out_variables.count(var.name))
+               return;
 
        const map<string, VariableDeclaration *> &prev_out = stage->previous->out_variables;
        map<string, VariableDeclaration *>::const_iterator i = prev_out.find(var.name);