Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shell/platform/android/context/android_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if adding this will cause issues elsewhere, I''m going to run it on CI and see.

Alternatively could just use a separate flag below.

};

//------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
15 changes: 11 additions & 4 deletions shell/platform/android/platform_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ static std::shared_ptr<flutter::AndroidContext> CreateAndroidContext(
return std::make_shared<AndroidContext>(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 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;
Expand All @@ -93,6 +91,15 @@ static std::shared_ptr<flutter::AndroidContext> CreateAndroidContext(
case AndroidRenderingAPI::kVulkan:
return std::make_unique<AndroidContextVulkanImpeller>(
enable_vulkan_validation, worker_task_runner);
case AndroidRenderingAPI::kAutoselect: {
auto vulkan_backend = std::make_unique<AndroidContextVulkanImpeller>(
enable_vulkan_validation, worker_task_runner);
if (!vulkan_backend->IsValid()) {
return std::make_unique<AndroidContextGLImpeller>(
std::make_unique<impeller::egl::Display>());
}
return vulkan_backend;
}
default:
FML_UNREACHABLE();
}
Expand Down