Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 14146011: Renamed 'software_rendering' to 'swiftshader' to differentiate from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 GpuChildThread* child_thread_; 318 GpuChildThread* child_thread_;
319 319
320 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); 320 DISALLOW_COPY_AND_ASSIGN(GpuMainThread);
321 }; 321 };
322 322
323 // static 323 // static
324 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) { 324 bool GpuProcessHost::ValidateHost(GpuProcessHost* host) {
325 if (!host) 325 if (!host)
326 return false; 326 return false;
327 327
328 // The Gpu process is invalid if it's not using software, the card is 328 // The Gpu process is invalid if it's not using SwiftShader, the card is
329 // blacklisted, and we can kill it and start over. 329 // blacklisted, and we can kill it and start over.
330 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || 330 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) ||
331 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU) || 331 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU) ||
332 (host->valid_ && 332 (host->valid_ &&
333 (host->software_rendering() || 333 (host->swiftshader_rendering_ ||
334 !GpuDataManagerImpl::GetInstance()->ShouldUseSoftwareRendering()))) { 334 !GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()))) {
335 return true; 335 return true;
336 } 336 }
337 337
338 host->ForceShutdown(); 338 host->ForceShutdown();
339 return false; 339 return false;
340 } 340 }
341 341
342 // static 342 // static
343 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind, 343 GpuProcessHost* GpuProcessHost::Get(GpuProcessKind kind,
344 CauseForGpuLaunch cause) { 344 CauseForGpuLaunch cause) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return host; 416 return host;
417 } 417 }
418 418
419 return NULL; 419 return NULL;
420 } 420 }
421 421
422 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) 422 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind)
423 : host_id_(host_id), 423 : host_id_(host_id),
424 valid_(true), 424 valid_(true),
425 in_process_(false), 425 in_process_(false),
426 software_rendering_(false), 426 swiftshader_rendering_(false),
427 kind_(kind), 427 kind_(kind),
428 process_launched_(false), 428 process_launched_(false),
429 initialized_(false), 429 initialized_(false),
430 uma_memory_stats_received_(false) { 430 uma_memory_stats_received_(false) {
431 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || 431 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) ||
432 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { 432 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) {
433 in_process_ = true; 433 in_process_ = true;
434 } 434 }
435 435
436 // If the 'single GPU process' policy ever changes, we still want to maintain 436 // If the 'single GPU process' policy ever changes, we still want to maintain
(...skipping 23 matching lines...) Expand all
460 // Maximum number of times the gpu process is allowed to crash in a session. 460 // Maximum number of times the gpu process is allowed to crash in a session.
461 // Once this limit is reached, any request to launch the gpu process will 461 // Once this limit is reached, any request to launch the gpu process will
462 // fail. 462 // fail.
463 const int kGpuMaxCrashCount = 3; 463 const int kGpuMaxCrashCount = 3;
464 464
465 // Number of times the gpu process has crashed in the current browser session. 465 // Number of times the gpu process has crashed in the current browser session.
466 static int gpu_crash_count = 0; 466 static int gpu_crash_count = 0;
467 static int gpu_recent_crash_count = 0; 467 static int gpu_recent_crash_count = 0;
468 static base::Time last_gpu_crash_time; 468 static base::Time last_gpu_crash_time;
469 static bool crashed_before = false; 469 static bool crashed_before = false;
470 static int gpu_software_crash_count = 0; 470 static int swiftshader_crash_count = 0;
471 471
472 // Ending only acts as a failure if the GPU process was actually started and 472 // Ending only acts as a failure if the GPU process was actually started and
473 // was intended for actual rendering (and not just checking caps or other 473 // was intended for actual rendering (and not just checking caps or other
474 // options). 474 // options).
475 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) { 475 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) {
476 if (software_rendering_) { 476 if (swiftshader_rendering_) {
477 UMA_HISTOGRAM_ENUMERATION("GPU.SoftwareRendererLifetimeEvents", 477 UMA_HISTOGRAM_ENUMERATION("GPU.SwiftShaderLifetimeEvents",
478 DIED_FIRST_TIME + gpu_software_crash_count, 478 DIED_FIRST_TIME + swiftshader_crash_count,
479 GPU_PROCESS_LIFETIME_EVENT_MAX); 479 GPU_PROCESS_LIFETIME_EVENT_MAX);
480 480
481 if (++gpu_software_crash_count >= kGpuMaxCrashCount) { 481 if (++swiftshader_crash_count >= kGpuMaxCrashCount) {
482 // The software renderer is too unstable to use. Disable it for current 482 // SwiftShader is too unstable to use. Disable it for current session.
483 // session.
484 gpu_enabled_ = false; 483 gpu_enabled_ = false;
485 } 484 }
486 } else { 485 } else {
487 ++gpu_crash_count; 486 ++gpu_crash_count;
488 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", 487 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents",
489 std::min(DIED_FIRST_TIME + gpu_crash_count, 488 std::min(DIED_FIRST_TIME + gpu_crash_count,
490 GPU_PROCESS_LIFETIME_EVENT_MAX - 1), 489 GPU_PROCESS_LIFETIME_EVENT_MAX - 1),
491 GPU_PROCESS_LIFETIME_EVENT_MAX); 490 GPU_PROCESS_LIFETIME_EVENT_MAX);
492 491
493 // Allow about 1 GPU crash per hour to be removed from the crash count, 492 // Allow about 1 GPU crash per hour to be removed from the crash count,
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", 1047 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
1049 base::TimeTicks::Now() - init_start_time_); 1048 base::TimeTicks::Now() - init_start_time_);
1050 } 1049 }
1051 1050
1052 void GpuProcessHost::OnProcessCrashed(int exit_code) { 1051 void GpuProcessHost::OnProcessCrashed(int exit_code) {
1053 SendOutstandingReplies(); 1052 SendOutstandingReplies();
1054 GpuDataManagerImpl::GetInstance()->ProcessCrashed( 1053 GpuDataManagerImpl::GetInstance()->ProcessCrashed(
1055 process_->GetTerminationStatus(NULL)); 1054 process_->GetTerminationStatus(NULL));
1056 } 1055 }
1057 1056
1058 bool GpuProcessHost::software_rendering() {
1059 return software_rendering_;
1060 }
1061
1062 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { 1057 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() {
1063 return kind_; 1058 return kind_;
1064 } 1059 }
1065 1060
1066 void GpuProcessHost::ForceShutdown() { 1061 void GpuProcessHost::ForceShutdown() {
1067 // This is only called on the IO thread so no race against the constructor 1062 // This is only called on the IO thread so no race against the constructor
1068 // for another GpuProcessHost. 1063 // for another GpuProcessHost.
1069 if (g_gpu_process_hosts[kind_] == this) 1064 if (g_gpu_process_hosts[kind_] == this)
1070 g_gpu_process_hosts[kind_] = NULL; 1065 g_gpu_process_hosts[kind_] = NULL;
1071 1066
1072 process_->ForceShutdown(); 1067 process_->ForceShutdown();
1073 } 1068 }
1074 1069
1075 void GpuProcessHost::BeginFrameSubscription( 1070 void GpuProcessHost::BeginFrameSubscription(
1076 int surface_id, 1071 int surface_id,
1077 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber) { 1072 base::WeakPtr<RenderWidgetHostViewFrameSubscriber> subscriber) {
1078 frame_subscribers_[surface_id] = subscriber; 1073 frame_subscribers_[surface_id] = subscriber;
1079 } 1074 }
1080 1075
1081 void GpuProcessHost::EndFrameSubscription(int surface_id) { 1076 void GpuProcessHost::EndFrameSubscription(int surface_id) {
1082 frame_subscribers_.erase(surface_id); 1077 frame_subscribers_.erase(surface_id);
1083 } 1078 }
1084 1079
1085 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { 1080 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) {
1086 if (!(gpu_enabled_ && 1081 if (!(gpu_enabled_ &&
1087 GpuDataManagerImpl::GetInstance()->ShouldUseSoftwareRendering()) && 1082 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) &&
1088 !hardware_gpu_enabled_) { 1083 !hardware_gpu_enabled_) {
1089 SendOutstandingReplies(); 1084 SendOutstandingReplies();
1090 return false; 1085 return false;
1091 } 1086 }
1092 1087
1093 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 1088 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1094 1089
1095 CommandLine::StringType gpu_launcher = 1090 CommandLine::StringType gpu_launcher =
1096 browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); 1091 browser_command_line.GetSwitchValueNative(switches::kGpuLauncher);
1097 1092
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 cmd_line->CopySwitchesFrom( 1144 cmd_line->CopySwitchesFrom(
1150 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost, 1145 browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost,
1151 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches); 1146 switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches);
1152 1147
1153 GetContentClient()->browser()->AppendExtraCommandLineSwitches( 1148 GetContentClient()->browser()->AppendExtraCommandLineSwitches(
1154 cmd_line, process_->GetData().id); 1149 cmd_line, process_->GetData().id);
1155 1150
1156 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line); 1151 GpuDataManagerImpl::GetInstance()->AppendGpuCommandLine(cmd_line);
1157 1152
1158 if (cmd_line->HasSwitch(switches::kUseGL)) { 1153 if (cmd_line->HasSwitch(switches::kUseGL)) {
1159 software_rendering_ = 1154 swiftshader_rendering_ =
1160 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); 1155 (cmd_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader");
1161 } 1156 }
1162 1157
1163 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSoftwareRendering", software_rendering_); 1158 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessSwiftShaderRendering",
jbauman 2013/04/23 00:17:37 Don't change this. It's clear that it relates only
slavi 2013/04/23 00:38:49 Done.
1159 swiftshader_rendering_);
1164 1160
1165 // If specified, prepend a launcher program to the command line. 1161 // If specified, prepend a launcher program to the command line.
1166 if (!gpu_launcher.empty()) 1162 if (!gpu_launcher.empty())
1167 cmd_line->PrependWrapper(gpu_launcher); 1163 cmd_line->PrependWrapper(gpu_launcher);
1168 1164
1169 process_->Launch( 1165 process_->Launch(
1170 #if defined(OS_WIN) 1166 #if defined(OS_WIN)
1171 new GpuSandboxedProcessLauncherDelegate(cmd_line), 1167 new GpuSandboxedProcessLauncherDelegate(cmd_line),
1172 #elif defined(OS_POSIX) 1168 #elif defined(OS_POSIX)
1173 false, 1169 false,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1242 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1247 ClientIdToShaderCacheMap::iterator iter = 1243 ClientIdToShaderCacheMap::iterator iter =
1248 client_id_to_shader_cache_.find(client_id); 1244 client_id_to_shader_cache_.find(client_id);
1249 // If the cache doesn't exist then this is an off the record profile. 1245 // If the cache doesn't exist then this is an off the record profile.
1250 if (iter == client_id_to_shader_cache_.end()) 1246 if (iter == client_id_to_shader_cache_.end())
1251 return; 1247 return;
1252 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1248 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1253 } 1249 }
1254 1250
1255 } // namespace content 1251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698