X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=30a3f08c58a98b34cf10ffc8224540375978c69e;hp=66a487fbccd4b7a63f2575295ecc03fcbfcddf5a;hb=6d11ee7d6137117f441951615cd4cde4d59bf968;hpb=caa84a9d8adce6dc702f6e0ae32961b77a0a73ea diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 66a487fb..30a3f08c 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -241,16 +241,12 @@ void Compiler::generate(Stage &stage, Mode mode) // Initial resolving pass BlockHierarchyResolver().apply(stage); - TypeResolver().apply(stage); - FunctionResolver().apply(stage); - VariableResolver().apply(stage); + resolve(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); - ExpressionResolver().apply(stage); + resolve(stage); FunctionResolver().apply(stage); ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0)); @@ -258,6 +254,15 @@ void Compiler::generate(Stage &stage, Mode mode) LegacyConverter().apply(stage, features); } +void Compiler::resolve(Stage &stage) +{ + TypeResolver().apply(stage); + // Use the bitwise or to always evaluate both operands + while(VariableResolver().apply(stage) | + ExpressionResolver().apply(stage)) ; + FunctionResolver().apply(stage); +} + bool Compiler::validate(Stage &stage) { TypeValidator().apply(stage); @@ -279,12 +284,7 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) bool any_inlined = FunctionInliner().apply(stage); any_inlined |= ExpressionInliner().apply(stage); if(any_inlined) - { - TypeResolver().apply(stage); - VariableResolver().apply(stage); - FunctionResolver().apply(stage); - ExpressionResolver().apply(stage); - } + resolve(stage); /* Removing variables or functions may cause things from the previous stage to become unused. */