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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
11 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 11 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
12 #include "gpu/command_buffer/service/error_state_mock.h" | 12 #include "gpu/command_buffer/service/error_state_mock.h" |
13 #include "gpu/command_buffer/service/feature_info.h" | 13 #include "gpu/command_buffer/service/feature_info.h" |
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
16 #include "gpu/command_buffer/service/gpu_service_test.h" | 16 #include "gpu/command_buffer/service/gpu_service_test.h" |
17 #include "gpu/command_buffer/service/query_manager.h" | 17 #include "gpu/command_buffer/service/query_manager.h" |
18 #include "gpu/command_buffer/service/test_helper.h" | 18 #include "gpu/command_buffer/service/test_helper.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gl/gl_context.h" | 20 #include "ui/gl/gl_context.h" |
21 #include "ui/gl/gl_mock.h" | 21 #include "ui/gl/gl_mock.h" |
22 #include "ui/gl/gpu_timing.h" | 22 #include "ui/gl/gpu_timing.h" |
23 #include "ui/gl/gpu_timing_fake.h" | 23 #include "ui/gl/gpu_timing_fake.h" |
24 | 24 |
25 using ::testing::_; | 25 using ::testing::_; |
26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
27 using ::testing::Return; | 27 using ::testing::Return; |
28 using ::testing::SetArgumentPointee; | 28 using ::testing::SetArgPointee; |
29 | 29 |
30 namespace gpu { | 30 namespace gpu { |
31 namespace gles2 { | 31 namespace gles2 { |
32 | 32 |
33 class QueryManagerTest : public GpuServiceTest { | 33 class QueryManagerTest : public GpuServiceTest { |
34 public: | 34 public: |
35 static const int32_t kSharedMemoryId = 401; | 35 static const int32_t kSharedMemoryId = 401; |
36 static const uint32_t kSharedMemoryOffset = 132; | 36 static const uint32_t kSharedMemoryOffset = 132; |
37 static const int32_t kSharedMemory2Id = 402; | 37 static const int32_t kSharedMemory2Id = 402; |
38 static const uint32_t kSharedMemory2Offset = 232; | 38 static const uint32_t kSharedMemory2Offset = 232; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 feature_info->InitializeForTesting(); | 74 feature_info->InitializeForTesting(); |
75 manager_.reset(new QueryManager(decoder_.get(), feature_info.get())); | 75 manager_.reset(new QueryManager(decoder_.get(), feature_info.get())); |
76 } | 76 } |
77 | 77 |
78 QueryManager::Query* CreateQuery(GLenum target, | 78 QueryManager::Query* CreateQuery(GLenum target, |
79 GLuint client_id, | 79 GLuint client_id, |
80 int32_t shm_id, | 80 int32_t shm_id, |
81 uint32_t shm_offset, | 81 uint32_t shm_offset, |
82 GLuint service_id) { | 82 GLuint service_id) { |
83 EXPECT_CALL(*gl_, GenQueries(1, _)) | 83 EXPECT_CALL(*gl_, GenQueries(1, _)) |
84 .WillOnce(SetArgumentPointee<1>(service_id)) | 84 .WillOnce(SetArgPointee<1>(service_id)) |
85 .RetiresOnSaturation(); | 85 .RetiresOnSaturation(); |
86 return manager_->CreateQuery(target, client_id, shm_id, shm_offset); | 86 return manager_->CreateQuery(target, client_id, shm_id, shm_offset); |
87 } | 87 } |
88 | 88 |
89 void QueueQuery(QueryManager::Query* query, | 89 void QueueQuery(QueryManager::Query* query, |
90 GLuint service_id, | 90 GLuint service_id, |
91 base::subtle::Atomic32 submit_count) { | 91 base::subtle::Atomic32 submit_count) { |
92 EXPECT_CALL(*gl_, BeginQuery(query->target(), service_id)) | 92 EXPECT_CALL(*gl_, BeginQuery(query->target(), service_id)) |
93 .Times(1) | 93 .Times(1) |
94 .RetiresOnSaturation(); | 94 .RetiresOnSaturation(); |
95 EXPECT_CALL(*gl_, EndQuery(query->target())) | 95 EXPECT_CALL(*gl_, EndQuery(query->target())) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 sync->Reset(); | 272 sync->Reset(); |
273 | 273 |
274 // Queue it | 274 // Queue it |
275 QueueQuery(query.get(), kService1Id, kSubmitCount); | 275 QueueQuery(query.get(), kService1Id, kSubmitCount); |
276 EXPECT_TRUE(query->IsPending()); | 276 EXPECT_TRUE(query->IsPending()); |
277 EXPECT_TRUE(manager_->HavePendingQueries()); | 277 EXPECT_TRUE(manager_->HavePendingQueries()); |
278 | 278 |
279 // Process with return not available. | 279 // Process with return not available. |
280 // Expect 1 GL command. | 280 // Expect 1 GL command. |
281 EXPECT_CALL(*gl_, | 281 EXPECT_CALL(*gl_, |
282 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 282 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
283 .WillOnce(SetArgumentPointee<2>(0)) | 283 .WillOnce(SetArgPointee<2>(0)) |
284 .RetiresOnSaturation(); | 284 .RetiresOnSaturation(); |
285 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 285 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
286 EXPECT_TRUE(query->IsPending()); | 286 EXPECT_TRUE(query->IsPending()); |
287 EXPECT_EQ(0, sync->process_count); | 287 EXPECT_EQ(0, sync->process_count); |
288 EXPECT_EQ(0u, sync->result); | 288 EXPECT_EQ(0u, sync->result); |
289 | 289 |
290 // Process with return available. | 290 // Process with return available. |
291 // Expect 2 GL commands. | 291 // Expect 2 GL commands. |
292 EXPECT_CALL(*gl_, | 292 EXPECT_CALL(*gl_, |
293 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 293 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
294 .WillOnce(SetArgumentPointee<2>(1)) | 294 .WillOnce(SetArgPointee<2>(1)) |
295 .RetiresOnSaturation(); | 295 .RetiresOnSaturation(); |
296 EXPECT_CALL(*gl_, | 296 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
297 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) | 297 .WillOnce(SetArgPointee<2>(kResult)) |
298 .WillOnce(SetArgumentPointee<2>(kResult)) | |
299 .RetiresOnSaturation(); | 298 .RetiresOnSaturation(); |
300 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 299 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
301 EXPECT_FALSE(query->IsPending()); | 300 EXPECT_FALSE(query->IsPending()); |
302 EXPECT_EQ(kSubmitCount, sync->process_count); | 301 EXPECT_EQ(kSubmitCount, sync->process_count); |
303 EXPECT_EQ(kResult, sync->result); | 302 EXPECT_EQ(kResult, sync->result); |
304 EXPECT_FALSE(manager_->HavePendingQueries()); | 303 EXPECT_FALSE(manager_->HavePendingQueries()); |
305 | 304 |
306 // Process with no queries. | 305 // Process with no queries. |
307 // Expect no GL commands/ | 306 // Expect no GL commands/ |
308 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 307 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 QueueQuery(query3.get(), kService3Id, kSubmitCount3); | 357 QueueQuery(query3.get(), kService3Id, kSubmitCount3); |
359 EXPECT_TRUE(query1->IsPending()); | 358 EXPECT_TRUE(query1->IsPending()); |
360 EXPECT_TRUE(query2->IsPending()); | 359 EXPECT_TRUE(query2->IsPending()); |
361 EXPECT_TRUE(query3->IsPending()); | 360 EXPECT_TRUE(query3->IsPending()); |
362 EXPECT_TRUE(manager_->HavePendingQueries()); | 361 EXPECT_TRUE(manager_->HavePendingQueries()); |
363 | 362 |
364 // Process with return available for first 2 queries. | 363 // Process with return available for first 2 queries. |
365 // Expect 4 GL commands. | 364 // Expect 4 GL commands. |
366 { | 365 { |
367 InSequence s; | 366 InSequence s; |
368 EXPECT_CALL(*gl_, | 367 EXPECT_CALL( |
369 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 368 *gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
370 .WillOnce(SetArgumentPointee<2>(1)) | 369 .WillOnce(SetArgPointee<2>(1)) |
371 .RetiresOnSaturation(); | 370 .RetiresOnSaturation(); |
372 EXPECT_CALL(*gl_, | 371 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
373 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) | 372 .WillOnce(SetArgPointee<2>(kResult1)) |
374 .WillOnce(SetArgumentPointee<2>(kResult1)) | |
375 .RetiresOnSaturation(); | 373 .RetiresOnSaturation(); |
376 EXPECT_CALL(*gl_, | 374 EXPECT_CALL( |
377 GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 375 *gl_, GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
378 .WillOnce(SetArgumentPointee<2>(1)) | 376 .WillOnce(SetArgPointee<2>(1)) |
379 .RetiresOnSaturation(); | 377 .RetiresOnSaturation(); |
380 EXPECT_CALL(*gl_, | 378 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_EXT, _)) |
381 GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_EXT, _)) | 379 .WillOnce(SetArgPointee<2>(kResult2)) |
382 .WillOnce(SetArgumentPointee<2>(kResult2)) | |
383 .RetiresOnSaturation(); | 380 .RetiresOnSaturation(); |
384 EXPECT_CALL(*gl_, | 381 EXPECT_CALL( |
385 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 382 *gl_, GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
386 .WillOnce(SetArgumentPointee<2>(0)) | 383 .WillOnce(SetArgPointee<2>(0)) |
387 .RetiresOnSaturation(); | 384 .RetiresOnSaturation(); |
388 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 385 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
389 } | 386 } |
390 EXPECT_FALSE(query1->IsPending()); | 387 EXPECT_FALSE(query1->IsPending()); |
391 EXPECT_FALSE(query2->IsPending()); | 388 EXPECT_FALSE(query2->IsPending()); |
392 EXPECT_TRUE(query3->IsPending()); | 389 EXPECT_TRUE(query3->IsPending()); |
393 EXPECT_EQ(kSubmitCount1, sync1->process_count); | 390 EXPECT_EQ(kSubmitCount1, sync1->process_count); |
394 EXPECT_EQ(kSubmitCount2, sync2->process_count); | 391 EXPECT_EQ(kSubmitCount2, sync2->process_count); |
395 EXPECT_EQ(kResult1, sync1->result); | 392 EXPECT_EQ(kResult1, sync1->result); |
396 EXPECT_EQ(kResult2, sync2->result); | 393 EXPECT_EQ(kResult2, sync2->result); |
397 EXPECT_EQ(0, sync3->process_count); | 394 EXPECT_EQ(0, sync3->process_count); |
398 EXPECT_EQ(0u, sync3->result); | 395 EXPECT_EQ(0u, sync3->result); |
399 EXPECT_TRUE(manager_->HavePendingQueries()); | 396 EXPECT_TRUE(manager_->HavePendingQueries()); |
400 | 397 |
401 // Process with renaming query. No result. | 398 // Process with renaming query. No result. |
402 // Expect 1 GL commands. | 399 // Expect 1 GL commands. |
403 EXPECT_CALL(*gl_, | 400 EXPECT_CALL(*gl_, |
404 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 401 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
405 .WillOnce(SetArgumentPointee<2>(0)) | 402 .WillOnce(SetArgPointee<2>(0)) |
406 .RetiresOnSaturation(); | 403 .RetiresOnSaturation(); |
407 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 404 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
408 EXPECT_TRUE(query3->IsPending()); | 405 EXPECT_TRUE(query3->IsPending()); |
409 EXPECT_EQ(0, sync3->process_count); | 406 EXPECT_EQ(0, sync3->process_count); |
410 EXPECT_EQ(0u, sync3->result); | 407 EXPECT_EQ(0u, sync3->result); |
411 EXPECT_TRUE(manager_->HavePendingQueries()); | 408 EXPECT_TRUE(manager_->HavePendingQueries()); |
412 | 409 |
413 // Process with renaming query. With result. | 410 // Process with renaming query. With result. |
414 // Expect 2 GL commands. | 411 // Expect 2 GL commands. |
415 EXPECT_CALL(*gl_, | 412 EXPECT_CALL(*gl_, |
416 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 413 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
417 .WillOnce(SetArgumentPointee<2>(1)) | 414 .WillOnce(SetArgPointee<2>(1)) |
418 .RetiresOnSaturation(); | 415 .RetiresOnSaturation(); |
419 EXPECT_CALL(*gl_, | 416 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_EXT, _)) |
420 GetQueryObjectuiv(kService3Id, GL_QUERY_RESULT_EXT, _)) | 417 .WillOnce(SetArgPointee<2>(kResult3)) |
421 .WillOnce(SetArgumentPointee<2>(kResult3)) | |
422 .RetiresOnSaturation(); | 418 .RetiresOnSaturation(); |
423 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); | 419 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); |
424 EXPECT_FALSE(query3->IsPending()); | 420 EXPECT_FALSE(query3->IsPending()); |
425 EXPECT_EQ(kSubmitCount3, sync3->process_count); | 421 EXPECT_EQ(kSubmitCount3, sync3->process_count); |
426 EXPECT_EQ(kResult3, sync3->result); | 422 EXPECT_EQ(kResult3, sync3->result); |
427 EXPECT_FALSE(manager_->HavePendingQueries()); | 423 EXPECT_FALSE(manager_->HavePendingQueries()); |
428 } | 424 } |
429 | 425 |
430 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryId) { | 426 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryId) { |
431 const GLuint kClient1Id = 1; | 427 const GLuint kClient1Id = 1; |
432 const GLuint kService1Id = 11; | 428 const GLuint kService1Id = 11; |
433 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 429 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
434 const base::subtle::Atomic32 kSubmitCount = 123; | 430 const base::subtle::Atomic32 kSubmitCount = 123; |
435 const GLuint kResult = 1; | 431 const GLuint kResult = 1; |
436 | 432 |
437 // Create Query. | 433 // Create Query. |
438 scoped_refptr<QueryManager::Query> query( | 434 scoped_refptr<QueryManager::Query> query( |
439 CreateQuery(kTarget, kClient1Id, | 435 CreateQuery(kTarget, kClient1Id, |
440 kInvalidSharedMemoryId, kSharedMemoryOffset, kService1Id)); | 436 kInvalidSharedMemoryId, kSharedMemoryOffset, kService1Id)); |
441 ASSERT_TRUE(query.get() != NULL); | 437 ASSERT_TRUE(query.get() != NULL); |
442 | 438 |
443 // Queue it | 439 // Queue it |
444 QueueQuery(query.get(), kService1Id, kSubmitCount); | 440 QueueQuery(query.get(), kService1Id, kSubmitCount); |
445 | 441 |
446 // Process with return available. | 442 // Process with return available. |
447 // Expect 2 GL commands. | 443 // Expect 2 GL commands. |
448 EXPECT_CALL(*gl_, | 444 EXPECT_CALL(*gl_, |
449 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 445 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
450 .WillOnce(SetArgumentPointee<2>(1)) | 446 .WillOnce(SetArgPointee<2>(1)) |
451 .RetiresOnSaturation(); | 447 .RetiresOnSaturation(); |
452 EXPECT_CALL(*gl_, | 448 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
453 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) | 449 .WillOnce(SetArgPointee<2>(kResult)) |
454 .WillOnce(SetArgumentPointee<2>(kResult)) | |
455 .RetiresOnSaturation(); | 450 .RetiresOnSaturation(); |
456 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); | 451 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); |
457 } | 452 } |
458 | 453 |
459 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryOffset) { | 454 TEST_F(QueryManagerTest, ProcessPendingBadSharedMemoryOffset) { |
460 const GLuint kClient1Id = 1; | 455 const GLuint kClient1Id = 1; |
461 const GLuint kService1Id = 11; | 456 const GLuint kService1Id = 11; |
462 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 457 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
463 const base::subtle::Atomic32 kSubmitCount = 123; | 458 const base::subtle::Atomic32 kSubmitCount = 123; |
464 const GLuint kResult = 1; | 459 const GLuint kResult = 1; |
465 | 460 |
466 // Create Query. | 461 // Create Query. |
467 scoped_refptr<QueryManager::Query> query( | 462 scoped_refptr<QueryManager::Query> query( |
468 CreateQuery(kTarget, kClient1Id, | 463 CreateQuery(kTarget, kClient1Id, |
469 kSharedMemoryId, kInvalidSharedMemoryOffset, kService1Id)); | 464 kSharedMemoryId, kInvalidSharedMemoryOffset, kService1Id)); |
470 ASSERT_TRUE(query.get() != NULL); | 465 ASSERT_TRUE(query.get() != NULL); |
471 | 466 |
472 // Queue it | 467 // Queue it |
473 QueueQuery(query.get(), kService1Id, kSubmitCount); | 468 QueueQuery(query.get(), kService1Id, kSubmitCount); |
474 | 469 |
475 // Process with return available. | 470 // Process with return available. |
476 // Expect 2 GL commands. | 471 // Expect 2 GL commands. |
477 EXPECT_CALL(*gl_, | 472 EXPECT_CALL(*gl_, |
478 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 473 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
479 .WillOnce(SetArgumentPointee<2>(1)) | 474 .WillOnce(SetArgPointee<2>(1)) |
480 .RetiresOnSaturation(); | 475 .RetiresOnSaturation(); |
481 EXPECT_CALL(*gl_, | 476 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
482 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) | 477 .WillOnce(SetArgPointee<2>(kResult)) |
483 .WillOnce(SetArgumentPointee<2>(kResult)) | |
484 .RetiresOnSaturation(); | 478 .RetiresOnSaturation(); |
485 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); | 479 EXPECT_FALSE(manager_->ProcessPendingQueries(false)); |
486 } | 480 } |
487 | 481 |
488 TEST_F(QueryManagerTest, ExitWithPendingQuery) { | 482 TEST_F(QueryManagerTest, ExitWithPendingQuery) { |
489 const GLuint kClient1Id = 1; | 483 const GLuint kClient1Id = 1; |
490 const GLuint kService1Id = 11; | 484 const GLuint kService1Id = 11; |
491 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; | 485 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; |
492 const base::subtle::Atomic32 kSubmitCount = 123; | 486 const base::subtle::Atomic32 kSubmitCount = 123; |
493 | 487 |
(...skipping 17 matching lines...) Expand all Loading... |
511 | 505 |
512 TestHelper::SetupFeatureInfoInitExpectations( | 506 TestHelper::SetupFeatureInfoInitExpectations( |
513 gl_.get(), | 507 gl_.get(), |
514 "GL_ARB_occlusion_query2"); | 508 "GL_ARB_occlusion_query2"); |
515 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 509 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
516 feature_info->InitializeForTesting(); | 510 feature_info->InitializeForTesting(); |
517 std::unique_ptr<QueryManager> manager( | 511 std::unique_ptr<QueryManager> manager( |
518 new QueryManager(decoder_.get(), feature_info.get())); | 512 new QueryManager(decoder_.get(), feature_info.get())); |
519 | 513 |
520 EXPECT_CALL(*gl_, GenQueries(1, _)) | 514 EXPECT_CALL(*gl_, GenQueries(1, _)) |
521 .WillOnce(SetArgumentPointee<1>(kService1Id)) | 515 .WillOnce(SetArgPointee<1>(kService1Id)) |
522 .RetiresOnSaturation(); | 516 .RetiresOnSaturation(); |
523 QueryManager::Query* query = manager->CreateQuery( | 517 QueryManager::Query* query = manager->CreateQuery( |
524 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); | 518 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); |
525 ASSERT_TRUE(query != NULL); | 519 ASSERT_TRUE(query != NULL); |
526 | 520 |
527 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kService1Id)) | 521 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kService1Id)) |
528 .Times(1) | 522 .Times(1) |
529 .RetiresOnSaturation(); | 523 .RetiresOnSaturation(); |
530 EXPECT_CALL(*gl_, EndQuery(GL_ANY_SAMPLES_PASSED_EXT)) | 524 EXPECT_CALL(*gl_, EndQuery(GL_ANY_SAMPLES_PASSED_EXT)) |
531 .Times(1) | 525 .Times(1) |
(...skipping 13 matching lines...) Expand all Loading... |
545 | 539 |
546 TestHelper::SetupFeatureInfoInitExpectations( | 540 TestHelper::SetupFeatureInfoInitExpectations( |
547 gl_.get(), | 541 gl_.get(), |
548 "GL_ARB_occlusion_query"); | 542 "GL_ARB_occlusion_query"); |
549 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 543 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
550 feature_info->InitializeForTesting(); | 544 feature_info->InitializeForTesting(); |
551 std::unique_ptr<QueryManager> manager( | 545 std::unique_ptr<QueryManager> manager( |
552 new QueryManager(decoder_.get(), feature_info.get())); | 546 new QueryManager(decoder_.get(), feature_info.get())); |
553 | 547 |
554 EXPECT_CALL(*gl_, GenQueries(1, _)) | 548 EXPECT_CALL(*gl_, GenQueries(1, _)) |
555 .WillOnce(SetArgumentPointee<1>(kService1Id)) | 549 .WillOnce(SetArgPointee<1>(kService1Id)) |
556 .RetiresOnSaturation(); | 550 .RetiresOnSaturation(); |
557 QueryManager::Query* query = manager->CreateQuery( | 551 QueryManager::Query* query = manager->CreateQuery( |
558 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); | 552 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); |
559 ASSERT_TRUE(query != NULL); | 553 ASSERT_TRUE(query != NULL); |
560 | 554 |
561 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) | 555 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) |
562 .Times(1) | 556 .Times(1) |
563 .RetiresOnSaturation(); | 557 .RetiresOnSaturation(); |
564 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) | 558 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) |
565 .Times(1) | 559 .Times(1) |
(...skipping 12 matching lines...) Expand all Loading... |
578 | 572 |
579 TestHelper::SetupFeatureInfoInitExpectations( | 573 TestHelper::SetupFeatureInfoInitExpectations( |
580 gl_.get(), | 574 gl_.get(), |
581 "GL_ARB_occlusion_query"); | 575 "GL_ARB_occlusion_query"); |
582 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 576 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
583 feature_info->InitializeForTesting(); | 577 feature_info->InitializeForTesting(); |
584 std::unique_ptr<QueryManager> manager( | 578 std::unique_ptr<QueryManager> manager( |
585 new QueryManager(decoder_.get(), feature_info.get())); | 579 new QueryManager(decoder_.get(), feature_info.get())); |
586 | 580 |
587 EXPECT_CALL(*gl_, GenQueries(1, _)) | 581 EXPECT_CALL(*gl_, GenQueries(1, _)) |
588 .WillOnce(SetArgumentPointee<1>(kService1Id)) | 582 .WillOnce(SetArgPointee<1>(kService1Id)) |
589 .RetiresOnSaturation(); | 583 .RetiresOnSaturation(); |
590 QueryManager::Query* query = manager->CreateQuery( | 584 QueryManager::Query* query = manager->CreateQuery( |
591 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); | 585 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); |
592 ASSERT_TRUE(query != NULL); | 586 ASSERT_TRUE(query != NULL); |
593 | 587 |
594 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) | 588 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) |
595 .Times(1) | 589 .Times(1) |
596 .RetiresOnSaturation(); | 590 .RetiresOnSaturation(); |
597 EXPECT_TRUE(manager->BeginQuery(query)); | 591 EXPECT_TRUE(manager->BeginQuery(query)); |
598 | 592 |
599 // Pause and Resume the manager. | 593 // Pause and Resume the manager. |
600 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) | 594 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) |
601 .Times(1) | 595 .Times(1) |
602 .RetiresOnSaturation(); | 596 .RetiresOnSaturation(); |
603 manager->PauseQueries(); | 597 manager->PauseQueries(); |
604 | 598 |
605 EXPECT_CALL(*gl_, GenQueries(1, _)) | 599 EXPECT_CALL(*gl_, GenQueries(1, _)) |
606 .WillOnce(SetArgumentPointee<1>(kService2Id)) | 600 .WillOnce(SetArgPointee<1>(kService2Id)) |
607 .RetiresOnSaturation(); | 601 .RetiresOnSaturation(); |
608 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService2Id)) | 602 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService2Id)) |
609 .Times(1) | 603 .Times(1) |
610 .RetiresOnSaturation(); | 604 .RetiresOnSaturation(); |
611 manager->ResumeQueries(); | 605 manager->ResumeQueries(); |
612 | 606 |
613 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) | 607 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) |
614 .Times(1) | 608 .Times(1) |
615 .RetiresOnSaturation(); | 609 .RetiresOnSaturation(); |
616 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); | 610 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); |
617 | 611 |
618 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService2Id, | 612 EXPECT_CALL(*gl_, |
619 GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 613 GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
620 .WillOnce(SetArgumentPointee<2>(1u)) | 614 .WillOnce(SetArgPointee<2>(1u)) |
621 .RetiresOnSaturation(); | 615 .RetiresOnSaturation(); |
622 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, | 616 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
623 GL_QUERY_RESULT_EXT, _)) | 617 .WillOnce(SetArgPointee<2>(0u)) |
624 .WillOnce(SetArgumentPointee<2>(0u)) | |
625 .RetiresOnSaturation(); | 618 .RetiresOnSaturation(); |
626 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService2Id, | 619 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService2Id, GL_QUERY_RESULT_EXT, _)) |
627 GL_QUERY_RESULT_EXT, _)) | 620 .WillOnce(SetArgPointee<2>(1u)) |
628 .WillOnce(SetArgumentPointee<2>(1u)) | |
629 .RetiresOnSaturation(); | 621 .RetiresOnSaturation(); |
630 EXPECT_TRUE(manager->ProcessPendingQueries(false)); | 622 EXPECT_TRUE(manager->ProcessPendingQueries(false)); |
631 EXPECT_TRUE(query->IsFinished()); | 623 EXPECT_TRUE(query->IsFinished()); |
632 | 624 |
633 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( | 625 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( |
634 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); | 626 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); |
635 EXPECT_EQ(1u, sync->result); | 627 EXPECT_EQ(1u, sync->result); |
636 | 628 |
637 // Make sure new query still works. | 629 // Make sure new query still works. |
638 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService2Id))) | 630 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService2Id))) |
639 .Times(1) | 631 .Times(1) |
640 .RetiresOnSaturation(); | 632 .RetiresOnSaturation(); |
641 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) | 633 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) |
642 .Times(1) | 634 .Times(1) |
643 .RetiresOnSaturation(); | 635 .RetiresOnSaturation(); |
644 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) | 636 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) |
645 .Times(1) | 637 .Times(1) |
646 .RetiresOnSaturation(); | 638 .RetiresOnSaturation(); |
647 EXPECT_TRUE(manager->BeginQuery(query)); | 639 EXPECT_TRUE(manager->BeginQuery(query)); |
648 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount + 1)); | 640 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount + 1)); |
649 | 641 |
650 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, | 642 EXPECT_CALL(*gl_, |
651 GL_QUERY_RESULT_AVAILABLE_EXT, _)) | 643 GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) |
652 .WillOnce(SetArgumentPointee<2>(1u)) | 644 .WillOnce(SetArgPointee<2>(1u)) |
653 .RetiresOnSaturation(); | 645 .RetiresOnSaturation(); |
654 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, | 646 EXPECT_CALL(*gl_, GetQueryObjectuiv(kService1Id, GL_QUERY_RESULT_EXT, _)) |
655 GL_QUERY_RESULT_EXT, _)) | 647 .WillOnce(SetArgPointee<2>(0u)) |
656 .WillOnce(SetArgumentPointee<2>(0u)) | |
657 .RetiresOnSaturation(); | 648 .RetiresOnSaturation(); |
658 EXPECT_TRUE(manager->ProcessPendingQueries(false)); | 649 EXPECT_TRUE(manager->ProcessPendingQueries(false)); |
659 EXPECT_TRUE(query->IsFinished()); | 650 EXPECT_TRUE(query->IsFinished()); |
660 | 651 |
661 EXPECT_EQ(0u, sync->result); | 652 EXPECT_EQ(0u, sync->result); |
662 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService1Id))) | 653 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService1Id))) |
663 .Times(1) | 654 .Times(1) |
664 .RetiresOnSaturation(); | 655 .RetiresOnSaturation(); |
665 manager->Destroy(true); | 656 manager->Destroy(true); |
666 } | 657 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 983 |
993 TestHelper::SetupFeatureInfoInitExpectations( | 984 TestHelper::SetupFeatureInfoInitExpectations( |
994 gl_.get(), | 985 gl_.get(), |
995 "GL_ARB_occlusion_query"); | 986 "GL_ARB_occlusion_query"); |
996 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); | 987 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); |
997 feature_info->InitializeForTesting(); | 988 feature_info->InitializeForTesting(); |
998 std::unique_ptr<QueryManager> manager( | 989 std::unique_ptr<QueryManager> manager( |
999 new QueryManager(decoder_.get(), feature_info.get())); | 990 new QueryManager(decoder_.get(), feature_info.get())); |
1000 | 991 |
1001 EXPECT_CALL(*gl_, GenQueries(1, _)) | 992 EXPECT_CALL(*gl_, GenQueries(1, _)) |
1002 .WillOnce(SetArgumentPointee<1>(kService1Id)) | 993 .WillOnce(SetArgPointee<1>(kService1Id)) |
1003 .RetiresOnSaturation(); | 994 .RetiresOnSaturation(); |
1004 QueryManager::Query* query = manager->CreateQuery( | 995 QueryManager::Query* query = manager->CreateQuery( |
1005 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); | 996 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); |
1006 ASSERT_TRUE(query != NULL); | 997 ASSERT_TRUE(query != NULL); |
1007 | 998 |
1008 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) | 999 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id)) |
1009 .Times(1) | 1000 .Times(1) |
1010 .RetiresOnSaturation(); | 1001 .RetiresOnSaturation(); |
1011 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) | 1002 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB)) |
1012 .Times(1) | 1003 .Times(1) |
1013 .RetiresOnSaturation(); | 1004 .RetiresOnSaturation(); |
1014 EXPECT_TRUE(manager->BeginQuery(query)); | 1005 EXPECT_TRUE(manager->BeginQuery(query)); |
1015 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); | 1006 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); |
1016 manager->Destroy(false); | 1007 manager->Destroy(false); |
1017 } | 1008 } |
1018 | 1009 |
1019 } // namespace gles2 | 1010 } // namespace gles2 |
1020 } // namespace gpu | 1011 } // namespace gpu |
1021 | 1012 |
1022 | 1013 |
OLD | NEW |