Commit e18d4aca authored by jbates@chromium.org's avatar jbates@chromium.org

Add compositor thread mode to latency tests

BUG=138883

Review URL: https://chromiumcodereview.appspot.com/10829015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148417 0039d316-1c4b-4281-b951-d872f2087c98
parent f18fb478
...@@ -58,7 +58,7 @@ function setCoordinates(e) { ...@@ -58,7 +58,7 @@ function setCoordinates(e) {
function init() { function init() {
parseParams(); parseParams();
if (testParams.mode == 'webgl') { if (testParams.mode.indexOf('webgl') != -1) {
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
if (!canvas) if (!canvas)
return false; return false;
...@@ -101,7 +101,7 @@ function draw() { ...@@ -101,7 +101,7 @@ function draw() {
sleep(parseInt(testParams.delayTimeMS)); sleep(parseInt(testParams.delayTimeMS));
} }
if (testParams.mode == 'webgl') { if (testParams.mode.indexOf('webgl') != -1) {
gl.viewport(0, 0, testParams.canvasWidth, testParams.canvasWidth); gl.viewport(0, 0, testParams.canvasWidth, testParams.canvasWidth);
if (testParams.paintHeavy) { if (testParams.paintHeavy) {
gl.clearColor(0, 0, 0.0, 1.0); gl.clearColor(0, 0, 0.0, 1.0);
...@@ -128,7 +128,7 @@ function draw() { ...@@ -128,7 +128,7 @@ function draw() {
frameCount++; frameCount++;
if (frameCount == parseInt(testParams.numFrames)) { if (frameCount == parseInt(testParams.numFrames)) {
if (testParams.mode == 'webgl') if (testParams.mode.indexOf('webgl') != -1)
gl.finish(); gl.finish();
endTest(); endTest();
} else { } else {
......
...@@ -80,6 +80,7 @@ using trace_analyzer::TraceEventVector; ...@@ -80,6 +80,7 @@ using trace_analyzer::TraceEventVector;
enum LatencyTestMode { enum LatencyTestMode {
kWebGL, kWebGL,
kWebGLThread,
kSoftware kSoftware
}; };
...@@ -109,7 +110,7 @@ class LatencyTest ...@@ -109,7 +110,7 @@ class LatencyTest
: public BrowserPerfTest, : public BrowserPerfTest,
public ::testing::WithParamInterface<int> { public ::testing::WithParamInterface<int> {
public: public:
LatencyTest() : explicit LatencyTest(LatencyTestMode mode) :
query_instant_(Query::EventPhase() == query_instant_(Query::EventPhase() ==
Query::Phase(TRACE_EVENT_PHASE_INSTANT)), Query::Phase(TRACE_EVENT_PHASE_INSTANT)),
// These queries are initialized in RunTest. // These queries are initialized in RunTest.
...@@ -120,20 +121,20 @@ class LatencyTest ...@@ -120,20 +121,20 @@ class LatencyTest
query_clears_(Query::Bool(false)), query_clears_(Query::Bool(false)),
mouse_x_(0), mouse_x_(0),
tab_width_(0), tab_width_(0),
mode_(kWebGL), mode_(mode),
delay_time_us_(0), delay_time_us_(0),
num_frames_(0), num_frames_(0),
verbose_(false), verbose_(false),
test_flags_(0) {} test_flags_(0),
use_gpu_(mode == kWebGL || mode == kWebGLThread) {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
std::vector<int> GetAllBehaviors(); std::vector<int> GetAllBehaviors();
// Run test with specified |mode| and |behaviors|. // Run test with specified |behaviors|.
// |mode| can be webgl or software.
// |behaviors| is a list of combinations of LatencyTestFlags. // |behaviors| is a list of combinations of LatencyTestFlags.
void RunTest(LatencyTestMode mode, const std::vector<int>& behaviors); void RunTest(const std::vector<int>& behaviors);
private: private:
void RunTestInternal(const std::string& test_url, void RunTestInternal(const std::string& test_url,
...@@ -146,6 +147,8 @@ class LatencyTest ...@@ -146,6 +147,8 @@ class LatencyTest
switch (mode_) { switch (mode_) {
case kWebGL: case kWebGL:
return "webgl"; return "webgl";
case kWebGLThread:
return "webgl_thread";
case kSoftware: case kSoftware:
return "software"; return "software";
default: default:
...@@ -220,14 +223,20 @@ class LatencyTest ...@@ -220,14 +223,20 @@ class LatencyTest
// Current test flags combination, determining the behavior of the test. // Current test flags combination, determining the behavior of the test.
int test_flags_; int test_flags_;
bool use_gpu_;
}; };
void LatencyTest::SetUpCommandLine(CommandLine* command_line) { void LatencyTest::SetUpCommandLine(CommandLine* command_line) {
BrowserPerfTest::SetUpCommandLine(command_line); BrowserPerfTest::SetUpCommandLine(command_line);
if (CommandLine::ForCurrentProcess()-> if (mode_ == kWebGLThread) {
HasSwitch(switches::kEnableThreadedCompositing)) { ASSERT_TRUE(use_gpu_);
command_line->AppendSwitch(switches::kEnableThreadedCompositing); command_line->AppendSwitch(switches::kEnableThreadedCompositing);
} else {
command_line->AppendSwitch(switches::kDisableThreadedCompositing);
} }
if (!use_gpu_)
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
command_line->AppendSwitch(switches::kDisableBackgroundNetworking); command_line->AppendSwitch(switches::kDisableBackgroundNetworking);
} }
...@@ -239,9 +248,7 @@ std::vector<int> LatencyTest::GetAllBehaviors() { ...@@ -239,9 +248,7 @@ std::vector<int> LatencyTest::GetAllBehaviors() {
return behaviors; return behaviors;
} }
void LatencyTest::RunTest(LatencyTestMode mode, void LatencyTest::RunTest(const std::vector<int>& behaviors) {
const std::vector<int>& behaviors) {
mode_ = mode;
verbose_ = (logging::GetVlogLevel("latency_tests") > 0); verbose_ = (logging::GetVlogLevel("latency_tests") > 0);
// Linux Intel uses mesa driver, where multisampling is not supported. // Linux Intel uses mesa driver, where multisampling is not supported.
...@@ -270,7 +277,7 @@ void LatencyTest::RunTest(LatencyTestMode mode, ...@@ -270,7 +277,7 @@ void LatencyTest::RunTest(LatencyTestMode mode,
#endif #endif
// Construct queries for searching trace events via TraceAnalyzer. // Construct queries for searching trace events via TraceAnalyzer.
if (mode_ == kWebGL) { if (use_gpu_) {
query_begin_swaps_ = query_instant_ && query_begin_swaps_ = query_instant_ &&
Query::EventName() == Query::String("SwapBuffersLatency") && Query::EventName() == Query::String("SwapBuffersLatency") &&
Query::EventArg("width") != Query::Int(kWebGLCanvasWidth); Query::EventArg("width") != Query::Int(kWebGLCanvasWidth);
...@@ -293,8 +300,10 @@ void LatencyTest::RunTest(LatencyTestMode mode, ...@@ -293,8 +300,10 @@ void LatencyTest::RunTest(LatencyTestMode mode,
query_clears_ = query_instant_ && query_clears_ = query_instant_ &&
Query::EventName() == Query::String("DoClear") && Query::EventName() == Query::String("DoClear") &&
Query::EventArg("green") == Query::Int(kClearColorGreen); Query::EventArg("green") == Query::Int(kClearColorGreen);
Query query_width_swaps = query_begin_swaps_; Query query_width_swaps = Query::Bool(false);
if (mode_ == kSoftware) { if (use_gpu_) {
query_width_swaps = query_begin_swaps_;
} else if (mode_ == kSoftware) {
query_width_swaps = query_instant_ && query_width_swaps = query_instant_ &&
Query::EventName() == Query::String("UpdateRectWidth") && Query::EventName() == Query::String("UpdateRectWidth") &&
Query::EventArg("width") > Query::Int(kWebGLCanvasWidth); Query::EventArg("width") > Query::Int(kWebGLCanvasWidth);
...@@ -422,7 +431,7 @@ void LatencyTest::RunTestInternal(const std::string& test_url, ...@@ -422,7 +431,7 @@ void LatencyTest::RunTestInternal(const std::string& test_url,
double LatencyTest::CalculateLatency() { double LatencyTest::CalculateLatency() {
TraceEventVector events; TraceEventVector events;
if (mode_ == kWebGL) { if (use_gpu_) {
// Search for three types of events in WebGL mode: // Search for three types of events in WebGL mode:
// - onscreen swaps. // - onscreen swaps.
// - DoClear calls that contain the mouse x coordinate. // - DoClear calls that contain the mouse x coordinate.
...@@ -460,7 +469,7 @@ double LatencyTest::CalculateLatency() { ...@@ -460,7 +469,7 @@ double LatencyTest::CalculateLatency() {
&begin_swap_pos)); &begin_swap_pos));
int mouse_x = 0; int mouse_x = 0;
if (mode_ == kWebGL) { if (use_gpu_) {
// Trace backwards through the events to find the input event that // Trace backwards through the events to find the input event that
// matches the glClear that was presented by this SwapBuffers. // matches the glClear that was presented by this SwapBuffers.
...@@ -639,36 +648,66 @@ void LatencyTest::PrintEvents(const TraceEventVector& events) { ...@@ -639,36 +648,66 @@ void LatencyTest::PrintEvents(const TraceEventVector& events) {
printf("\n"); printf("\n");
} }
// For running tests on GPU:
class LatencyTestWebGL : public LatencyTest {
public:
LatencyTestWebGL() : LatencyTest(kWebGL) {}
};
// For running tests on GPU with the compositor thread:
class LatencyTestWebGLThread : public LatencyTest {
public:
LatencyTestWebGLThread() : LatencyTest(kWebGLThread) {}
};
// For running tests on Software:
class LatencyTestSW : public LatencyTest {
public:
LatencyTestSW() : LatencyTest(kSoftware) {}
};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// Tests /// Tests
using ::testing::Values; using ::testing::Values;
// For manual testing only, run all input latency tests and print summary. // For manual testing only, run all input latency tests and print summary.
IN_PROC_BROWSER_TEST_F(LatencyTest, DISABLED_LatencyWebGLAll) { IN_PROC_BROWSER_TEST_F(LatencyTestWebGL, DISABLED_LatencyWebGLAll) {
RunTest(kWebGL, GetAllBehaviors()); RunTest(GetAllBehaviors());
} }
// For manual testing only, run all input latency tests and print summary. // For manual testing only, run all input latency tests and print summary.
IN_PROC_BROWSER_TEST_F(LatencyTest, DISABLED_LatencySoftwareAll) { IN_PROC_BROWSER_TEST_F(LatencyTestWebGLThread, DISABLED_LatencyWebGLThreadAll) {
RunTest(kSoftware, GetAllBehaviors()); RunTest(GetAllBehaviors());
}
// For manual testing only, run all input latency tests and print summary.
IN_PROC_BROWSER_TEST_F(LatencyTestSW, DISABLED_LatencySoftwareAll) {
RunTest(GetAllBehaviors());
}
IN_PROC_BROWSER_TEST_P(LatencyTestWebGL, LatencyWebGL) {
RunTest(std::vector<int>(1, GetParam()));
} }
IN_PROC_BROWSER_TEST_P(LatencyTest, LatencySoftware) { IN_PROC_BROWSER_TEST_P(LatencyTestWebGLThread, LatencyWebGLThread) {
RunTest(kSoftware, std::vector<int>(1, GetParam())); RunTest(std::vector<int>(1, GetParam()));
} }
IN_PROC_BROWSER_TEST_P(LatencyTest, LatencyWebGL) { IN_PROC_BROWSER_TEST_P(LatencyTestSW, LatencySoftware) {
RunTest(kWebGL, std::vector<int>(1, GetParam())); RunTest(std::vector<int>(1, GetParam()));
} }
INSTANTIATE_TEST_CASE_P(, LatencyTest, ::testing::Values( #define LATENCY_SUITE_MODES() ::testing::Values( \
0, 0, \
kInputHeavy, kInputHeavy, \
kInputHeavy | kInputDirty | kRafHeavy, kInputHeavy | kInputDirty | kRafHeavy, \
kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy, kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy, \
kInputDirty | kPaintHeavy, kInputDirty | kPaintHeavy, \
kInputDirty | kRafHeavy | kPaintHeavy kInputDirty | kRafHeavy | kPaintHeavy)
));
INSTANTIATE_TEST_CASE_P(, LatencyTestWebGL, LATENCY_SUITE_MODES());
INSTANTIATE_TEST_CASE_P(, LatencyTestWebGLThread, LATENCY_SUITE_MODES());
INSTANTIATE_TEST_CASE_P(, LatencyTestSW, LATENCY_SUITE_MODES());
} // namespace } // namespace
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