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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 1916303003: Report lost context from GLES2Implementation based on share group state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lost-share-group: disconnect-channel Created 4 years, 7 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 // Tests for GLES2Implementation. 5 // Tests for GLES2Implementation.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 mem.ptr = static_cast<uint8_t*>( 665 mem.ptr = static_cast<uint8_t*>(
666 gl_->mapped_memory_->Alloc(size, &mem.id, &mem.offset)); 666 gl_->mapped_memory_->Alloc(size, &mem.id, &mem.offset));
667 gl_->mapped_memory_->Free(mem.ptr); 667 gl_->mapped_memory_->Free(mem.ptr);
668 668
669 return mem; 669 return mem;
670 } 670 }
671 671
672 // Sets the ProgramInfoManager. The manager will be owned 672 // Sets the ProgramInfoManager. The manager will be owned
673 // by the ShareGroup. 673 // by the ShareGroup.
674 void SetProgramInfoManager(ProgramInfoManager* manager) { 674 void SetProgramInfoManager(ProgramInfoManager* manager) {
675 gl_->share_group()->set_program_info_manager(manager); 675 gl_->share_group()->SetProgramInfoManagerForTesting(manager);
676 } 676 }
677 677
678 int CheckError() { 678 int CheckError() {
679 ExpectedMemoryInfo result = 679 ExpectedMemoryInfo result =
680 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); 680 GetExpectedResultMemory(sizeof(cmds::GetError::Result));
681 EXPECT_CALL(*command_buffer(), OnFlush()) 681 EXPECT_CALL(*command_buffer(), OnFlush())
682 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) 682 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR)))
683 .RetiresOnSaturation(); 683 .RetiresOnSaturation();
684 return gl_->GetError(); 684 return gl_->GetError();
685 } 685 }
(...skipping 3794 matching lines...) Expand 10 before | Expand all | Expand 10 after
4480 .WillOnce(SaveArg<1>(&signal_closure)); 4480 .WillOnce(SaveArg<1>(&signal_closure));
4481 gl_->SignalSyncToken(sync_token, base::Bind(&CountCallback, &signaled_count)); 4481 gl_->SignalSyncToken(sync_token, base::Bind(&CountCallback, &signaled_count));
4482 EXPECT_EQ(0, signaled_count); 4482 EXPECT_EQ(0, signaled_count);
4483 4483
4484 // When GpuControl runs the callback, the original callback we gave to 4484 // When GpuControl runs the callback, the original callback we gave to
4485 // GLES2Implementation is run. 4485 // GLES2Implementation is run.
4486 signal_closure.Run(); 4486 signal_closure.Run();
4487 EXPECT_EQ(1, signaled_count); 4487 EXPECT_EQ(1, signaled_count);
4488 } 4488 }
4489 4489
4490 // TODO(danakj): Re-enable after/during re-land of https://crrev.com/389947. 4490 TEST_F(GLES2ImplementationTest, SignalSyncTokenAfterContextLoss) {
4491 // This test depends on r389947 but that CL was reverted in r389980.
4492 TEST_F(GLES2ImplementationTest, DISABLED_SignalSyncTokenAfterContextLoss) {
4493 EXPECT_CALL(*gpu_control_, GenerateFenceSyncRelease()).WillOnce(Return(1)); 4491 EXPECT_CALL(*gpu_control_, GenerateFenceSyncRelease()).WillOnce(Return(1));
4494 const uint64_t fence_sync = gl_->InsertFenceSyncCHROMIUM(); 4492 const uint64_t fence_sync = gl_->InsertFenceSyncCHROMIUM();
4495 gl_->ShallowFlushCHROMIUM(); 4493 gl_->ShallowFlushCHROMIUM();
4496 4494
4497 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(fence_sync)) 4495 EXPECT_CALL(*gpu_control_, IsFenceSyncRelease(fence_sync))
4498 .WillOnce(Return(true)); 4496 .WillOnce(Return(true));
4499 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(fence_sync)) 4497 EXPECT_CALL(*gpu_control_, IsFenceSyncFlushReceived(fence_sync))
4500 .WillOnce(Return(true)); 4498 .WillOnce(Return(true));
4501 EXPECT_CALL(*gpu_control_, GetNamespaceID()).WillOnce(Return(GPU_IO)); 4499 EXPECT_CALL(*gpu_control_, GetNamespaceID()).WillOnce(Return(GPU_IO));
4502 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()).WillOnce(Return(0)); 4500 EXPECT_CALL(*gpu_control_, GetExtraCommandBufferData()).WillOnce(Return(0));
(...skipping 16 matching lines...) Expand all
4519 GpuControlClient* gl_as_client = gl_; 4517 GpuControlClient* gl_as_client = gl_;
4520 gl_as_client->OnGpuControlLostContext(); 4518 gl_as_client->OnGpuControlLostContext();
4521 4519
4522 // When GpuControl runs the callback, the original callback we gave to 4520 // When GpuControl runs the callback, the original callback we gave to
4523 // GLES2Implementation is *not* run, since the context is lost and we 4521 // GLES2Implementation is *not* run, since the context is lost and we
4524 // have already run the lost context callback. 4522 // have already run the lost context callback.
4525 signal_closure.Run(); 4523 signal_closure.Run();
4526 EXPECT_EQ(0, signaled_count); 4524 EXPECT_EQ(0, signaled_count);
4527 } 4525 }
4528 4526
4527 TEST_F(GLES2ImplementationTest, ReportLoss) {
4528 GpuControlClient* gl_as_client = gl_;
4529 int lost_count = 0;
4530 gl_->SetLostContextCallback(base::Bind(&CountCallback, &lost_count));
4531 EXPECT_EQ(0, lost_count);
4532
4533 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR());
4534 gl_as_client->OnGpuControlLostContext();
4535 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR());
4536 // The lost context callback should be run when GLES2Implementation is
4537 // notified of the loss.
4538 EXPECT_EQ(1, lost_count);
4539 }
4540
4541 TEST_F(GLES2ImplementationTest, ReportLossReentrant) {
4542 GpuControlClient* gl_as_client = gl_;
4543 int lost_count = 0;
4544 gl_->SetLostContextCallback(base::Bind(&CountCallback, &lost_count));
4545 EXPECT_EQ(0, lost_count);
4546
4547 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR());
4548 gl_as_client->OnGpuControlLostContextMaybeReentrant();
4549 EXPECT_NE(static_cast<GLenum>(GL_NO_ERROR), gl_->GetGraphicsResetStatusKHR());
4550 // The lost context callback should not be run yet to avoid calling back into
4551 // clients re-entrantly, and having them re-enter GLES2Implementation.
4552 EXPECT_EQ(0, lost_count);
4553 }
4554
4529 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { 4555 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) {
4530 ContextInitOptions init_options; 4556 ContextInitOptions init_options;
4531 init_options.lose_context_when_out_of_memory = true; 4557 init_options.lose_context_when_out_of_memory = true;
4532 ASSERT_TRUE(Initialize(init_options)); 4558 ASSERT_TRUE(Initialize(init_options));
4533 4559
4534 struct Cmds { 4560 struct Cmds {
4535 cmds::LoseContextCHROMIUM cmd; 4561 cmds::LoseContextCHROMIUM cmd;
4536 }; 4562 };
4537 4563
4538 GLsizei max = std::numeric_limits<GLsizei>::max(); 4564 GLsizei max = std::numeric_limits<GLsizei>::max();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4581 ContextInitOptions init_options; 4607 ContextInitOptions init_options;
4582 init_options.transfer_buffer_initialize_fail = true; 4608 init_options.transfer_buffer_initialize_fail = true;
4583 EXPECT_FALSE(Initialize(init_options)); 4609 EXPECT_FALSE(Initialize(init_options));
4584 } 4610 }
4585 4611
4586 #include "base/macros.h" 4612 #include "base/macros.h"
4587 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 4613 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
4588 4614
4589 } // namespace gles2 4615 } // namespace gles2
4590 } // namespace gpu 4616 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/client/gpu_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698