]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/compiler.cpp
Take care of SPIR-V load IDs in ternary expressions
[libs/gl.git] / source / glsl / compiler.cpp
index e676fcc87233764cc529fe98203bc5d8b666df0f..4c8c1d03d893d277395b2f64b5def34aa7e55168 100644 (file)
@@ -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);
@@ -92,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);
@@ -157,7 +163,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();
 }
 
@@ -208,11 +214,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));
 }
 
@@ -298,6 +304,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>
@@ -363,7 +372,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))