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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress 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
« no previous file with comments | « gpu/command_buffer/service/gpu_tracer.cc ('k') | gpu/command_buffer/service/shader_manager.h » ('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 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 public: 191 public:
192 explicit BaseGpuTest(gfx::GPUTiming::TimerType test_timer_type) 192 explicit BaseGpuTest(gfx::GPUTiming::TimerType test_timer_type)
193 : test_timer_type_(test_timer_type) { 193 : test_timer_type_(test_timer_type) {
194 } 194 }
195 195
196 protected: 196 protected:
197 void SetUp() override { 197 void SetUp() override {
198 g_fakeCPUTime = 0; 198 g_fakeCPUTime = 0;
199 const char* gl_version = "3.2"; 199 const char* gl_version = "3.2";
200 const char* extensions = ""; 200 const char* extensions = "";
201 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) { 201 if (GetTimerType() == gfx::GPUTiming::kTimerTypeEXT) {
202 gl_version = "opengl 2.1";
203 extensions = "GL_EXT_timer_query";
204 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
202 gl_version = "opengl es 3.0"; 205 gl_version = "opengl es 3.0";
203 extensions = "GL_EXT_disjoint_timer_query"; 206 extensions = "GL_EXT_disjoint_timer_query";
204 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB) { 207 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB) {
205 // TODO(sievers): The tracer should not depend on ARB_occlusion_query. 208 // TODO(sievers): The tracer should not depend on ARB_occlusion_query.
206 // Try merge Query APIs (core, ARB, EXT) into a single binding each. 209 // Try merge Query APIs (core, ARB, EXT) into a single binding each.
207 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query"; 210 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query";
208 } 211 }
209 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); 212 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions);
210 213
211 // Disjoint check should only be called by kTracerTypeDisjointTimer type. 214 // Disjoint check should only be called by kTracerTypeDisjointTimer type.
(...skipping 12 matching lines...) Expand all
224 } 227 }
225 228
226 void TearDown() override { 229 void TearDown() override {
227 outputter_ref_ = NULL; 230 outputter_ref_ = NULL;
228 231
229 gl_fake_queries_.Reset(); 232 gl_fake_queries_.Reset();
230 GpuServiceTest::TearDown(); 233 GpuServiceTest::TearDown();
231 } 234 }
232 235
233 void ExpectTraceQueryMocks() { 236 void ExpectTraceQueryMocks() {
234 if (GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid) { 237 if (gpu_timing_client_->IsAvailable() &&
238 gpu_timing_client_->IsTimerOffsetAvailable()) {
235 // Delegate query APIs used by GPUTrace to a GlFakeQueries 239 // Delegate query APIs used by GPUTrace to a GlFakeQueries
236 EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1)) 240 EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1))
237 .WillRepeatedly( 241 .WillRepeatedly(
238 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB)); 242 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB));
239 243
240 EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE, 244 EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE,
241 NotNull())) 245 NotNull()))
242 .WillRepeatedly( 246 .WillRepeatedly(
243 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB)); 247 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB));
244 248
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 expect_start_time, expect_end_time)) 290 expect_start_time, expect_end_time))
287 .Times(Exactly(0)); 291 .Times(Exactly(0));
288 } 292 }
289 } 293 }
290 294
291 void ExpectOutputterMocks(MockOutputter* outputter, 295 void ExpectOutputterMocks(MockOutputter* outputter,
292 const std::string& category, 296 const std::string& category,
293 const std::string& name, int64 expect_start_time, 297 const std::string& name, int64 expect_start_time,
294 int64 expect_end_time) { 298 int64 expect_end_time) {
295 ExpectOutputterBeginMocks(outputter, category, name); 299 ExpectOutputterBeginMocks(outputter, category, name);
296 bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid; 300 bool valid_timer = gpu_timing_client_->IsAvailable() &&
301 gpu_timing_client_->IsTimerOffsetAvailable();
297 ExpectOutputterEndMocks(outputter, category, name, expect_start_time, 302 ExpectOutputterEndMocks(outputter, category, name, expect_start_time,
298 expect_end_time, valid_timer); 303 expect_end_time, valid_timer);
299 } 304 }
300 305
301 void ExpectTracerOffsetQueryMocks() { 306 void ExpectTracerOffsetQueryMocks() {
302 if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB) { 307 if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB) {
303 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull())) 308 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull()))
304 .Times(Exactly(0)); 309 .Times(Exactly(0));
305 } else { 310 } else {
306 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull())) 311 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull()))
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 gl_fake_queries_.SetCurrentGLTime( 476 gl_fake_queries_.SetCurrentGLTime(
472 end_timestamp + 477 end_timestamp +
473 (i * base::Time::kNanosecondsPerMicrosecond)); 478 (i * base::Time::kNanosecondsPerMicrosecond));
474 g_fakeCPUTime = expect_end_time + i; 479 g_fakeCPUTime = expect_end_time + i;
475 480
476 // Each trace name should be different to differentiate. 481 // Each trace name should be different to differentiate.
477 const char num_char = static_cast<char>('0' + i); 482 const char num_char = static_cast<char>('0' + i);
478 std::string source_category = category_name + num_char; 483 std::string source_category = category_name + num_char;
479 std::string source_trace_name = trace_name + num_char; 484 std::string source_trace_name = trace_name + num_char;
480 485
481 bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid; 486 bool valid_timer = gpu_timing_client_->IsAvailable() &&
487 gpu_timing_client_->IsTimerOffsetAvailable();
482 ExpectOutputterEndMocks(outputter_ref_.get(), source_category, 488 ExpectOutputterEndMocks(outputter_ref_.get(), source_category,
483 source_trace_name, expect_start_time + i, 489 source_trace_name, expect_start_time + i,
484 expect_end_time + i, valid_timer); 490 expect_end_time + i, valid_timer);
485 491
486 const GpuTracerSource source = static_cast<GpuTracerSource>(i); 492 const GpuTracerSource source = static_cast<GpuTracerSource>(i);
487 493
488 // Check if the current category/name are correct for this source. 494 // Check if the current category/name are correct for this source.
489 ASSERT_EQ(source_category, tracer.CurrentCategory(source)); 495 ASSERT_EQ(source_category, tracer.CurrentCategory(source));
490 ASSERT_EQ(source_trace_name, tracer.CurrentName(source)); 496 ASSERT_EQ(source_trace_name, tracer.CurrentName(source));
491 497
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 outputter_ref_ = NULL; 564 outputter_ref_ = NULL;
559 } 565 }
560 }; 566 };
561 567
562 class InvalidTimerTracerTest : public BaseGpuTracerTest { 568 class InvalidTimerTracerTest : public BaseGpuTracerTest {
563 public: 569 public:
564 InvalidTimerTracerTest() 570 InvalidTimerTracerTest()
565 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeInvalid) {} 571 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeInvalid) {}
566 }; 572 };
567 573
574 class GpuEXTTimerTracerTest : public BaseGpuTracerTest {
575 public:
576 GpuEXTTimerTracerTest() : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeEXT) {}
577 };
578
568 class GpuARBTimerTracerTest : public BaseGpuTracerTest { 579 class GpuARBTimerTracerTest : public BaseGpuTracerTest {
569 public: 580 public:
570 GpuARBTimerTracerTest() 581 GpuARBTimerTracerTest()
571 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeARB) {} 582 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeARB) {}
572 }; 583 };
573 584
574 class GpuDisjointTimerTracerTest : public BaseGpuTracerTest { 585 class GpuDisjointTimerTracerTest : public BaseGpuTracerTest {
575 public: 586 public:
576 GpuDisjointTimerTracerTest() 587 GpuDisjointTimerTracerTest()
577 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeDisjoint) {} 588 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeDisjoint) {}
578 }; 589 };
579 590
580 TEST_F(InvalidTimerTracerTest, InvalidTimerBasicTracerTest) { 591 TEST_F(InvalidTimerTracerTest, InvalidTimerBasicTracerTest) {
581 DoBasicTracerTest(); 592 DoBasicTracerTest();
582 } 593 }
583 594
595 TEST_F(GpuEXTTimerTracerTest, EXTTimerBasicTracerTest) {
596 DoBasicTracerTest();
597 }
598
584 TEST_F(GpuARBTimerTracerTest, ARBTimerBasicTracerTest) { 599 TEST_F(GpuARBTimerTracerTest, ARBTimerBasicTracerTest) {
585 DoBasicTracerTest(); 600 DoBasicTracerTest();
586 } 601 }
587 602
588 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerBasicTracerTest) { 603 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerBasicTracerTest) {
589 DoBasicTracerTest(); 604 DoBasicTracerTest();
590 } 605 }
591 606
592 TEST_F(InvalidTimerTracerTest, InvalidTimerTracerMarkersTest) { 607 TEST_F(InvalidTimerTracerTest, InvalidTimerTracerMarkersTest) {
593 DoTracerMarkersTest(); 608 DoTracerMarkersTest();
594 } 609 }
595 610
611 TEST_F(GpuEXTTimerTracerTest, EXTTimerTracerMarkersTest) {
612 DoTracerMarkersTest();
613 }
614
596 TEST_F(GpuARBTimerTracerTest, ARBTimerBasicTracerMarkersTest) { 615 TEST_F(GpuARBTimerTracerTest, ARBTimerBasicTracerMarkersTest) {
597 DoTracerMarkersTest(); 616 DoTracerMarkersTest();
598 } 617 }
599 618
600 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerBasicTracerMarkersTest) { 619 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerBasicTracerMarkersTest) {
601 DoTracerMarkersTest(); 620 DoTracerMarkersTest();
602 } 621 }
603 622
604 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerDisjointTraceTest) { 623 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerDisjointTraceTest) {
605 DoDisjointTest(); 624 DoDisjointTest();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 scoped_refptr<gfx::GPUTimingClient> client3 = 698 scoped_refptr<gfx::GPUTimingClient> client3 =
680 GetGLContext()->CreateGPUTimingClient(); 699 GetGLContext()->CreateGPUTimingClient();
681 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); 700 ASSERT_TRUE(client1->CheckAndResetTimerErrors());
682 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); 701 ASSERT_TRUE(client2->CheckAndResetTimerErrors());
683 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); 702 ASSERT_FALSE(client3->CheckAndResetTimerErrors());
684 } 703 }
685 704
686 } // namespace 705 } // namespace
687 } // namespace gles2 706 } // namespace gles2
688 } // namespace gpu 707 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_tracer.cc ('k') | gpu/command_buffer/service/shader_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698