Revert "[Impeller] Use Vulkan by default (#40809)" (flutter/engine#40820)

This reverts commit 35efb76a06.

Reverting for https://github.com/flutter/flutter/issues/123859
This commit is contained in:
Zachary Anderson
2023-03-31 08:05:36 -07:00
committed by GitHub
parent 799576572a
commit db6bf07686
17 changed files with 60 additions and 104 deletions

View File

@@ -2184,10 +2184,10 @@ ORIGIN: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.h + ../../../flut
ORIGIN: ../../../flutter/shell/platform/android/AndroidManifest.xml + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_choreographer.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_choreographer.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_impeller.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_impeller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_skia.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_gl_skia.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_impeller.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_context_impeller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_display.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_display.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/android_egl_surface.cc + ../../../flutter/LICENSE
@@ -4763,10 +4763,10 @@ FILE: ../../../flutter/shell/gpu/gpu_surface_vulkan_impeller.h
FILE: ../../../flutter/shell/platform/android/AndroidManifest.xml
FILE: ../../../flutter/shell/platform/android/android_choreographer.cc
FILE: ../../../flutter/shell/platform/android/android_choreographer.h
FILE: ../../../flutter/shell/platform/android/android_context_gl_impeller.cc
FILE: ../../../flutter/shell/platform/android/android_context_gl_impeller.h
FILE: ../../../flutter/shell/platform/android/android_context_gl_skia.cc
FILE: ../../../flutter/shell/platform/android/android_context_gl_skia.h
FILE: ../../../flutter/shell/platform/android/android_context_impeller.cc
FILE: ../../../flutter/shell/platform/android/android_context_impeller.h
FILE: ../../../flutter/shell/platform/android/android_display.cc
FILE: ../../../flutter/shell/platform/android/android_display.h
FILE: ../../../flutter/shell/platform/android/android_egl_surface.cc

View File

@@ -221,11 +221,6 @@ struct Settings {
// must be available to the application.
bool enable_vulkan_validation = false;
// Force Impeller to use the GL backend if possible.
// On platforms where there is no GL backend (e.g. macOS and iOS), this is a
// no-op.
bool impeller_force_gl = false;
// Data set by platform-specific embedders for use in font initialization.
uint32_t font_initialization_data = 0;

View File

@@ -453,9 +453,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
settings.enable_vulkan_validation =
command_line.HasOption(FlagForSwitch(Switch::EnableVulkanValidation));
settings.impeller_force_gl =
command_line.HasOption(FlagForSwitch(Switch::ImpellerForceGL));
settings.enable_embedder_api =
command_line.HasOption(FlagForSwitch(Switch::EnableEmbedderAPI));

View File

@@ -266,12 +266,6 @@ DEF_SWITCH(EnableVulkanValidation,
"Enable loading Vulkan validation layers. The layers must be "
"available to the application and loadable. On non-Vulkan backends, "
"this flag does nothing.")
DEF_SWITCH(
ImpellerForceGL,
"impeller-force-gl",
"Force Impeller to use the GL backend if it is available. If Impeller is "
"not enabled or it does not support a GL backend for the target "
"platform this flag does nothing.")
DEF_SWITCH(LeakVM,
"leak-vm",
"When the last shell shuts down, the shared VM is leaked by default "

View File

@@ -66,10 +66,10 @@ source_set("flutter_shell_native_src") {
"$root_build_dir/flutter_icu/icudtl.o",
"android_choreographer.cc",
"android_choreographer.h",
"android_context_gl_impeller.cc",
"android_context_gl_impeller.h",
"android_context_gl_skia.cc",
"android_context_gl_skia.h",
"android_context_impeller.cc",
"android_context_impeller.h",
"android_display.cc",
"android_display.h",
"android_egl_surface.cc",

View File

@@ -0,0 +1,18 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/android/android_context_gl_impeller.h"
namespace flutter {
AndroidContextGLImpeller::AndroidContextGLImpeller()
: AndroidContext(AndroidRenderingAPI::kOpenGLES) {}
AndroidContextGLImpeller::~AndroidContextGLImpeller() = default;
bool AndroidContextGLImpeller::IsValid() const {
return true;
}
} // namespace flutter

View File

@@ -2,27 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_android_context_impeller_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_android_context_impeller_H_
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_IMPELLER_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_IMPELLER_H_
#include "flutter/fml/macros.h"
#include "flutter/shell/platform/android/context/android_context.h"
namespace flutter {
class AndroidContextImpeller : public AndroidContext {
class AndroidContextGLImpeller : public AndroidContext {
public:
AndroidContextImpeller();
AndroidContextGLImpeller();
~AndroidContextImpeller();
~AndroidContextGLImpeller();
// |AndroidContext|
bool IsValid() const override;
private:
FML_DISALLOW_COPY_AND_ASSIGN(AndroidContextImpeller);
FML_DISALLOW_COPY_AND_ASSIGN(AndroidContextGLImpeller);
};
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_android_context_impeller_H_
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_IMPELLER_H_

View File

@@ -69,7 +69,7 @@ AndroidContextGLSkia::AndroidContextGLSkia(
fml::RefPtr<AndroidEnvironmentGL> environment,
const TaskRunners& task_runners,
uint8_t msaa_samples)
: AndroidContext(AndroidRenderingAPI::kGPU),
: AndroidContext(AndroidRenderingAPI::kOpenGLES),
environment_(std::move(environment)),
config_(nullptr),
task_runners_(task_runners) {

View File

@@ -87,7 +87,7 @@ TEST(AndroidContextGl, Create) {
ThreadHost::Type::UI | ThreadHost::Type::RASTER | ThreadHost::Type::IO));
TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
auto context = std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 0);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 0);
context->SetMainSkiaContext(main_context);
EXPECT_NE(context.get(), nullptr);
context.reset();
@@ -108,7 +108,7 @@ TEST(AndroidContextGl, CreateSingleThread) {
TaskRunners(thread_label, platform_runner, platform_runner,
platform_runner, platform_runner);
auto context = std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 0);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 0);
context->SetMainSkiaContext(main_context);
EXPECT_NE(context.get(), nullptr);
context.reset();
@@ -127,7 +127,7 @@ TEST(AndroidSurfaceGL, CreateSnapshopSurfaceWhenOnscreenSurfaceIsNotNull) {
ThreadHost::Type::UI | ThreadHost::Type::RASTER | ThreadHost::Type::IO));
TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
auto android_context = std::make_shared<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 0);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 0);
auto jni = std::make_shared<MockPlatformViewAndroidJNI>();
auto android_surface =
std::make_unique<AndroidSurfaceGLSkia>(android_context, jni);
@@ -155,7 +155,7 @@ TEST(AndroidSurfaceGL, CreateSnapshopSurfaceWhenOnscreenSurfaceIsNull) {
ThreadHost thread_host(host_config);
TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
auto android_context = std::make_shared<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 0);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 0);
auto jni = std::make_shared<MockPlatformViewAndroidJNI>();
auto android_surface =
std::make_unique<AndroidSurfaceGLSkia>(android_context, jni);
@@ -178,7 +178,7 @@ TEST(AndroidContextGl, DISABLED_MSAAx4) {
ThreadHost::Type::UI | ThreadHost::Type::RASTER | ThreadHost::Type::IO));
TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
auto context = std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 4);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 4);
context->SetMainSkiaContext(main_context);
EGLint sample_count;
@@ -200,7 +200,7 @@ TEST(AndroidContextGl, EnsureMakeCurrentChecksCurrentContextStatus) {
ThreadHost::Type::UI | ThreadHost::Type::RASTER | ThreadHost::Type::IO));
TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
auto context = std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, environment, task_runners, 0);
AndroidRenderingAPI::kOpenGLES, environment, task_runners, 0);
auto pbuffer_surface = context->CreatePbufferSurface();
auto status = pbuffer_surface->MakeCurrent();

View File

@@ -1,18 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/android/android_context_impeller.h"
namespace flutter {
AndroidContextImpeller::AndroidContextImpeller()
: AndroidContext(AndroidRenderingAPI::kGPU) {}
AndroidContextImpeller::~AndroidContextImpeller() = default;
bool AndroidContextImpeller::IsValid() const {
return true;
}
} // namespace flutter

View File

@@ -75,9 +75,10 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
FML_LOG(ERROR) << "Could not add reactor worker.";
return nullptr;
}
FML_LOG(ERROR) << "Using the Impeller GL rendering backend.";
FML_LOG(ERROR) << "Using the Impeller rendering backend.";
return context;
}
AndroidSurfaceGLImpeller::AndroidSurfaceGLImpeller(
const std::shared_ptr<AndroidContext>& android_context,
const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade)

View File

@@ -56,9 +56,6 @@ AndroidSurfaceVulkanImpeller::AndroidSurfaceVulkanImpeller(
CreateImpellerContext(proc_table_, workers_, enable_vulkan_validation);
is_valid_ =
proc_table_->HasAcquiredMandatoryProcAddresses() && impeller_context_;
if (is_valid_) {
FML_LOG(ERROR) << "Using the Impeller Vulkan rendering backend.";
}
}
AndroidSurfaceVulkanImpeller::~AndroidSurfaceVulkanImpeller() = default;

View File

@@ -13,7 +13,7 @@ namespace flutter {
enum class AndroidRenderingAPI {
kSoftware,
kGPU,
kOpenGLES,
};
//------------------------------------------------------------------------------

View File

@@ -46,8 +46,6 @@ public class FlutterShellArgs {
public static final String ARG_ENABLE_IMPELLER = "--enable-impeller";
public static final String ARG_KEY_ENABLE_VULKAN_VALIDATION = "enable-vulkan-validation";
public static final String ARG_ENABLE_VULKAN_VALIDATION = "--enable-vulkan-validation";
public static final String ARG_KEY_IMPELLER_FORCE_GL = "impeller-force-gl";
public static final String ARG_IMPELLER_FORCE_GL = "--impeller-force-gl";
public static final String ARG_KEY_DUMP_SHADER_SKP_ON_SHADER_COMPILATION =
"dump-skp-on-shader-compilation";
public static final String ARG_DUMP_SHADER_SKP_ON_SHADER_COMPILATION =
@@ -128,9 +126,6 @@ public class FlutterShellArgs {
if (intent.getBooleanExtra(ARG_KEY_ENABLE_VULKAN_VALIDATION, false)) {
args.add(ARG_ENABLE_VULKAN_VALIDATION);
}
if (intent.getBooleanExtra(ARG_KEY_IMPELLER_FORCE_GL, false)) {
args.add(ARG_IMPELLER_FORCE_GL);
}
if (intent.getBooleanExtra(ARG_KEY_DUMP_SHADER_SKP_ON_SHADER_COMPILATION, false)) {
args.add(ARG_DUMP_SHADER_SKP_ON_SHADER_COMPILATION);
}

View File

@@ -10,8 +10,8 @@
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/shell/common/shell_io_manager.h"
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
#include "flutter/shell/platform/android/android_context_gl_impeller.h"
#include "flutter/shell/platform/android/android_context_gl_skia.h"
#include "flutter/shell/platform/android/android_context_impeller.h"
#include "flutter/shell/platform/android/android_external_texture_gl.h"
#include "flutter/shell/platform/android/android_surface_gl_impeller.h"
#include "flutter/shell/platform/android/android_surface_gl_skia.h"
@@ -33,13 +33,11 @@ AndroidSurfaceFactoryImpl::AndroidSurfaceFactoryImpl(
const std::shared_ptr<AndroidContext>& context,
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
bool enable_impeller,
bool enable_vulkan_validation,
bool impeller_force_gl)
bool enable_vulkan_validation)
: android_context_(context),
jni_facade_(std::move(jni_facade)),
enable_impeller_(enable_impeller),
enable_vulkan_validation_(enable_vulkan_validation),
impeller_force_gl_(impeller_force_gl) {}
enable_vulkan_validation_(enable_vulkan_validation) {}
AndroidSurfaceFactoryImpl::~AndroidSurfaceFactoryImpl() = default;
@@ -48,17 +46,17 @@ std::unique_ptr<AndroidSurface> AndroidSurfaceFactoryImpl::CreateSurface() {
case AndroidRenderingAPI::kSoftware:
return std::make_unique<AndroidSurfaceSoftware>(android_context_,
jni_facade_);
case AndroidRenderingAPI::kGPU:
case AndroidRenderingAPI::kOpenGLES:
if (enable_impeller_) {
if (!impeller_force_gl_) {
auto vk_surface = std::make_unique<AndroidSurfaceVulkanImpeller>(
android_context_, jni_facade_, enable_vulkan_validation_);
if (vk_surface->IsValid()) {
return vk_surface;
}
}
// TODO(kaushikiska@): Enable this after wiring a preference for Vulkan backend.
#if false
return std::make_unique<AndroidSurfaceVulkanImpeller>(
android_context_, jni_facade_, enable_vulkan_validation_);
#else
return std::make_unique<AndroidSurfaceGLImpeller>(android_context_,
jni_facade_);
#endif
} else {
return std::make_unique<AndroidSurfaceGLSkia>(android_context_,
jni_facade_);
@@ -78,10 +76,10 @@ static std::shared_ptr<flutter::AndroidContext> CreateAndroidContext(
return std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
}
if (enable_impeller) {
return std::make_unique<AndroidContextImpeller>();
return std::make_unique<AndroidContextGLImpeller>();
}
return std::make_unique<AndroidContextGLSkia>(
AndroidRenderingAPI::kGPU, //
AndroidRenderingAPI::kOpenGLES, //
fml::MakeRefCounted<AndroidEnvironmentGL>(), //
task_runners, //
msaa_samples //
@@ -118,11 +116,10 @@ PlatformViewAndroid::PlatformViewAndroid(
FML_CHECK(android_context_->IsValid())
<< "Could not create surface from invalid Android context.";
surface_factory_ = std::make_shared<AndroidSurfaceFactoryImpl>(
android_context_, //
jni_facade_, //
delegate.OnPlatformViewGetSettings().enable_impeller, //
delegate.OnPlatformViewGetSettings().enable_vulkan_validation, //
delegate.OnPlatformViewGetSettings().impeller_force_gl //
android_context_, //
jni_facade_, //
delegate.OnPlatformViewGetSettings().enable_impeller, //
delegate.OnPlatformViewGetSettings().enable_vulkan_validation //
);
android_surface_ = surface_factory_->CreateSurface();
FML_CHECK(android_surface_ && android_surface_->IsValid())
@@ -274,7 +271,7 @@ void PlatformViewAndroid::UpdateSemantics(
void PlatformViewAndroid::RegisterExternalTexture(
int64_t texture_id,
const fml::jni::ScopedJavaGlobalRef<jobject>& surface_texture) {
if (android_context_->RenderingApi() == AndroidRenderingAPI::kGPU) {
if (android_context_->RenderingApi() == AndroidRenderingAPI::kOpenGLES) {
RegisterTexture(std::make_shared<AndroidExternalTextureGL>(
texture_id, surface_texture, jni_facade_));
} else {

View File

@@ -29,8 +29,7 @@ class AndroidSurfaceFactoryImpl : public AndroidSurfaceFactory {
AndroidSurfaceFactoryImpl(const std::shared_ptr<AndroidContext>& context,
std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
bool enable_impeller,
bool enable_vulkan_validation,
bool impeller_force_gl);
bool enable_vulkan_validation);
~AndroidSurfaceFactoryImpl() override;
@@ -41,7 +40,6 @@ class AndroidSurfaceFactoryImpl : public AndroidSurfaceFactory {
std::shared_ptr<PlatformViewAndroidJNI> jni_facade_;
const bool enable_impeller_;
const bool enable_vulkan_validation_;
const bool impeller_force_gl_;
};
class PlatformViewAndroid final : public PlatformView {

View File

@@ -193,24 +193,6 @@ public class FlutterLoaderTest {
assertFalse(arguments.contains(enableVulkanValidationArg));
}
@Test
public void itDoesNotSetEnableGLByDefault() {
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
assertFalse(flutterLoader.initialized());
flutterLoader.startInitialization(ctx);
flutterLoader.ensureInitializationComplete(ctx, null);
shadowOf(getMainLooper()).idle();
final String enableGLArg = "--impeller-force-gl";
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
verify(mockFlutterJNI, times(1))
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
assertFalse(arguments.contains(enableGLArg));
}
@Test
public void itSetsEnableImpellerFromMetaData() {
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);