Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
index 8650c9d64842cd7eb39e1227d75dee493e4592ca..043fdd61013284cbfa75e8738d37db4f199c1c2c 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
@@ -628,6 +628,14 @@ static error::Error ExecuteEndQueryCmd(GLES2DecoderTestBase* test, |
return test->ExecuteCmd(end_cmd); |
} |
+// Note: If the extensions GL_ARB_timer_query or GL_EXT_disjoint_timer_query are |
+// loaded, timestamp queries do an implicit call of glGetQueryiv() to determine |
+// if a fallback to elapsed time queries is needed. The fake timer query |
+// emulates this call and returns a value such that a fallback is not needed. If |
+// this method is being called with either of those extensions enabled (and not |
+// GL_EXT_timer_query), set check_timestamp_bits to true on the first call and |
+// set it to false on ALL subsequent calls. If using GL_EXT_timer_query, |
+// check_timestamp_bits should always be false |
static error::Error ExecuteQueryCounterCmd(GLES2DecoderTestBase* test, |
::gfx::MockGLInterface* gl, |
::gfx::GPUTimingFake* timing_queries, |
@@ -636,9 +644,10 @@ static error::Error ExecuteQueryCounterCmd(GLES2DecoderTestBase* test, |
GLuint service_id, |
int32_t shm_id, |
uint32_t shm_offset, |
- uint32_t submit_count) { |
+ uint32_t submit_count, |
+ bool check_timestamp_bits) { |
if (GL_TIMESTAMP == target) { |
- timing_queries->ExpectGPUTimeStampQuery(*gl, false); |
+ timing_queries->ExpectGPUTimeStampQuery(*gl, false, check_timestamp_bits); |
} |
QueryCounterEXT query_counter_cmd; |
@@ -705,9 +714,8 @@ static void CheckBeginEndQueryBadMemoryFails(GLES2DecoderTestBase* test, |
error::Error error2 = error::kNoError; |
if (query_type.is_counter) { |
error1 = ExecuteQueryCounterCmd(test, gl, &gpu_timing_queries, |
- query_type.type, |
- client_id, service_id, |
- shm_id, shm_offset, 1); |
+ query_type.type, client_id, service_id, |
+ shm_id, shm_offset, 1, true); |
} else { |
error1 = ExecuteBeginQueryCmd(test, gl, &gpu_timing_queries, |
query_type.type, |
@@ -777,14 +785,11 @@ TEST_P(GLES2DecoderManualInitTest, QueryReuseTest) { |
// Query once. |
if (query_type.is_counter) { |
- EXPECT_EQ(error::kNoError, ExecuteQueryCounterCmd(this, gl, |
- &gpu_timing_queries, |
- query_type.type, |
- kNewClientId, |
- kNewServiceId, |
- kSharedMemoryId, |
- kSharedMemoryOffset, |
- 1)); |
+ EXPECT_EQ( |
+ error::kNoError, |
+ ExecuteQueryCounterCmd(this, gl, &gpu_timing_queries, query_type.type, |
+ kNewClientId, kNewServiceId, kSharedMemoryId, |
+ kSharedMemoryOffset, 1, true)); |
} else { |
EXPECT_EQ(error::kNoError, ExecuteBeginQueryCmd(this, gl, |
&gpu_timing_queries, |
@@ -801,14 +806,11 @@ TEST_P(GLES2DecoderManualInitTest, QueryReuseTest) { |
// Reuse query. |
if (query_type.is_counter) { |
- EXPECT_EQ(error::kNoError, ExecuteQueryCounterCmd(this, gl, |
- &gpu_timing_queries, |
- query_type.type, |
- kNewClientId, |
- kNewServiceId, |
- kSharedMemoryId, |
- kSharedMemoryOffset, |
- 2)); |
+ EXPECT_EQ( |
+ error::kNoError, |
+ ExecuteQueryCounterCmd(this, gl, &gpu_timing_queries, query_type.type, |
+ kNewClientId, kNewServiceId, kSharedMemoryId, |
+ kSharedMemoryOffset, 2, false)); |
} else { |
EXPECT_EQ(error::kNoError, ExecuteBeginQueryCmd(this, gl, |
&gpu_timing_queries, |
@@ -1029,6 +1031,9 @@ TEST_P(GLES2DecoderManualInitTest, QueryCounterEXTTimeStamp) { |
EXPECT_CALL(*gl_, GenQueries(1, _)) |
.WillOnce(SetArgPointee<1>(kNewServiceId)) |
.RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, _)) |
+ .WillOnce(SetArgPointee<2>(64)) |
+ .RetiresOnSaturation(); |
EXPECT_CALL(*gl_, QueryCounter(kNewServiceId, GL_TIMESTAMP)) |
.Times(1) |
.RetiresOnSaturation(); |