]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/generate.cpp
Avoid generating passthroughs for builtin variables
[libs/gl.git] / source / glsl / generate.cpp
index a2fd3608220e836d268d2310ad1ec6c8915e4550..c670bc1a814ee1002eac71285c9002fe568c1968 100644 (file)
@@ -219,6 +219,8 @@ bool VariableResolver::apply(Stage &s)
        s.interface_blocks.clear();
        r_any_resolved = false;
        s.content.visit(*this);
+       for(vector<VariableDeclaration *>::const_iterator i=redeclared_builtins.begin(); i!=redeclared_builtins.end(); ++i)
+               (*i)->source = GENERATED_SOURCE;
        NodeRemover().apply(s, nodes_to_remove);
        return r_any_resolved;
 }
@@ -461,6 +463,12 @@ void VariableResolver::visit(VariableDeclaration &var)
                ptr = &var;
        else if(!current_block->parent && ptr->interface==var.interface && ptr->type==var.type)
        {
+               if(ptr->source==BUILTIN_SOURCE)
+                       redeclared_builtins.push_back(&var);
+               else
+                       stage->diagnostics.push_back(Diagnostic(Diagnostic::WARN, var.source, var.line,
+                               format("Redeclaring non-builtin variable '%s' is deprecated", var.name)));
+
                if(var.init_expression)
                        ptr->init_expression = var.init_expression;
                if(var.layout)
@@ -1216,7 +1224,8 @@ void InterfaceGenerator::visit(VariableDeclaration &var)
        }
        else if(var.interface=="in" && current_block==&stage->content)
        {
-               declared_inputs.push_back(&var);
+               if(var.name.compare(0, 3, "gl_"))
+                       declared_inputs.push_back(&var);
 
                /* Try to link input variables in global scope with output variables from
                previous stage. */