Chromium Code Reviews| 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/math_util.h" |
| 14 #include "cc/base/switches.h" | 14 #include "cc/base/switches.h" |
| 15 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | |
| 15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 16 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 17 #include "gpu/config/gpu_feature_type.h" | 18 #include "gpu/config/gpu_feature_type.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 static bool IsGpuRasterizationBlacklisted() { | 24 static bool IsGpuRasterizationBlacklisted() { |
| 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 25 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 25 return manager->IsFeatureBlacklisted( | 26 return manager->IsFeatureBlacklisted( |
| 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 27 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
| 27 } | 28 } |
| 28 | 29 |
| 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 30 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 30 const char* kWebGLFeatureName = "webgl"; | 31 const char* kWebGLFeatureName = "webgl"; |
| 31 const char* kRasterizationFeatureName = "rasterization"; | 32 const char* kRasterizationFeatureName = "rasterization"; |
| 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; | 33 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| 34 const char* kGpuMemoryBufferFeatureName = "gpu_memory_buffer"; | |
| 33 | 35 |
| 34 const int kMinRasterThreads = 1; | 36 const int kMinRasterThreads = 1; |
| 35 const int kMaxRasterThreads = 4; | 37 const int kMaxRasterThreads = 4; |
| 36 | 38 |
| 37 const int kMinMSAASampleCount = 0; | 39 const int kMinMSAASampleCount = 0; |
| 38 | 40 |
| 39 struct GpuFeatureInfo { | 41 struct GpuFeatureInfo { |
| 40 std::string name; | 42 std::string name; |
| 41 bool blocked; | 43 bool blocked; |
| 42 bool disabled; | 44 bool disabled; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 " or command line.", | 145 " or command line.", |
| 144 true | 146 true |
| 145 }, | 147 }, |
| 146 { | 148 { |
| 147 kMultipleRasterThreadsFeatureName, | 149 kMultipleRasterThreadsFeatureName, |
| 148 false, | 150 false, |
| 149 NumberOfRendererRasterThreads() == 1, | 151 NumberOfRendererRasterThreads() == 1, |
| 150 "Raster is using a single thread.", | 152 "Raster is using a single thread.", |
| 151 false | 153 false |
| 152 }, | 154 }, |
| 155 { | |
| 156 kGpuMemoryBufferFeatureName, | |
| 157 false, | |
| 158 !IsNativeGpuMemoryBufferEnabled(), | |
| 159 "GpuMemoryByffer is using the fall back path through shared memory" | |
| 160 " instead the hardware backed one.", | |
|
reveman
2015/09/29 11:58:02
This is not completely true. Just because native G
| |
| 161 true | |
| 162 }, | |
| 153 }; | 163 }; |
| 154 DCHECK(index < arraysize(kGpuFeatureInfo)); | 164 DCHECK(index < arraysize(kGpuFeatureInfo)); |
| 155 *eof = (index == arraysize(kGpuFeatureInfo) - 1); | 165 *eof = (index == arraysize(kGpuFeatureInfo) - 1); |
| 156 return kGpuFeatureInfo[index]; | 166 return kGpuFeatureInfo[index]; |
| 157 } | 167 } |
| 158 | 168 |
| 159 } // namespace | 169 } // namespace |
| 160 | 170 |
| 161 bool IsPropertyTreeVerificationEnabled() { | 171 bool IsPropertyTreeVerificationEnabled() { |
| 162 const base::CommandLine& command_line = | 172 const base::CommandLine& command_line = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 bool IsZeroCopyUploadEnabled() { | 211 bool IsZeroCopyUploadEnabled() { |
| 202 const base::CommandLine& command_line = | 212 const base::CommandLine& command_line = |
| 203 *base::CommandLine::ForCurrentProcess(); | 213 *base::CommandLine::ForCurrentProcess(); |
| 204 #if defined(OS_MACOSX) | 214 #if defined(OS_MACOSX) |
| 205 return !command_line.HasSwitch(switches::kDisableZeroCopy); | 215 return !command_line.HasSwitch(switches::kDisableZeroCopy); |
| 206 #else | 216 #else |
| 207 return command_line.HasSwitch(switches::kEnableZeroCopy); | 217 return command_line.HasSwitch(switches::kEnableZeroCopy); |
| 208 #endif | 218 #endif |
| 209 } | 219 } |
| 210 | 220 |
| 221 bool IsNativeGpuMemoryBufferEnabled() { | |
| 222 const auto& command_line = *base::CommandLine::ForCurrentProcess(); | |
| 223 bool enabled = | |
| 224 command_line.HasSwitch(switches::kEnableNativeGpuMemoryBuffers); | |
| 225 BrowserGpuMemoryBufferManager* gmb_manager = | |
| 226 BrowserGpuMemoryBufferManager::current(); | |
| 227 | |
| 228 // We need buffer mapping configuration to proper support native GMB. | |
|
reveman
2015/09/29 11:58:02
That's why this gets messy and I don't think it's
| |
| 229 enabled &= gmb_manager->IsGpuMemoryBufferConfigurationSupported( | |
| 230 gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP) | | |
| 231 gmb_manager->IsGpuMemoryBufferConfigurationSupported( | |
| 232 gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::PERSISTENT_MAP); | |
| 233 return enabled; | |
| 234 } | |
| 235 | |
| 211 bool IsPersistentGpuMemoryBufferEnabled() { | 236 bool IsPersistentGpuMemoryBufferEnabled() { |
| 212 // Zero copy currently doesn't take advantage of persistent buffers. | 237 // Zero copy currently doesn't take advantage of persistent buffers. |
| 213 if (IsZeroCopyUploadEnabled()) | 238 if (IsZeroCopyUploadEnabled()) |
| 214 return false; | 239 return false; |
| 215 const auto& command_line = *base::CommandLine::ForCurrentProcess(); | 240 const auto& command_line = *base::CommandLine::ForCurrentProcess(); |
| 216 return command_line.HasSwitch(switches::kEnablePersistentGpuMemoryBuffer); | 241 return command_line.HasSwitch(switches::kEnablePersistentGpuMemoryBuffer); |
| 217 } | 242 } |
| 218 | 243 |
| 219 bool IsGpuRasterizationEnabled() { | 244 bool IsGpuRasterizationEnabled() { |
| 220 const base::CommandLine& command_line = | 245 const base::CommandLine& command_line = |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 status += "_off"; | 339 status += "_off"; |
| 315 } else { | 340 } else { |
| 316 status = "enabled"; | 341 status = "enabled"; |
| 317 if (gpu_feature_info.name == kWebGLFeatureName && | 342 if (gpu_feature_info.name == kWebGLFeatureName && |
| 318 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 343 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
| 319 status += "_readback"; | 344 status += "_readback"; |
| 320 if (gpu_feature_info.name == kRasterizationFeatureName) { | 345 if (gpu_feature_info.name == kRasterizationFeatureName) { |
| 321 if (IsForceGpuRasterizationEnabled()) | 346 if (IsForceGpuRasterizationEnabled()) |
| 322 status += "_force"; | 347 status += "_force"; |
| 323 } | 348 } |
| 349 if (gpu_feature_info.name == kGpuMemoryBufferFeatureName) { | |
| 350 status += "_native"; | |
| 351 if (IsZeroCopyUploadEnabled()) | |
| 352 status += "_zero_copy"; | |
| 353 else | |
| 354 status += "_one_copy"; | |
| 355 } | |
| 324 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { | 356 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { |
| 325 const base::CommandLine& command_line = | 357 const base::CommandLine& command_line = |
| 326 *base::CommandLine::ForCurrentProcess(); | 358 *base::CommandLine::ForCurrentProcess(); |
| 327 if (command_line.HasSwitch(switches::kNumRasterThreads)) | 359 if (command_line.HasSwitch(switches::kNumRasterThreads)) |
| 328 status += "_force"; | 360 status += "_force"; |
| 329 } | 361 } |
| 330 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) | 362 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) |
| 331 status += "_on"; | 363 status += "_on"; |
| 332 } | 364 } |
| 333 if (gpu_feature_info.name == kWebGLFeatureName && | 365 if (gpu_feature_info.name == kWebGLFeatureName && |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 } | 413 } |
| 382 } | 414 } |
| 383 return problem_list; | 415 return problem_list; |
| 384 } | 416 } |
| 385 | 417 |
| 386 std::vector<std::string> GetDriverBugWorkarounds() { | 418 std::vector<std::string> GetDriverBugWorkarounds() { |
| 387 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 419 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
| 388 } | 420 } |
| 389 | 421 |
| 390 } // namespace content | 422 } // namespace content |
| OLD | NEW |