From 05c9c3ff0100e6e2c342801abb59cfbd0691c5f1 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 13 Jun 2023 12:29:31 -0700 Subject: [PATCH 1/2] finish out switches. --- shell/platform/android/context/android_context.h | 3 +++ .../embedding/engine/loader/FlutterLoader.java | 6 ++++-- shell/platform/android/platform_view_android.cc | 13 +++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/context/android_context.h b/shell/platform/android/context/android_context.h index ac3b7d49dee8a..a967ca2451ace 100644 --- a/shell/platform/android/context/android_context.h +++ b/shell/platform/android/context/android_context.h @@ -16,6 +16,9 @@ enum class AndroidRenderingAPI { kSoftware, kOpenGLES, kVulkan, + /// @brief Attempt to create a Vulkan surface, if that fails then fall back + /// to GLES. + kAutoselect, }; //------------------------------------------------------------------------------ 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 fc5c9417e4190..8265cd46a8858 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -327,8 +327,10 @@ public void ensureInitializationComplete( if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) { shellArgs.add("--enable-vulkan-validation"); } - String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY, "opengles"); - shellArgs.add("--impeller-backend=" + backend); + String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY); + if (backend != null) { + shellArgs.add("--impeller-backend=" + backend); + } } final String leakVM = isLeakVM(metaData) ? "true" : "false"; diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 7e8b10f778d03..e1b51127a5695 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -74,8 +74,8 @@ static std::shared_ptr CreateAndroidContext( if (enable_impeller) { // TODO(gaaclarke): We need to devise a more complete heuristic about what // backend to use by default. - // Default value is OpenGLES. - AndroidRenderingAPI backend = AndroidRenderingAPI::kOpenGLES; + // Default value is Vulkan with gles fallback. + AndroidRenderingAPI backend = AndroidRenderingAPI::kAutoselect; if (impeller_backend.has_value()) { if (impeller_backend.value() == "opengles") { backend = AndroidRenderingAPI::kOpenGLES; @@ -93,6 +93,15 @@ static std::shared_ptr CreateAndroidContext( case AndroidRenderingAPI::kVulkan: return std::make_unique( enable_vulkan_validation, worker_task_runner); + case AndroidRenderingAPI::kAutoselect: { + auto vulkan_backend = std::make_unique( + enable_vulkan_validation, worker_task_runner); + if (!vulkan_backend->IsValid()) { + return std::make_unique( + std::make_unique()); + } + return vulkan_backend; + } default: FML_UNREACHABLE(); } From f4c9d008b297f87dd5b6d69613b65bd1eae1e7f1 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Tue, 13 Jun 2023 12:34:37 -0700 Subject: [PATCH 2/2] ++ --- shell/platform/android/platform_view_android.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index e1b51127a5695..a1053fbcaaa13 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -72,9 +72,7 @@ static std::shared_ptr CreateAndroidContext( return std::make_shared(AndroidRenderingAPI::kSoftware); } if (enable_impeller) { - // TODO(gaaclarke): We need to devise a more complete heuristic about what - // backend to use by default. - // Default value is Vulkan with gles fallback. + // Default value is Vulkan with GLES fallback. AndroidRenderingAPI backend = AndroidRenderingAPI::kAutoselect; if (impeller_backend.has_value()) { if (impeller_backend.value() == "opengles") {