Improve GPU tests to fail when GPU drawing fails.
Changed the accelerated html pages to use raf to draw multiple frames. Changed the webgl and canvas2d pages to draw onscreen rather than offscreen to make sure the compositor draws the page. BUG=105785,104142 Review URL: http://codereview.chromium.org/8692013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112763 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
base/debug
chrome/test
content
@ -197,6 +197,11 @@
|
||||
#define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0
|
||||
#define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) (void)0
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) (void)0
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
(void)0
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) (void)0
|
||||
#else
|
||||
#define UNSHIPPED_TRACE_EVENT0(category, name) \
|
||||
TRACE_EVENT0(category, name)
|
||||
@ -205,6 +210,14 @@
|
||||
#define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val)
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) \
|
||||
TRACE_EVENT_INSTANT0(category, name)
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val)
|
||||
#define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val)
|
||||
#endif
|
||||
|
||||
// Records a single event called "name" immediately, with 0, 1 or 2
|
||||
|
@ -4,26 +4,38 @@
|
||||
<meta charset="utf-8">
|
||||
<title>GPU Feature Testing: Canvas2D</title>
|
||||
<script>
|
||||
var frameCount = 0;
|
||||
var context = null;
|
||||
|
||||
function init() {
|
||||
var canvas = document.createElement("canvas");
|
||||
var canvas = document.getElementById("da-canvas");
|
||||
if (!canvas)
|
||||
return null;
|
||||
// Make sure canvas is large enough to trigger gpu acceleration.
|
||||
canvas.width = 500;
|
||||
canvas.height = 500;
|
||||
var context = null;
|
||||
return;
|
||||
try {
|
||||
context = canvas.getContext("2d");
|
||||
} catch(e) {}
|
||||
return context;
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var c2d = init();
|
||||
if (c2d) {
|
||||
// Initialization was triggered lazily on the first draw.
|
||||
c2d.fillRect(0, 0, 1, 1);
|
||||
init();
|
||||
if (context)
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
else
|
||||
endTest();
|
||||
}
|
||||
|
||||
function draw() {
|
||||
frameCount++;
|
||||
document.body.style.backgroundColor = (frameCount & 1) ? "red" : "blue";
|
||||
context.fillRect(0, 0, 500, frameCount*100);
|
||||
if (frameCount == 5) {
|
||||
endTest();
|
||||
} else {
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
}
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
domAutomationController.setAutomationId(1);
|
||||
domAutomationController.send("FINISHED");
|
||||
}
|
||||
@ -31,5 +43,6 @@ function runTest() {
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
Canvas2D should trigger GPU process launch if accelerated-2d-canvas is allowed.
|
||||
<canvas id="da-canvas" width="500" height="500"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,9 +9,20 @@ body {
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var frameCount = 0;
|
||||
|
||||
function runTest() {
|
||||
domAutomationController.setAutomationId(1);
|
||||
domAutomationController.send("FINISHED");
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
}
|
||||
function draw() {
|
||||
frameCount++;
|
||||
document.body.style.backgroundColor = (frameCount & 1) ? "red" : "blue";
|
||||
if (frameCount == 5) {
|
||||
domAutomationController.setAutomationId(1);
|
||||
domAutomationController.send("FINISHED");
|
||||
} else {
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
@ -4,24 +4,44 @@
|
||||
<meta charset="utf-8">
|
||||
<title>GPU Feature Testing: WebGL</title>
|
||||
<script>
|
||||
var frameCount = 0;
|
||||
var gl = null;
|
||||
|
||||
function init() {
|
||||
var canvas = document.createElement("canvas");
|
||||
var canvas = document.getElementById("da-canvas");
|
||||
if (!canvas)
|
||||
return null;
|
||||
var context = null;
|
||||
return;
|
||||
try {
|
||||
context = canvas.getContext("webgl");
|
||||
gl = canvas.getContext("webgl");
|
||||
} catch(e) {}
|
||||
if (!context) {
|
||||
if (!gl) {
|
||||
try {
|
||||
context = canvas.getContext("experimental-webgl");
|
||||
gl = canvas.getContext("experimental-webgl");
|
||||
} catch(e) {}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var gl = init();
|
||||
init();
|
||||
if (gl)
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
else
|
||||
endTest();
|
||||
}
|
||||
|
||||
function draw() {
|
||||
frameCount++;
|
||||
gl.viewport(0, 0, 500, 500);
|
||||
gl.clearColor(1.0/frameCount, 0.0, 0.0, 1.0);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
if (frameCount == 5) {
|
||||
endTest();
|
||||
} else {
|
||||
window.webkitRequestAnimationFrame(draw);
|
||||
}
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
domAutomationController.setAutomationId(1);
|
||||
domAutomationController.send("FINISHED");
|
||||
}
|
||||
@ -29,5 +49,6 @@ function runTest() {
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
WebGL should trigger GPU process launch if it is allowed.
|
||||
<canvas id="da-canvas" width="500" height="500"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/file_util.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/path_service.h"
|
||||
@ -15,16 +16,33 @@
|
||||
#include "content/browser/gpu/gpu_blacklist.h"
|
||||
#include "content/browser/gpu/gpu_data_manager.h"
|
||||
#include "net/base/net_util.h"
|
||||
#include "ui/gfx/gl/gl_switches.h"
|
||||
|
||||
namespace {
|
||||
|
||||
typedef uint32 GpuResultFlags;
|
||||
#define EXPECT_NO_GPU_PROCESS GpuResultFlags(0)
|
||||
// Expect GPU process to be created.
|
||||
#define EXPECT_GPU_PROCESS GpuResultFlags(1<<0)
|
||||
// Expect num_contexts_ to be created (onscreen or offscreen).
|
||||
#define EXPECT_GPU_CONTEXTS GpuResultFlags(1<<1)
|
||||
// Expect a SwapBuffers to occur (see gles2_cmd_decoder.cc).
|
||||
#define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<2)
|
||||
|
||||
class GpuFeatureTest : public InProcessBrowserTest {
|
||||
public:
|
||||
GpuFeatureTest() {}
|
||||
GpuFeatureTest()
|
||||
: num_contexts_(0),
|
||||
num_offscreen_contexts_(0) {}
|
||||
|
||||
virtual void SetUpCommandLine(CommandLine* command_line) {
|
||||
// This enables DOM automation for tab contents.
|
||||
EnableDOMAutomation();
|
||||
#if !defined(OS_MACOSX)
|
||||
CHECK(!command_line->HasSwitch(switches::kUseGL)) <<
|
||||
"kUseGL must not be set by test framework code!";
|
||||
command_line->AppendSwitchASCII(switches::kUseGL, "osmesa");
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetupBlacklist(const std::string& json_blacklist) {
|
||||
@ -36,7 +54,7 @@ class GpuFeatureTest : public InProcessBrowserTest {
|
||||
GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist);
|
||||
}
|
||||
|
||||
void RunTest(const FilePath& url, bool expect_gpu_process) {
|
||||
void RunTest(const FilePath& url, GpuResultFlags expectations) {
|
||||
using namespace trace_analyzer;
|
||||
|
||||
FilePath test_path;
|
||||
@ -61,18 +79,48 @@ class GpuFeatureTest : public InProcessBrowserTest {
|
||||
ASSERT_TRUE(tracing::EndTracing(&json_events));
|
||||
|
||||
scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events));
|
||||
EXPECT_EQ(expect_gpu_process, analyzer->FindOneEvent(
|
||||
Query(EVENT_NAME) == Query::String("GpuProcessLaunched")) != NULL);
|
||||
analyzer->AssociateBeginEndEvents();
|
||||
TraceAnalyzer::TraceEventVector events;
|
||||
|
||||
size_t num_gpu_processes = (expectations & EXPECT_GPU_PROCESS) ? 1 : 0;
|
||||
analyzer->FindEvents(Query::MatchBeginName("OnGraphicsInfoCollected"),
|
||||
&events);
|
||||
EXPECT_EQ(num_gpu_processes, events.size());
|
||||
|
||||
// Check for context creation if expected:
|
||||
if (expectations & EXPECT_GPU_CONTEXTS) {
|
||||
analyzer->FindEvents(
|
||||
Query(EVENT_NAME) == Query::String("TryCreateGLContext"),
|
||||
&events);
|
||||
EXPECT_EQ(num_contexts_, events.size());
|
||||
analyzer->FindEvents(
|
||||
Query(EVENT_NAME) == Query::String("CreateGLContextSuccess"),
|
||||
&events);
|
||||
EXPECT_EQ(num_contexts_, events.size());
|
||||
}
|
||||
|
||||
// Check for swap buffers if expected:
|
||||
if (expectations & EXPECT_GPU_SWAP_BUFFERS) {
|
||||
analyzer->FindEvents(
|
||||
Query(EVENT_NAME) == Query::String("SwapBuffers"),
|
||||
&events);
|
||||
EXPECT_GT(events.size(), size_t(0));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t num_contexts_;
|
||||
size_t num_offscreen_contexts_;
|
||||
};
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) {
|
||||
GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
|
||||
EXPECT_EQ(flags.flags(), 0u);
|
||||
|
||||
const bool expect_gpu_process = true;
|
||||
num_contexts_ = 1;
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS |
|
||||
EXPECT_GPU_CONTEXTS);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
|
||||
@ -95,24 +143,18 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
|
||||
flags.flags(),
|
||||
static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
|
||||
|
||||
const bool expect_gpu_process = false;
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, EXPECT_NO_GPU_PROCESS);
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
// http://crbug.com/104142
|
||||
#define MAYBE_WebGLAllowed DISABLED_WebGLAllowed
|
||||
#else
|
||||
#define MAYBE_WebGLAllowed WebGLAllowed
|
||||
#endif
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_WebGLAllowed) {
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, FLAKY_WebGLAllowed) {
|
||||
GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
|
||||
EXPECT_EQ(flags.flags(), 0u);
|
||||
|
||||
const bool expect_gpu_process = true;
|
||||
num_contexts_ = 2;
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS |
|
||||
EXPECT_GPU_CONTEXTS);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
|
||||
@ -135,9 +177,8 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
|
||||
flags.flags(),
|
||||
static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
|
||||
|
||||
const bool expect_gpu_process = false;
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, EXPECT_NO_GPU_PROCESS);
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
@ -150,12 +191,15 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) {
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// TODO(zmo): enabling Mac when skia backend is enabled.
|
||||
const bool expect_gpu_process = false;
|
||||
const GpuResultFlags expectations = EXPECT_NO_GPU_PROCESS;
|
||||
#else
|
||||
const bool expect_gpu_process = true;
|
||||
num_contexts_ = 2;
|
||||
const GpuResultFlags expectations = EXPECT_GPU_PROCESS |
|
||||
EXPECT_GPU_SWAP_BUFFERS |
|
||||
EXPECT_GPU_CONTEXTS;
|
||||
#endif
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, expectations);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
|
||||
@ -178,9 +222,8 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
|
||||
flags.flags(),
|
||||
static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas));
|
||||
|
||||
const bool expect_gpu_process = false;
|
||||
const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
|
||||
RunTest(url, expect_gpu_process);
|
||||
RunTest(url, EXPECT_NO_GPU_PROCESS);
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
@ -481,6 +481,10 @@ void GpuProcessHost::OnDestroyCommandBuffer(
|
||||
}
|
||||
|
||||
void GpuProcessHost::OnGraphicsInfoCollected(const content::GPUInfo& gpu_info) {
|
||||
// OnGraphicsInfoCollected is sent back after the GPU process successfully
|
||||
// initializes GL.
|
||||
TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected");
|
||||
|
||||
GpuDataManager::GetInstance()->UpdateGpuInfo(gpu_info);
|
||||
}
|
||||
|
||||
@ -493,8 +497,6 @@ void GpuProcessHost::OnProcessLaunched() {
|
||||
// respond to any requests to establish a GPU channel. The response
|
||||
// to such requests require that the GPU process handle be known.
|
||||
|
||||
TRACE_EVENT0("test_gpu", "GpuProcessLaunched");
|
||||
|
||||
base::ProcessHandle child_handle = in_process_ ?
|
||||
base::GetCurrentProcessHandle() : handle();
|
||||
|
||||
|
@ -164,6 +164,8 @@ void GpuCommandBufferStub::OnInitialize(
|
||||
IPC::Message* reply_message) {
|
||||
DCHECK(!command_buffer_.get());
|
||||
|
||||
UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext");
|
||||
|
||||
command_buffer_.reset(new gpu::CommandBufferService);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@ -179,6 +181,7 @@ void GpuCommandBufferStub::OnInitialize(
|
||||
#endif
|
||||
|
||||
if (!command_buffer_->Initialize(&shared_memory, size)) {
|
||||
DLOG(ERROR) << "CommandBufferService failed to initialize.\n";
|
||||
OnInitializeFailed(reply_message);
|
||||
return;
|
||||
}
|
||||
@ -194,6 +197,7 @@ void GpuCommandBufferStub::OnInitialize(
|
||||
if (handle_) {
|
||||
#if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
|
||||
if (software_) {
|
||||
DLOG(ERROR) << "No software support.\n";
|
||||
OnInitializeFailed(reply_message);
|
||||
return;
|
||||
}
|
||||
@ -278,6 +282,9 @@ void GpuCommandBufferStub::OnInitialize(
|
||||
|
||||
GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true);
|
||||
Send(reply_message);
|
||||
|
||||
UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess",
|
||||
"offscreen", surface_->IsOffscreen());
|
||||
}
|
||||
|
||||
void GpuCommandBufferStub::OnSetParent(int32 parent_route_id,
|
||||
|
@ -103,12 +103,12 @@ void GpuChildThread::OnInitialize() {
|
||||
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU))
|
||||
logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
|
||||
|
||||
// Always set gpu info and send it back, even if there's an error and it's
|
||||
// impartially collected.
|
||||
bool succeeded = gpu_info_collector::CollectGraphicsInfo(&gpu_info_);
|
||||
|
||||
if (succeeded) {
|
||||
content::GetContentClient()->SetGpuInfo(gpu_info_);
|
||||
LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete";
|
||||
}
|
||||
content::GetContentClient()->SetGpuInfo(gpu_info_);
|
||||
LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete. success = " <<
|
||||
succeeded;
|
||||
|
||||
// Record initialization only after collecting the GPU info because that can
|
||||
// take a significant amount of time.
|
||||
@ -157,8 +157,7 @@ void GpuChildThread::OnInitialize() {
|
||||
|
||||
// Ensure the browser process receives the GPU info before a reply to any
|
||||
// subsequent IPC it might send.
|
||||
if (succeeded)
|
||||
Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_));
|
||||
Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_));
|
||||
}
|
||||
|
||||
void GpuChildThread::StopWatchdog() {
|
||||
|
Reference in New Issue
Block a user