Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: gpu/command_buffer/service/query_manager_unittest.cc

Issue 1006093002: Collapsed gl query functions with their ARB/EXT variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed gles2 decoder tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 decoder_.reset(); 54 decoder_.reset();
55 manager_->Destroy(false); 55 manager_->Destroy(false);
56 manager_.reset(); 56 manager_.reset();
57 engine_.reset(); 57 engine_.reset();
58 GpuServiceTest::TearDown(); 58 GpuServiceTest::TearDown();
59 } 59 }
60 60
61 QueryManager::Query* CreateQuery( 61 QueryManager::Query* CreateQuery(
62 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset, 62 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset,
63 GLuint service_id) { 63 GLuint service_id) {
64 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) 64 EXPECT_CALL(*gl_, GenQueries(1, _))
65 .WillOnce(SetArgumentPointee<1>(service_id)) 65 .WillOnce(SetArgumentPointee<1>(service_id))
66 .RetiresOnSaturation(); 66 .RetiresOnSaturation();
67 return manager_->CreateQuery(target, client_id, shm_id, shm_offset); 67 return manager_->CreateQuery(target, client_id, shm_id, shm_offset);
68 } 68 }
69 69
70 void QueueQuery(QueryManager::Query* query, 70 void QueueQuery(QueryManager::Query* query,
71 GLuint service_id, 71 GLuint service_id,
72 base::subtle::Atomic32 submit_count) { 72 base::subtle::Atomic32 submit_count) {
73 EXPECT_CALL(*gl_, BeginQueryARB(query->target(), service_id)) 73 EXPECT_CALL(*gl_, BeginQuery(query->target(), service_id))
74 .Times(1) 74 .Times(1)
75 .RetiresOnSaturation(); 75 .RetiresOnSaturation();
76 EXPECT_CALL(*gl_, EndQueryARB(query->target())) 76 EXPECT_CALL(*gl_, EndQuery(query->target()))
77 .Times(1) 77 .Times(1)
78 .RetiresOnSaturation(); 78 .RetiresOnSaturation();
79 EXPECT_TRUE(manager_->BeginQuery(query)); 79 EXPECT_TRUE(manager_->BeginQuery(query));
80 EXPECT_TRUE(manager_->EndQuery(query, submit_count)); 80 EXPECT_TRUE(manager_->EndQuery(query, submit_count));
81 } 81 }
82 82
83 scoped_ptr<MockGLES2Decoder> decoder_; 83 scoped_ptr<MockGLES2Decoder> decoder_;
84 scoped_ptr<QueryManager> manager_; 84 scoped_ptr<QueryManager> manager_;
85 85
86 private: 86 private:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 TEST_F(QueryManagerTest, Destroy) { 171 TEST_F(QueryManagerTest, Destroy) {
172 const GLuint kClient1Id = 1; 172 const GLuint kClient1Id = 1;
173 const GLuint kService1Id = 11; 173 const GLuint kService1Id = 11;
174 174
175 // Create Query. 175 // Create Query.
176 scoped_refptr<QueryManager::Query> query( 176 scoped_refptr<QueryManager::Query> query(
177 CreateQuery(GL_ANY_SAMPLES_PASSED_EXT, kClient1Id, 177 CreateQuery(GL_ANY_SAMPLES_PASSED_EXT, kClient1Id,
178 kSharedMemoryId, kSharedMemoryOffset, kService1Id)); 178 kSharedMemoryId, kSharedMemoryOffset, kService1Id));
179 ASSERT_TRUE(query.get() != NULL); 179 ASSERT_TRUE(query.get() != NULL);
180 EXPECT_CALL(*gl_, DeleteQueriesARB(1, ::testing::Pointee(kService1Id))) 180 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService1Id)))
181 .Times(1) 181 .Times(1)
182 .RetiresOnSaturation(); 182 .RetiresOnSaturation();
183 manager_->Destroy(true); 183 manager_->Destroy(true);
184 // Check we get nothing for a non-existent query. 184 // Check we get nothing for a non-existent query.
185 EXPECT_TRUE(manager_->GetQuery(kClient1Id) == NULL); 185 EXPECT_TRUE(manager_->GetQuery(kClient1Id) == NULL);
186 // Check query is deleted 186 // Check query is deleted
187 EXPECT_TRUE(query->IsDeleted()); 187 EXPECT_TRUE(query->IsDeleted());
188 } 188 }
189 189
190 TEST_F(QueryManagerTest, QueryBasic) { 190 TEST_F(QueryManagerTest, QueryBasic) {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 const base::subtle::Atomic32 kSubmitCount = 123; 467 const base::subtle::Atomic32 kSubmitCount = 123;
468 468
469 TestHelper::SetupFeatureInfoInitExpectations( 469 TestHelper::SetupFeatureInfoInitExpectations(
470 gl_.get(), 470 gl_.get(),
471 "GL_ARB_occlusion_query2"); 471 "GL_ARB_occlusion_query2");
472 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); 472 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo());
473 feature_info->Initialize(); 473 feature_info->Initialize();
474 scoped_ptr<QueryManager> manager( 474 scoped_ptr<QueryManager> manager(
475 new QueryManager(decoder_.get(), feature_info.get())); 475 new QueryManager(decoder_.get(), feature_info.get()));
476 476
477 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) 477 EXPECT_CALL(*gl_, GenQueries(1, _))
478 .WillOnce(SetArgumentPointee<1>(kService1Id)) 478 .WillOnce(SetArgumentPointee<1>(kService1Id))
479 .RetiresOnSaturation(); 479 .RetiresOnSaturation();
480 QueryManager::Query* query = manager->CreateQuery( 480 QueryManager::Query* query = manager->CreateQuery(
481 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); 481 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
482 ASSERT_TRUE(query != NULL); 482 ASSERT_TRUE(query != NULL);
483 483
484 EXPECT_CALL(*gl_, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, kService1Id)) 484 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kService1Id))
485 .Times(1) 485 .Times(1)
486 .RetiresOnSaturation(); 486 .RetiresOnSaturation();
487 EXPECT_CALL(*gl_, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) 487 EXPECT_CALL(*gl_, EndQuery(GL_ANY_SAMPLES_PASSED_EXT))
488 .Times(1) 488 .Times(1)
489 .RetiresOnSaturation(); 489 .RetiresOnSaturation();
490 EXPECT_TRUE(manager->BeginQuery(query)); 490 EXPECT_TRUE(manager->BeginQuery(query));
491 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); 491 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount));
492 manager->Destroy(false); 492 manager->Destroy(false);
493 } 493 }
494 494
495 // Test that when based on ARB_occlusion_query we use GL_SAMPLES_PASSED_ARB 495 // Test that when based on ARB_occlusion_query we use GL_SAMPLES_PASSED_ARB
496 // for GL_ANY_SAMPLES_PASSED_EXT 496 // for GL_ANY_SAMPLES_PASSED_EXT
497 TEST_F(QueryManagerTest, ARBOcclusionQuery) { 497 TEST_F(QueryManagerTest, ARBOcclusionQuery) {
498 const GLuint kClient1Id = 1; 498 const GLuint kClient1Id = 1;
499 const GLuint kService1Id = 11; 499 const GLuint kService1Id = 11;
500 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT; 500 const GLenum kTarget = GL_ANY_SAMPLES_PASSED_EXT;
501 const base::subtle::Atomic32 kSubmitCount = 123; 501 const base::subtle::Atomic32 kSubmitCount = 123;
502 502
503 TestHelper::SetupFeatureInfoInitExpectations( 503 TestHelper::SetupFeatureInfoInitExpectations(
504 gl_.get(), 504 gl_.get(),
505 "GL_ARB_occlusion_query"); 505 "GL_ARB_occlusion_query");
506 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo()); 506 scoped_refptr<FeatureInfo> feature_info(new FeatureInfo());
507 feature_info->Initialize(); 507 feature_info->Initialize();
508 scoped_ptr<QueryManager> manager( 508 scoped_ptr<QueryManager> manager(
509 new QueryManager(decoder_.get(), feature_info.get())); 509 new QueryManager(decoder_.get(), feature_info.get()));
510 510
511 EXPECT_CALL(*gl_, GenQueriesARB(1, _)) 511 EXPECT_CALL(*gl_, GenQueries(1, _))
512 .WillOnce(SetArgumentPointee<1>(kService1Id)) 512 .WillOnce(SetArgumentPointee<1>(kService1Id))
513 .RetiresOnSaturation(); 513 .RetiresOnSaturation();
514 QueryManager::Query* query = manager->CreateQuery( 514 QueryManager::Query* query = manager->CreateQuery(
515 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); 515 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
516 ASSERT_TRUE(query != NULL); 516 ASSERT_TRUE(query != NULL);
517 517
518 EXPECT_CALL(*gl_, BeginQueryARB(GL_SAMPLES_PASSED_ARB, kService1Id)) 518 EXPECT_CALL(*gl_, BeginQuery(GL_SAMPLES_PASSED_ARB, kService1Id))
519 .Times(1) 519 .Times(1)
520 .RetiresOnSaturation(); 520 .RetiresOnSaturation();
521 EXPECT_CALL(*gl_, EndQueryARB(GL_SAMPLES_PASSED_ARB)) 521 EXPECT_CALL(*gl_, EndQuery(GL_SAMPLES_PASSED_ARB))
522 .Times(1) 522 .Times(1)
523 .RetiresOnSaturation(); 523 .RetiresOnSaturation();
524 EXPECT_TRUE(manager->BeginQuery(query)); 524 EXPECT_TRUE(manager->BeginQuery(query));
525 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); 525 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount));
526 manager->Destroy(false); 526 manager->Destroy(false);
527 } 527 }
528 528
529 TEST_F(QueryManagerTest, GetErrorQuery) { 529 TEST_F(QueryManagerTest, GetErrorQuery) {
530 const GLuint kClient1Id = 1; 530 const GLuint kClient1Id = 1;
531 const GLenum kTarget = GL_GET_ERROR_QUERY_CHROMIUM; 531 const GLenum kTarget = GL_GET_ERROR_QUERY_CHROMIUM;
(...skipping 29 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698