From a3745fa7fe62fb3c60cba96e35bcc59295789c46 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 20 Aug 2021 14:59:54 -0700 Subject: [PATCH] Eliminate Android-specific Vulkan support This eliminates Vulkan support for Android. As of flutter/engine#27980 (c2f2291) 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. --- ci/licenses_golden/licenses_flutter | 2 - shell/config.gni | 2 +- shell/platform/android/BUILD.gn | 13 +-- .../android/android_surface_vulkan.cc | 99 ------------------- .../platform/android/android_surface_vulkan.h | 62 ------------ .../android/context/android_context.h | 1 - .../platform/android/platform_view_android.cc | 13 --- shell/platform/fuchsia/flutter/BUILD.gn | 2 + tools/gn | 12 --- 9 files changed, 4 insertions(+), 202 deletions(-) delete mode 100644 shell/platform/android/android_surface_vulkan.cc delete mode 100644 shell/platform/android/android_surface_vulkan.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 0600745f1713f..a62148fd49ce0 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -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 diff --git a/shell/config.gni b/shell/config.gni index 22305c93d4802..781727443e305 100644 --- a/shell/config.gni +++ b/shell/config.gni @@ -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 } diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 7ba0ddf388406..e4d5f496ddc58 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -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", diff --git a/shell/platform/android/android_surface_vulkan.cc b/shell/platform/android/android_surface_vulkan.cc deleted file mode 100644 index 2815e0a40d38e..0000000000000 --- a/shell/platform/android/android_surface_vulkan.cc +++ /dev/null @@ -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 -#include - -#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& android_context, - std::shared_ptr jni_facade) - : AndroidSurface(android_context), - proc_table_(fml::MakeRefCounted()) {} - -AndroidSurfaceVulkan::~AndroidSurfaceVulkan() = default; - -bool AndroidSurfaceVulkan::IsValid() const { - return proc_table_->HasAcquiredMandatoryProcAddresses(); -} - -void AndroidSurfaceVulkan::TeardownOnScreenContext() { - // Nothing to do. -} - -std::unique_ptr AndroidSurfaceVulkan::CreateGPUSurface( - GrDirectContext* gr_context) { - if (!IsValid()) { - return nullptr; - } - - if (!native_window_ || !native_window_->IsValid()) { - return nullptr; - } - - auto vulkan_surface_android = - std::make_unique( - native_window_->handle()); - - if (!vulkan_surface_android->IsValid()) { - return nullptr; - } - - sk_sp 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 gpu_surface; - if (provided_gr_context) { - gpu_surface = std::make_unique( - provided_gr_context, this, std::move(vulkan_surface_android), true); - } else { - gpu_surface = std::make_unique( - 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 window) { - native_window_ = std::move(window); - return native_window_ && native_window_->IsValid(); -} - -fml::RefPtr AndroidSurfaceVulkan::vk() { - return proc_table_; -} - -} // namespace flutter diff --git a/shell/platform/android/android_surface_vulkan.h b/shell/platform/android/android_surface_vulkan.h deleted file mode 100644 index 7639d01ab26a3..0000000000000 --- a/shell/platform/android/android_surface_vulkan.h +++ /dev/null @@ -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 - -#include - -#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& android_context, - std::shared_ptr jni_facade); - - ~AndroidSurfaceVulkan() override; - - // |AndroidSurface| - bool IsValid() const override; - - // |AndroidSurface| - std::unique_ptr 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 window) override; - - // |GPUSurfaceVulkanDelegate| - fml::RefPtr vk() override; - - private: - fml::RefPtr proc_table_; - fml::RefPtr native_window_; - - FML_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceVulkan); -}; - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_VULKAN_H_ diff --git a/shell/platform/android/context/android_context.h b/shell/platform/android/context/android_context.h index 6f4e40bb10021..61662c5c81376 100644 --- a/shell/platform/android/context/android_context.h +++ b/shell/platform/android/context/android_context.h @@ -13,7 +13,6 @@ namespace flutter { enum class AndroidRenderingAPI { kSoftware, kOpenGLES, - kVulkan, }; //------------------------------------------------------------------------------ diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 1cf74795e599b..899870961c639 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -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 AndroidSurfaceFactoryImpl::CreateSurface() { jni_facade_); case AndroidRenderingAPI::kOpenGLES: return std::make_unique(android_context_, jni_facade_); - case AndroidRenderingAPI::kVulkan: -#if SHELL_ENABLE_VULKAN - return std::make_unique(android_context_, - jni_facade_); -#endif // SHELL_ENABLE_VULKAN default: FML_DCHECK(false); return nullptr; @@ -63,13 +54,9 @@ static std::shared_ptr CreateAndroidContext( if (use_software_rendering) { return std::make_shared(AndroidRenderingAPI::kSoftware); } -#if SHELL_ENABLE_VULKAN - return std::make_shared(AndroidRenderingAPI::kVulkan); -#else // SHELL_ENABLE_VULKAN return std::make_unique( AndroidRenderingAPI::kOpenGLES, fml::MakeRefCounted()); -#endif // SHELL_ENABLE_VULKAN } PlatformViewAndroid::PlatformViewAndroid( diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index d39289fde591f..ec9ffb7182259 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -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 } diff --git a/tools/gn b/tools/gn index b4b2e9e667188..666f99c3817f7 100755 --- a/tools/gn +++ b/tools/gn @@ -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 @@ -115,9 +112,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 = {} @@ -301,12 +295,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.