X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=5bec9c8b1b8f475163b50a35b57b0a92e5bec84b;hp=a18b8e8c2c3df57e0f26c2d126719edbaced8fb5;hb=30465dd3b9f55ec42c4b19c3c2077eede7237a26;hpb=a47639620c40397939ae4d79c08d5d8f460bad5c diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index a18b8e8c..5bec9c8b 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -214,11 +214,17 @@ void Compiler::generate(Stage &stage, Mode mode) inject_block(stage.content, module->shared.content); DeclarationReorderer().apply(stage); - BlockResolver().apply(stage); + + // Initial resolving pass + BlockHierarchyResolver().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); VariableResolver().apply(stage); + DeclarationReorderer().apply(stage); FunctionResolver().apply(stage); ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0)); @@ -231,9 +237,11 @@ bool Compiler::optimize(Stage &stage) ConstantConditionEliminator().apply(stage); FunctionInliner().apply(stage); - BlockResolver().apply(stage); + BlockHierarchyResolver().apply(stage); VariableResolver().apply(stage); + /* Removing variables or functions may cause things from the previous stage + to become unused. */ bool result = UnusedVariableRemover().apply(stage); result |= UnusedFunctionRemover().apply(stage);