| OLD | NEW |
| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 protected: | 143 protected: |
| 144 bool disjointed_ = false; | 144 bool disjointed_ = false; |
| 145 GLint64 current_time_ = 0; | 145 GLint64 current_time_ = 0; |
| 146 GLuint next_query_id_ = 0; | 146 GLuint next_query_id_ = 0; |
| 147 std::set<GLuint> alloced_queries_; | 147 std::set<GLuint> alloced_queries_; |
| 148 std::map<GLuint, GLint64> query_timestamp_; | 148 std::map<GLuint, GLint64> query_timestamp_; |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 class GPUTracerTester : public GPUTracer { | 151 class GPUTracerTester : public GPUTracer { |
| 152 public: | 152 public: |
| 153 explicit GPUTracerTester(gles2::GLES2Decoder* decoder) | 153 GPUTracerTester(gles2::GLES2Decoder* decoder, GPUTiming* gpu_timing) |
| 154 : GPUTracer(decoder), tracing_enabled_(0) { | 154 : GPUTracer(decoder, gpu_timing), tracing_enabled_(0) { |
| 155 gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); | |
| 156 | |
| 157 // Force tracing to be dependent on our mock variable here. | 155 // Force tracing to be dependent on our mock variable here. |
| 158 gpu_trace_srv_category = &tracing_enabled_; | 156 gpu_trace_srv_category = &tracing_enabled_; |
| 159 gpu_trace_dev_category = &tracing_enabled_; | 157 gpu_trace_dev_category = &tracing_enabled_; |
| 160 } | 158 } |
| 161 | 159 |
| 162 ~GPUTracerTester() override {} | 160 ~GPUTracerTester() override {} |
| 163 | 161 |
| 164 void SetTracingEnabled(bool enabled) { | 162 void SetTracingEnabled(bool enabled) { |
| 165 tracing_enabled_ = enabled ? 1 : 0; | 163 tracing_enabled_ = enabled ? 1 : 0; |
| 166 } | 164 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 184 | 182 |
| 185 unsigned char tracing_enabled_; | 183 unsigned char tracing_enabled_; |
| 186 | 184 |
| 187 scoped_refptr<Outputter> set_outputter_; | 185 scoped_refptr<Outputter> set_outputter_; |
| 188 }; | 186 }; |
| 189 | 187 |
| 190 class BaseGpuTest : public GpuServiceTest { | 188 class BaseGpuTest : public GpuServiceTest { |
| 191 public: | 189 public: |
| 192 explicit BaseGpuTest(GPUTiming::TimerType test_timer_type) | 190 explicit BaseGpuTest(GPUTiming::TimerType test_timer_type) |
| 193 : test_timer_type_(test_timer_type) { | 191 : test_timer_type_(test_timer_type) { |
| 194 gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); | |
| 195 gpu_timing_.SetTimerTypeForTesting(test_timer_type); | |
| 196 } | 192 } |
| 197 | 193 |
| 198 protected: | 194 protected: |
| 199 void SetUp() override { | 195 void SetUp() override { |
| 200 g_fakeCPUTime = 0; | 196 g_fakeCPUTime = 0; |
| 201 const char* gl_version = "3.2"; | 197 const char* gl_version = "3.2"; |
| 202 const char* extensions = ""; | 198 const char* extensions = ""; |
| 203 if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) { | 199 if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) { |
| 204 gl_version = "opengl es 3.0"; | 200 gl_version = "opengl es 3.0"; |
| 205 extensions = "GL_EXT_disjoint_timer_query"; | 201 extensions = "GL_EXT_disjoint_timer_query"; |
| 206 } else if (GetTimerType() == GPUTiming::kTimerTypeARB) { | 202 } else if (GetTimerType() == GPUTiming::kTimerTypeARB) { |
| 207 // TODO(sievers): The tracer should not depend on ARB_occlusion_query. | 203 // TODO(sievers): The tracer should not depend on ARB_occlusion_query. |
| 208 // Try merge Query APIs (core, ARB, EXT) into a single binding each. | 204 // Try merge Query APIs (core, ARB, EXT) into a single binding each. |
| 209 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query"; | 205 extensions = "GL_ARB_timer_query GL_ARB_occlusion_query"; |
| 210 } | 206 } |
| 211 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); | 207 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); |
| 208 gpu_timing_.Initialize(GetGLContext()); |
| 209 gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); |
| 212 gl_fake_queries_.Reset(); | 210 gl_fake_queries_.Reset(); |
| 213 | 211 |
| 214 outputter_ref_ = new MockOutputter(); | 212 outputter_ref_ = new MockOutputter(); |
| 215 } | 213 } |
| 216 | 214 |
| 217 void TearDown() override { | 215 void TearDown() override { |
| 218 outputter_ref_ = NULL; | 216 outputter_ref_ = NULL; |
| 219 | 217 |
| 220 gl_fake_queries_.Reset(); | 218 gl_fake_queries_.Reset(); |
| 221 GpuServiceTest::TearDown(); | 219 GpuServiceTest::TearDown(); |
| 222 } | 220 } |
| 223 | 221 |
| 224 void ExpectTraceQueryMocks() { | 222 void ExpectTraceQueryMocks() { |
| 225 if (GetTimerType() != GPUTiming::kTimerTypeInvalid) { | 223 if (GetTimerType() != GPUTiming::kTimerTypeInvalid) { |
| 226 // Delegate query APIs used by GPUTrace to a GlFakeQueries | 224 // Delegate query APIs used by GPUTrace to a GlFakeQueries |
| 227 EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1)) | 225 EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1)) |
| 228 .WillRepeatedly( | 226 .WillRepeatedly( |
| 229 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB)); | 227 Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB)); |
| 230 | 228 |
| 231 EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE, | 229 EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE, |
| 232 NotNull())) | 230 NotNull())) |
| 233 .WillRepeatedly( | 231 .WillRepeatedly( |
| 234 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB)); | 232 Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB)); |
| 235 | 233 |
| 236 if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) { | 234 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _)) |
| 237 EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _)) | |
| 238 .WillRepeatedly( | 235 .WillRepeatedly( |
| 239 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v)); | 236 Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v)); |
| 240 } | |
| 241 | 237 |
| 242 EXPECT_CALL(*gl_, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(2)) | 238 EXPECT_CALL(*gl_, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(2)) |
| 243 .WillRepeatedly( | 239 .WillRepeatedly( |
| 244 Invoke(&gl_fake_queries_, &GlFakeQueries::QueryCounter)); | 240 Invoke(&gl_fake_queries_, &GlFakeQueries::QueryCounter)); |
| 245 | 241 |
| 246 EXPECT_CALL(*gl_, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) | 242 EXPECT_CALL(*gl_, GetQueryObjectui64v(_, GL_QUERY_RESULT, NotNull())) |
| 247 .WillRepeatedly( | 243 .WillRepeatedly( |
| 248 Invoke(&gl_fake_queries_, | 244 Invoke(&gl_fake_queries_, |
| 249 &GlFakeQueries::GetQueryObjectui64v)); | 245 &GlFakeQueries::GetQueryObjectui64v)); |
| 250 | 246 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 const int64 expect_end_time = | 336 const int64 expect_end_time = |
| 341 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; | 337 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; |
| 342 | 338 |
| 343 ExpectTraceQueryMocks(); | 339 ExpectTraceQueryMocks(); |
| 344 ExpectOutputterMocks(outputter_ref_.get(), category_name, trace_name, | 340 ExpectOutputterMocks(outputter_ref_.get(), category_name, trace_name, |
| 345 expect_start_time, expect_end_time); | 341 expect_start_time, expect_end_time); |
| 346 | 342 |
| 347 scoped_refptr<GPUTrace> trace = new GPUTrace( | 343 scoped_refptr<GPUTrace> trace = new GPUTrace( |
| 348 outputter_ref_, &gpu_timing_, category_name, trace_name, true); | 344 outputter_ref_, &gpu_timing_, category_name, trace_name, true); |
| 349 | 345 |
| 350 gpu_timing_.SetOffsetForTesting( | |
| 351 offset_time, test_timer_type_ == GPUTiming::kTimerTypeARB); | |
| 352 | |
| 353 gl_fake_queries_.SetCurrentGLTime(start_timestamp); | 346 gl_fake_queries_.SetCurrentGLTime(start_timestamp); |
| 354 g_fakeCPUTime = expect_start_time; | 347 g_fakeCPUTime = expect_start_time; |
| 355 trace->Start(true); | 348 trace->Start(true); |
| 356 | 349 |
| 357 // Shouldn't be available before End() call | 350 // Shouldn't be available before End() call |
| 358 gl_fake_queries_.SetCurrentGLTime(end_timestamp); | 351 gl_fake_queries_.SetCurrentGLTime(end_timestamp); |
| 359 g_fakeCPUTime = expect_end_time; | 352 g_fakeCPUTime = expect_end_time; |
| 360 EXPECT_FALSE(trace->IsAvailable()); | 353 EXPECT_FALSE(trace->IsAvailable()); |
| 361 | 354 |
| 362 trace->End(true); | 355 trace->End(true); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // Test GPUTracer calls all the correct gl calls. | 392 // Test GPUTracer calls all the correct gl calls. |
| 400 class BaseGpuTracerTest : public BaseGpuTest { | 393 class BaseGpuTracerTest : public BaseGpuTest { |
| 401 public: | 394 public: |
| 402 explicit BaseGpuTracerTest(GPUTiming::TimerType test_timer_type) | 395 explicit BaseGpuTracerTest(GPUTiming::TimerType test_timer_type) |
| 403 : BaseGpuTest(test_timer_type) {} | 396 : BaseGpuTest(test_timer_type) {} |
| 404 | 397 |
| 405 void DoBasicTracerTest() { | 398 void DoBasicTracerTest() { |
| 406 ExpectTracerOffsetQueryMocks(); | 399 ExpectTracerOffsetQueryMocks(); |
| 407 | 400 |
| 408 MockGLES2Decoder decoder; | 401 MockGLES2Decoder decoder; |
| 409 EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); | 402 GPUTracerTester tracer(&decoder, &gpu_timing_); |
| 410 GPUTracerTester tracer(&decoder); | |
| 411 tracer.SetTracingEnabled(true); | 403 tracer.SetTracingEnabled(true); |
| 412 | 404 |
| 413 tracer.SetOutputter(outputter_ref_); | 405 tracer.SetOutputter(outputter_ref_); |
| 414 | 406 |
| 415 ASSERT_TRUE(tracer.BeginDecoding()); | 407 ASSERT_TRUE(tracer.BeginDecoding()); |
| 416 ASSERT_TRUE(tracer.EndDecoding()); | 408 ASSERT_TRUE(tracer.EndDecoding()); |
| 417 | 409 |
| 418 outputter_ref_ = NULL; | 410 outputter_ref_ = NULL; |
| 419 } | 411 } |
| 420 | 412 |
| 421 void DoTracerMarkersTest() { | 413 void DoTracerMarkersTest() { |
| 422 ExpectTracerOffsetQueryMocks(); | 414 ExpectTracerOffsetQueryMocks(); |
| 423 | 415 |
| 424 EXPECT_CALL(*gl_, GetError()).Times(AtLeast(0)) | 416 EXPECT_CALL(*gl_, GetError()).Times(AtLeast(0)) |
| 425 .WillRepeatedly( | 417 .WillRepeatedly( |
| 426 Invoke(&gl_fake_queries_, &GlFakeQueries::GetError)); | 418 Invoke(&gl_fake_queries_, &GlFakeQueries::GetError)); |
| 427 | 419 |
| 428 const std::string category_name("trace_category"); | 420 const std::string category_name("trace_category"); |
| 429 const std::string trace_name("trace_test"); | 421 const std::string trace_name("trace_test"); |
| 430 const int64 offset_time = 3231; | 422 const int64 offset_time = 3231; |
| 431 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; | 423 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; |
| 432 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; | 424 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; |
| 433 const int64 expect_start_time = | 425 const int64 expect_start_time = |
| 434 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + | 426 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + |
| 435 offset_time; | 427 offset_time; |
| 436 const int64 expect_end_time = | 428 const int64 expect_end_time = |
| 437 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; | 429 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; |
| 438 | 430 |
| 439 MockGLES2Decoder decoder; | 431 MockGLES2Decoder decoder; |
| 440 EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); | 432 GPUTracerTester tracer(&decoder, &gpu_timing_); |
| 441 GPUTracerTester tracer(&decoder); | |
| 442 tracer.SetTracingEnabled(true); | 433 tracer.SetTracingEnabled(true); |
| 443 | 434 |
| 444 tracer.SetOutputter(outputter_ref_); | 435 tracer.SetOutputter(outputter_ref_); |
| 445 | 436 |
| 446 gl_fake_queries_.SetCurrentGLTime(start_timestamp); | 437 gl_fake_queries_.SetCurrentGLTime(start_timestamp); |
| 447 g_fakeCPUTime = expect_start_time; | 438 g_fakeCPUTime = expect_start_time; |
| 448 | 439 |
| 449 ASSERT_TRUE(tracer.BeginDecoding()); | 440 ASSERT_TRUE(tracer.BeginDecoding()); |
| 450 | 441 |
| 451 ExpectTraceQueryMocks(); | 442 ExpectTraceQueryMocks(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 const int64 offset_time = 3231; | 506 const int64 offset_time = 3231; |
| 516 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; | 507 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; |
| 517 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; | 508 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; |
| 518 const int64 expect_start_time = | 509 const int64 expect_start_time = |
| 519 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + | 510 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + |
| 520 offset_time; | 511 offset_time; |
| 521 const int64 expect_end_time = | 512 const int64 expect_end_time = |
| 522 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; | 513 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; |
| 523 | 514 |
| 524 MockGLES2Decoder decoder; | 515 MockGLES2Decoder decoder; |
| 525 EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); | 516 GPUTracerTester tracer(&decoder, &gpu_timing_); |
| 526 GPUTracerTester tracer(&decoder); | |
| 527 tracer.SetTracingEnabled(true); | 517 tracer.SetTracingEnabled(true); |
| 528 | 518 |
| 529 tracer.SetOutputter(outputter_ref_); | 519 tracer.SetOutputter(outputter_ref_); |
| 530 | 520 |
| 531 gl_fake_queries_.SetCurrentGLTime(start_timestamp); | 521 gl_fake_queries_.SetCurrentGLTime(start_timestamp); |
| 532 g_fakeCPUTime = expect_start_time; | 522 g_fakeCPUTime = expect_start_time; |
| 533 | 523 |
| 534 ASSERT_TRUE(tracer.BeginDecoding()); | 524 ASSERT_TRUE(tracer.BeginDecoding()); |
| 535 | 525 |
| 536 ExpectTraceQueryMocks(); | 526 ExpectTraceQueryMocks(); |
| 537 | 527 |
| 538 ExpectOutputterBeginMocks(outputter_ref_.get(), | 528 ExpectOutputterBeginMocks(outputter_ref_.get(), |
| 539 category_name, trace_name); | 529 category_name, trace_name); |
| 540 ASSERT_TRUE(tracer.Begin(category_name, trace_name, source)); | 530 ASSERT_TRUE(tracer.Begin(category_name, trace_name, source)); |
| 541 | 531 |
| 542 gl_fake_queries_.SetCurrentGLTime(end_timestamp); | 532 gl_fake_queries_.SetCurrentGLTime(end_timestamp); |
| 543 g_fakeCPUTime = expect_end_time; | 533 g_fakeCPUTime = expect_end_time; |
| 534 |
| 535 // Create a disjoint context to test disjoint behavior. This should not |
| 536 // interfere with the tracer's disjoint context. |
| 537 int disjoint_id = gpu_timing_.CreateDisjointContextID(); |
| 538 |
| 539 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id)); |
| 544 gl_fake_queries_.SetDisjoint(); | 540 gl_fake_queries_.SetDisjoint(); |
| 541 ASSERT_TRUE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id)); |
| 545 | 542 |
| 546 ExpectOutputterEndMocks(outputter_ref_.get(), category_name, trace_name, | 543 ExpectOutputterEndMocks(outputter_ref_.get(), category_name, trace_name, |
| 547 expect_start_time, expect_end_time, false); | 544 expect_start_time, expect_end_time, false); |
| 548 | 545 |
| 549 ASSERT_TRUE(tracer.End(source)); | 546 ASSERT_TRUE(tracer.End(source)); |
| 550 ASSERT_TRUE(tracer.EndDecoding()); | 547 ASSERT_TRUE(tracer.EndDecoding()); |
| 551 | 548 |
| 552 outputter_ref_ = NULL; | 549 outputter_ref_ = NULL; |
| 553 } | 550 } |
| 554 }; | 551 }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 592 |
| 596 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerDisjointTraceTest) { | 593 TEST_F(GpuDisjointTimerTracerTest, DisjointTimerDisjointTraceTest) { |
| 597 DoDisjointTest(); | 594 DoDisjointTest(); |
| 598 } | 595 } |
| 599 | 596 |
| 600 class GPUTracerTest : public GpuServiceTest { | 597 class GPUTracerTest : public GpuServiceTest { |
| 601 protected: | 598 protected: |
| 602 void SetUp() override { | 599 void SetUp() override { |
| 603 g_fakeCPUTime = 0; | 600 g_fakeCPUTime = 0; |
| 604 GpuServiceTest::SetUpWithGLVersion("3.2", ""); | 601 GpuServiceTest::SetUpWithGLVersion("3.2", ""); |
| 602 gpu_timing_.Initialize(GetGLContext()); |
| 603 gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); |
| 605 decoder_.reset(new MockGLES2Decoder()); | 604 decoder_.reset(new MockGLES2Decoder()); |
| 606 EXPECT_CALL(*decoder_, GetGLContext()) | 605 tracer_tester_.reset(new GPUTracerTester(decoder_.get(), &gpu_timing_)); |
| 607 .Times(AtMost(1)) | |
| 608 .WillRepeatedly(Return(GetGLContext())); | |
| 609 tracer_tester_.reset(new GPUTracerTester(decoder_.get())); | |
| 610 } | 606 } |
| 611 | 607 |
| 612 void TearDown() override { | 608 void TearDown() override { |
| 613 tracer_tester_ = nullptr; | 609 tracer_tester_ = nullptr; |
| 614 decoder_ = nullptr; | 610 decoder_ = nullptr; |
| 615 GpuServiceTest::TearDown(); | 611 GpuServiceTest::TearDown(); |
| 616 } | 612 } |
| 613 GPUTiming gpu_timing_; |
| 617 scoped_ptr<MockGLES2Decoder> decoder_; | 614 scoped_ptr<MockGLES2Decoder> decoder_; |
| 618 scoped_ptr<GPUTracerTester> tracer_tester_; | 615 scoped_ptr<GPUTracerTester> tracer_tester_; |
| 619 }; | 616 }; |
| 620 | 617 |
| 621 TEST_F(GPUTracerTest, IsTracingTest) { | 618 TEST_F(GPUTracerTest, IsTracingTest) { |
| 622 EXPECT_FALSE(tracer_tester_->IsTracing()); | 619 EXPECT_FALSE(tracer_tester_->IsTracing()); |
| 623 tracer_tester_->SetTracingEnabled(true); | 620 tracer_tester_->SetTracingEnabled(true); |
| 624 EXPECT_TRUE(tracer_tester_->IsTracing()); | 621 EXPECT_TRUE(tracer_tester_->IsTracing()); |
| 625 } | 622 } |
| 626 // Test basic functionality of the GPUTracerTester. | 623 // Test basic functionality of the GPUTracerTester. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 637 | 634 |
| 638 EXPECT_FALSE( | 635 EXPECT_FALSE( |
| 639 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); | 636 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); |
| 640 | 637 |
| 641 ASSERT_TRUE(tracer_tester_->BeginDecoding()); | 638 ASSERT_TRUE(tracer_tester_->BeginDecoding()); |
| 642 EXPECT_TRUE( | 639 EXPECT_TRUE( |
| 643 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); | 640 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); |
| 644 ASSERT_TRUE(tracer_tester_->EndDecoding()); | 641 ASSERT_TRUE(tracer_tester_->EndDecoding()); |
| 645 } | 642 } |
| 646 | 643 |
| 644 TEST_F(GpuDisjointTimerTracerTest, MultipleDisjointContexts) { |
| 645 EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) |
| 646 .WillRepeatedly( |
| 647 Invoke(&gl_fake_queries_, &GlFakeQueries::GetIntegerv)); |
| 648 |
| 649 int disjoint_id1 = gpu_timing_.CreateDisjointContextID(); |
| 650 int disjoint_id2 = gpu_timing_.CreateDisjointContextID(); |
| 651 |
| 652 // Test both contexts are initialized as no errors. |
| 653 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id1)); |
| 654 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id2)); |
| 655 |
| 656 // Issue a disjoint. |
| 657 gl_fake_queries_.SetDisjoint(); |
| 658 |
| 659 ASSERT_TRUE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id1)); |
| 660 ASSERT_TRUE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id2)); |
| 661 |
| 662 // Test new context gets the disjoint value as if no other contexts reset it. |
| 663 int disjoint_id3 = gpu_timing_.CreateDisjointContextID(); |
| 664 ASSERT_TRUE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id3)); |
| 665 |
| 666 // Test all 3 are all reset. |
| 667 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id1)); |
| 668 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id2)); |
| 669 ASSERT_FALSE(gpu_timing_.CheckAndResetTimerErrors(disjoint_id3)); |
| 670 } |
| 671 |
| 647 } // namespace | 672 } // namespace |
| 648 } // namespace gles2 | 673 } // namespace gles2 |
| 649 } // namespace gpu | 674 } // namespace gpu |
| OLD | NEW |