| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 25 return manager->IsFeatureBlacklisted( | 25 return manager->IsFeatureBlacklisted( |
| 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
| 27 } | 27 } |
| 28 | 28 |
| 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 30 const char* kWebGLFeatureName = "webgl"; | 30 const char* kWebGLFeatureName = "webgl"; |
| 31 const char* kRasterizationFeatureName = "rasterization"; | 31 const char* kRasterizationFeatureName = "rasterization"; |
| 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; | 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| 33 | 33 |
| 34 const int kMinRasterThreads = 1; | 34 const int kMinWorkerThreads = 1; |
| 35 const int kMaxRasterThreads = 16; | 35 const int kMaxWorkerThreads = 16; |
| 36 | 36 |
| 37 const int kMinMSAASampleCount = 0; | 37 const int kMinMSAASampleCount = 0; |
| 38 | 38 |
| 39 struct GpuFeatureInfo { | 39 struct GpuFeatureInfo { |
| 40 std::string name; | 40 std::string name; |
| 41 bool blocked; | 41 bool blocked; |
| 42 bool disabled; | 42 bool disabled; |
| 43 std::string disabled_description; | 43 std::string disabled_description; |
| 44 bool fallback_to_software; | 44 bool fallback_to_software; |
| 45 }; | 45 }; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), | 139 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), |
| 140 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && | 140 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && |
| 141 !IsGpuRasterizationBlacklisted(), | 141 !IsGpuRasterizationBlacklisted(), |
| 142 "Accelerated rasterization has been disabled, either via about:flags" | 142 "Accelerated rasterization has been disabled, either via about:flags" |
| 143 " or command line.", | 143 " or command line.", |
| 144 true | 144 true |
| 145 }, | 145 }, |
| 146 { | 146 { |
| 147 kMultipleRasterThreadsFeatureName, | 147 kMultipleRasterThreadsFeatureName, |
| 148 false, | 148 false, |
| 149 NumberOfRendererRasterThreads() == 1, | 149 NumberOfRendererWorkerThreads() == 1, |
| 150 "Raster is using a single thread.", | 150 "Raster is using a single thread.", |
| 151 false | 151 false |
| 152 }, | 152 }, |
| 153 }; | 153 }; |
| 154 DCHECK(index < arraysize(kGpuFeatureInfo)); | 154 DCHECK(index < arraysize(kGpuFeatureInfo)); |
| 155 *eof = (index == arraysize(kGpuFeatureInfo) - 1); | 155 *eof = (index == arraysize(kGpuFeatureInfo) - 1); |
| 156 return kGpuFeatureInfo[index]; | 156 return kGpuFeatureInfo[index]; |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace | 159 } // namespace |
| (...skipping 13 matching lines...) Expand all Loading... |
| 173 // Enable on Aura and Mac. | 173 // Enable on Aura and Mac. |
| 174 enabled = true; | 174 enabled = true; |
| 175 #endif | 175 #endif |
| 176 | 176 |
| 177 // Flags override. | 177 // Flags override. |
| 178 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 178 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
| 179 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); | 179 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); |
| 180 return enabled; | 180 return enabled; |
| 181 } | 181 } |
| 182 | 182 |
| 183 int NumberOfRendererRasterThreads() { | 183 int NumberOfRendererWorkerThreads() { |
| 184 int num_processors = base::SysInfo::NumberOfProcessors(); | 184 int num_processors = base::SysInfo::NumberOfProcessors(); |
| 185 | 185 |
| 186 #if defined(OS_ANDROID) | 186 #if defined(OS_ANDROID) |
| 187 // Android may report 6 to 8 CPUs for big.LITTLE configurations. | 187 // Android may report 6 to 8 CPUs for big.LITTLE configurations. |
| 188 // Limit the number of raster threads based on maximum of 4 big cores. | 188 // Limit the number of raster threads based on maximum of 4 big cores. |
| 189 num_processors = std::min(num_processors, 4); | 189 num_processors = std::min(num_processors, 4); |
| 190 #endif | 190 #endif |
| 191 | 191 |
| 192 int num_raster_threads = num_processors / 2; | 192 int num_worker_threads = num_processors / 2; |
| 193 | 193 |
| 194 // Async uploads is used when neither zero-copy nor one-copy is enabled and | 194 // Async uploads is used when neither zero-copy nor one-copy is enabled and |
| 195 // it uses its own thread, so reduce the number of raster threads when async | 195 // it uses its own thread, so reduce the number of worker threads when async |
| 196 // uploads is in use. | 196 // uploads is in use. |
| 197 bool async_uploads_is_used = | 197 bool async_uploads_is_used = |
| 198 !IsZeroCopyUploadEnabled() && !IsOneCopyUploadEnabled(); | 198 !IsZeroCopyUploadEnabled() && !IsOneCopyUploadEnabled(); |
| 199 if (async_uploads_is_used) | 199 if (async_uploads_is_used) |
| 200 --num_raster_threads; | 200 --num_worker_threads; |
| 201 | 201 |
| 202 const base::CommandLine& command_line = | 202 const base::CommandLine& command_line = |
| 203 *base::CommandLine::ForCurrentProcess(); | 203 *base::CommandLine::ForCurrentProcess(); |
| 204 | 204 |
| 205 if (command_line.HasSwitch(switches::kNumRasterThreads)) { | 205 if (command_line.HasSwitch(switches::kNumWorkerThreads)) { |
| 206 std::string string_value = command_line.GetSwitchValueASCII( | 206 std::string string_value = command_line.GetSwitchValueASCII( |
| 207 switches::kNumRasterThreads); | 207 switches::kNumWorkerThreads); |
| 208 if (!base::StringToInt(string_value, &num_raster_threads)) { | 208 if (!base::StringToInt(string_value, &num_worker_threads)) { |
| 209 DLOG(WARNING) << "Failed to parse switch " << | 209 DLOG(WARNING) << "Failed to parse switch " << |
| 210 switches::kNumRasterThreads << ": " << string_value; | 210 switches::kNumWorkerThreads << ": " << string_value; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads, | 214 return cc::MathUtil::ClampToRange(num_worker_threads, kMinWorkerThreads, |
| 215 kMaxRasterThreads); | 215 kMaxWorkerThreads); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool IsOneCopyUploadEnabled() { | 218 bool IsOneCopyUploadEnabled() { |
| 219 if (IsZeroCopyUploadEnabled()) | 219 if (IsZeroCopyUploadEnabled()) |
| 220 return false; | 220 return false; |
| 221 | 221 |
| 222 const base::CommandLine& command_line = | 222 const base::CommandLine& command_line = |
| 223 *base::CommandLine::ForCurrentProcess(); | 223 *base::CommandLine::ForCurrentProcess(); |
| 224 return !command_line.HasSwitch(switches::kDisableOneCopy); | 224 return !command_line.HasSwitch(switches::kDisableOneCopy); |
| 225 } | 225 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 if (gpu_feature_info.name == kWebGLFeatureName && | 338 if (gpu_feature_info.name == kWebGLFeatureName && |
| 339 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 339 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
| 340 status += "_readback"; | 340 status += "_readback"; |
| 341 if (gpu_feature_info.name == kRasterizationFeatureName) { | 341 if (gpu_feature_info.name == kRasterizationFeatureName) { |
| 342 if (IsForceGpuRasterizationEnabled()) | 342 if (IsForceGpuRasterizationEnabled()) |
| 343 status += "_force"; | 343 status += "_force"; |
| 344 } | 344 } |
| 345 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { | 345 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { |
| 346 const base::CommandLine& command_line = | 346 const base::CommandLine& command_line = |
| 347 *base::CommandLine::ForCurrentProcess(); | 347 *base::CommandLine::ForCurrentProcess(); |
| 348 if (command_line.HasSwitch(switches::kNumRasterThreads)) | 348 if (command_line.HasSwitch(switches::kNumWorkerThreads)) |
| 349 status += "_force"; | 349 status += "_force"; |
| 350 } | 350 } |
| 351 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) | 351 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) |
| 352 status += "_on"; | 352 status += "_on"; |
| 353 } | 353 } |
| 354 if (gpu_feature_info.name == kWebGLFeatureName && | 354 if (gpu_feature_info.name == kWebGLFeatureName && |
| 355 (gpu_feature_info.blocked || gpu_access_blocked) && | 355 (gpu_feature_info.blocked || gpu_access_blocked) && |
| 356 manager->ShouldUseSwiftShader()) { | 356 manager->ShouldUseSwiftShader()) { |
| 357 status = "unavailable_software"; | 357 status = "unavailable_software"; |
| 358 } | 358 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 return problem_list; | 404 return problem_list; |
| 405 } | 405 } |
| 406 | 406 |
| 407 std::vector<std::string> GetDriverBugWorkarounds() { | 407 std::vector<std::string> GetDriverBugWorkarounds() { |
| 408 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 408 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace content | 411 } // namespace content |
| OLD | NEW |