0

[Fuchsia] Handle VULKAN feature flag in WebEngine

Now WebEngine will enable Vulkan only when ContextFeatureFlags::VULKAN
is specified for web::Context. Also Context process now explicitly
disables hardware-accelerated compositing when VULKAN is not enabled
(otherwise it restarts the GPU process several times before it falls
back to software compositing).

Bug: 962617, fuchsia:35009
Change-Id: I74a463a1514df99134d929981fe44151c1d9dd17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774967
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Jonathan Backer <backer@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691856}
This commit is contained in:
Sergey Ulanov
2019-08-29 23:32:16 +00:00
committed by Commit Bot
parent cfec9d675d
commit 74c69a759f
4 changed files with 37 additions and 17 deletions

@ -10,12 +10,6 @@ import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")
import("//tools/grit/repack.gni")
declare_args() {
# Enables Vulkan in WebEngine (has effect only for context instances that have
# Vulkan loader service in the service directory).
web_engine_enable_vulkan = false
}
config("web_engine_implementation") {
defines = [ "WEB_ENGINE_IMPLEMENTATION" ]
}
@ -54,6 +48,7 @@ repack("web_engine_pak") {
"//content/app/resources",
"//content/app/strings",
"//content/browser/tracing:resources",
"//gpu/command_buffer/service",
"//mojo/public/js:resources",
"//net:net_resources",
"//third_party/blink/public:resources",
@ -80,6 +75,7 @@ component("web_engine_core") {
"//fuchsia/base",
"//fuchsia/base:message_port",
"//fuchsia/base:modular",
"//gpu/command_buffer/service",
"//media/fuchsia/cdm/service",
"//media/fuchsia/mojom",
"//mojo/public/cpp/bindings",
@ -163,9 +159,6 @@ component("web_engine_core") {
":*",
"//fuchsia/runners:cast_runner_browsertests__exec",
]
if (web_engine_enable_vulkan) {
defines = [ "WEB_ENGINE_ENABLE_VULKAN" ]
}
}
executable("web_engine_exe") {

@ -1,5 +1,8 @@
include_rules = [
"+components/viz/common",
"+content/public/app",
"+gpu/command_buffer/service",
"+services/service_manager",
"+ui/base",
"+ui/gl/gl_switches.h",
]

@ -10,12 +10,14 @@
#include "base/command_line.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/main_function_params.h"
#include "fuchsia/engine/browser/context_impl.h"
#include "fuchsia/engine/browser/web_engine_browser_context.h"
#include "fuchsia/engine/browser/web_engine_screen.h"
#include "fuchsia/engine/common.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "ui/aura/screen_ozone.h"
#include "ui/ozone/public/ozone_platform.h"
@ -42,6 +44,17 @@ void WebEngineBrowserMainParts::PreMainMessageLoopRun() {
display::Screen::SetScreenInstance(screen_.get());
// If Vulkan is not enabled then disable hardware acceleration. Otherwise gpu
// process will be restarted several times trying to initialize GL before
// falling back to software compositing.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseVulkan)) {
content::GpuDataManager* gpu_data_manager =
content::GpuDataManager::GetInstance();
DCHECK(gpu_data_manager);
gpu_data_manager->DisableHardwareAcceleration();
}
DCHECK(!browser_context_);
browser_context_ = std::make_unique<WebEngineBrowserContext>(
base::CommandLine::ForCurrentProcess()->HasSwitch(kIncognitoSwitch));

@ -21,6 +21,7 @@
#include <vector>
#include "base/base_paths_fuchsia.h"
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/scoped_file.h"
@ -32,10 +33,13 @@
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/viz/common/features.h"
#include "content/public/common/content_switches.h"
#include "fuchsia/engine/common.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "net/http/http_util.h"
#include "services/service_manager/sandbox/fuchsia/sandbox_policy_fuchsia.h"
#include "ui/gl/gl_switches.h"
namespace {
@ -192,14 +196,21 @@ void ContextProviderImpl::Create(
base::JoinString(handles_ids, ","));
}
#if defined(WEB_ENGINE_ENABLE_VULKAN)
// TODO(fbx/35009): Add a flag in CreateContextParams to enable/disable Vulkan
// and use it here.
launch_command.AppendSwitchASCII(
"--enable-features", "DefaultEnableOopRasterization,UseSkiaRenderer");
launch_command.AppendSwitch("--use-vulkan");
launch_command.AppendSwitchASCII("--use-gl", "stub");
#endif // WEB_ENGINE_ENABLE_VULKAN
fuchsia::web::ContextFeatureFlags features = {};
if (params.has_features())
features = params.features();
bool enable_vulkan = (features & fuchsia::web::ContextFeatureFlags::VULKAN) ==
fuchsia::web::ContextFeatureFlags::VULKAN;
if (enable_vulkan) {
launch_command.AppendSwitch(switches::kUseVulkan);
launch_command.AppendSwitchASCII(switches::kEnableFeatures,
features::kUseSkiaRenderer.name);
launch_command.AppendSwitch(switches::kEnableOopRasterization);
launch_command.AppendSwitchASCII(switches::kUseGL,
gl::kGLImplementationStubName);
}
// Validate embedder-supplied product, and optional version, and pass it to
// the Context to include in the UserAgent.