#include <msp/core/algorithm.h>
-#include <msp/gl/extensions/ext_gpu_shader4.h>
#include <msp/strings/format.h>
#include "builtin.h"
#include "compatibility.h"
#include "optimize.h"
#include "output.h"
#include "resources.h"
-#include "shader.h"
#undef interface
OptimizeResult result = optimize(*i);
if(result==REDO_PREVIOUS)
i = module->stages.begin();
- else
+ else if(result!=REDO_STAGE)
++i;
}
for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
stage.required_features.glsl_version = module->shared.required_features.glsl_version;
inject_block(stage.content, module->shared.content);
- DeclarationReorderer().apply(stage);
-
// Initial resolving pass
BlockHierarchyResolver().apply(stage);
FunctionResolver().apply(stage);
InterfaceGenerator().apply(stage);
VariableResolver().apply(stage);
- DeclarationReorderer().apply(stage);
FunctionResolver().apply(stage);
ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0));
if(mode==PROGRAM)
{
ConstantConditionEliminator().apply(stage);
- FunctionInliner().apply(stage);
- BlockHierarchyResolver().apply(stage);
- VariableResolver().apply(stage);
+ bool any_inlined = FunctionInliner().apply(stage);
+ any_inlined |= ExpressionInliner().apply(stage);
+ if(any_inlined)
+ {
+ VariableResolver().apply(stage);
+ FunctionResolver().apply(stage);
+ }
/* Removing variables or functions may cause things from the previous stage
to become unused. */
bool any_removed = UnusedVariableRemover().apply(stage);
any_removed |= UnusedFunctionRemover().apply(stage);
- return any_removed ? REDO_PREVIOUS : NEXT_STAGE;
+ return any_removed ? REDO_PREVIOUS : any_inlined ? REDO_STAGE : NEXT_STAGE;
}
void Compiler::finalize(Stage &stage, Mode mode)