OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/query_manager.h" | 5 #include "gpu/command_buffer/service/query_manager.h" |
6 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 6 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
7 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 7 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
8 #include "gpu/command_buffer/service/error_state_mock.h" | 8 #include "gpu/command_buffer/service/error_state_mock.h" |
9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 TEST_F(QueryManagerTest, ProcessPendingQuery) { | 209 TEST_F(QueryManagerTest, ProcessPendingQuery) { |
210 const GLuint kClient1Id = 1; | 210 const GLuint kClient1Id = 1; |
211 const GLuint kService1Id = 11; | 211 const GLuint kService1Id = 11; |
212 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 212 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
213 const base::subtle::Atomic32 kSubmitCount = 123; | 213 const base::subtle::Atomic32 kSubmitCount = 123; |
214 const GLuint kResult = 1; | 214 const GLuint kResult = 1; |
215 | 215 |
216 // Check nothing happens if there are no pending queries. | 216 // Check nothing happens if there are no pending queries. |
217 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 217 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
218 | 218 |
219 // Create Query. | 219 // Create Query. |
220 scoped_refptr<QueryManager::Query> query( | 220 scoped_refptr<QueryManager::Query> query( |
221 CreateQuery(kTarget, kClient1Id, | 221 CreateQuery(kTarget, kClient1Id, |
222 kSharedMemoryId, kSharedMemoryOffset, kService1Id)); | 222 kSharedMemoryId, kSharedMemoryOffset, kService1Id)); |
223 ASSERT_TRUE(query.get() != NULL); | 223 ASSERT_TRUE(query.get() != NULL); |
224 | 224 |
225 // Setup shared memory like client would. | 225 // Setup shared memory like client would. |
226 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( | 226 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( |
227 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); | 227 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); |
228 ASSERT_TRUE(sync != NULL); | 228 ASSERT_TRUE(sync != NULL); |
229 sync->Reset(); | 229 sync->Reset(); |
230 | 230 |
231 // Queue it | 231 // Queue it |
232 QueueQuery(query.get(), kService1Id, kSubmitCount); | 232 QueueQuery(query.get(), kService1Id, kSubmitCount); |
233 EXPECT_TRUE(query->pending()); | 233 EXPECT_TRUE(query->pending()); |
234 EXPECT_TRUE(manager_->HavePendingQueries()); | 234 EXPECT_TRUE(manager_->HavePendingQueries()); |
235 | 235 |
236 // Process with return not available. | 236 // Process with return not available. |
237 // Expect 1 GL command. | 237 // Expect 1 GL command. |
238 EXPECT_CALL(*gl_, | 238 EXPECT_CALL(*gl_, |
239 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 239 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
240 .WillOnce(SetArgumentPointee<2>(0)) | 240 .WillOnce(SetArgumentPointee<2>(0)) |
241 .RetiresOnSaturation(); | 241 .RetiresOnSaturation(); |
242 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 242 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
243 EXPECT_TRUE(query->pending()); | 243 EXPECT_TRUE(query->pending()); |
244 EXPECT_EQ(0, sync->process_count); | 244 EXPECT_EQ(0, sync->process_count); |
245 EXPECT_EQ(0u, sync->result); | 245 EXPECT_EQ(0u, sync->result); |
246 | 246 |
247 // Process with return available. | 247 // Process with return available. |
248 // Expect 2 GL commands. | 248 // Expect 2 GL commands. |
249 EXPECT_CALL(*gl_, | 249 EXPECT_CALL(*gl_, |
250 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 250 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
251 .WillOnce(SetArgumentPointee<2>(1)) | 251 .WillOnce(SetArgumentPointee<2>(1)) |
252 .RetiresOnSaturation(); | 252 .RetiresOnSaturation(); |
253 EXPECT_CALL(*gl_, | 253 EXPECT_CALL(*gl_, |
254 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) | 254 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) |
255 .WillOnce(SetArgumentPointee<2>(kResult)) | 255 .WillOnce(SetArgumentPointee<2>(kResult)) |
256 .RetiresOnSaturation(); | 256 .RetiresOnSaturation(); |
257 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 257 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
258 EXPECT_FALSE(query->pending()); | 258 EXPECT_FALSE(query->pending()); |
259 EXPECT_EQ(kSubmitCount, sync->process_count); | 259 EXPECT_EQ(kSubmitCount, sync->process_count); |
260 EXPECT_EQ(kResult, sync->result); | 260 EXPECT_EQ(kResult, sync->result); |
261 EXPECT_FALSE(manager_->HavePendingQueries()); | 261 EXPECT_FALSE(manager_->HavePendingQueries()); |
262 | 262 |
263 // Process with no queries. | 263 // Process with no queries. |
264 // Expect no GL commands/ | 264 // Expect no GL commands/ |
265 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 265 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
266 } | 266 } |
267 | 267 |
268 TEST_F(QueryManagerTest, ProcessPendingQueries) { | 268 TEST_F(QueryManagerTest, ProcessPendingQueries) { |
269 const GLuint kClient1Id = 1; | 269 const GLuint kClient1Id = 1; |
270 const GLuint kService1Id = 11; | 270 const GLuint kService1Id = 11; |
271 const GLuint kClient2Id = 2; | 271 const GLuint kClient2Id = 2; |
272 const GLuint kService2Id = 12; | 272 const GLuint kService2Id = 12; |
273 const GLuint kClient3Id = 3; | 273 const GLuint kClient3Id = 3; |
274 const GLuint kService3Id = 13; | 274 const GLuint kService3Id = 13; |
275 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 275 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 .WillOnce(SetArgumentPointee<2>(1)) | 335 .WillOnce(SetArgumentPointee<2>(1)) |
336 .RetiresOnSaturation(); | 336 .RetiresOnSaturation(); |
337 EXPECT_CALL(*gl_, | 337 EXPECT_CALL(*gl_, |
338 GetQueryObjectuivARB(kService2Id, GL_QUERY_RESULT_EXT, _)) | 338 GetQueryObjectuivARB(kService2Id, GL_QUERY_RESULT_EXT, _)) |
339 .WillOnce(SetArgumentPointee<2>(kResult2)) | 339 .WillOnce(SetArgumentPointee<2>(kResult2)) |
340 .RetiresOnSaturation(); | 340 .RetiresOnSaturation(); |
341 EXPECT_CALL(*gl_, | 341 EXPECT_CALL(*gl_, |
342 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 342 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
343 .WillOnce(SetArgumentPointee<2>(0)) | 343 .WillOnce(SetArgumentPointee<2>(0)) |
344 .RetiresOnSaturation(); | 344 .RetiresOnSaturation(); |
345 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 345 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
346 } | 346 } |
347 EXPECT_FALSE(query1->pending()); | 347 EXPECT_FALSE(query1->pending()); |
348 EXPECT_FALSE(query2->pending()); | 348 EXPECT_FALSE(query2->pending()); |
349 EXPECT_TRUE(query3->pending()); | 349 EXPECT_TRUE(query3->pending()); |
350 EXPECT_EQ(kSubmitCount1, sync1->process_count); | 350 EXPECT_EQ(kSubmitCount1, sync1->process_count); |
351 EXPECT_EQ(kSubmitCount2, sync2->process_count); | 351 EXPECT_EQ(kSubmitCount2, sync2->process_count); |
352 EXPECT_EQ(kResult1, sync1->result); | 352 EXPECT_EQ(kResult1, sync1->result); |
353 EXPECT_EQ(kResult2, sync2->result); | 353 EXPECT_EQ(kResult2, sync2->result); |
354 EXPECT_EQ(0, sync3->process_count); | 354 EXPECT_EQ(0, sync3->process_count); |
355 EXPECT_EQ(0u, sync3->result); | 355 EXPECT_EQ(0u, sync3->result); |
356 EXPECT_TRUE(manager_->HavePendingQueries()); | 356 EXPECT_TRUE(manager_->HavePendingQueries()); |
357 | 357 |
358 // Process with renaming query. No result. | 358 // Process with renaming query. No result. |
359 // Expect 1 GL commands. | 359 // Expect 1 GL commands. |
360 EXPECT_CALL(*gl_, | 360 EXPECT_CALL(*gl_, |
361 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 361 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
362 .WillOnce(SetArgumentPointee<2>(0)) | 362 .WillOnce(SetArgumentPointee<2>(0)) |
363 .RetiresOnSaturation(); | 363 .RetiresOnSaturation(); |
364 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 364 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
365 EXPECT_TRUE(query3->pending()); | 365 EXPECT_TRUE(query3->pending()); |
366 EXPECT_EQ(0, sync3->process_count); | 366 EXPECT_EQ(0, sync3->process_count); |
367 EXPECT_EQ(0u, sync3->result); | 367 EXPECT_EQ(0u, sync3->result); |
368 EXPECT_TRUE(manager_->HavePendingQueries()); | 368 EXPECT_TRUE(manager_->HavePendingQueries()); |
369 | 369 |
370 // Process with renaming query. With result. | 370 // Process with renaming query. With result. |
371 // Expect 2 GL commands. | 371 // Expect 2 GL commands. |
372 EXPECT_CALL(*gl_, | 372 EXPECT_CALL(*gl_, |
373 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 373 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
374 .WillOnce(SetArgumentPointee<2>(1)) | 374 .WillOnce(SetArgumentPointee<2>(1)) |
375 .RetiresOnSaturation(); | 375 .RetiresOnSaturation(); |
376 EXPECT_CALL(*gl_, | 376 EXPECT_CALL(*gl_, |
377 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_EXT, _)) | 377 GetQueryObjectuivARB(kService3Id, GL_QUERY_RESULT_EXT, _)) |
378 .WillOnce(SetArgumentPointee<2>(kResult3)) | 378 .WillOnce(SetArgumentPointee<2>(kResult3)) |
379 .RetiresOnSaturation(); | 379 .RetiresOnSaturation(); |
380 EXPECT_TRUE(manager_->ProcessPendingQueries()); | 380 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
381 EXPECT_FALSE(query3->pending()); | 381 EXPECT_FALSE(query3->pending()); |
382 EXPECT_EQ(kSubmitCount3, sync3->process_count); | 382 EXPECT_EQ(kSubmitCount3, sync3->process_count); |
383 EXPECT_EQ(kResult3, sync3->result); | 383 EXPECT_EQ(kResult3, sync3->result); |
384 EXPECT_FALSE(manager_->HavePendingQueries()); | 384 EXPECT_FALSE(manager_->HavePendingQueries()); |
385 } | 385 } |
386 | 386 |
387 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryId) { | 387 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryId) { |
388 const GLuint kClient1Id = 1; | 388 const GLuint kClient1Id = 1; |
389 const GLuint kService1Id = 11; | 389 const GLuint kService1Id = 11; |
390 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 390 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
(...skipping 12 matching lines...) Expand all Loading... |
403 // Process with return available. | 403 // Process with return available. |
404 // Expect 2 GL commands. | 404 // Expect 2 GL commands. |
405 EXPECT_CALL(*gl_, | 405 EXPECT_CALL(*gl_, |
406 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 406 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
407 .WillOnce(SetArgumentPointee<2>(1)) | 407 .WillOnce(SetArgumentPointee<2>(1)) |
408 .RetiresOnSaturation(); | 408 .RetiresOnSaturation(); |
409 EXPECT_CALL(*gl_, | 409 EXPECT_CALL(*gl_, |
410 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) | 410 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) |
411 .WillOnce(SetArgumentPointee<2>(kResult)) | 411 .WillOnce(SetArgumentPointee<2>(kResult)) |
412 .RetiresOnSaturation(); | 412 .RetiresOnSaturation(); |
413 EXPECT_FALSE(manager_->ProcessPendingQueries()); | 413 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); |
414 } | 414 } |
415 | 415 |
416 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryOffset) { | 416 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryOffset) { |
417 const GLuint kClient1Id = 1; | 417 const GLuint kClient1Id = 1; |
418 const GLuint kService1Id = 11; | 418 const GLuint kService1Id = 11; |
419 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 419 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
420 const base::subtle::Atomic32 kSubmitCount = 123; | 420 const base::subtle::Atomic32 kSubmitCount = 123; |
421 const GLuint kResult = 1; | 421 const GLuint kResult = 1; |
422 | 422 |
423 // Create Query. | 423 // Create Query. |
424 scoped_refptr<QueryManager::Query> query( | 424 scoped_refptr<QueryManager::Query> query( |
425 CreateQuery(kTarget, kClient1Id, | 425 CreateQuery(kTarget, kClient1Id, |
426 kSharedMemoryId, kInvalidSharedMemoryOffset, kService1Id)); | 426 kSharedMemoryId, kInvalidSharedMemoryOffset, kService1Id)); |
427 ASSERT_TRUE(query.get() != NULL); | 427 ASSERT_TRUE(query.get() != NULL); |
428 | 428 |
429 // Queue it | 429 // Queue it |
430 QueueQuery(query.get(), kService1Id, kSubmitCount); | 430 QueueQuery(query.get(), kService1Id, kSubmitCount); |
431 | 431 |
432 // Process with return available. | 432 // Process with return available. |
433 // Expect 2 GL commands. | 433 // Expect 2 GL commands. |
434 EXPECT_CALL(*gl_, | 434 EXPECT_CALL(*gl_, |
435 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 435 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
436 .WillOnce(SetArgumentPointee<2>(1)) | 436 .WillOnce(SetArgumentPointee<2>(1)) |
437 .RetiresOnSaturation(); | 437 .RetiresOnSaturation(); |
438 EXPECT_CALL(*gl_, | 438 EXPECT_CALL(*gl_, |
439 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) | 439 GetQueryObjectuivARB(kService1Id, GL_QUERY_RESULT_EXT, _)) |
440 .WillOnce(SetArgumentPointee<2>(kResult)) | 440 .WillOnce(SetArgumentPointee<2>(kResult)) |
441 .RetiresOnSaturation(); | 441 .RetiresOnSaturation(); |
442 EXPECT_FALSE(manager_->ProcessPendingQueries()); | 442 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); |
443 } | 443 } |
444 | 444 |
445 TEST_F(QueryManagerTest, ExitWithPendingQuery) { | 445 TEST_F(QueryManagerTest, ExitWithPendingQuery) { |
446 const GLuint kClient1Id = 1; | 446 const GLuint kClient1Id = 1; |
447 const GLuint kService1Id = 11; | 447 const GLuint kService1Id = 11; |
448 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 448 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
449 const base::subtle::Atomic32 kSubmitCount = 123; | 449 const base::subtle::Atomic32 kSubmitCount = 123; |
450 | 450 |
451 // Create Query. | 451 // Create Query. |
452 scoped_refptr<QueryManager::Query> query( | 452 scoped_refptr<QueryManager::Query> query( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 561 |
562 EXPECT_EQ(static_cast<GLuint>(GL_INVALID_ENUM), sync->result); | 562 EXPECT_EQ(static_cast<GLuint>(GL_INVALID_ENUM), sync->result); |
563 | 563 |
564 manager->Destroy(false); | 564 manager->Destroy(false); |
565 } | 565 } |
566 | 566 |
567 } // namespace gles2 | 567 } // namespace gles2 |
568 } // namespace gpu | 568 } // namespace gpu |
569 | 569 |
570 | 570 |
OLD | NEW |