From bfe6f50b8e8a61a764e36be4674e3de18986117c Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 15 Jan 2018 13:20:30 +0100 Subject: [PATCH] Remove cfg_analysis option. Not using this is broken, and won't work anymore. --- main.cpp | 5 +---- spirv_glsl.cpp | 51 +++++++++++++++++++++++--------------------------- spirv_glsl.hpp | 3 --- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/main.cpp b/main.cpp index 695c152..49fc865 100644 --- a/main.cpp +++ b/main.cpp @@ -479,12 +479,11 @@ struct CLIArguments bool flatten_multidimensional_arrays = false; bool use_420pack_extension = true; bool remove_unused = false; - bool cfg_analysis = true; }; static void print_help() { - fprintf(stderr, "Usage: spirv-cross [--output ] [SPIR-V file] [--es] [--no-es] [--no-cfg-analysis] " + fprintf(stderr, "Usage: spirv-cross [--output ] [SPIR-V file] [--es] [--no-es] " "[--version ] [--dump-resources] [--help] [--force-temporary] " "[--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--flip-vert-y] [--iterations iter] " "[--cpp] [--cpp-interface-name ] " @@ -634,7 +633,6 @@ static int main_inner(int argc, char *argv[]) args.version = parser.next_uint(); args.set_version = true; }); - cbs.add("--no-cfg-analysis", [&args](CLIParser &) { args.cfg_analysis = false; }); cbs.add("--dump-resources", [&args](CLIParser &) { args.dump_resources = true; }); cbs.add("--force-temporary", [&args](CLIParser &) { args.force_temporary = true; }); cbs.add("--flatten-ubo", [&args](CLIParser &) { args.flatten_ubo = true; }); @@ -796,7 +794,6 @@ static int main_inner(int argc, char *argv[]) opts.vulkan_semantics = args.vulkan_semantics; opts.vertex.fixup_clipspace = args.fixup; opts.vertex.flip_vert_y = args.yflip; - opts.cfg_analysis = args.cfg_analysis; compiler->set_options(opts); // Set HLSL specific options. diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index a3e5b5c..a56c82d 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -7701,41 +7701,36 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags) if (!func.analyzed_variable_scope) { - if (options.cfg_analysis) + analyze_variable_scope(func); + + // Check if we can actually use the loop variables we found in analyze_variable_scope. + // To use multiple initializers, we need the same type and qualifiers. + for (auto block : func.blocks) { - analyze_variable_scope(func); + auto &b = get(block); + if (b.loop_variables.size() < 2) + continue; - // Check if we can actually use the loop variables we found in analyze_variable_scope. - // To use multiple initializers, we need the same type and qualifiers. - for (auto block : func.blocks) + uint64_t flags = get_decoration_mask(b.loop_variables.front()); + uint32_t type = get(b.loop_variables.front()).basetype; + bool invalid_initializers = false; + for (auto loop_variable : b.loop_variables) { - auto &b = get(block); - if (b.loop_variables.size() < 2) - continue; - - uint64_t flags = get_decoration_mask(b.loop_variables.front()); - uint32_t type = get(b.loop_variables.front()).basetype; - bool invalid_initializers = false; - for (auto loop_variable : b.loop_variables) + if (flags != get_decoration_mask(loop_variable) || + type != get(b.loop_variables.front()).basetype) { - if (flags != get_decoration_mask(loop_variable) || - type != get(b.loop_variables.front()).basetype) - { - invalid_initializers = true; - break; - } - } - - if (invalid_initializers) - { - for (auto loop_variable : b.loop_variables) - get(loop_variable).loop_variable = false; - b.loop_variables.clear(); + invalid_initializers = true; + break; } } + + if (invalid_initializers) + { + for (auto loop_variable : b.loop_variables) + get(loop_variable).loop_variable = false; + b.loop_variables.clear(); + } } - else - entry_block.dominated_variables = func.local_variables; func.analyzed_variable_scope = true; } diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp index 72d5e6a..2c5ee67 100644 --- a/spirv_glsl.hpp +++ b/spirv_glsl.hpp @@ -65,9 +65,6 @@ public: // Debug option to always emit temporary variables for all expressions. bool force_temporary = false; - // If true, variables will be moved to their appropriate scope through CFG analysis. - bool cfg_analysis = true; - // If true, Vulkan GLSL features are used instead of GL-compatible features. // Mostly useful for debugging SPIR-V files. bool vulkan_semantics = false;