]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't replace in/out with attribute/varying until formatting
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Jan 2017 13:17:08 +0000 (15:17 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Jan 2017 13:27:22 +0000 (15:27 +0200)
Some parts of the code depend on having the correct interfaces present in
the AST.

source/programcompiler.cpp

index 0d61c6853c737a75bac34212114077e1b691286c..f9a14f2f00a119ffbd7ba7604fd36a84e5a96585 100644 (file)
@@ -368,7 +368,17 @@ void ProgramCompiler::Formatter::visit(VariableDeclaration &var)
        if(!var.sampling.empty())
                formatted += format("%s ", var.sampling);
        if(!var.interface.empty() && var.interface!=block_interface)
-               formatted += format("%s ", var.interface);
+       {
+               string interface = var.interface;
+               if(stage->required_version<Version(1, 30))
+               {
+                       if(stage->type==VERTEX && var.interface=="in")
+                               interface = "attribute";
+                       else if((stage->type==VERTEX && var.interface=="out") || (stage->type==FRAGMENT && var.interface=="in"))
+                               interface = "varying";
+               }
+               formatted += format("%s ", interface);
+       }
        formatted += format("%s %s", var.type, var.name);
        if(var.array)
        {
@@ -1569,11 +1579,7 @@ void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var)
 
        if((var.interface=="in" || var.interface=="out") && !check_version(Version(1, 30)))
        {
-               if(stage->type==VERTEX && var.interface=="in")
-                       var.interface = "attribute";
-               else if((stage->type==VERTEX && var.interface=="out") || (stage->type==FRAGMENT && var.interface=="in"))
-                       var.interface = "varying";
-               else if(stage->type==FRAGMENT && var.interface=="out")
+               if(stage->type==FRAGMENT && var.interface=="out")
                {
                        frag_out_name = var.name;
                        remove_node = true;