Eliminate Android-specific Vulkan support (flutter/engine#28239)

This eliminates Vulkan support for Android. As of flutter/engine#27980
(684ad82) we are no longer running Android-Vulkan builds. This
eliminates the --enable-vulkan flag from tools/gn and any code that is
only reachable when that flag is enabled.

Note that after this patch, `shell_enable_vulkan` is always false,
however the //flutter/shell/gpu:gpu_surface_vulkan target and source
files remain since they are still used when `test_enable_vulkan` is
true, which is the case when `is_fuchsia` is true. Note that these files
are *not* built as part of a regular fuchsia build (see the
`shell_gpu_configuration` in //shell/platform/fuchsia/flutter/BUILD.gn),
but may be enabled once the Fuchsia embedder is migrated to the Embedder
API.

Also updates TODOs to dworsham, who is the committer who'll be
transitioning the Fuchsia embedder to the embedding API.
This commit is contained in:
Chris Bracken 2021-08-23 13:59:43 -07:00 committed by GitHub
parent d8ce6688ad
commit a858cceed8
9 changed files with 4 additions and 202 deletions

View File

@ -778,8 +778,6 @@ FILE: ../../../flutter/shell/platform/android/android_surface_gl.cc
FILE: ../../../flutter/shell/platform/android/android_surface_gl.h
FILE: ../../../flutter/shell/platform/android/android_surface_software.cc
FILE: ../../../flutter/shell/platform/android/android_surface_software.h
FILE: ../../../flutter/shell/platform/android/android_surface_vulkan.cc
FILE: ../../../flutter/shell/platform/android/android_surface_vulkan.h
FILE: ../../../flutter/shell/platform/android/apk_asset_provider.cc
FILE: ../../../flutter/shell/platform/android/apk_asset_provider.h
FILE: ../../../flutter/shell/platform/android/context/android_context.cc

View File

@ -6,7 +6,7 @@ declare_args() {
shell_enable_gl = !is_fuchsia
shell_enable_metal = false
# TODO(gw280): Enable once Fuchsia supports Vulkan through the embedder
# TODO(dworsham): Enable once Fuchsia supports Vulkan through the embedder.
shell_enable_vulkan = false
shell_enable_software = true
}

View File

@ -12,8 +12,8 @@ import("//flutter/shell/version/version.gni")
shell_gpu_configuration("android_gpu_configuration") {
enable_software = true
enable_vulkan = shell_enable_vulkan
enable_gl = true
enable_vulkan = false
enable_metal = false
}
@ -95,17 +95,6 @@ shared_library("flutter_shell_native") {
defines = []
if (shell_enable_vulkan) {
sources += [
"android_surface_vulkan.cc",
"android_surface_vulkan.h",
]
deps += [ "//flutter/vulkan" ]
defines += [ "SHELL_ENABLE_VULKAN" ]
}
libs = [
"android",
"EGL",

View File

@ -1,99 +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_surface_vulkan.h"
#include <memory>
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/shell/gpu/gpu_surface_vulkan.h"
#include "flutter/vulkan/vulkan_native_surface_android.h"
#include "include/core/SkRefCnt.h"
namespace flutter {
AndroidSurfaceVulkan::AndroidSurfaceVulkan(
const std::shared_ptr<AndroidContext>& android_context,
std::shared_ptr<PlatformViewAndroidJNI> jni_facade)
: AndroidSurface(android_context),
proc_table_(fml::MakeRefCounted<vulkan::VulkanProcTable>()) {}
AndroidSurfaceVulkan::~AndroidSurfaceVulkan() = default;
bool AndroidSurfaceVulkan::IsValid() const {
return proc_table_->HasAcquiredMandatoryProcAddresses();
}
void AndroidSurfaceVulkan::TeardownOnScreenContext() {
// Nothing to do.
}
std::unique_ptr<Surface> AndroidSurfaceVulkan::CreateGPUSurface(
GrDirectContext* gr_context) {
if (!IsValid()) {
return nullptr;
}
if (!native_window_ || !native_window_->IsValid()) {
return nullptr;
}
auto vulkan_surface_android =
std::make_unique<vulkan::VulkanNativeSurfaceAndroid>(
native_window_->handle());
if (!vulkan_surface_android->IsValid()) {
return nullptr;
}
sk_sp<GrDirectContext> provided_gr_context;
if (gr_context) {
provided_gr_context = sk_ref_sp(gr_context);
} else if (android_context_->GetMainSkiaContext()) {
provided_gr_context = android_context_->GetMainSkiaContext();
}
std::unique_ptr<GPUSurfaceVulkan> gpu_surface;
if (provided_gr_context) {
gpu_surface = std::make_unique<GPUSurfaceVulkan>(
provided_gr_context, this, std::move(vulkan_surface_android), true);
} else {
gpu_surface = std::make_unique<GPUSurfaceVulkan>(
this, std::move(vulkan_surface_android), true);
android_context_->SetMainSkiaContext(sk_ref_sp(gpu_surface->GetContext()));
}
if (!gpu_surface->IsValid()) {
return nullptr;
}
return gpu_surface;
}
bool AndroidSurfaceVulkan::OnScreenSurfaceResize(const SkISize& size) {
return true;
}
bool AndroidSurfaceVulkan::ResourceContextMakeCurrent() {
FML_DLOG(ERROR) << "The vulkan backend does not support resource contexts.";
return false;
}
bool AndroidSurfaceVulkan::ResourceContextClearCurrent() {
FML_DLOG(ERROR) << "The vulkan backend does not support resource contexts.";
return false;
}
bool AndroidSurfaceVulkan::SetNativeWindow(
fml::RefPtr<AndroidNativeWindow> window) {
native_window_ = std::move(window);
return native_window_ && native_window_->IsValid();
}
fml::RefPtr<vulkan::VulkanProcTable> AndroidSurfaceVulkan::vk() {
return proc_table_;
}
} // namespace flutter

View File

@ -1,62 +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.
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_VULKAN_H_
#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_VULKAN_H_
#include <jni.h>
#include <memory>
#include "flutter/fml/macros.h"
#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h"
#include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
#include "flutter/shell/platform/android/surface/android_surface.h"
#include "flutter/vulkan/vulkan_window.h"
namespace flutter {
class AndroidSurfaceVulkan : public AndroidSurface,
public GPUSurfaceVulkanDelegate {
public:
AndroidSurfaceVulkan(const std::shared_ptr<AndroidContext>& android_context,
std::shared_ptr<PlatformViewAndroidJNI> jni_facade);
~AndroidSurfaceVulkan() override;
// |AndroidSurface|
bool IsValid() const override;
// |AndroidSurface|
std::unique_ptr<Surface> CreateGPUSurface(
GrDirectContext* gr_context) override;
// |AndroidSurface|
void TeardownOnScreenContext() override;
// |AndroidSurface|
bool OnScreenSurfaceResize(const SkISize& size) override;
// |AndroidSurface|
bool ResourceContextMakeCurrent() override;
// |AndroidSurface|
bool ResourceContextClearCurrent() override;
// |AndroidSurface|
bool SetNativeWindow(fml::RefPtr<AndroidNativeWindow> window) override;
// |GPUSurfaceVulkanDelegate|
fml::RefPtr<vulkan::VulkanProcTable> vk() override;
private:
fml::RefPtr<vulkan::VulkanProcTable> proc_table_;
fml::RefPtr<AndroidNativeWindow> native_window_;
FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkan);
};
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_VULKAN_H_

View File

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

View File

@ -18,10 +18,6 @@
#include "flutter/shell/platform/android/surface/android_surface.h"
#include "flutter/shell/platform/android/surface/snapshot_surface_producer.h"
#if SHELL_ENABLE_VULKAN
#include "flutter/shell/platform/android/android_surface_vulkan.h"
#endif // SHELL_ENABLE_VULKAN
#include "flutter/shell/platform/android/context/android_context.h"
#include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
#include "flutter/shell/platform/android/platform_message_response_android.h"
@ -43,11 +39,6 @@ std::unique_ptr<AndroidSurface> AndroidSurfaceFactoryImpl::CreateSurface() {
jni_facade_);
case AndroidRenderingAPI::kOpenGLES:
return std::make_unique<AndroidSurfaceGL>(android_context_, jni_facade_);
case AndroidRenderingAPI::kVulkan:
#if SHELL_ENABLE_VULKAN
return std::make_unique<AndroidSurfaceVulkan>(android_context_,
jni_facade_);
#endif // SHELL_ENABLE_VULKAN
default:
FML_DCHECK(false);
return nullptr;
@ -63,13 +54,9 @@ static std::shared_ptr<flutter::AndroidContext> CreateAndroidContext(
if (use_software_rendering) {
return std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
}
#if SHELL_ENABLE_VULKAN
return std::make_shared<AndroidContext>(AndroidRenderingAPI::kVulkan);
#else // SHELL_ENABLE_VULKAN
return std::make_unique<AndroidContextGL>(
AndroidRenderingAPI::kOpenGLES,
fml::MakeRefCounted<AndroidEnvironmentGL>());
#endif // SHELL_ENABLE_VULKAN
}
PlatformViewAndroid::PlatformViewAndroid(

View File

@ -17,6 +17,8 @@ import("//flutter/vulkan/config.gni")
shell_gpu_configuration("fuchsia_gpu_configuration") {
enable_software = false
enable_gl = false
# TODO(dworsham): Enable once Fuchsia supports Vulkan through the embedder.
enable_vulkan = false
enable_metal = false
}

View File

@ -54,9 +54,6 @@ def get_out_dir(args):
if args.target_os == 'fuchsia' and args.fuchsia_cpu is not None:
target_dir.append(args.fuchsia_cpu)
if args.enable_vulkan:
target_dir.append('vulkan')
# This exists for backwards compatibility of tests that are being run
# on LUCI. This can be removed in coordination with a LUCI change:
# https://github.com/flutter/flutter/issues/76547
@ -123,9 +120,6 @@ def to_gn_args(args):
if args.target_os == 'android':
raise Exception('--simulator is not supported on Android')
if args.target_os != 'android' and args.enable_vulkan:
raise Exception('--enable-vulkan is only supported on Android')
runtime_mode = args.runtime_mode
gn_args = {}
@ -309,12 +303,6 @@ def to_gn_args(args):
gn_args['skia_use_metal'] = True
gn_args['shell_enable_metal'] = True
if args.enable_vulkan:
# Enable vulkan in the Flutter shell.
gn_args['shell_enable_vulkan'] = True
# Configure Skia for Vulkan support.
gn_args['skia_use_vulkan'] = True
if sys.platform.startswith(('cygwin', 'win')):
# The buildroot currently isn't set up to support Vulkan in the
# Windows ANGLE build, so disable it regardless of enable_vulkan's value.