diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/opt/opt.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 34ab4cb1..1eab922e 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -48,6 +48,12 @@ std::string GetListOfPassesAsString(const spvtools::Optimizer& optimizer) { return ss.str(); } +std::string GetLegalizationPasses() { + spvtools::Optimizer optimizer(SPV_ENV_UNIVERSAL_1_2); + optimizer.RegisterLegalizationPasses(); + return GetListOfPassesAsString(optimizer); +} + std::string GetOptimizationPasses() { spvtools::Optimizer optimizer(SPV_ENV_UNIVERSAL_1_2); optimizer.RegisterPerformancePasses(); @@ -140,6 +146,14 @@ Options (in lexicographical order): Exhaustively inline all function calls in entry point call tree functions. Currently does not inline calls to functions with early return in a loop. + --legalize-hlsl + Runs a series of optimizations that attempts to take SPIR-V + generated by and HLSL front-end and generate legal Vulkan SPIR-V. + The optimizations are: + %s + + Note this does not guarantee legal code. This option implies + --skip-validation. --local-redundancy-elimination Looks for instructions in the same basic block that compute the same value, and deletes the redundant ones. @@ -234,8 +248,8 @@ Options (in lexicographical order): --version Display optimizer version information. )", - program, program, GetOptimizationPasses().c_str(), - GetSizePasses().c_str()); + program, program, GetLegalizationPasses().c_str(), + GetOptimizationPasses().c_str(), GetSizePasses().c_str()); } // Reads command-line flags the file specified in |oconfig_flag|. This string @@ -421,6 +435,9 @@ OptStatus ParseFlags(int argc, const char** argv, Optimizer* optimizer, optimizer->RegisterPerformancePasses(); } else if (0 == strcmp(cur_arg, "-Os")) { optimizer->RegisterSizePasses(); + } else if (0 == strcmp(cur_arg, "--legalize-hlsl")) { + *skip_validator = true; + optimizer->RegisterLegalizationPasses(); } else if (0 == strncmp(cur_arg, "-Oconfig=", sizeof("-Oconfig=") - 1)) { OptStatus status = ParseOconfigFlag(argv[0], cur_arg, optimizer, in_file, out_file); |