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

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

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 <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"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService1Id))) 662 EXPECT_CALL(*gl_, DeleteQueries(1, ::testing::Pointee(kService1Id)))
663 .Times(1) 663 .Times(1)
664 .RetiresOnSaturation(); 664 .RetiresOnSaturation();
665 manager->Destroy(true); 665 manager->Destroy(true);
666 } 666 }
667 667
668 TEST_F(QueryManagerTest, TimeElapsedQuery) { 668 TEST_F(QueryManagerTest, TimeElapsedQuery) {
669 const GLuint kClient1Id = 1; 669 const GLuint kClient1Id = 1;
670 const GLenum kTarget = GL_TIME_ELAPSED_EXT; 670 const GLenum kTarget = GL_TIME_ELAPSED_EXT;
671 const base::subtle::Atomic32 kSubmitCount = 123; 671 const base::subtle::Atomic32 kSubmitCount = 123;
672 gfx::GPUTimingFake fake_timing_queries; 672 gl::GPUTimingFake fake_timing_queries;
673 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting( 673 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting(
674 base::Bind(&gfx::GPUTimingFake::GetFakeCPUTime)); 674 base::Bind(&gl::GPUTimingFake::GetFakeCPUTime));
675 675
676 QueryManager::Query* query = manager_->CreateQuery( 676 QueryManager::Query* query = manager_->CreateQuery(
677 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); 677 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
678 ASSERT_TRUE(query != NULL); 678 ASSERT_TRUE(query != NULL);
679 679
680 fake_timing_queries.ExpectGPUTimerQuery(*gl_, true); 680 fake_timing_queries.ExpectGPUTimerQuery(*gl_, true);
681 fake_timing_queries.SetCurrentGLTime( 681 fake_timing_queries.SetCurrentGLTime(
682 200 * base::Time::kNanosecondsPerMicrosecond); 682 200 * base::Time::kNanosecondsPerMicrosecond);
683 EXPECT_TRUE(manager_->BeginQuery(query)); 683 EXPECT_TRUE(manager_->BeginQuery(query));
684 fake_timing_queries.SetCurrentGLTime( 684 fake_timing_queries.SetCurrentGLTime(
685 300 * base::Time::kNanosecondsPerMicrosecond); 685 300 * base::Time::kNanosecondsPerMicrosecond);
686 EXPECT_TRUE(manager_->EndQuery(query, kSubmitCount)); 686 EXPECT_TRUE(manager_->EndQuery(query, kSubmitCount));
687 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); 687 EXPECT_TRUE(manager_->ProcessPendingQueries(false));
688 688
689 EXPECT_TRUE(query->IsFinished()); 689 EXPECT_TRUE(query->IsFinished());
690 690
691 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( 691 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>(
692 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); 692 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync));
693 const uint64_t expected_result = 693 const uint64_t expected_result =
694 100u * base::Time::kNanosecondsPerMicrosecond; 694 100u * base::Time::kNanosecondsPerMicrosecond;
695 EXPECT_EQ(expected_result, sync->result); 695 EXPECT_EQ(expected_result, sync->result);
696 696
697 manager_->Destroy(false); 697 manager_->Destroy(false);
698 } 698 }
699 699
700 TEST_F(QueryManagerTest, TimeElapsedPauseResume) { 700 TEST_F(QueryManagerTest, TimeElapsedPauseResume) {
701 const GLuint kClient1Id = 1; 701 const GLuint kClient1Id = 1;
702 const GLenum kTarget = GL_TIME_ELAPSED_EXT; 702 const GLenum kTarget = GL_TIME_ELAPSED_EXT;
703 const base::subtle::Atomic32 kSubmitCount = 123; 703 const base::subtle::Atomic32 kSubmitCount = 123;
704 gfx::GPUTimingFake fake_timing_queries; 704 gl::GPUTimingFake fake_timing_queries;
705 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting( 705 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting(
706 base::Bind(&gfx::GPUTimingFake::GetFakeCPUTime)); 706 base::Bind(&gl::GPUTimingFake::GetFakeCPUTime));
707 707
708 QueryManager::Query* query = manager_->CreateQuery( 708 QueryManager::Query* query = manager_->CreateQuery(
709 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); 709 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
710 ASSERT_TRUE(query != NULL); 710 ASSERT_TRUE(query != NULL);
711 711
712 fake_timing_queries.ExpectGPUTimerQuery(*gl_, true); 712 fake_timing_queries.ExpectGPUTimerQuery(*gl_, true);
713 fake_timing_queries.SetCurrentGLTime( 713 fake_timing_queries.SetCurrentGLTime(
714 200 * base::Time::kNanosecondsPerMicrosecond); 714 200 * base::Time::kNanosecondsPerMicrosecond);
715 EXPECT_TRUE(manager_->BeginQuery(query)); 715 EXPECT_TRUE(manager_->BeginQuery(query));
716 716
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 const uint64_t expected_result2 = 750 const uint64_t expected_result2 =
751 100u * base::Time::kNanosecondsPerMicrosecond; 751 100u * base::Time::kNanosecondsPerMicrosecond;
752 EXPECT_EQ(expected_result2, sync->result); 752 EXPECT_EQ(expected_result2, sync->result);
753 753
754 manager_->Destroy(false); 754 manager_->Destroy(false);
755 } 755 }
756 756
757 TEST_F(QueryManagerManualSetupTest, TimeElapsedDisjoint) { 757 TEST_F(QueryManagerManualSetupTest, TimeElapsedDisjoint) {
758 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0", 758 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0",
759 "GL_EXT_disjoint_timer_query"); 759 "GL_EXT_disjoint_timer_query");
760 gfx::GPUTimingFake fake_timing_queries; 760 gl::GPUTimingFake fake_timing_queries;
761 fake_timing_queries.ExpectDisjointCalls(*gl_); 761 fake_timing_queries.ExpectDisjointCalls(*gl_);
762 SetUpMockGL("GL_EXT_disjoint_timer_query"); 762 SetUpMockGL("GL_EXT_disjoint_timer_query");
763 763
764 DisjointValueSync* disjoint_sync = 764 DisjointValueSync* disjoint_sync =
765 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id, 765 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id,
766 kSharedMemory2Offset, 766 kSharedMemory2Offset,
767 sizeof(*disjoint_sync)); 767 sizeof(*disjoint_sync));
768 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset); 768 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset);
769 769
770 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount(); 770 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount();
(...skipping 28 matching lines...) Expand all
799 EXPECT_TRUE(query->IsFinished()); 799 EXPECT_TRUE(query->IsFinished());
800 EXPECT_NE(current_disjoint_value, disjoint_sync->GetDisjointCount()); 800 EXPECT_NE(current_disjoint_value, disjoint_sync->GetDisjointCount());
801 801
802 manager_->Destroy(false); 802 manager_->Destroy(false);
803 } 803 }
804 804
805 TEST_F(QueryManagerTest, TimeStampQuery) { 805 TEST_F(QueryManagerTest, TimeStampQuery) {
806 const GLuint kClient1Id = 1; 806 const GLuint kClient1Id = 1;
807 const GLenum kTarget = GL_TIMESTAMP_EXT; 807 const GLenum kTarget = GL_TIMESTAMP_EXT;
808 const base::subtle::Atomic32 kSubmitCount = 123; 808 const base::subtle::Atomic32 kSubmitCount = 123;
809 gfx::GPUTimingFake fake_timing_queries; 809 gl::GPUTimingFake fake_timing_queries;
810 810
811 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting( 811 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting(
812 base::Bind(&gfx::GPUTimingFake::GetFakeCPUTime)); 812 base::Bind(&gl::GPUTimingFake::GetFakeCPUTime));
813 813
814 QueryManager::Query* query = manager_->CreateQuery( 814 QueryManager::Query* query = manager_->CreateQuery(
815 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset); 815 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
816 ASSERT_TRUE(query != NULL); 816 ASSERT_TRUE(query != NULL);
817 817
818 const uint64_t expected_result = 818 const uint64_t expected_result =
819 100u * base::Time::kNanosecondsPerMicrosecond; 819 100u * base::Time::kNanosecondsPerMicrosecond;
820 fake_timing_queries.SetCurrentGLTime(expected_result); 820 fake_timing_queries.SetCurrentGLTime(expected_result);
821 fake_timing_queries.ExpectGPUTimeStampQuery(*gl_, false); 821 fake_timing_queries.ExpectGPUTimeStampQuery(*gl_, false);
822 EXPECT_TRUE(manager_->QueryCounter(query, kSubmitCount)); 822 EXPECT_TRUE(manager_->QueryCounter(query, kSubmitCount));
823 EXPECT_TRUE(manager_->ProcessPendingQueries(false)); 823 EXPECT_TRUE(manager_->ProcessPendingQueries(false));
824 824
825 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>( 825 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>(
826 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync)); 826 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync));
827 EXPECT_EQ(expected_result, sync->result); 827 EXPECT_EQ(expected_result, sync->result);
828 828
829 manager_->Destroy(false); 829 manager_->Destroy(false);
830 } 830 }
831 831
832 TEST_F(QueryManagerManualSetupTest, TimeStampDisjoint) { 832 TEST_F(QueryManagerManualSetupTest, TimeStampDisjoint) {
833 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0", 833 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0",
834 "GL_EXT_disjoint_timer_query"); 834 "GL_EXT_disjoint_timer_query");
835 gfx::GPUTimingFake fake_timing_queries; 835 gl::GPUTimingFake fake_timing_queries;
836 fake_timing_queries.ExpectDisjointCalls(*gl_); 836 fake_timing_queries.ExpectDisjointCalls(*gl_);
837 SetUpMockGL("GL_EXT_disjoint_timer_query"); 837 SetUpMockGL("GL_EXT_disjoint_timer_query");
838 838
839 DisjointValueSync* disjoint_sync = 839 DisjointValueSync* disjoint_sync =
840 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id, 840 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id,
841 kSharedMemory2Offset, 841 kSharedMemory2Offset,
842 sizeof(*disjoint_sync)); 842 sizeof(*disjoint_sync));
843 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset); 843 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset);
844 844
845 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount(); 845 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount();
(...skipping 25 matching lines...) Expand all
871 871
872 EXPECT_TRUE(query->IsFinished()); 872 EXPECT_TRUE(query->IsFinished());
873 EXPECT_NE(current_disjoint_value, disjoint_sync->GetDisjointCount()); 873 EXPECT_NE(current_disjoint_value, disjoint_sync->GetDisjointCount());
874 874
875 manager_->Destroy(false); 875 manager_->Destroy(false);
876 } 876 }
877 877
878 TEST_F(QueryManagerManualSetupTest, DisjointContinualTest) { 878 TEST_F(QueryManagerManualSetupTest, DisjointContinualTest) {
879 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0", 879 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0",
880 "GL_EXT_disjoint_timer_query"); 880 "GL_EXT_disjoint_timer_query");
881 gfx::GPUTimingFake fake_timing_queries; 881 gl::GPUTimingFake fake_timing_queries;
882 fake_timing_queries.ExpectDisjointCalls(*gl_); 882 fake_timing_queries.ExpectDisjointCalls(*gl_);
883 SetUpMockGL("GL_EXT_disjoint_timer_query"); 883 SetUpMockGL("GL_EXT_disjoint_timer_query");
884 884
885 DisjointValueSync* disjoint_sync = 885 DisjointValueSync* disjoint_sync =
886 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id, 886 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id,
887 kSharedMemory2Offset, 887 kSharedMemory2Offset,
888 sizeof(*disjoint_sync)); 888 sizeof(*disjoint_sync));
889 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset); 889 manager_->SetDisjointSync(kSharedMemory2Id, kSharedMemory2Offset);
890 890
891 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount(); 891 const uint32_t current_disjoint_value = disjoint_sync->GetDisjointCount();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 951
952 EXPECT_EQ(static_cast<GLuint>(GL_INVALID_ENUM), sync->result); 952 EXPECT_EQ(static_cast<GLuint>(GL_INVALID_ENUM), sync->result);
953 953
954 manager->Destroy(false); 954 manager->Destroy(false);
955 } 955 }
956 956
957 } // namespace gles2 957 } // namespace gles2
958 } // namespace gpu 958 } // namespace gpu
959 959
960 960
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.cc ('k') | gpu/command_buffer/service/renderbuffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698