From c43203c52410ee8a734e775e7ee7368a12f82ff7 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 10 Oct 2021 14:14:54 +0300 Subject: [PATCH] Remove some unused code from UnusedVariableRemover The interface_block variable has always been null since dfcf8eb. --- source/glsl/optimize.cpp | 18 +++--------------- source/glsl/optimize.h | 2 -- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 0d6f7537..a8ff44a5 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -1267,16 +1267,8 @@ bool UnusedVariableRemover::apply(Stage &s) for(AssignmentInfo *a: kvp.second.assignments) unused_nodes.erase(a->node); } - - if(!kvp.second.output && !kvp.second.referenced) - { - // Don't remove variables from inside interface blocks. - if(!kvp.second.interface_block) - unused_nodes.insert(kvp.first); - } - else if(kvp.second.interface_block) - // Interface blocks are kept if even one member is used. - unused_nodes.erase(kvp.second.interface_block); + else if(!kvp.second.referenced) + unused_nodes.insert(kvp.first); } NodeRemover().apply(s, unused_nodes); @@ -1493,14 +1485,10 @@ void UnusedVariableRemover::visit(VariableDeclaration &var) return; VariableInfo &var_info = variables[&var]; - var_info.interface_block = interface_block; /* Mark variables as output if they're used by the next stage or the graphics API. */ - if(interface_block) - var_info.output = (interface_block->interface=="out" && (interface_block->linked_block || !interface_block->block_name.compare(0, 3, "gl_"))); - else - var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_"))); + var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_"))); if(var.init_expression) { diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index b8ab3201..d9fc2d6a 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -328,7 +328,6 @@ private: struct VariableInfo { - InterfaceBlock *interface_block = 0; std::vector assignments; bool initialized = false; bool output = false; @@ -340,7 +339,6 @@ private: Stage *stage = 0; BlockVariableMap variables; std::list assignments; - InterfaceBlock *interface_block = 0; Assignment *r_assignment = 0; bool assignment_target = false; bool r_side_effects = false; -- 2.43.0