X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=2a71cfe4e23ff49eb8914aee64639a4e5c19dec5;hb=61c8a3f2f3a39d17fe90ee7b2bce93e771f58a03;hp=d5ee6691ff83cd3d877c845431ab9a29698c1edb;hpb=0febee9a8fdf1f9b03d3f2e23e72f8194b3698c7;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index d5ee6691..2a71cfe4 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -206,13 +206,6 @@ void Compiler::append_stage(Stage &stage) target = &*i; } - if(target->content.body.empty()) - { - Stage *builtins = get_builtins(stage.type); - if(builtins && builtins!=&stage) - append_stage(*builtins); - } - if(stage.required_features.glsl_version>target->required_features.glsl_version) target->required_features.glsl_version = stage.required_features.glsl_version; for(NodeList::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i) @@ -239,16 +232,23 @@ void Compiler::generate(Stage &stage, Mode mode) stage.required_features.gl_api = features.gl_api; if(module->shared.required_features.glsl_version>stage.required_features.glsl_version) stage.required_features.glsl_version = module->shared.required_features.glsl_version; + inject_block(stage.content, module->shared.content); + if(const Stage *builtins = get_builtins(stage.type)) + inject_block(stage.content, builtins->content); + if(const Stage *builtins = get_builtins(Stage::SHARED)) + inject_block(stage.content, builtins->content); // Initial resolving pass BlockHierarchyResolver().apply(stage); + TypeResolver().apply(stage); FunctionResolver().apply(stage); VariableResolver().apply(stage); /* All variables local to a stage have been resolved. Resolve non-local variables through interfaces. */ InterfaceGenerator().apply(stage); + TypeResolver().apply(stage); VariableResolver().apply(stage); FunctionResolver().apply(stage); @@ -259,7 +259,9 @@ void Compiler::generate(Stage &stage, Mode mode) bool Compiler::validate(Stage &stage) { + TypeValidator().apply(stage); DeclarationValidator().apply(stage); + ReferenceValidator().apply(stage); for(vector::const_iterator i=stage.diagnostics.begin(); i!=stage.diagnostics.end(); ++i) if(i->severity==Diagnostic::ERR) @@ -276,6 +278,7 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) any_inlined |= ExpressionInliner().apply(stage); if(any_inlined) { + TypeResolver().apply(stage); VariableResolver().apply(stage); FunctionResolver().apply(stage); } @@ -284,6 +287,7 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) to become unused. */ bool any_removed = UnusedVariableRemover().apply(stage); any_removed |= UnusedFunctionRemover().apply(stage); + any_removed |= UnusedTypeRemover().apply(stage); return any_removed ? REDO_PREVIOUS : any_inlined ? REDO_STAGE : NEXT_STAGE; }