]> git.tdb.fi Git - libs/gl.git/commitdiff
Resolve variables after eliminating constant conditions
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 12:16:46 +0000 (14:16 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 12:16:46 +0000 (14:16 +0200)
source/glsl/compiler.cpp
source/glsl/optimize.cpp
source/glsl/optimize.h

index 4e9f94d86b51e0044786927f7bc77c6d8e32c720..a447c9c9adbb5c07550bfb090b0923552a1d916a 100644 (file)
@@ -364,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))
index 64ceddcc16ba92968c2f0d517f0230bb8e739598..ea0f96f0e60920cba9dd23523e83c37a07133ffb 100644 (file)
@@ -1057,10 +1057,11 @@ void ConstantFolder::visit(Iteration &iter)
 }
 
 
-void ConstantConditionEliminator::apply(Stage &stage)
+bool ConstantConditionEliminator::apply(Stage &stage)
 {
        stage.content.visit(*this);
        NodeRemover().apply(stage, nodes_to_remove);
+       return !nodes_to_remove.empty();
 }
 
 ConstantConditionEliminator::ConstantStatus ConstantConditionEliminator::check_constant_condition(const Expression &expr)
index 82fc78cc546e562b5c77ea096112ae2ec59fab38..75fffa13bb4fcaf6527d56ab676a7b88553cb8c5 100644 (file)
@@ -262,7 +262,7 @@ private:
        bool r_external_side_effects = false;
 
 public:
-       void apply(Stage &);
+       bool apply(Stage &);
 
 private:
        ConstantStatus check_constant_condition(const Expression &);