X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramcompiler.cpp;h=d021ab4f75732769855e9370fe0c8eec990aca20;hp=bb77e0ea911e205c192c68cd88462f6affdf1ff6;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=b699b811b22450828268be7ed67e35900be7bdad diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index bb77e0ea..d021ab4f 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -208,6 +209,8 @@ void ProgramCompiler::append_stage(Stage &stage) target = &*i; } + if(stage.required_version>target->required_version) + target->required_version = stage.required_version; for(NodeList::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i) target->content.body.push_back(*i); apply(*target); @@ -244,6 +247,8 @@ void ProgramCompiler::import(const string &name) void ProgramCompiler::generate(Stage &stage) { + if(module->shared.required_version>stage.required_version) + stage.required_version = module->shared.required_version; inject_block(stage.content, module->shared.content); apply(stage); @@ -347,6 +352,7 @@ void ProgramCompiler::BlockModifier::visit(Block &block) ProgramCompiler::Formatter::Formatter(): + source_index(0), source_line(1), indent(0), parameter_list(false) @@ -989,7 +995,7 @@ bool ProgramCompiler::InterfaceGenerator::generate_interface(VariableDeclaration return true; } -void ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left, ProgramSyntax::Expression *right) +ExpressionStatement &ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left, ProgramSyntax::Expression *right) { Assignment *assign = new Assignment; VariableReference *ref = new VariableReference; @@ -1002,6 +1008,8 @@ void ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left, stmt->expression = assign; stmt->visit(*this); insert_nodes.push_back(stmt); + + return *stmt; } void ProgramCompiler::InterfaceGenerator::visit(VariableReference &var) @@ -1033,7 +1041,9 @@ void ProgramCompiler::InterfaceGenerator::visit(VariableDeclaration &var) remove_node = true; if(var.init_expression) { - insert_assignment(var.name, var.init_expression->clone()); + ExpressionStatement &stmt = insert_assignment(var.name, var.init_expression->clone()); + stmt.source = var.source; + stmt.line = var.line; return; } } @@ -1671,7 +1681,7 @@ void ProgramCompiler::UnusedVariableLocator::merge_down_variables() { if(!i->second.referenced) unused_nodes.insert(i->first); - clear_assignments(i->second, true); + clear_assignments(i->second, i->first->interface!="out"); continue; } @@ -1944,10 +1954,32 @@ void ProgramCompiler::LegacyConverter::visit(FunctionCall &call) call.name = "texture2D"; else if(type=="sampler3D") call.name = "texture3D"; + else if(type=="samplerCube") + call.name = "textureCube"; else if(type=="sampler1DShadow") call.name = "shadow1D"; else if(type=="sampler2DShadow") call.name = "shadow2D"; + else if(type=="sampler1DArray") + { + check_extension(EXT_texture_array); + call.name = "texture1DArray"; + } + else if(type=="sampler2DArray") + { + check_extension(EXT_texture_array); + call.name = "texture2DArray"; + } + else if(type=="sampler1DArrayShadow") + { + check_extension(EXT_texture_array); + call.name = "shadow1DArray"; + } + else if(type=="sampler2DArrayShadow") + { + check_extension(EXT_texture_array); + call.name = "shadow2DArray"; + } for(; i!=call.arguments.end(); ++i) (*i)->visit(*this);