]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Remove Vulkan checks from feature converters
[libs/gl.git] / source / glsl / compiler.cpp
index 4e9f94d86b51e0044786927f7bc77c6d8e32c720..05bf421cd422428dbf1b09b5eef3d0daf737c3f9 100644 (file)
@@ -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<uint32_t> 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<typename T>
@@ -364,7 +385,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))