From ab0ade1fc8dffd6b7ecf9d18115cdd2d68e9e9fe Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Tue, 6 Jun 2023 13:05:51 -0700 Subject: [PATCH 1/6] [Impeller] made a switch for turning on validation layers --- DEPS | 2 +- shell/config.gni | 1 + shell/platform/android/BUILD.gn | 18 ++++++++++++++++ .../engine/loader/FlutterLoader.java | 21 +++++++++++++++++-- .../scenario_app/android/gradle.properties | 2 +- tools/gn | 9 ++++---- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 06e3bbf036f00..9d21bb1e7949a 100644 --- a/DEPS +++ b/DEPS @@ -257,7 +257,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + '859e7ccc38f55f89dac8aea49367b7a4c1656490', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'fabb92f0ada787444ad0be22638c80a6d5927a2c', # Fuchsia compatibility # diff --git a/shell/config.gni b/shell/config.gni index 3f498d2c044f7..1875137080d69 100644 --- a/shell/config.gni +++ b/shell/config.gni @@ -10,6 +10,7 @@ declare_args() { shell_enable_vulkan = false shell_enable_software = true + enable_vulkan_validation_layers = false } declare_args() { diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 0f3ff3ebb5b9a..3e964a4e53316 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -478,6 +478,24 @@ action("android_jar") { ":pom_libflutter", ] + if (enable_vulkan_validation_layers) { + deps += [ "//third_party/vulkan_validation_layers" ] + args += [ + "--native_lib", + rebase_path("libVkLayer_khronos_validation.so", + root_build_dir, + root_build_dir), + ] + if (current_cpu == "arm64") { + args += [ + "--native_lib", + rebase_path("$android_libcpp_root/libs/arm64-v8a/libc++_shared.so", root_build_dir), + ] + } else { + assert(false, "Validation layers not supported for arch.") + } + } + if (flutter_runtime_mode == "profile") { deps += [ "//flutter/shell/vmservice:vmservice_snapshot" ] args += [ diff --git a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java index 5461838e7ad85..e9fb3cb6dd83c 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -41,6 +41,13 @@ public class FlutterLoader { "io.flutter.embedding.android.OldGenHeapSize"; private static final String ENABLE_IMPELLER_META_DATA_KEY = "io.flutter.embedding.android.EnableImpeller"; +<<<<<<< HEAD +======= + private static final String IMPELLER_BACKEND_META_DATA_KEY = + "io.flutter.embedding.android.ImpellerBackend"; + private static final String ENABLE_VULKAN_VALIDATION_META_DATA_KEY = + "io.flutter.embedding.android.EnableVulkanValidation"; +>>>>>>> 2e93fc1cf8 ([Impeller] made a switch for turning on validation layers) /** * Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's @@ -316,8 +323,18 @@ public void ensureInitializationComplete( shellArgs.add("--prefetched-default-font-manager"); - if (metaData != null && metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) { - shellArgs.add("--enable-impeller"); + if (metaData != null) { + if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) { + shellArgs.add("--enable-impeller"); + } + String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY, "opengles"); + shellArgs.add("--impeller-backend=" + backend); + + Log.d(TAG, "foobar has metadata"); + if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) { + Log.d(TAG, "foobar has validation flag"); + shellArgs.add("--enable-vulkan-validation"); + } } final String leakVM = isLeakVM(metaData) ? "true" : "false"; diff --git a/testing/scenario_app/android/gradle.properties b/testing/scenario_app/android/gradle.properties index 06d12a7d35f42..0b5c48ae64de0 100644 --- a/testing/scenario_app/android/gradle.properties +++ b/testing/scenario_app/android/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx2048M android.useAndroidX=true android.enableJetifier=true android.builder.sdkDownload=false diff --git a/tools/gn b/tools/gn index d94ba6e56ffc9..102add1b30daa 100755 --- a/tools/gn +++ b/tools/gn @@ -80,6 +80,8 @@ def to_command_line(gn_args): def merge(key, value): if isinstance(value, bool): return '%s=%s' % (key, 'true' if value else 'false') + elif isinstance(value, int): + return '%s=%d' % (key, value) return '%s="%s"' % (key, value) return [merge(x, y) for x, y in gn_args.items()] @@ -548,11 +550,8 @@ def to_gn_args(args): gn_args['use_fstack_protector'] = True if args.enable_vulkan_validation_layers: - if args.target_os != 'fuchsia': - print( - 'Vulkan validation layers are currently only supported on Fuchsia targets.' - ) - sys.exit(1) + if args.target_os == 'android': + gn_args['android_api_level'] = int(26) gn_args['enable_vulkan_validation_layers'] = True # Enable pointer compression on 64-bit mobile targets. iOS is excluded due to From 462ae8ca05769259fdf6905ae840aa6b878472d1 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 7 Jun 2023 15:15:18 -0700 Subject: [PATCH 2/6] swaped out fuchsias arg --- shell/platform/fuchsia/flutter/BUILD.gn | 1 + tools/gn | 2 +- vulkan/config.gni | 6 ------ 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index 68af2224ef07b..b9b4202306471 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -6,6 +6,7 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") import("//flutter/common/config.gni") +import("//flutter/shell/config.gni") import("//flutter/shell/gpu/gpu.gni") import("//flutter/testing/testing.gni") import("//flutter/tools/fuchsia/dart.gni") diff --git a/tools/gn b/tools/gn index 102add1b30daa..84f240e112b4d 100755 --- a/tools/gn +++ b/tools/gn @@ -80,7 +80,7 @@ def to_command_line(gn_args): def merge(key, value): if isinstance(value, bool): return '%s=%s' % (key, 'true' if value else 'false') - elif isinstance(value, int): + if isinstance(value, int): return '%s=%d' % (key, value) return '%s="%s"' % (key, value) diff --git a/vulkan/config.gni b/vulkan/config.gni index 08ccbab720647..b26dd589a5190 100644 --- a/vulkan/config.gni +++ b/vulkan/config.gni @@ -3,10 +3,4 @@ # found in the LICENSE file. declare_args() { - # Whether to include vulkan validation layers, if available. - # - # Currently these are only supported on Fuchsia, where by default they are - # disabled, to enable them pass `--enable-vulkan-validation-layers` to your - # gn args. - enable_vulkan_validation_layers = false } From e4ba2168f11e8dcccdd283308cb8d896c2e2c879 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 7 Jun 2023 15:17:24 -0700 Subject: [PATCH 3/6] format android build --- shell/platform/android/BUILD.gn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 3e964a4e53316..79c71e31eb7b3 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -489,8 +489,9 @@ action("android_jar") { if (current_cpu == "arm64") { args += [ "--native_lib", - rebase_path("$android_libcpp_root/libs/arm64-v8a/libc++_shared.so", root_build_dir), - ] + rebase_path("$android_libcpp_root/libs/arm64-v8a/libc++_shared.so", + root_build_dir), + ] } else { assert(false, "Validation layers not supported for arch.") } From 4236be3fda4172add04eeb65c5580ae92c04f437 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Wed, 7 Jun 2023 15:18:30 -0700 Subject: [PATCH 4/6] removed stray logs --- .../io/flutter/embedding/engine/loader/FlutterLoader.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java index e9fb3cb6dd83c..e3600d564c2f4 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -330,9 +330,7 @@ public void ensureInitializationComplete( String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY, "opengles"); shellArgs.add("--impeller-backend=" + backend); - Log.d(TAG, "foobar has metadata"); if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) { - Log.d(TAG, "foobar has validation flag"); shellArgs.add("--enable-vulkan-validation"); } } From 83879f60a7415740829b1295b6e55c1f20e26846 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 8 Jun 2023 11:03:49 -0700 Subject: [PATCH 5/6] zach feedback --- shell/config.gni | 1 - shell/platform/android/BUILD.gn | 3 +++ tools/gn | 2 +- vulkan/config.gni | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/config.gni b/shell/config.gni index 1875137080d69..3f498d2c044f7 100644 --- a/shell/config.gni +++ b/shell/config.gni @@ -10,7 +10,6 @@ declare_args() { shell_enable_vulkan = false shell_enable_software = true - enable_vulkan_validation_layers = false } declare_args() { diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 79c71e31eb7b3..da4811bdcfb0e 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -6,9 +6,11 @@ import("//build/config/android/config.gni") import("//build/toolchain/clang.gni") import("//flutter/build/zip_bundle.gni") import("//flutter/common/config.gni") +import("//flutter/impeller/tools/impeller.gni") import("//flutter/shell/config.gni") import("//flutter/shell/gpu/gpu.gni") import("//flutter/shell/version/version.gni") +import("//flutter/vulkan/config.gni") shell_gpu_configuration("android_gpu_configuration") { enable_software = true @@ -479,6 +481,7 @@ action("android_jar") { ] if (enable_vulkan_validation_layers) { + assert(impeller_enable_vulkan) deps += [ "//third_party/vulkan_validation_layers" ] args += [ "--native_lib", diff --git a/tools/gn b/tools/gn index 84f240e112b4d..07334fbdde93b 100755 --- a/tools/gn +++ b/tools/gn @@ -551,7 +551,7 @@ def to_gn_args(args): if args.enable_vulkan_validation_layers: if args.target_os == 'android': - gn_args['android_api_level'] = int(26) + gn_args['android_api_level'] = 26 gn_args['enable_vulkan_validation_layers'] = True # Enable pointer compression on 64-bit mobile targets. iOS is excluded due to diff --git a/vulkan/config.gni b/vulkan/config.gni index b26dd589a5190..bbddfb1dfa491 100644 --- a/vulkan/config.gni +++ b/vulkan/config.gni @@ -3,4 +3,6 @@ # found in the LICENSE file. declare_args() { + # Whether to include vulkan validation layers. + enable_vulkan_validation_layers = false } From 73f4eaf7cd25ff851e711e3bd83ebe1a12aa9dff Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 8 Jun 2023 11:11:44 -0700 Subject: [PATCH 6/6] fixed rebase errors --- .../io/flutter/embedding/engine/loader/FlutterLoader.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java index e3600d564c2f4..38334c6452b06 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -41,13 +41,8 @@ public class FlutterLoader { "io.flutter.embedding.android.OldGenHeapSize"; private static final String ENABLE_IMPELLER_META_DATA_KEY = "io.flutter.embedding.android.EnableImpeller"; -<<<<<<< HEAD -======= - private static final String IMPELLER_BACKEND_META_DATA_KEY = - "io.flutter.embedding.android.ImpellerBackend"; private static final String ENABLE_VULKAN_VALIDATION_META_DATA_KEY = "io.flutter.embedding.android.EnableVulkanValidation"; ->>>>>>> 2e93fc1cf8 ([Impeller] made a switch for turning on validation layers) /** * Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's @@ -327,9 +322,6 @@ public void ensureInitializationComplete( if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) { shellArgs.add("--enable-impeller"); } - String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY, "opengles"); - shellArgs.add("--impeller-backend=" + backend); - if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) { shellArgs.add("--enable-vulkan-validation"); }