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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix Clipboard.java 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
10 #include "gpu/command_buffer/service/gpu_service_test.h" 10 #include "gpu/command_buffer/service/gpu_service_test.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const char* extensions = ""; 200 const char* extensions = "";
201 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) { 201 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
202 gl_version = "opengl es 3.0"; 202 gl_version = "opengl es 3.0";
203 extensions = "GL_EXT_disjoint_timer_query"; 203 extensions = "GL_EXT_disjoint_timer_query";
204 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB) { 204 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB) {
205 // TODO(sievers): The tracer should not depend on ARB_occlusion_query. 205 // TODO(sievers): The tracer should not depend on ARB_occlusion_query.
206 // Try merge Query APIs (core, ARB, EXT) into a single binding each. 206 // Try merge Query APIs (core, ARB, EXT) into a single binding each.
207 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query"; 207 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query";
208 } 208 }
209 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); 209 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions);
210
211 // Disjoint check should only be called by kTracerTypeDisjointTimer type.
212 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
213 EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1))
214 .WillRepeatedly(
215 Invoke(&gl_fake_queries_, &GlFakeQueries::GetIntegerv));
216 } else {
217 EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0));
218 }
210 gpu_timing_client_ = GetGLContext()->CreateGPUTimingClient(); 219 gpu_timing_client_ = GetGLContext()->CreateGPUTimingClient();
211 gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); 220 gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime));
212 gl_fake_queries_.Reset(); 221 gl_fake_queries_.Reset();
213 222
214 outputter_ref_ = new MockOutputter(); 223 outputter_ref_ = new MockOutputter();
215 } 224 }
216 225
217 void TearDown() override { 226 void TearDown() override {
218 outputter_ref_ = NULL; 227 outputter_ref_ = NULL;
219 228
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const std::string& category, 292 const std::string& category,
284 const std::string& name, int64 expect_start_time, 293 const std::string& name, int64 expect_start_time,
285 int64 expect_end_time) { 294 int64 expect_end_time) {
286 ExpectOutputterBeginMocks(outputter, category, name); 295 ExpectOutputterBeginMocks(outputter, category, name);
287 bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid; 296 bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid;
288 ExpectOutputterEndMocks(outputter, category, name, expect_start_time, 297 ExpectOutputterEndMocks(outputter, category, name, expect_start_time,
289 expect_end_time, valid_timer); 298 expect_end_time, valid_timer);
290 } 299 }
291 300
292 void ExpectTracerOffsetQueryMocks() { 301 void ExpectTracerOffsetQueryMocks() {
293 // Disjoint check should only be called by kTracerTypeDisjointTimer type.
294 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
295 EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1))
296 .WillRepeatedly(
297 Invoke(&gl_fake_queries_, &GlFakeQueries::GetIntegerv));
298 } else {
299 EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0));
300 }
301
302 if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB) { 302 if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB) {
303 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull())) 303 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull()))
304 .Times(Exactly(0)); 304 .Times(Exactly(0));
305 } else { 305 } else {
306 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull())) 306 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull()))
307 .Times(AtMost(1)) 307 .Times(AtMost(1))
308 .WillRepeatedly( 308 .WillRepeatedly(
309 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v)); 309 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v));
310 } 310 }
311 } 311 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ASSERT_TRUE(tracer.BeginDecoding()); 530 ASSERT_TRUE(tracer.BeginDecoding());
531 531
532 ExpectTraceQueryMocks(); 532 ExpectTraceQueryMocks();
533 533
534 ExpectOutputterBeginMocks(outputter_ref_.get(), 534 ExpectOutputterBeginMocks(outputter_ref_.get(),
535 category_name, trace_name); 535 category_name, trace_name);
536 ASSERT_TRUE(tracer.Begin(category_name, trace_name, source)); 536 ASSERT_TRUE(tracer.Begin(category_name, trace_name, source));
537 537
538 gl_fake_queries_.SetCurrentGLTime(end_timestamp); 538 gl_fake_queries_.SetCurrentGLTime(end_timestamp);
539 g_fakeCPUTime = expect_end_time; 539 g_fakeCPUTime = expect_end_time;
540
541 // Create GPUTimingClient to make sure disjoint value is correct. This
542 // should not interfere with the tracer's disjoint value.
543 scoped_refptr<gfx::GPUTimingClient> disjoint_client =
544 GetGLContext()->CreateGPUTimingClient();
545
546 // We assert here based on the disjoint_client because if disjoints are not
547 // working properly there is no point testing the tracer output.
548 ASSERT_FALSE(disjoint_client->CheckAndResetTimerErrors());
540 gl_fake_queries_.SetDisjoint(); 549 gl_fake_queries_.SetDisjoint();
550 ASSERT_TRUE(disjoint_client->CheckAndResetTimerErrors());
541 551
542 ExpectOutputterEndMocks(outputter_ref_.get(), category_name, trace_name, 552 ExpectOutputterEndMocks(outputter_ref_.get(), category_name, trace_name,
543 expect_start_time, expect_end_time, false); 553 expect_start_time, expect_end_time, false);
544 554
545 ASSERT_TRUE(tracer.End(source)); 555 ASSERT_TRUE(tracer.End(source));
546 ASSERT_TRUE(tracer.EndDecoding()); 556 ASSERT_TRUE(tracer.EndDecoding());
547 557
548 outputter_ref_ = NULL; 558 outputter_ref_ = NULL;
549 } 559 }
550 }; 560 };
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 645
636 EXPECT_FALSE( 646 EXPECT_FALSE(
637 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); 647 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker));
638 648
639 ASSERT_TRUE(tracer_tester_->BeginDecoding()); 649 ASSERT_TRUE(tracer_tester_->BeginDecoding());
640 EXPECT_TRUE( 650 EXPECT_TRUE(
641 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); 651 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker));
642 ASSERT_TRUE(tracer_tester_->EndDecoding()); 652 ASSERT_TRUE(tracer_tester_->EndDecoding());
643 } 653 }
644 654
655 TEST_F(GpuDisjointTimerTracerTest, MultipleClientsDisjointTest) {
656 scoped_refptr<gfx::GPUTimingClient> client1 =
657 GetGLContext()->CreateGPUTimingClient();
658 scoped_refptr<gfx::GPUTimingClient> client2 =
659 GetGLContext()->CreateGPUTimingClient();
660
661 // Test both clients are initialized as no errors.
662 ASSERT_FALSE(client1->CheckAndResetTimerErrors());
663 ASSERT_FALSE(client2->CheckAndResetTimerErrors());
664
665 // Issue a disjoint.
666 gl_fake_queries_.SetDisjoint();
667
668 ASSERT_TRUE(client1->CheckAndResetTimerErrors());
669 ASSERT_TRUE(client2->CheckAndResetTimerErrors());
670
671 // Test both are now reset.
672 ASSERT_FALSE(client1->CheckAndResetTimerErrors());
673 ASSERT_FALSE(client2->CheckAndResetTimerErrors());
674
675 // Issue a disjoint.
676 gl_fake_queries_.SetDisjoint();
677
678 // Test new client disjoint value is cleared.
679 scoped_refptr<gfx::GPUTimingClient> client3 =
680 GetGLContext()->CreateGPUTimingClient();
681 ASSERT_TRUE(client1->CheckAndResetTimerErrors());
682 ASSERT_TRUE(client2->CheckAndResetTimerErrors());
683 ASSERT_FALSE(client3->CheckAndResetTimerErrors());
684 }
685
645 } // namespace 686 } // namespace
646 } // namespace gles2 687 } // namespace gles2
647 } // namespace gpu 688 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698