X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=e9933e2f9b67c4ec414999438a9e8c1c0ec60ba9;hb=5e4204e;hp=332dd331f69b6bc6e287e89306e2e21eeff52e72;hpb=4c6f1a526ed949f6c9f4c3a57c036b3cdb1aaa91;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 332dd331..e9933e2f 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -108,7 +108,7 @@ string Compiler::get_combined_glsl() const for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) { glsl += format("#pragma MSP stage(%s)\n", Stage::get_stage_name(i->type)); - glsl += Formatter().apply(*i, MODULE); + glsl += Formatter().apply(*i); glsl += '\n'; } @@ -128,7 +128,7 @@ string Compiler::get_stage_glsl(Stage::Type stage_type) const { for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) if(i->type==stage_type) - return Formatter().apply(*i, PROGRAM); + return Formatter().apply(*i); throw key_error(Stage::get_stage_name(stage_type)); } @@ -214,7 +214,6 @@ void Compiler::append_stage(Stage &stage) target->required_features.glsl_version = stage.required_features.glsl_version; for(NodeList::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i) target->content.body.push_back(*i); - DeclarationCombiner().apply(*target); } void Compiler::import(DataFile::Collection *resources, const string &name) @@ -282,7 +281,7 @@ void Compiler::resolve(Stage &stage, unsigned flags) else if(resolve(stage, flags, RESOLVE_FUNCTIONS)) flags |= RESOLVE_EXPRESSIONS; else if(resolve(stage, flags, RESOLVE_EXPRESSIONS)) - flags |= RESOLVE_VARIABLES; + flags |= RESOLVE_VARIABLES|RESOLVE_FUNCTIONS; } } @@ -319,6 +318,8 @@ bool Compiler::diagnostic_line_order(const Diagnostic &diag1, const Diagnostic & Compiler::OptimizeResult Compiler::optimize(Stage &stage) { + if(ConstantFolder().apply(stage)) + resolve(stage, RESOLVE_EXPRESSIONS); ConstantConditionEliminator().apply(stage); bool any_inlined = false;