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

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

Issue 2020243004: content: Rename num raster threads -> num worker threads. Base URL: https://chromium.googlesource.com/chromium/src.git@categorized_worker_pool_3
Patch Set: build break Created 4 years, 6 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 17 matching lines...) Expand all
28 28
29 static bool IsGpuRasterizationBlacklisted() { 29 static bool IsGpuRasterizationBlacklisted() {
30 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); 30 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
31 return manager->IsFeatureBlacklisted( 31 return manager->IsFeatureBlacklisted(
32 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); 32 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION);
33 } 33 }
34 34
35 const char kGpuCompositingFeatureName[] = "gpu_compositing"; 35 const char kGpuCompositingFeatureName[] = "gpu_compositing";
36 const char kWebGLFeatureName[] = "webgl"; 36 const char kWebGLFeatureName[] = "webgl";
37 const char kRasterizationFeatureName[] = "rasterization"; 37 const char kRasterizationFeatureName[] = "rasterization";
38 const char kMultipleRasterThreadsFeatureName[] = "multiple_raster_threads"; 38 const char kMultipleCategorizedWorkerThreadsFeatureName[] =
39 "multiple_categorized_worker_threads";
39 const char kNativeGpuMemoryBuffersFeatureName[] = "native_gpu_memory_buffers"; 40 const char kNativeGpuMemoryBuffersFeatureName[] = "native_gpu_memory_buffers";
40 41
41 const int kMinRasterThreads = 1; 42 const int kMinCategorizedWorkerThreads = 1;
42 const int kMaxRasterThreads = 4; 43 const int kMaxCategorizedWorkerThreads = 4;
43 44
44 const int kMinMSAASampleCount = 0; 45 const int kMinMSAASampleCount = 0;
45 46
46 struct GpuFeatureInfo { 47 struct GpuFeatureInfo {
47 std::string name; 48 std::string name;
48 bool blocked; 49 bool blocked;
49 bool disabled; 50 bool disabled;
50 std::string disabled_description; 51 std::string disabled_description;
51 bool fallback_to_software; 52 bool fallback_to_software;
52 }; 53 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 false}, 120 false},
120 #endif 121 #endif
121 {kRasterizationFeatureName, 122 {kRasterizationFeatureName,
122 IsGpuRasterizationBlacklisted() && !IsGpuRasterizationEnabled() && 123 IsGpuRasterizationBlacklisted() && !IsGpuRasterizationEnabled() &&
123 !IsForceGpuRasterizationEnabled(), 124 !IsForceGpuRasterizationEnabled(),
124 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && 125 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() &&
125 !IsGpuRasterizationBlacklisted(), 126 !IsGpuRasterizationBlacklisted(),
126 "Accelerated rasterization has been disabled, either via blacklist," 127 "Accelerated rasterization has been disabled, either via blacklist,"
127 " about:flags or the command line.", 128 " about:flags or the command line.",
128 true}, 129 true},
129 {kMultipleRasterThreadsFeatureName, false, 130 {kMultipleCategorizedWorkerThreadsFeatureName, false,
130 NumberOfRendererRasterThreads() == 1, "Raster is using a single thread.", 131 NumberOfRendererCategorizedWorkerThreads() == 1,
131 false}, 132 "Categorized worker pool is using a single thread.", false},
132 {kNativeGpuMemoryBuffersFeatureName, false, 133 {kNativeGpuMemoryBuffersFeatureName, false,
133 !BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled(), 134 !BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBuffersEnabled(),
134 "Native GpuMemoryBuffers have been disabled, either via about:flags" 135 "Native GpuMemoryBuffers have been disabled, either via about:flags"
135 " or command line.", 136 " or command line.",
136 true}, 137 true},
137 }; 138 };
138 DCHECK(index < arraysize(kGpuFeatureInfo)); 139 DCHECK(index < arraysize(kGpuFeatureInfo));
139 *eof = (index == arraysize(kGpuFeatureInfo) - 1); 140 *eof = (index == arraysize(kGpuFeatureInfo) - 1);
140 return kGpuFeatureInfo[index]; 141 return kGpuFeatureInfo[index];
141 } 142 }
142 143
143 } // namespace 144 } // namespace
144 145
145 int NumberOfRendererRasterThreads() { 146 int NumberOfRendererCategorizedWorkerThreads() {
146 int num_processors = base::SysInfo::NumberOfProcessors(); 147 int num_processors = base::SysInfo::NumberOfProcessors();
147 148
148 #if defined(OS_ANDROID) 149 #if defined(OS_ANDROID)
149 // Android may report 6 to 8 CPUs for big.LITTLE configurations. 150 // Android may report 6 to 8 CPUs for big.LITTLE configurations.
150 // Limit the number of raster threads based on maximum of 4 big cores. 151 // Limit the number of categorized worker threads based on maximum of 4 big
152 // cores.
151 num_processors = std::min(num_processors, 4); 153 num_processors = std::min(num_processors, 4);
152 #endif 154 #endif
153 155
154 int num_raster_threads = num_processors / 2; 156 int num_categorized_worker_threads = num_processors / 2;
155 157
156 #if defined(OS_ANDROID) 158 #if defined(OS_ANDROID)
157 // Limit the number of raster threads to 1 on Android. 159 // Limit the number of categorized worker threads to 1 on Android.
158 // TODO(reveman): Remove this when we have a better mechanims to prevent 160 // TODO(reveman): Remove this when we have a better mechanism to prevent
159 // pre-paint raster work from slowing down non-raster work. crbug.com/504515 161 // pre-paint raster work from slowing down non-raster work. crbug.com/504515
160 num_raster_threads = 1; 162 num_categorized_worker_threads = 1;
161 #endif 163 #endif
162 164
163 const base::CommandLine& command_line = 165 const base::CommandLine& command_line =
164 *base::CommandLine::ForCurrentProcess(); 166 *base::CommandLine::ForCurrentProcess();
165 167
166 if (command_line.HasSwitch(switches::kNumRasterThreads)) { 168 if (command_line.HasSwitch(switches::kNumCategorizedWorkerThreads)) {
167 std::string string_value = command_line.GetSwitchValueASCII( 169 std::string string_value = command_line.GetSwitchValueASCII(
168 switches::kNumRasterThreads); 170 switches::kNumCategorizedWorkerThreads);
169 if (!base::StringToInt(string_value, &num_raster_threads)) { 171 if (!base::StringToInt(string_value, &num_categorized_worker_threads)) {
170 DLOG(WARNING) << "Failed to parse switch " << 172 DLOG(WARNING) << "Failed to parse switch "
171 switches::kNumRasterThreads << ": " << string_value; 173 << switches::kNumCategorizedWorkerThreads << ": "
174 << string_value;
172 } 175 }
173 } 176 }
174 177
175 return cc::MathUtil::ClampToRange(num_raster_threads, kMinRasterThreads, 178 return cc::MathUtil::ClampToRange(num_categorized_worker_threads,
176 kMaxRasterThreads); 179 kMinCategorizedWorkerThreads,
180 kMaxCategorizedWorkerThreads);
177 } 181 }
178 182
179 bool IsZeroCopyUploadEnabled() { 183 bool IsZeroCopyUploadEnabled() {
180 const base::CommandLine& command_line = 184 const base::CommandLine& command_line =
181 *base::CommandLine::ForCurrentProcess(); 185 *base::CommandLine::ForCurrentProcess();
182 #if defined(OS_MACOSX) 186 #if defined(OS_MACOSX)
183 return !command_line.HasSwitch(switches::kDisableZeroCopy); 187 return !command_line.HasSwitch(switches::kDisableZeroCopy);
184 #else 188 #else
185 return command_line.HasSwitch(switches::kEnableZeroCopy); 189 return command_line.HasSwitch(switches::kEnableZeroCopy);
186 #endif 190 #endif
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 status += "_off"; 330 status += "_off";
327 } else { 331 } else {
328 status = "enabled"; 332 status = "enabled";
329 if (gpu_feature_info.name == kWebGLFeatureName && 333 if (gpu_feature_info.name == kWebGLFeatureName &&
330 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) 334 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING))
331 status += "_readback"; 335 status += "_readback";
332 if (gpu_feature_info.name == kRasterizationFeatureName) { 336 if (gpu_feature_info.name == kRasterizationFeatureName) {
333 if (IsForceGpuRasterizationEnabled()) 337 if (IsForceGpuRasterizationEnabled())
334 status += "_force"; 338 status += "_force";
335 } 339 }
336 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { 340 if (gpu_feature_info.name ==
341 kMultipleCategorizedWorkerThreadsFeatureName) {
337 const base::CommandLine& command_line = 342 const base::CommandLine& command_line =
338 *base::CommandLine::ForCurrentProcess(); 343 *base::CommandLine::ForCurrentProcess();
339 if (command_line.HasSwitch(switches::kNumRasterThreads)) 344 if (command_line.HasSwitch(switches::kNumCategorizedWorkerThreads))
340 status += "_force"; 345 status += "_force";
341 } 346 }
342 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) 347 if (gpu_feature_info.name == kMultipleCategorizedWorkerThreadsFeatureName)
343 status += "_on"; 348 status += "_on";
344 } 349 }
345 if (gpu_feature_info.name == kWebGLFeatureName && 350 if (gpu_feature_info.name == kWebGLFeatureName &&
346 (gpu_feature_info.blocked || gpu_access_blocked) && 351 (gpu_feature_info.blocked || gpu_access_blocked) &&
347 manager->ShouldUseSwiftShader()) { 352 manager->ShouldUseSwiftShader()) {
348 status = "unavailable_software"; 353 status = "unavailable_software";
349 } 354 }
350 355
351 feature_status_dict->SetString( 356 feature_status_dict->SetString(
352 gpu_feature_info.name.c_str(), status.c_str()); 357 gpu_feature_info.name.c_str(), status.c_str());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 398 }
394 } 399 }
395 return problem_list; 400 return problem_list;
396 } 401 }
397 402
398 std::vector<std::string> GetDriverBugWorkarounds() { 403 std::vector<std::string> GetDriverBugWorkarounds() {
399 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); 404 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds();
400 } 405 }
401 406
402 } // namespace content 407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698