From 26a5b404558cebdfa514e397985e607eda2ee7ec Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Thu, 21 Jul 2022 13:52:33 -0700 Subject: [PATCH] [impellerc] Adds an --iplr flag (flutter/engine#34822) --- .../impeller/compiler/impellerc_main.cc | 2 +- .../src/flutter/impeller/compiler/switches.cc | 3 +++ .../src/flutter/impeller/compiler/switches.h | 1 + engine/src/flutter/impeller/fixtures/BUILD.gn | 1 + engine/src/flutter/impeller/tools/impeller.gni | 18 +++++++++++++++++- engine/src/flutter/lib/spirv/test/BUILD.gn | 1 + .../lib/spirv/test/general_shaders/BUILD.gn | 1 + .../test/supported_glsl_op_shaders/BUILD.gn | 1 + .../spirv/test/supported_op_shaders/BUILD.gn | 1 + 9 files changed, 27 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/compiler/impellerc_main.cc b/engine/src/flutter/impeller/compiler/impellerc_main.cc index bf23ae3f3e4..76d844c070c 100644 --- a/engine/src/flutter/impeller/compiler/impellerc_main.cc +++ b/engine/src/flutter/impeller/compiler/impellerc_main.cc @@ -85,7 +85,7 @@ bool Main(const fml::CommandLine& command_line) { if (TargetPlatformNeedsSL(options.target_platform)) { auto sl_file_name = std::filesystem::absolute( std::filesystem::current_path() / switches.sl_file_name); - const bool is_runtime_stage_data = HasSuffix(switches.sl_file_name, "iplr"); + const bool is_runtime_stage_data = switches.iplr; if (is_runtime_stage_data) { auto reflector = compiler.GetReflector(); if (reflector == nullptr) { diff --git a/engine/src/flutter/impeller/compiler/switches.cc b/engine/src/flutter/impeller/compiler/switches.cc index 84d516b6d8d..8b7f928850f 100644 --- a/engine/src/flutter/impeller/compiler/switches.cc +++ b/engine/src/flutter/impeller/compiler/switches.cc @@ -52,6 +52,8 @@ void Switches::PrintHelp(std::ostream& stream) { stream << "}" << std::endl; stream << "--sl=" << std::endl; stream << "--spirv=" << std::endl; + stream << "[optional] --iplr (causes --sl file to be emitted in iplr format)" + << std::endl; stream << "[optional] --reflection-json=" << std::endl; stream << "[optional] --reflection-header=" << std::endl; @@ -103,6 +105,7 @@ Switches::Switches(const fml::CommandLine& command_line) source_file_name(command_line.GetOptionValueWithDefault("input", "")), input_type(SourceTypeFromCommandLine(command_line)), sl_file_name(command_line.GetOptionValueWithDefault("sl", "")), + iplr(command_line.HasOption("iplr")), spirv_file_name(command_line.GetOptionValueWithDefault("spirv", "")), reflection_json_name( command_line.GetOptionValueWithDefault("reflection-json", "")), diff --git a/engine/src/flutter/impeller/compiler/switches.h b/engine/src/flutter/impeller/compiler/switches.h index 8d73ceb36c7..81b0b8b1ce1 100644 --- a/engine/src/flutter/impeller/compiler/switches.h +++ b/engine/src/flutter/impeller/compiler/switches.h @@ -24,6 +24,7 @@ struct Switches { std::string source_file_name; SourceType input_type; std::string sl_file_name; + bool iplr; std::string spirv_file_name; std::string reflection_json_name; std::string reflection_header_name; diff --git a/engine/src/flutter/impeller/fixtures/BUILD.gn b/engine/src/flutter/impeller/fixtures/BUILD.gn index 14825acf310..5d205a4f146 100644 --- a/engine/src/flutter/impeller/fixtures/BUILD.gn +++ b/engine/src/flutter/impeller/fixtures/BUILD.gn @@ -26,6 +26,7 @@ impellerc("runtime_stages") { shaders = [ "ink_sparkle.frag" ] sl_file_extension = "iplr" shader_target_flag = "--runtime-stage-metal" + iplr = true } test_fixtures("file_fixtures") { diff --git a/engine/src/flutter/impeller/tools/impeller.gni b/engine/src/flutter/impeller/tools/impeller.gni index d3487d334af..287147063df 100644 --- a/engine/src/flutter/impeller/tools/impeller.gni +++ b/engine/src/flutter/impeller/tools/impeller.gni @@ -248,7 +248,18 @@ template("impellerc") { defined(invoker.sl_file_extension), "The extension of the SL file must be specified (metal, glsl, etc..).") } + iplr = false + if (defined(invoker.iplr) && invoker.iplr) { + iplr = invoker.iplr + } + # Not needed on every path. + not_needed([ + "iplr", + "sksl", + ]) + + # Optional: invoker.iplr Causes --sl output to be in iplr format. # Optional: invoker.defines specifies a list of valueless macro definitions. # Optional: invoker.intermediates_subdir specifies the subdirectory in which # to put intermediates. @@ -281,7 +292,6 @@ template("impellerc") { ] if (flutter_spirv) { - not_needed([ "sksl" ]) args += [ "--spirv=$spirv_intermediate_path" ] outputs = [ spirv_intermediate ] } else if (sksl) { @@ -292,6 +302,9 @@ template("impellerc") { "--sl=$sl_intermediate_path", "--spirv=$spirv_intermediate_path", ] + if (iplr) { + args += [ "--iplr" ] + } outputs = [ sl_intermediate ] } else { @@ -316,6 +329,9 @@ template("impellerc") { "--reflection-header=$reflection_header_path", "--reflection-cc=$reflection_cc_path", ] + if (iplr) { + args += [ "--iplr" ] + } outputs = [ sl_intermediate, diff --git a/engine/src/flutter/lib/spirv/test/BUILD.gn b/engine/src/flutter/lib/spirv/test/BUILD.gn index e9aaedb4c57..64955689515 100644 --- a/engine/src/flutter/lib/spirv/test/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/BUILD.gn @@ -51,6 +51,7 @@ if (enable_unittests) { shader_target_flag = "--sksl" intermediates_subdir = "iplr" sl_file_extension = "iplr" + iplr = true } test_fixtures("fixtures") { diff --git a/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn b/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn index 4eb3fd746e5..bbe4deb3c8f 100644 --- a/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/general_shaders/BUILD.gn @@ -44,6 +44,7 @@ if (enable_unittests) { shader_target_flag = "--sksl" intermediates_subdir = "iplr" sl_file_extension = "iplr" + iplr = true } test_fixtures("fixtures") { diff --git a/engine/src/flutter/lib/spirv/test/supported_glsl_op_shaders/BUILD.gn b/engine/src/flutter/lib/spirv/test/supported_glsl_op_shaders/BUILD.gn index bd7b16d3f50..b359766f70a 100644 --- a/engine/src/flutter/lib/spirv/test/supported_glsl_op_shaders/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/supported_glsl_op_shaders/BUILD.gn @@ -70,6 +70,7 @@ if (enable_unittests) { shader_target_flag = "--sksl" intermediates_subdir = "iplr" sl_file_extension = "iplr" + iplr = true } test_fixtures("fixtures") { diff --git a/engine/src/flutter/lib/spirv/test/supported_op_shaders/BUILD.gn b/engine/src/flutter/lib/spirv/test/supported_op_shaders/BUILD.gn index bf239541433..13e1c5a4daf 100644 --- a/engine/src/flutter/lib/spirv/test/supported_op_shaders/BUILD.gn +++ b/engine/src/flutter/lib/spirv/test/supported_op_shaders/BUILD.gn @@ -66,6 +66,7 @@ if (enable_unittests) { shader_target_flag = "--sksl" intermediates_subdir = "iplr" sl_file_extension = "iplr" + iplr = true } test_fixtures("fixtures") {