From 602d4d6c3e639e05a45214d7f50a590a653decbc Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 31 Aug 2023 14:49:58 -0700 Subject: [PATCH 1/5] [Impeller] turned on validations for all debug builds --- shell/platform/android/BUILD.gn | 4 +++- .../flutter/embedding/engine/loader/FlutterLoader.java | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 18562b0ae24c4..6ebed9f200336 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -490,7 +490,9 @@ action("android_jar") { ":pom_libflutter", ] - if (enable_vulkan_validation_layers) { + if (enable_vulkan_validation_layers || + (impeller_enable_vulkan && current_cpu == "arm64" && + flutter_runtime_mode == "debug")) { assert(impeller_enable_vulkan) deps += [ "//third_party/vulkan_validation_layers" ] 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 8265cd46a8858..01f940b95b7c3 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -214,6 +214,13 @@ public InitResult call() { } } + private static boolean areValidationLayersOnByDefault() { + if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + return Build.SUPPORTED_ABIS[0].equals("arm64-v8a"); + } + return false; + } + /** * Blocks until initialization of the native system has completed. * @@ -324,7 +331,8 @@ public void ensureInitializationComplete( if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) { shellArgs.add("--enable-impeller"); } - if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) { + if (metaData.getBoolean( + ENABLE_VULKAN_VALIDATION_META_DATA_KEY, areValidationLayersOnByDefault())) { shellArgs.add("--enable-vulkan-validation"); } String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY); From ed153785099e73b9604a040c53eaceabd55c6c24 Mon Sep 17 00:00:00 2001 From: Zach Anderson Date: Fri, 1 Sep 2023 14:21:32 -0700 Subject: [PATCH 2/5] Build vulkan validation layers with api level 26, and bundle --- DEPS | 2 +- shell/platform/android/BUILD.gn | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DEPS b/DEPS index a2ec8dc8fc719..0f06f1986a01b 100644 --- a/DEPS +++ b/DEPS @@ -261,7 +261,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + '6b0243e97d94836767ea8b94a477d7d15ee3bb91', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b615dd6af4c2e95a388060151c7fd1e429e34d61', # Fuchsia compatibility # diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 6ebed9f200336..ec965a4c0a53f 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -494,12 +494,15 @@ action("android_jar") { (impeller_enable_vulkan && current_cpu == "arm64" && flutter_runtime_mode == "debug")) { assert(impeller_enable_vulkan) - deps += [ "//third_party/vulkan_validation_layers" ] + apilevel26_toolchain = "//build/toolchain/android:clang_arm64_apilevel26" + validation_layer_target = + "//third_party/vulkan_validation_layers($apilevel26_toolchain)" + validation_layer_out_dir = + get_label_info(validation_layer_target, "root_out_dir") + deps += [ validation_layer_target ] args += [ "--native_lib", - rebase_path("libVkLayer_khronos_validation.so", - root_build_dir, - root_build_dir), + rebase_path("$validation_layer_out_dir/libVkLayer_khronos_validation.so"), ] if (current_cpu == "arm64") { args += [ From ba3544d8799c193f76c5c3a1641748c042f75345 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 1 Sep 2023 10:51:30 -0700 Subject: [PATCH 3/5] moved the logic to turn on the validation layers to gn --- shell/platform/android/BUILD.gn | 4 +--- .../io/flutter/embedding/engine/loader/FlutterLoader.java | 2 +- tools/gn | 4 +++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index ec965a4c0a53f..df9324c064491 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -490,9 +490,7 @@ action("android_jar") { ":pom_libflutter", ] - if (enable_vulkan_validation_layers || - (impeller_enable_vulkan && current_cpu == "arm64" && - flutter_runtime_mode == "debug")) { + if (enable_vulkan_validation_layers) { assert(impeller_enable_vulkan) apilevel26_toolchain = "//build/toolchain/android:clang_arm64_apilevel26" validation_layer_target = 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 01f940b95b7c3..2b880ba3e9883 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -215,7 +215,7 @@ public InitResult call() { } private static boolean areValidationLayersOnByDefault() { - if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { return Build.SUPPORTED_ABIS[0].equals("arm64-v8a"); } return false; diff --git a/tools/gn b/tools/gn index deaea47283957..3bac2e7219685 100755 --- a/tools/gn +++ b/tools/gn @@ -646,7 +646,9 @@ def to_gn_args(args): if args.unoptimized and args.target_os == 'android' and args.android_cpu == 'arm64': enable_vulkan_validation = True - if enable_vulkan_validation: + if enable_vulkan_validation or (args.enable_impeller_vulkan and + runtime_mode == 'debug' and + gn_args['target_cpu'] == 'arm64'): gn_args['enable_vulkan_validation_layers'] = True if args.target_os == 'android': gn_args['android_api_level'] = 26 From 8e1c91a7b0c4bddd7b4c4041e90c34d5415dc645 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 1 Sep 2023 15:58:53 -0700 Subject: [PATCH 4/5] added log statement about using validation layers --- shell/platform/android/android_context_vulkan_impeller.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/android_context_vulkan_impeller.cc b/shell/platform/android/android_context_vulkan_impeller.cc index 4adc2d1beefb6..0aa4b391d59d7 100644 --- a/shell/platform/android/android_context_vulkan_impeller.cc +++ b/shell/platform/android/android_context_vulkan_impeller.cc @@ -38,7 +38,11 @@ static std::shared_ptr CreateImpellerContext( settings.cache_directory = fml::paths::GetCachesDirectory(); settings.enable_validation = enable_vulkan_validation; - FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan)."; + if (settings.enable_validation) { + FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan with Validation Layers)."; + } else { + FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan)."; + } return impeller::ContextVK::Create(std::move(settings)); } From 27f55152e058b5dcd56639ebb9236698cb87ffab Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Fri, 1 Sep 2023 15:59:19 -0700 Subject: [PATCH 5/5] added log statement --- shell/platform/android/android_context_vulkan_impeller.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/android_context_vulkan_impeller.cc b/shell/platform/android/android_context_vulkan_impeller.cc index 0aa4b391d59d7..7c5743ea48b2b 100644 --- a/shell/platform/android/android_context_vulkan_impeller.cc +++ b/shell/platform/android/android_context_vulkan_impeller.cc @@ -39,7 +39,8 @@ static std::shared_ptr CreateImpellerContext( settings.enable_validation = enable_vulkan_validation; if (settings.enable_validation) { - FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan with Validation Layers)."; + FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan with " + "Validation Layers)."; } else { FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan)."; }