X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=fab054737a8872bc7e8631b2298615c0fc9b6cf0;hb=d9d7ab44d5f88c4537906e77c49db06d6bdc099c;hp=8a18fdf48df64d6224f9fc3f8d0b00d6a749be7e;hpb=8c4d64c71df5c4dcab1838d81412d7a7244ada58;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 8a18fdf4..fab05473 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -2,14 +2,15 @@ #include #include #include "builtin.h" -#include "compatibility.h" #include "compiler.h" #include "debug.h" #include "error.h" +#include "finalize.h" #include "generate.h" #include "glsl_error.h" #include "optimize.h" #include "output.h" +#include "resolve.h" #include "resources.h" #include "validate.h" @@ -78,7 +79,7 @@ void Compiler::specialize(const map &sv) void Compiler::compile(Mode mode) { for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) - generate(*i, mode); + generate(*i); bool valid = true; for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) @@ -87,8 +88,12 @@ void Compiler::compile(Mode mode) if(!valid) throw invalid_shader_source(get_diagnostics()); - unsigned n = 0; - for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++n) + if(mode==PROGRAM && specialized) + { + for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) + ConstantSpecializer().apply(*i, spec_values); + } + for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ) { OptimizeResult result = optimize(*i); if(result==REDO_PREVIOUS) @@ -243,7 +248,7 @@ void Compiler::import(DataFile::Collection *resources, const string &name) append_module(import_parser.parse(*io, fn, module->source_map.get_count()), resources); } -void Compiler::generate(Stage &stage, Mode mode) +void Compiler::generate(Stage &stage) { stage.required_features.gl_api = features.gl_api; if(module->shared.required_features.glsl_version>stage.required_features.glsl_version) @@ -263,12 +268,7 @@ void Compiler::generate(Stage &stage, Mode mode) InterfaceGenerator().apply(stage); resolve(stage, RESOLVE_BLOCKS|RESOLVE_TYPES|RESOLVE_VARIABLES); - ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0)); - if(mode==PROGRAM) - { - LegacyConverter().apply(stage, features); - resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS); - } + ConstantIdAssigner().apply(stage); } template @@ -300,8 +300,8 @@ void Compiler::resolve(Stage &stage, unsigned flags) bool Compiler::validate(Stage &stage) { - TypeValidator().apply(stage); DeclarationValidator().apply(stage); + IdentifierValidator().apply(stage); ReferenceValidator().apply(stage); ExpressionValidator().apply(stage); @@ -358,10 +358,12 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) void Compiler::finalize(Stage &stage, Mode mode) { - if(get_gl_api()==OPENGL_ES2 && mode==PROGRAM) - DefaultPrecisionGenerator().apply(stage); - else if(mode==MODULE) - PrecisionRemover().apply(stage); + if(mode==PROGRAM) + { + LegacyConverter().apply(stage, features); + resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS); + PrecisionConverter().apply(stage); + } } void Compiler::inject_block(Block &target, const Block &source)