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

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

Issue 2747823004: Fix QueryCounter on a pending query (Closed)
Patch Set: Created 3 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
« no previous file with comments | « gpu/command_buffer/service/query_manager.cc ('k') | ui/gl/gpu_timing_fake.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(QueryManagerTest, TimeStampQueryPending) {
833 const GLuint kClient1Id = 1;
834 const GLenum kTarget = GL_TIMESTAMP_EXT;
835 const base::subtle::Atomic32 kSubmitCount = 123;
836 gl::GPUTimingFake fake_timing_queries;
837
838 decoder_->GetGLContext()->CreateGPUTimingClient()->SetCpuTimeForTesting(
839 base::Bind(&gl::GPUTimingFake::GetFakeCPUTime));
840
841 QueryManager::Query* query = manager_->CreateQuery(
842 kTarget, kClient1Id, kSharedMemoryId, kSharedMemoryOffset);
843 ASSERT_TRUE(query != NULL);
844
845 const uint64_t expected_result =
846 100u * base::Time::kNanosecondsPerMicrosecond;
847 fake_timing_queries.SetCurrentGLTime(expected_result);
848 fake_timing_queries.ExpectGPUTimeStampQuery(*gl_, false);
849 EXPECT_TRUE(manager_->QueryCounter(query, kSubmitCount));
850 EXPECT_TRUE(query->IsPending());
851 fake_timing_queries.ExpectGPUTimeStampQuery(*gl_, false);
852 EXPECT_TRUE(manager_->QueryCounter(query, kSubmitCount));
853 EXPECT_TRUE(manager_->ProcessPendingQueries(false));
854
855 QuerySync* sync = decoder_->GetSharedMemoryAs<QuerySync*>(
856 kSharedMemoryId, kSharedMemoryOffset, sizeof(*sync));
857 EXPECT_EQ(expected_result, sync->result);
858
859 manager_->Destroy(false);
860 }
861
832 TEST_F(QueryManagerManualSetupTest, TimeStampDisjoint) { 862 TEST_F(QueryManagerManualSetupTest, TimeStampDisjoint) {
833 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0", 863 GpuServiceTest::SetUpWithGLVersion("OpenGL ES 3.0",
834 "GL_EXT_disjoint_timer_query"); 864 "GL_EXT_disjoint_timer_query");
835 gl::GPUTimingFake fake_timing_queries; 865 gl::GPUTimingFake fake_timing_queries;
836 fake_timing_queries.ExpectDisjointCalls(*gl_); 866 fake_timing_queries.ExpectDisjointCalls(*gl_);
837 SetUpMockGL("GL_EXT_disjoint_timer_query"); 867 SetUpMockGL("GL_EXT_disjoint_timer_query");
838 868
839 DisjointValueSync* disjoint_sync = 869 DisjointValueSync* disjoint_sync =
840 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id, 870 decoder_->GetSharedMemoryAs<DisjointValueSync*>(kSharedMemory2Id,
841 kSharedMemory2Offset, 871 kSharedMemory2Offset,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 .RetiresOnSaturation(); 1013 .RetiresOnSaturation();
984 EXPECT_TRUE(manager->BeginQuery(query)); 1014 EXPECT_TRUE(manager->BeginQuery(query));
985 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount)); 1015 EXPECT_TRUE(manager->EndQuery(query, kSubmitCount));
986 manager->Destroy(false); 1016 manager->Destroy(false);
987 } 1017 }
988 1018
989 } // namespace gles2 1019 } // namespace gles2
990 } // namespace gpu 1020 } // namespace gpu
991 1021
992 1022
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.cc ('k') | ui/gl/gpu_timing_fake.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698