mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-09 22:00:05 +00:00
Cleanup, and make cfg analysis optional.
This commit is contained in:
parent
5ff11cc689
commit
b847c88559
6
main.cpp
6
main.cpp
@ -401,11 +401,13 @@ struct CLIArguments
|
||||
bool metal = false;
|
||||
bool vulkan_semantics = false;
|
||||
bool remove_unused = false;
|
||||
bool cfg_analysis = true;
|
||||
};
|
||||
|
||||
static void print_help()
|
||||
{
|
||||
fprintf(stderr, "Usage: spirv-cross [--output <output path>] [SPIR-V file] [--es] [--no-es] [--version <GLSL "
|
||||
fprintf(stderr, "Usage: spirv-cross [--output <output path>] [SPIR-V file] [--es] [--no-es] [--no-cfg-analysis] "
|
||||
"[--version <GLSL "
|
||||
"version>] [--dump-resources] [--help] [--force-temporary] [--cpp] [--cpp-interface-name <name>] "
|
||||
"[--metal] [--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--iterations iter] [--pls-in "
|
||||
"format input-name] [--pls-out format output-name] [--remap source_name target_name components] "
|
||||
@ -519,6 +521,7 @@ int main(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; });
|
||||
@ -623,6 +626,7 @@ int main(int argc, char *argv[])
|
||||
opts.force_temporary = args.force_temporary;
|
||||
opts.vulkan_semantics = args.vulkan_semantics;
|
||||
opts.vertex.fixup_clipspace = args.fixup;
|
||||
opts.cfg_analysis = args.cfg_analysis;
|
||||
compiler->set_options(opts);
|
||||
|
||||
ShaderResources res;
|
||||
|
@ -513,6 +513,7 @@ struct SPIRFunction : IVariant
|
||||
bool active = false;
|
||||
bool flush_undeclared = true;
|
||||
bool do_combined_parameters = true;
|
||||
bool analyzed_variable_scope = false;
|
||||
};
|
||||
|
||||
struct SPIRVariable : IVariant
|
||||
|
@ -578,10 +578,6 @@ private:
|
||||
ShaderResources get_shader_resources(const std::unordered_set<uint32_t> *active_variables) const;
|
||||
|
||||
VariableTypeRemapCallback variable_remap_callback;
|
||||
|
||||
SPIRBlock &find_common_dominator(
|
||||
const SPIRBlock &entry, uint32_t variable,
|
||||
const std::unordered_map<uint32_t, std::unordered_set<uint32_t>> &block_to_variable_map);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5232,9 +5232,17 @@ void CompilerGLSL::emit_function(SPIRFunction &func, uint64_t return_flags)
|
||||
}
|
||||
}
|
||||
|
||||
analyze_variable_scope(func);
|
||||
|
||||
auto &entry_block = get<SPIRBlock>(func.entry_block);
|
||||
|
||||
if (!func.analyzed_variable_scope)
|
||||
{
|
||||
if (options.cfg_analysis)
|
||||
analyze_variable_scope(func);
|
||||
else
|
||||
entry_block.dominated_variables = func.local_variables;
|
||||
func.analyzed_variable_scope = true;
|
||||
}
|
||||
|
||||
entry_block.loop_dominator = SPIRBlock::NoDominator;
|
||||
emit_block_chain(entry_block);
|
||||
|
||||
|
@ -60,6 +60,9 @@ public:
|
||||
bool es = false;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user