X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramcompiler.cpp;h=f9a14f2f00a119ffbd7ba7604fd36a84e5a96585;hb=6b89fb751617dd51eddf2adcc55e9a8da66f8e84;hp=cc4b5efe3df0bfca482feb8d9ae3f46e46391d42;hpb=4fe225bf15048fcb7a678370f87d09f2de37031a;p=libs%2Fgl.git diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index cc4b5efe..f9a14f2f 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -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_versiontype==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) { @@ -1346,6 +1356,8 @@ void ProgramCompiler::UnusedVariableLocator::visit(FunctionDeclaration &func) BlockVariableMap &block_variables = variables.back(); for(BlockVariableMap::iterator i=block_variables.begin(); i!=block_variables.end(); ++i) i->second.conditionally_assigned = true; + for(vector >::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) + block_variables[i->get()].referenced = true; merge_down_variables(); } @@ -1445,7 +1457,7 @@ void ProgramCompiler::UnusedFunctionLocator::visit(FunctionDeclaration &func) { TraversingVisitor::visit(func); - if(func.name!="main" && !used_definitions.count(&func)) + if((func.name!="main" || func.body.body.empty()) && !used_definitions.count(&func)) unused_nodes.insert(&func); } @@ -1567,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;