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

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

Issue 1143473002: Re-land: content: Use NumberOfProcessors() / 2 raster threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup and reduce kMaxRasterThreads to 16 Created 5 years, 7 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
« no previous file with comments | « content/browser/gpu/compositor_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compositor_util.h" 5 #include "content/browser/gpu/compositor_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_info.h" 11 #include "base/sys_info.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "cc/base/math_util.h"
13 #include "cc/base/switches.h" 14 #include "cc/base/switches.h"
14 #include "content/browser/gpu/gpu_data_manager_impl.h" 15 #include "content/browser/gpu/gpu_data_manager_impl.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "gpu/config/gpu_feature_type.h" 17 #include "gpu/config/gpu_feature_type.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
21 22
22 static bool IsGpuRasterizationBlacklisted() { 23 static bool IsGpuRasterizationBlacklisted() {
23 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
24 return manager->IsFeatureBlacklisted( 25 return manager->IsFeatureBlacklisted(
25 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION);
26 } 27 }
27 28
28 const char* kGpuCompositingFeatureName = "gpu_compositing"; 29 const char* kGpuCompositingFeatureName = "gpu_compositing";
29 const char* kWebGLFeatureName = "webgl"; 30 const char* kWebGLFeatureName = "webgl";
30 const char* kRasterizationFeatureName = "rasterization"; 31 const char* kRasterizationFeatureName = "rasterization";
31 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; 32 const char* kThreadedRasterizationFeatureName = "threaded_rasterization";
32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; 33 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads";
33 34
34 const int kMinRasterThreads = 1; 35 const int kMinRasterThreads = 1;
35 const int kMaxRasterThreads = 64; 36 const int kMaxRasterThreads = 16;
36 37
37 const int kMinMSAASampleCount = 0; 38 const int kMinMSAASampleCount = 0;
38 39
39 struct GpuFeatureInfo { 40 struct GpuFeatureInfo {
40 std::string name; 41 std::string name;
41 bool blocked; 42 bool blocked;
42 bool disabled; 43 bool disabled;
43 std::string disabled_description; 44 std::string disabled_description;
44 bool fallback_to_software; 45 bool fallback_to_software;
45 }; 46 };
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 bool IsImplSidePaintingEnabled() { 205 bool IsImplSidePaintingEnabled() {
205 const base::CommandLine& command_line = 206 const base::CommandLine& command_line =
206 *base::CommandLine::ForCurrentProcess(); 207 *base::CommandLine::ForCurrentProcess();
207 if (command_line.HasSwitch(switches::kDisableImplSidePainting)) 208 if (command_line.HasSwitch(switches::kDisableImplSidePainting))
208 return false; 209 return false;
209 return true; 210 return true;
210 } 211 }
211 212
212 int NumberOfRendererRasterThreads() { 213 int NumberOfRendererRasterThreads() {
213 int num_raster_threads = 1; 214 int num_raster_threads = base::SysInfo::NumberOfProcessors() / 2;
214 215
215 // Async uploads uses its own thread, so allow an extra thread when async 216 // Async uploads is used when neither zero-copy nor one-copy is enabled and
216 // uploads is not in use. 217 // it uses its own thread, so reduce the number of raster threads when async
217 bool allow_extra_thread = 218 // uploads is in use.
219 bool async_uploads_is_used =
218 IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled(); 220 IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled();
vmpstr 2015/05/19 16:37:04 Is this condition supposed to be negated?
reveman 2015/05/19 16:40:31 Oops. I'll revert and re-land a fixed version of t
219 if (base::SysInfo::NumberOfProcessors() >= 4 && allow_extra_thread) 221 if (async_uploads_is_used)
220 num_raster_threads = 2; 222 --num_raster_threads;
221 223
222 int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); 224 const base::CommandLine& command_line =
223 if (force_num_raster_threads) 225 *base::CommandLine::ForCurrentProcess();
224 num_raster_threads = force_num_raster_threads;
225 226
226 return num_raster_threads; 227 if (command_line.HasSwitch(switches::kNumRasterThreads)) {
228 std::string string_value = command_line.GetSwitchValueASCII(
229 switches::kNumRasterThreads);
230 if (!base::StringToInt(string_value, &num_raster_threads)) {
231 DLOG(WARNING) << "Failed to parse switch " <<
232 switches::kNumRasterThreads << ": " << string_value;
233 }
234 }
235
236 return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads,
237 kMaxRasterThreads);
227 } 238 }
228 239
229 bool IsOneCopyUploadEnabled() { 240 bool IsOneCopyUploadEnabled() {
230 if (IsZeroCopyUploadEnabled()) 241 if (IsZeroCopyUploadEnabled())
231 return false; 242 return false;
232 243
233 const base::CommandLine& command_line = 244 const base::CommandLine& command_line =
234 *base::CommandLine::ForCurrentProcess(); 245 *base::CommandLine::ForCurrentProcess();
235 if (command_line.HasSwitch(switches::kEnableOneCopy)) 246 if (command_line.HasSwitch(switches::kEnableOneCopy))
236 return true; 247 return true;
237 if (command_line.HasSwitch(switches::kDisableOneCopy)) 248 if (command_line.HasSwitch(switches::kDisableOneCopy))
238 return false; 249 return false;
239 250
240 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID)
241 return false; 252 return false;
242 #endif 253 #endif
243 return true; 254 return true;
244 } 255 }
245 256
246 bool IsZeroCopyUploadEnabled() { 257 bool IsZeroCopyUploadEnabled() {
247 const base::CommandLine& command_line = 258 const base::CommandLine& command_line =
248 *base::CommandLine::ForCurrentProcess(); 259 *base::CommandLine::ForCurrentProcess();
249 return command_line.HasSwitch(switches::kEnableZeroCopy); 260 return command_line.HasSwitch(switches::kEnableZeroCopy);
250 } 261 }
251 262
252 int ForceNumberOfRendererRasterThreads() {
253 const base::CommandLine& command_line =
254 *base::CommandLine::ForCurrentProcess();
255
256 if (!command_line.HasSwitch(switches::kNumRasterThreads))
257 return 0;
258 std::string string_value =
259 command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
260 int force_num_raster_threads = 0;
261 if (base::StringToInt(string_value, &force_num_raster_threads) &&
262 force_num_raster_threads >= kMinRasterThreads &&
263 force_num_raster_threads <= kMaxRasterThreads) {
264 return force_num_raster_threads;
265 } else {
266 DLOG(WARNING) << "Failed to parse switch " <<
267 switches::kNumRasterThreads << ": " << string_value;
268 return 0;
269 }
270 }
271
272 bool IsGpuRasterizationEnabled() { 263 bool IsGpuRasterizationEnabled() {
273 const base::CommandLine& command_line = 264 const base::CommandLine& command_line =
274 *base::CommandLine::ForCurrentProcess(); 265 *base::CommandLine::ForCurrentProcess();
275 266
276 if (!IsImplSidePaintingEnabled()) 267 if (!IsImplSidePaintingEnabled())
277 return false; 268 return false;
278 269
279 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) 270 if (command_line.HasSwitch(switches::kDisableGpuRasterization))
280 return false; 271 return false;
281 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) 272 else if (command_line.HasSwitch(switches::kEnableGpuRasterization))
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } else { 367 } else {
377 status = "enabled"; 368 status = "enabled";
378 if (gpu_feature_info.name == kWebGLFeatureName && 369 if (gpu_feature_info.name == kWebGLFeatureName &&
379 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) 370 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING))
380 status += "_readback"; 371 status += "_readback";
381 if (gpu_feature_info.name == kRasterizationFeatureName) { 372 if (gpu_feature_info.name == kRasterizationFeatureName) {
382 if (IsForceGpuRasterizationEnabled()) 373 if (IsForceGpuRasterizationEnabled())
383 status += "_force"; 374 status += "_force";
384 } 375 }
385 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { 376 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) {
386 if (ForceNumberOfRendererRasterThreads() > 0) 377 const base::CommandLine& command_line =
378 *base::CommandLine::ForCurrentProcess();
379 if (command_line.HasSwitch(switches::kNumRasterThreads))
387 status += "_force"; 380 status += "_force";
388 } 381 }
389 if (gpu_feature_info.name == kThreadedRasterizationFeatureName || 382 if (gpu_feature_info.name == kThreadedRasterizationFeatureName ||
390 gpu_feature_info.name == kMultipleRasterThreadsFeatureName) 383 gpu_feature_info.name == kMultipleRasterThreadsFeatureName)
391 status += "_on"; 384 status += "_on";
392 } 385 }
393 if (gpu_feature_info.name == kWebGLFeatureName && 386 if (gpu_feature_info.name == kWebGLFeatureName &&
394 (gpu_feature_info.blocked || gpu_access_blocked) && 387 (gpu_feature_info.blocked || gpu_access_blocked) &&
395 manager->ShouldUseSwiftShader()) { 388 manager->ShouldUseSwiftShader()) {
396 status = "unavailable_software"; 389 status = "unavailable_software";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 434 }
442 } 435 }
443 return problem_list; 436 return problem_list;
444 } 437 }
445 438
446 std::vector<std::string> GetDriverBugWorkarounds() { 439 std::vector<std::string> GetDriverBugWorkarounds() {
447 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); 440 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds();
448 } 441 }
449 442
450 } // namespace content 443 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/compositor_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698