]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/optimize.cpp
Use OriginUpperLeft execution mode on Vulkan as required by the spec
[libs/gl.git] / source / glsl / optimize.cpp
index 96a75d603d6db5bdaaae35de41bbe16fb938cecf..ea0f96f0e60920cba9dd23523e83c37a07133ffb 100644 (file)
@@ -114,9 +114,13 @@ string InlineContentInjector::apply(Stage &stage, FunctionDeclaration &target_fu
        source_func = call.declaration->definition;
 
        /* Populate referenced_names from the target function so we can rename
-       variables from the inlined function that would conflict. */
+       variables from the inlined function that would conflict.  Only consider
+       names which declared in blocks linearly related to the target block. */
        pass = REFERENCED;
-       target_func.visit(*this);
+       tgt_blk.visit(*this);
+       for(const Block *b=&tgt_blk; b; b=b->parent)
+               for(const auto &kvp: b->variables)
+                       referenced_names.insert(kvp.first);
 
        /* Inline and rename passes must be interleaved so used variable names are
        known when inlining the return statement. */
@@ -1053,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)