From: Mikko Rasa Date: Sat, 13 Nov 2021 12:16:46 +0000 (+0200) Subject: Resolve variables after eliminating constant conditions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1420854eb3827b8229bae2c2c6cebdd34a320f13;p=libs%2Fgl.git Resolve variables after eliminating constant conditions --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 4e9f94d8..a447c9c9 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -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)) diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 64ceddcc..ea0f96f0 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -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) diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index 82fc78cc..75fffa13 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -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 &);