X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Foptimize.cpp;fp=source%2Fglsl%2Foptimize.cpp;h=64ceddcc16ba92968c2f0d517f0230bb8e739598;hp=96a75d603d6db5bdaaae35de41bbe16fb938cecf;hb=76cc18518fc8b0b4fa11fda153e7d9b3899ed112;hpb=dfcad2edfd319ae1e6e0af53a4701ac3447e9450 diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index 96a75d60..64ceddcc 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -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. */