X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fcompiler.cpp;h=05bf421cd422428dbf1b09b5eef3d0daf737c3f9;hp=a447c9c9adbb5c07550bfb090b0923552a1d916a;hb=1a5dafe20e47c764f2914c341fb7b8f1fba59fb8;hpb=1420854eb3827b8229bae2c2c6cebdd34a320f13 diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index a447c9c9..05bf421c 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -93,6 +93,11 @@ void Compiler::compile(Mode mode) for(Stage &s: module->stages) ConstantSpecializer().apply(s, spec_values); } + if(mode==PROGRAM) + { + for(Stage &s: module->stages) + DepthRangeConverter().apply(s, features); + } for(auto i=module->stages.begin(); i!=module->stages.end(); ) { OptimizeResult result = optimize(*i); @@ -102,6 +107,19 @@ void Compiler::compile(Mode mode) ++i; } + Stage *prev_stage = 0; + for(auto i=module->stages.begin(); i!=module->stages.end(); ) + { + if(i->functions.empty()) + i = module->stages.erase(i); + else + { + i->previous = prev_stage; + prev_stage = &*i; + ++i; + } + } + for(Stage &s: module->stages) { StructuralFeatureConverter().apply(s, features); @@ -158,7 +176,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(); } @@ -209,11 +227,11 @@ const SourceMap &Compiler::get_source_map() const return module->source_map; } -string Compiler::get_stage_debug(Stage::Type stage_type) const +string Compiler::get_stage_debug(Stage::Type stage_type, bool use_colors) const { auto i = find_member(module->stages, stage_type, &Stage::type); if(i!=module->stages.end()) - return DumpTree().apply(*i); + return DumpTree(use_colors).apply(*i); throw key_error(Stage::get_stage_name(stage_type)); } @@ -299,6 +317,9 @@ void Compiler::generate(Stage &stage) variables through interfaces. */ InterfaceGenerator().apply(stage); resolve(stage, RESOLVE_BLOCKS|RESOLVE_TYPES|RESOLVE_VARIABLES); + + ArraySizer().apply(stage); + resolve(stage, RESOLVE_EXPRESSIONS); } template