| Index: gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| index c354fd9343c62d093c4f06fc51092a52c0b01b60..2580c8cec99d89556fdd167a37541179da8e488f 100644
|
| --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| @@ -412,7 +412,8 @@ class GLES2ImplementationTest : public testing::Test {
|
| bool lose_context_when_out_of_memory,
|
| bool transfer_buffer_initialize_fail,
|
| bool sync_query,
|
| - bool occlusion_query_boolean) {
|
| + bool occlusion_query_boolean,
|
| + bool timer_queries) {
|
| command_buffer_.reset(new StrictMock<MockClientCommandBuffer>());
|
| if (!command_buffer_->Initialize())
|
| return false;
|
| @@ -457,6 +458,7 @@ class GLES2ImplementationTest : public testing::Test {
|
| bind_generates_resource_service ? 1 : 0;
|
| capabilities.sync_query = sync_query;
|
| capabilities.occlusion_query_boolean = occlusion_query_boolean;
|
| + capabilities.timer_queries = timer_queries;
|
| EXPECT_CALL(*gpu_control_, GetCapabilities())
|
| .WillOnce(testing::Return(capabilities));
|
|
|
| @@ -549,7 +551,8 @@ class GLES2ImplementationTest : public testing::Test {
|
| lose_context_when_out_of_memory(false),
|
| transfer_buffer_initialize_fail(false),
|
| sync_query(true),
|
| - occlusion_query_boolean(true) {}
|
| + occlusion_query_boolean(true),
|
| + timer_queries(true) {}
|
|
|
| bool bind_generates_resource_client;
|
| bool bind_generates_resource_service;
|
| @@ -557,6 +560,7 @@ class GLES2ImplementationTest : public testing::Test {
|
| bool transfer_buffer_initialize_fail;
|
| bool sync_query;
|
| bool occlusion_query_boolean;
|
| + bool timer_queries;
|
| };
|
|
|
| bool Initialize(const ContextInitOptions& init_options) {
|
| @@ -571,7 +575,8 @@ class GLES2ImplementationTest : public testing::Test {
|
| init_options.lose_context_when_out_of_memory,
|
| init_options.transfer_buffer_initialize_fail,
|
| init_options.sync_query,
|
| - init_options.occlusion_query_boolean))
|
| + init_options.occlusion_query_boolean,
|
| + init_options.timer_queries))
|
| success = false;
|
| }
|
|
|
| @@ -3217,6 +3222,7 @@ TEST_F(GLES2ImplementationManualInitTest, BadQueryTargets) {
|
| ContextInitOptions init_options;
|
| init_options.sync_query = false;
|
| init_options.occlusion_query_boolean = false;
|
| + init_options.timer_queries = false;
|
| ASSERT_TRUE(Initialize(init_options));
|
|
|
| GLuint id = 0;
|
| @@ -3235,9 +3241,104 @@ TEST_F(GLES2ImplementationManualInitTest, BadQueryTargets) {
|
| EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
|
| EXPECT_EQ(nullptr, GetQuery(id));
|
|
|
| + gl_->BeginQueryEXT(GL_TIME_ELAPSED_EXT, id);
|
| + EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
|
| + EXPECT_EQ(nullptr, GetQuery(id));
|
| +
|
| gl_->BeginQueryEXT(0x123, id);
|
| + EXPECT_EQ(GL_INVALID_ENUM, CheckError());
|
| + EXPECT_EQ(nullptr, GetQuery(id));
|
| +
|
| + gl_->QueryCounterEXT(id, GL_TIMESTAMP_EXT);
|
| EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
|
| EXPECT_EQ(nullptr, GetQuery(id));
|
| +
|
| + gl_->QueryCounterEXT(id, 0x123);
|
| + EXPECT_EQ(GL_INVALID_ENUM, CheckError());
|
| + EXPECT_EQ(nullptr, GetQuery(id));
|
| +}
|
| +
|
| +TEST_F(GLES2ImplementationTest, QueryCounterEXT) {
|
| + GLuint expected_ids[2] = { 1, 2 }; // These must match what's actually genned.
|
| + struct GenCmds {
|
| + cmds::GenQueriesEXTImmediate gen;
|
| + GLuint data[2];
|
| + };
|
| + GenCmds expected_gen_cmds;
|
| + expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]);
|
| + GLuint ids[arraysize(expected_ids)] = { 0, };
|
| + gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]);
|
| + EXPECT_EQ(0, memcmp(
|
| + &expected_gen_cmds, commands_, sizeof(expected_gen_cmds)));
|
| + GLuint id1 = ids[0];
|
| + GLuint id2 = ids[1];
|
| + ClearCommands();
|
| +
|
| + // Test QueryCounterEXT fails if id = 0.
|
| + gl_->QueryCounterEXT(0, GL_TIMESTAMP_EXT);
|
| + EXPECT_TRUE(NoCommandsWritten());
|
| + EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
|
| +
|
| + // Test QueryCounterEXT fails if target is unknown.
|
| + ClearCommands();
|
| + gl_->QueryCounterEXT(id1, GL_TIME_ELAPSED_EXT);
|
| + EXPECT_TRUE(NoCommandsWritten());
|
| + EXPECT_EQ(GL_INVALID_ENUM, CheckError());
|
| +
|
| + // Test QueryCounterEXT inserts command.
|
| + struct QueryCounterCmds {
|
| + cmds::QueryCounterEXT query_counter;
|
| + };
|
| + QueryCounterCmds expected_query_counter_cmds;
|
| + const void* commands = GetPut();
|
| + gl_->QueryCounterEXT(id1, GL_TIMESTAMP_EXT);
|
| + EXPECT_EQ(GL_NO_ERROR, CheckError());
|
| + QueryTracker::Query* query = GetQuery(id1);
|
| + ASSERT_TRUE(query != NULL);
|
| + expected_query_counter_cmds.query_counter.Init(
|
| + GL_TIMESTAMP_EXT, id1, query->shm_id(), query->shm_offset(),
|
| + query->submit_count());
|
| + EXPECT_EQ(0, memcmp(&expected_query_counter_cmds, commands,
|
| + sizeof(expected_query_counter_cmds)));
|
| + ClearCommands();
|
| +
|
| + // Test 2nd QueryCounterEXT succeeds.
|
| + commands = GetPut();
|
| + gl_->QueryCounterEXT(id2, GL_TIMESTAMP_EXT);
|
| + EXPECT_EQ(GL_NO_ERROR, CheckError());
|
| + QueryTracker::Query* query2 = GetQuery(id2);
|
| + ASSERT_TRUE(query2 != NULL);
|
| + expected_query_counter_cmds.query_counter.Init(
|
| + GL_TIMESTAMP_EXT, id2, query2->shm_id(), query2->shm_offset(),
|
| + query2->submit_count());
|
| + EXPECT_EQ(0, memcmp(&expected_query_counter_cmds, commands,
|
| + sizeof(expected_query_counter_cmds)));
|
| + ClearCommands();
|
| +
|
| + // Test QueryCounterEXT increments count.
|
| + base::subtle::Atomic32 old_submit_count = query->submit_count();
|
| + commands = GetPut();
|
| + gl_->QueryCounterEXT(id1, GL_TIMESTAMP_EXT);
|
| + EXPECT_EQ(GL_NO_ERROR, CheckError());
|
| + EXPECT_NE(old_submit_count, query->submit_count());
|
| + expected_query_counter_cmds.query_counter.Init(
|
| + GL_TIMESTAMP_EXT, id1, query->shm_id(), query->shm_offset(),
|
| + query->submit_count());
|
| + EXPECT_EQ(0, memcmp(&expected_query_counter_cmds, commands,
|
| + sizeof(expected_query_counter_cmds)));
|
| + ClearCommands();
|
| +
|
| + // Test GetQueryObjectuivEXT CheckResultsAvailable
|
| + GLuint available = 0xBDu;
|
| + ClearCommands();
|
| + gl_->GetQueryObjectuivEXT(id1, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
|
| + EXPECT_EQ(0u, available);
|
| +
|
| + // Test GetQueryObjectui64vEXT CheckResultsAvailable
|
| + GLuint64 available2 = 0xBDu;
|
| + ClearCommands();
|
| + gl_->GetQueryObjectui64vEXT(id1, GL_QUERY_RESULT_AVAILABLE_EXT, &available2);
|
| + EXPECT_EQ(0u, available2);
|
| }
|
|
|
| TEST_F(GLES2ImplementationTest, ErrorQuery) {
|
|
|