[Impeller] Reland attempt Vulkan setup and fallback to GLES. (flutter/engine#42820)
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -327,8 +327,10 @@ public class FlutterLoader {
|
||||
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";
|
||||
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user