Commit 8a91b03e authored by danakj's avatar danakj Committed by Commit bot

Make the number of raster threads appear in chrome://gpu.

This add methods to compositor_util.cc to compute the number of
raster threads to be used in the renderer process. Then this number
is passed to the renderer process explicitly instead of just forwarding
a command line flag blindly.

If the renderer will use more than one thread, chrome://gpu will report
that "Multiple Raster Threads" is enabled, otherwise it shows disabled.
If the --num-raster-threads command line argument is used to force more
than one thread, then it will show Force enabled.

There is no change in behaviour with this patch, it still uses one thread
unless forced otherwise on the command line.

BUG=237669

Review URL: https://codereview.chromium.org/519923002

Cr-Commit-Position: refs/heads/master@{#292726}
parent 08906d2c
......@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
......@@ -27,6 +28,10 @@ const char* kGpuCompositingFeatureName = "gpu_compositing";
const char* kWebGLFeatureName = "webgl";
const char* kRasterizationFeatureName = "rasterization";
const char* kThreadedRasterizationFeatureName = "threaded_rasterization";
const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads";
const int kMinRasterThreads = 1;
const int kMaxRasterThreads = 64;
struct GpuFeatureInfo {
std::string name;
......@@ -142,8 +147,14 @@ const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) {
"Threaded rasterization has not been enabled or"
" is not supported by the current system.",
false
}
},
{
kMultipleRasterThreadsFeatureName,
false,
NumberOfRendererRasterThreads() == 1,
"Raster is using a single thread.",
false
},
};
DCHECK(index < arraysize(kGpuFeatureInfo));
*eof = (index == arraysize(kGpuFeatureInfo) - 1);
......@@ -200,6 +211,36 @@ bool IsImplSidePaintingEnabled() {
return true;
}
int NumberOfRendererRasterThreads() {
int num_raster_threads = 1;
int force_num_raster_threads = ForceNumberOfRendererRasterThreads();
if (force_num_raster_threads)
num_raster_threads = force_num_raster_threads;
return num_raster_threads;
}
int ForceNumberOfRendererRasterThreads() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kNumRasterThreads))
return 0;
std::string string_value =
command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
int force_num_raster_threads = 0;
if (base::StringToInt(string_value, &force_num_raster_threads) &&
force_num_raster_threads >= kMinRasterThreads &&
force_num_raster_threads <= kMaxRasterThreads) {
return force_num_raster_threads;
} else {
LOG(WARNING) << "Failed to parse switch " <<
switches::kNumRasterThreads << ": " << string_value;
return 0;
}
}
bool IsGpuRasterizationEnabled() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
......@@ -252,9 +293,9 @@ base::Value* GetFeatureStatus() {
} else if (gpu_feature_info.blocked ||
gpu_access_blocked) {
status = "unavailable";
if (gpu_feature_info.fallback_to_software) {
if (gpu_feature_info.fallback_to_software)
status += "_software";
} else
else
status += "_off";
} else {
status = "enabled";
......@@ -265,7 +306,12 @@ base::Value* GetFeatureStatus() {
if (IsForceGpuRasterizationEnabled())
status += "_force";
}
if (gpu_feature_info.name == kThreadedRasterizationFeatureName)
if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) {
if (ForceNumberOfRendererRasterThreads() > 0)
status += "_force";
}
if (gpu_feature_info.name == kThreadedRasterizationFeatureName ||
gpu_feature_info.name == kMultipleRasterThreadsFeatureName)
status += "_on";
}
if (gpu_feature_info.name == kWebGLFeatureName &&
......
......@@ -30,6 +30,13 @@ CONTENT_EXPORT bool IsGpuRasterizationEnabled();
// Returns true if force-gpu-rasterization is on (via flags) for the renderer.
CONTENT_EXPORT bool IsForceGpuRasterizationEnabled();
// Returns the number of raster threads to use for compositing.
CONTENT_EXPORT int NumberOfRendererRasterThreads();
// Returns the number of raster threads to use for compositing that are forced
// by the command line.
CONTENT_EXPORT int ForceNumberOfRendererRasterThreads();
CONTENT_EXPORT base::Value* GetFeatureStatus();
CONTENT_EXPORT base::Value* GetProblems();
CONTENT_EXPORT base::Value* GetDriverBugWorkarounds();
......
......@@ -1020,8 +1020,12 @@ static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) {
if (IsDelegatedRendererEnabled())
command_line->AppendSwitch(switches::kEnableDelegatedRenderer);
if (IsImplSidePaintingEnabled())
if (IsImplSidePaintingEnabled()) {
command_line->AppendSwitch(switches::kEnableImplSidePainting);
command_line->AppendSwitchASCII(
switches::kNumRasterThreads,
base::IntToString(NumberOfRendererRasterThreads()));
}
if (content::IsGpuRasterizationEnabled())
command_line->AppendSwitch(switches::kEnableGpuRasterization);
......@@ -1179,7 +1183,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kMemoryMetrics,
switches::kNoReferrers,
switches::kNoSandbox,
switches::kNumRasterThreads,
switches::kPpapiInProcess,
switches::kProfilerTiming,
switches::kReduceSecurityForTesting,
......
......@@ -94,6 +94,7 @@ cr.define('gpu', function() {
'panel_fitting': 'Panel Fitting',
'rasterization': 'Rasterization',
'threaded_rasterization': 'Threaded Rasterization',
'multiple_raster_threads': 'Multiple Raster Threads',
};
var statusMap = {
......@@ -136,7 +137,11 @@ cr.define('gpu', function() {
'enabled_on': {
'label': 'Enabled',
'class': 'feature-green'
}
},
'enabled_force_on': {
'label': 'Force enabled',
'class': 'feature-green'
},
};
// GPU info, basic
......
......@@ -173,8 +173,6 @@ const int64 kInitialIdleHandlerDelayMs = 1000;
const int64 kShortIdleHandlerDelayMs = 1000;
const int64 kLongIdleHandlerDelayMs = 30*1000;
const int kIdleCPUUsageThresholdInPercents = 3;
const int kMinRasterThreads = 1;
const int kMaxRasterThreads = 64;
// Maximum allocation size allowed for image scaling filters that
// require pre-scaling. Skia will fallback to a filter that doesn't
......@@ -556,18 +554,15 @@ void RenderThreadImpl::Init() {
// it doesn't have to be the same thread RenderThreadImpl is created on.
allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
if (command_line.HasSwitch(switches::kNumRasterThreads)) {
int num_raster_threads;
if (is_impl_side_painting_enabled_) {
int num_raster_threads = 0;
std::string string_value =
command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
if (base::StringToInt(string_value, &num_raster_threads) &&
num_raster_threads >= kMinRasterThreads &&
num_raster_threads <= kMaxRasterThreads) {
cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads);
} else {
LOG(WARNING) << "Failed to parse switch " <<
switches::kNumRasterThreads << ": " << string_value;
}
bool parsed_num_raster_threads =
base::StringToInt(string_value, &num_raster_threads);
DCHECK(parsed_num_raster_threads) << string_value;
DCHECK_GT(num_raster_threads, 0);
cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads);
}
service_registry()->AddService<RenderFrameSetup>(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment