OLD | NEW |
---|---|
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 = 64; |
danakj
2015/05/13 20:01:23
does 64 threads really ever make sense? at what po
reveman
2015/05/13 20:24:35
We're going to use these threads for more than ras
| |
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 Loading... | |
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 = cc::MathUtil::ClampToRange( |
215 base::SysInfo::NumberOfProcessors() / 2, | |
216 kMinRasterThreads, kMaxRasterThreads); | |
danakj
2015/05/13 20:01:23
nit: how about do the computation for a number her
reveman
2015/05/13 20:24:35
I did that first but didn't like it as it's alread
| |
214 | 217 |
215 // Async uploads uses its own thread, so allow an extra thread when async | 218 // Async uploads is used when neither zero-copy nor one-copy is enabled and |
216 // uploads is not in use. | 219 // it uses its own thread, so reduce the number of raster threads when async |
217 bool allow_extra_thread = | 220 // uploads is in use. |
221 bool async_uploads_is_used = | |
218 IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled(); | 222 IsZeroCopyUploadEnabled() || IsOneCopyUploadEnabled(); |
219 if (base::SysInfo::NumberOfProcessors() >= 4 && allow_extra_thread) | 223 if (async_uploads_is_used) |
220 num_raster_threads = 2; | 224 num_raster_threads = std::max(kMinRasterThreads, num_raster_threads - 1); |
221 | 225 |
222 int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); | 226 int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); |
223 if (force_num_raster_threads) | 227 if (force_num_raster_threads) |
224 num_raster_threads = force_num_raster_threads; | 228 num_raster_threads = force_num_raster_threads; |
225 | 229 |
226 return num_raster_threads; | 230 return num_raster_threads; |
227 } | 231 } |
228 | 232 |
229 bool IsOneCopyUploadEnabled() { | 233 bool IsOneCopyUploadEnabled() { |
230 if (IsZeroCopyUploadEnabled()) | 234 if (IsZeroCopyUploadEnabled()) |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 } | 445 } |
442 } | 446 } |
443 return problem_list; | 447 return problem_list; |
444 } | 448 } |
445 | 449 |
446 std::vector<std::string> GetDriverBugWorkarounds() { | 450 std::vector<std::string> GetDriverBugWorkarounds() { |
447 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 451 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
448 } | 452 } |
449 | 453 |
450 } // namespace content | 454 } // namespace content |
OLD | NEW |