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( ...@@ -204,10 +204,9 @@ void GpuDataManagerImpl::AppendRendererCommandLine(
} }
void GpuDataManagerImpl::AppendGpuCommandLine( void GpuDataManagerImpl::AppendGpuCommandLine(
base::CommandLine* command_line, base::CommandLine* command_line) const {
gpu::GpuPreferences* gpu_preferences) const {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
private_->AppendGpuCommandLine(command_line, gpu_preferences); private_->AppendGpuCommandLine(command_line);
} }
void GpuDataManagerImpl::UpdateRendererWebPrefs( void GpuDataManagerImpl::UpdateRendererWebPrefs(
...@@ -216,6 +215,12 @@ void GpuDataManagerImpl::UpdateRendererWebPrefs( ...@@ -216,6 +215,12 @@ void GpuDataManagerImpl::UpdateRendererWebPrefs(
private_->UpdateRendererWebPrefs(prefs); 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 { std::string GpuDataManagerImpl::GetBlacklistVersion() const {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
return private_->GetBlacklistVersion(); return private_->GetBlacklistVersion();
......
...@@ -120,15 +120,14 @@ class CONTENT_EXPORT GpuDataManagerImpl ...@@ -120,15 +120,14 @@ class CONTENT_EXPORT GpuDataManagerImpl
void AppendRendererCommandLine(base::CommandLine* command_line) const; void AppendRendererCommandLine(base::CommandLine* command_line) const;
// Insert switches into gpu process command line: kUseGL, etc. // Insert switches into gpu process command line: kUseGL, etc.
// If the gpu_preferences isn't a nullptr, the gpu_preferences will be set void AppendGpuCommandLine(base::CommandLine* command_line) const;
// 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;
// Update WebPreferences for renderer based on blacklisting decisions. // Update WebPreferences for renderer based on blacklisting decisions.
void UpdateRendererWebPrefs(WebPreferences* prefs) const; void UpdateRendererWebPrefs(WebPreferences* prefs) const;
// Update GpuPreferences based on blacklisting decisions.
void UpdateGpuPreferences(gpu::GpuPreferences* gpu_preferences) const;
std::string GetBlacklistVersion() const; std::string GetBlacklistVersion() const;
std::string GetDriverBugListVersion() const; std::string GetDriverBugListVersion() const;
......
...@@ -669,7 +669,7 @@ void GpuDataManagerImplPrivate::Initialize() { ...@@ -669,7 +669,7 @@ void GpuDataManagerImplPrivate::Initialize() {
if (in_process_gpu_) { if (in_process_gpu_) {
command_line->AppendSwitch(switches::kDisableGpuWatchdog); command_line->AppendSwitch(switches::kDisableGpuWatchdog);
AppendGpuCommandLine(command_line, nullptr); AppendGpuCommandLine(command_line);
} }
} }
...@@ -772,8 +772,7 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine( ...@@ -772,8 +772,7 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
} }
void GpuDataManagerImplPrivate::AppendGpuCommandLine( void GpuDataManagerImplPrivate::AppendGpuCommandLine(
base::CommandLine* command_line, base::CommandLine* command_line) const {
gpu::GpuPreferences* gpu_preferences) const {
DCHECK(command_line); DCHECK(command_line);
std::string use_gl = std::string use_gl =
...@@ -818,16 +817,9 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine( ...@@ -818,16 +817,9 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
disabled_extensions_); disabled_extensions_);
} }
if (gpu_preferences && IsGpuSchedulerEnabled())
gpu_preferences->enable_gpu_scheduler = true;
if (ShouldDisableAcceleratedVideoDecode(command_line)) { 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) != if (gpu_driver_bugs_.find(gpu::CREATE_DEFAULT_GL_CONTEXT) !=
gpu_driver_bugs_.end()) { gpu_driver_bugs_.end()) {
...@@ -841,15 +833,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine( ...@@ -841,15 +833,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
} }
#endif #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 // 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, // info collection at GPU process startup, but we need gpu vendor_id,
// device_id, driver_vendor, driver_version for deciding whether we need to // device_id, driver_vendor, driver_version for deciding whether we need to
...@@ -937,6 +920,25 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( ...@@ -937,6 +920,25 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); 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() { void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
if (!is_initialized_) { if (!is_initialized_) {
post_init_tasks_.push_back( post_init_tasks_.push_back(
......
...@@ -75,11 +75,12 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -75,11 +75,12 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void AppendRendererCommandLine(base::CommandLine* command_line) const; void AppendRendererCommandLine(base::CommandLine* command_line) const;
void AppendGpuCommandLine(base::CommandLine* command_line, void AppendGpuCommandLine(base::CommandLine* command_line) const;
gpu::GpuPreferences* gpu_preferences) const;
void UpdateRendererWebPrefs(WebPreferences* prefs) const; void UpdateRendererWebPrefs(WebPreferences* prefs) const;
void UpdateGpuPreferences(gpu::GpuPreferences* gpu_preferences) const;
std::string GetBlacklistVersion() const; std::string GetBlacklistVersion() const;
std::string GetDriverBugListVersion() const; std::string GetDriverBugListVersion() const;
......
...@@ -654,7 +654,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { ...@@ -654,7 +654,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) {
manager->gpu_driver_bugs_.insert(5); manager->gpu_driver_bugs_.insert(5);
base::CommandLine command_line(0, NULL); base::CommandLine command_line(0, NULL);
manager->AppendGpuCommandLine(&command_line, nullptr); manager->AppendGpuCommandLine(&command_line);
EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)); EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds));
std::string args = command_line.GetSwitchValueASCII( std::string args = command_line.GetSwitchValueASCII(
...@@ -668,7 +668,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListMultiple) { ...@@ -668,7 +668,7 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListMultiple) {
manager->gpu_driver_bugs_.insert(7); manager->gpu_driver_bugs_.insert(7);
base::CommandLine command_line(0, NULL); base::CommandLine command_line(0, NULL);
manager->AppendGpuCommandLine(&command_line, nullptr); manager->AppendGpuCommandLine(&command_line);
EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)); EXPECT_TRUE(command_line.HasSwitch(switches::kGpuDriverBugWorkarounds));
std::string args = command_line.GetSwitchValueASCII( std::string args = command_line.GetSwitchValueASCII(
......
...@@ -611,6 +611,7 @@ bool GpuProcessHost::Init() { ...@@ -611,6 +611,7 @@ bool GpuProcessHost::Init() {
process_->GetHost()->CreateChannelMojo(); process_->GetHost()->CreateChannelMojo();
gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine();
GpuDataManagerImpl::GetInstance()->UpdateGpuPreferences(&gpu_preferences);
if (in_process_) { if (in_process_) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(GetGpuMainThreadFactory()); DCHECK(GetGpuMainThreadFactory());
...@@ -630,7 +631,7 @@ bool GpuProcessHost::Init() { ...@@ -630,7 +631,7 @@ bool GpuProcessHost::Init() {
in_process_gpu_thread_->StartWithOptions(options); in_process_gpu_thread_->StartWithOptions(options);
OnProcessLaunched(); // Fake a callback that the process is ready. OnProcessLaunched(); // Fake a callback that the process is ready.
} else if (!LaunchGpuProcess(&gpu_preferences)) { } else if (!LaunchGpuProcess()) {
return false; return false;
} }
...@@ -988,7 +989,7 @@ void GpuProcessHost::ForceShutdown() { ...@@ -988,7 +989,7 @@ void GpuProcessHost::ForceShutdown() {
process_->ForceShutdown(); process_->ForceShutdown();
} }
bool GpuProcessHost::LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences) { bool GpuProcessHost::LaunchGpuProcess() {
const base::CommandLine& browser_command_line = const base::CommandLine& browser_command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
...@@ -1046,8 +1047,7 @@ bool GpuProcessHost::LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences) { ...@@ -1046,8 +1047,7 @@ bool GpuProcessHost::LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences) {
GetContentClient()->browser()->AppendExtraCommandLineSwitches( GetContentClient()->browser()->AppendExtraCommandLineSwitches(
cmd_line.get(), process_->GetData().id); cmd_line.get(), process_->GetData().id);
GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line.get(), GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line.get());
gpu_preferences);
if (cmd_line->HasSwitch(switches::kUseGL)) { if (cmd_line->HasSwitch(switches::kUseGL)) {
swiftshader_rendering_ = (cmd_line->GetSwitchValueASCII(switches::kUseGL) == swiftshader_rendering_ = (cmd_line->GetSwitchValueASCII(switches::kUseGL) ==
gl::kGLImplementationSwiftShaderForWebGLName); gl::kGLImplementationSwiftShaderForWebGLName);
......
...@@ -47,7 +47,6 @@ struct ChannelHandle; ...@@ -47,7 +47,6 @@ struct ChannelHandle;
} }
namespace gpu { namespace gpu {
struct GpuPreferences;
class ShaderDiskCache; class ShaderDiskCache;
struct SyncToken; struct SyncToken;
} }
...@@ -217,7 +216,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -217,7 +216,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void CreateChannelCache(int32_t client_id); void CreateChannelCache(int32_t client_id);
bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences); bool LaunchGpuProcess();
void SendOutstandingReplies(); 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