X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=0e26a16353b46bf1ae73876fc08be92b20621b2d;hb=5871764de7aa23d2c40cac03ad9d07088fb57e06;hp=3f25935064beafe5c0fbecd86bcf4dae40eaa16c;hpb=4b05add0a40cc7503b9dc7ff3b15844b02f51e16;p=libs%2Fgl.git diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 3f259350..0e26a163 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -75,6 +75,7 @@ void Compiler::compile(Mode mode) for(Stage &s: module->stages) generate(s); ConstantIdAssigner().apply(*module, features); + LocationAllocator().apply(*module, features, false); for(Stage &s: module->stages) validate(s); @@ -101,6 +102,11 @@ void Compiler::compile(Mode mode) ++i; } + for(Stage &s: module->stages) + { + StructuralFeatureConverter().apply(s, features); + resolve(s, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS); + } LocationAllocator().apply(*module, features); for(Stage &s: module->stages) finalize(s, mode); @@ -152,7 +158,7 @@ vector Compiler::get_combined_spirv() const if(!compiled) throw invalid_operation("Compiler::get_combined_spirv"); SpirVGenerator gen; - gen.apply(*module); + gen.apply(*module, features); return gen.get_code(); } @@ -324,7 +330,7 @@ void Compiler::resolve(Stage &stage, unsigned flags) void Compiler::validate(Stage &stage) { - DeclarationValidator().apply(stage); + DeclarationValidator().apply(stage, features); IdentifierValidator().apply(stage); ReferenceValidator().apply(stage); ExpressionValidator().apply(stage); @@ -358,7 +364,8 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) { if(ConstantFolder().apply(stage)) resolve(stage, RESOLVE_EXPRESSIONS); - ConstantConditionEliminator().apply(stage); + if(ConstantConditionEliminator().apply(stage)) + resolve(stage, RESOLVE_VARIABLES); bool any_inlined = false; if(FunctionInliner().apply(stage)) @@ -389,14 +396,9 @@ Compiler::OptimizeResult Compiler::optimize(Stage &stage) void Compiler::finalize(Stage &stage, Mode mode) { - if(mode==PROGRAM) - { - StructuralFeatureConverter().apply(stage, features); - QualifierConverter().apply(stage, features); - resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS); - PrecisionConverter().apply(stage); - } - else if(mode==SPIRV) + QualifierConverter().apply(stage, features); + PrecisionConverter().apply(stage); + if(mode==SPIRV) StructOrganizer().apply(stage); // Collect bindings from all stages into the shared stage's maps