Commit 82496fc9 authored by perryuwang's avatar perryuwang Committed by Commit Bot

Update GpuPreferences when running GPU thread inside browser process.

When running GPU thread inside browser process, GpuPreferences is not
updated from GPU command line switches and blacklists. So we need update
those preferences in GpuDataManagerImplPrivate::UpdateGpuPreferences
when in_process_ is true.

Change-Id: Ic60e778e0c436b8f44365eec70c2855935629a54
Reviewed-on: https://chromium-review.googlesource.com/569324Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486963}
parent 4c3d6a64
......@@ -204,10 +204,9 @@ void GpuDataManagerImpl::AppendRendererCommandLine(
}
void GpuDataManagerImpl::AppendGpuCommandLine(
base::CommandLine* command_line,
gpu::GpuPreferences* gpu_preferences) const {
base::CommandLine* command_line) const {
base::AutoLock auto_lock(lock_);
private_->AppendGpuCommandLine(command_line, gpu_preferences);
private_->AppendGpuCommandLine(command_line);
}
void GpuDataManagerImpl::UpdateRendererWebPrefs(
......@@ -216,6 +215,12 @@ void GpuDataManagerImpl::UpdateRendererWebPrefs(
private_->UpdateRendererWebPrefs(prefs);
}
void GpuDataManagerImpl::UpdateGpuPreferences(
gpu::GpuPreferences* gpu_preferences) const {
base::AutoLock auto_lock(lock_);
private_->UpdateGpuPreferences(gpu_preferences);
}
std::string GpuDataManagerImpl::GetBlacklistVersion() const {
base::AutoLock auto_lock(lock_);
return private_->GetBlacklistVersion();
......
......@@ -120,15 +120,14 @@ class CONTENT_EXPORT GpuDataManagerImpl
void AppendRendererCommandLine(base::CommandLine* command_line) const;
// Insert switches into gpu process command line: kUseGL, etc.
// If the gpu_preferences isn't a nullptr, the gpu_preferences will be set
// for some GPU switches which have been replaced by GpuPreferences, and those
// switches will not be append to the command_line anymore.
void AppendGpuCommandLine(base::CommandLine* command_line,
gpu::GpuPreferences* gpu_preferences) const;
void AppendGpuCommandLine(base::CommandLine* command_line) const;
// Update WebPreferences for renderer based on blacklisting decisions.
void UpdateRendererWebPrefs(WebPreferences* prefs) const;
// Update GpuPreferences based on blacklisting decisions.
void UpdateGpuPreferences(gpu::GpuPreferences* gpu_preferences) const;
std::string GetBlacklistVersion() const;
std::string GetDriverBugListVersion() const;
......
......@@ -669,7 +669,7 @@ void GpuDataManagerImplPrivate::Initialize() {
if (in_process_gpu_) {
command_line->AppendSwitch(switches::kDisableGpuWatchdog);
AppendGpuCommandLine(command_line, nullptr);
AppendGpuCommandLine(command_line);
}
}
......@@ -772,8 +772,7 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
}
void GpuDataManagerImplPrivate::AppendGpuCommandLine(
base::CommandLine* command_line,
gpu::GpuPreferences* gpu_preferences) const {
base::CommandLine* command_line) const {
DCHECK(command_line);
std::string use_gl =
......@@ -818,15 +817,8 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
disabled_extensions_);
}
if (gpu_preferences && IsGpuSchedulerEnabled())
gpu_preferences->enable_gpu_scheduler = true;
if (ShouldDisableAcceleratedVideoDecode(command_line)) {
if (gpu_preferences) {
gpu_preferences->disable_accelerated_video_decode = true;
} else {
command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
}
command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
}
if (gpu_driver_bugs_.find(gpu::CREATE_DEFAULT_GL_CONTEXT) !=
......@@ -841,15 +833,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
}
#endif
if (gpu_preferences) { // enable_es3_apis
bool blacklisted = IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2);
bool enabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableES3APIs);
bool disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableES3APIs);
gpu_preferences->enable_es3_apis = (enabled || !blacklisted) && !disabled;
}
// Pass GPU and driver information to GPU process. We try to avoid full GPU
// info collection at GPU process startup, but we need gpu vendor_id,
// device_id, driver_vendor, driver_version for deciding whether we need to
......@@ -937,6 +920,25 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes);
}
void GpuDataManagerImplPrivate::UpdateGpuPreferences(
gpu::GpuPreferences* gpu_preferences) const {
DCHECK(gpu_preferences);
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (IsGpuSchedulerEnabled())
gpu_preferences->enable_gpu_scheduler = true;
if (ShouldDisableAcceleratedVideoDecode(command_line))
gpu_preferences->disable_accelerated_video_decode = true;
gpu_preferences->enable_es3_apis =
(command_line->HasSwitch(switches::kEnableES3APIs) ||
!IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)) &&
!command_line->HasSwitch(switches::kDisableES3APIs);
}
void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
if (!is_initialized_) {
post_init_tasks_.push_back(
......
......@@ -75,11 +75,12 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void AppendRendererCommandLine(base::CommandLine* command_line) const;
void AppendGpuCommandLine(base::CommandLine* command_line,
gpu::GpuPreferences* gpu_preferences) const;
void AppendGpuCommandLine(base::CommandLine* command_line) const;
void UpdateRendererWebPrefs(WebPreferences* prefs) const;
void UpdateGpuPreferences(gpu::GpuPreferences* gpu_preferences) const;
std::string GetBlacklistVersion() const;
std::string GetDriverBugListVersion() const;
......
......@@ -654,7 +654,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) {
manager->gpu_driver_bugs_.insert(5);
base::CommandLine command_line(0, NULL);
manager->AppendGpuCommandLine(&command_line, nullptr);
manager->AppendGpuCommandLine(&command_line);
EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds));
std::string args = command_line.GetSwitchValueASCII(
......@@ -668,7 +668,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListMultiple) {
manager->gpu_driver_bugs_.insert(7);
base::CommandLine command_line(0, NULL);
manager->AppendGpuCommandLine(&command_line, nullptr);
manager->AppendGpuCommandLine(&command_line);
EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds));
std::string args = command_line.GetSwitchValueASCII(
......
......@@ -611,6 +611,7 @@ bool GpuProcessHost::Init() {
process_->GetHost()->CreateChannelMojo();
gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine();
GpuDataManagerImpl::GetInstance()->UpdateGpuPreferences(&gpu_preferences);
if (in_process_) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(GetGpuMainThreadFactory());
......@@ -630,7 +631,7 @@ bool GpuProcessHost::Init() {
in_process_gpu_thread_->StartWithOptions(options);
OnProcessLaunched(); // Fake a callback that the process is ready.
} else if (!LaunchGpuProcess(&gpu_preferences)) {
} else if (!LaunchGpuProcess()) {
return false;
}
......@@ -988,7 +989,7 @@ void GpuProcessHost::ForceShutdown() {
process_->ForceShutdown();
}
bool GpuProcessHost::LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences) {
bool GpuProcessHost::LaunchGpuProcess() {
const base::CommandLine& browser_command_line =
*base::CommandLine::ForCurrentProcess();
......@@ -1046,8 +1047,7 @@ bool GpuProcessHost::LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences) {
GetContentClient()->browser()->AppendExtraCommandLineSwitches(
cmd_line.get(), process_->GetData().id);
GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line.get(),
gpu_preferences);
GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line.get());
if (cmd_line->HasSwitch(switches::kUseGL)) {
swiftshader_rendering_ = (cmd_line->GetSwitchValueASCII(switches::kUseGL) ==
gl::kGLImplementationSwiftShaderForWebGLName);
......
......@@ -47,7 +47,6 @@ struct ChannelHandle;
}
namespace gpu {
struct GpuPreferences;
class ShaderDiskCache;
struct SyncToken;
}
......@@ -217,7 +216,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void CreateChannelCache(int32_t client_id);
bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences);
bool LaunchGpuProcess();
void SendOutstandingReplies();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment