Skip to content

Commit

Permalink
Revert "[Impeller] Added a switch to turn on vulkan" (flutter#42660)
Browse files Browse the repository at this point in the history
Reverts flutter#42585

Reverting to investigate
flutter/flutter#128484
  • Loading branch information
zanderso authored Jun 8, 2023
1 parent 65cb727 commit 30a2d61
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 63 deletions.
3 changes: 0 additions & 3 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@ struct Settings {
bool enable_impeller = false;
#endif

// Requests a particular backend to be used (ex "opengles" or "vulkan")
std::optional<std::string> impeller_backend;

// Enable Vulkan validation on backends that support it. The validation layers
// must be available to the application.
bool enable_vulkan_validation = false;
Expand Down
22 changes: 5 additions & 17 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,23 +443,11 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
settings.use_asset_fonts =
!command_line.HasOption(FlagForSwitch(Switch::DisableAssetFonts));

{
std::string enable_impeller_value;
if (command_line.GetOptionValue(FlagForSwitch(Switch::EnableImpeller),
&enable_impeller_value)) {
settings.enable_impeller =
enable_impeller_value.empty() || "true" == enable_impeller_value;
}
}

{
std::string impeller_backend_value;
if (command_line.GetOptionValue(FlagForSwitch(Switch::ImpellerBackend),
&impeller_backend_value)) {
if (!impeller_backend_value.empty()) {
settings.impeller_backend = impeller_backend_value;
}
}
std::string enable_impeller_value;
if (command_line.GetOptionValue(FlagForSwitch(Switch::EnableImpeller),
&enable_impeller_value)) {
settings.enable_impeller =
enable_impeller_value.empty() || "true" == enable_impeller_value;
}

settings.enable_vulkan_validation =
Expand Down
4 changes: 0 additions & 4 deletions shell/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ DEF_SWITCH(EnableImpeller,
"enable-impeller",
"Enable the Impeller renderer on supported platforms. Ignored if "
"Impeller is not supported on the platform.")
DEF_SWITCH(ImpellerBackend,
"impeller-backend",
"Requests a particular Impeller backend on platforms that support "
"multiple backends. (ex `opengles` or `vulkan`)")
DEF_SWITCH(EnableVulkanValidation,
"enable-vulkan-validation",
"Enable loading Vulkan validation layers. The layers must be "
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/android_context_gl_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
FML_LOG(ERROR) << "Could not add reactor worker.";
return nullptr;
}
FML_LOG(ERROR) << "Using the Impeller rendering backend (OpenGLES).";
FML_LOG(ERROR) << "Using the Impeller rendering backend.";
return context;
}

Expand Down
3 changes: 0 additions & 3 deletions shell/platform/android/android_context_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
settings.cache_directory = fml::paths::GetCachesDirectory();
settings.worker_task_runner = std::move(worker_task_runner);
settings.enable_validation = enable_vulkan_validation;

FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan).";

return impeller::ContextVK::Create(std::move(settings));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public class FlutterLoader {
"io.flutter.embedding.android.OldGenHeapSize";
private static final String ENABLE_IMPELLER_META_DATA_KEY =
"io.flutter.embedding.android.EnableImpeller";
private static final String IMPELLER_BACKEND_META_DATA_KEY =
"io.flutter.embedding.android.ImpellerBackend";

/**
* Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's
Expand Down Expand Up @@ -318,12 +316,8 @@ public void ensureInitializationComplete(

shellArgs.add("--prefetched-default-font-manager");

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);
if (metaData != null && metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
shellArgs.add("--enable-impeller");
}

final String leakVM = isLeakVM(metaData) ? "true" : "false";
Expand Down
43 changes: 16 additions & 27 deletions shell/platform/android/platform_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ std::unique_ptr<AndroidSurface> AndroidSurfaceFactoryImpl::CreateSurface() {
}
case AndroidRenderingAPI::kVulkan:
FML_DCHECK(enable_impeller_);
return std::make_unique<AndroidSurfaceVulkanImpeller>(
// TODO(kaushikiska@): Enable this after wiring a preference for Vulkan
// backend.
#if false
return std::make_unique<AndroidSurfaceVulkanImpeller>(
std::static_pointer_cast<AndroidContextVulkanImpeller>(
android_context_));
#else
return std::make_unique<AndroidSurfaceGLImpeller>(
std::static_pointer_cast<AndroidContextGLImpeller>(android_context_));
#endif
default:
FML_DCHECK(false);
return nullptr;
Expand All @@ -66,36 +73,19 @@ static std::shared_ptr<flutter::AndroidContext> CreateAndroidContext(
const std::shared_ptr<fml::ConcurrentTaskRunner>& worker_task_runner,
uint8_t msaa_samples,
bool enable_impeller,
const std::optional<std::string>& impeller_backend,
bool enable_vulkan_validation) {
if (use_software_rendering) {
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;
if (impeller_backend.has_value()) {
if (impeller_backend.value() == "opengles") {
backend = AndroidRenderingAPI::kOpenGLES;
} else if (impeller_backend.value() == "vulkan") {
backend = AndroidRenderingAPI::kVulkan;
} else {
FML_CHECK(impeller_backend.value() == "vulkan" ||
impeller_backend.value() == "opengles");
}
}
switch (backend) {
case AndroidRenderingAPI::kOpenGLES:
return std::make_unique<AndroidContextGLImpeller>(
std::make_unique<impeller::egl::Display>());
case AndroidRenderingAPI::kVulkan:
return std::make_unique<AndroidContextVulkanImpeller>(
enable_vulkan_validation, worker_task_runner);
default:
FML_UNREACHABLE();
}
// TODO(kaushikiska@): Enable this after wiring a preference for Vulkan
// backend.
#if false
return std::make_unique<AndroidContextVulkanImpeller>(enable_vulkan_validation, std::move(worker_task_runner));
#else
return std::make_unique<AndroidContextGLImpeller>(
std::make_unique<impeller::egl::Display>());
#endif
}
return std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kOpenGLES, //
Expand All @@ -122,7 +112,6 @@ PlatformViewAndroid::PlatformViewAndroid(
worker_task_runner,
msaa_samples,
delegate.OnPlatformViewGetSettings().enable_impeller,
delegate.OnPlatformViewGetSettings().impeller_backend,
delegate.OnPlatformViewGetSettings().enable_vulkan_validation)) {}

PlatformViewAndroid::PlatformViewAndroid(
Expand Down

0 comments on commit 30a2d61

Please sign in to comment.