Commit 5b7348a8 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

gpu: Invalidate the fence if context is lost.

Make sure to invalidate the fence if context was lost, so that it
doesn't attempt to make gl calls during tear down.

BUG=777594

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I0722193e020fe01483d55e17d640a99061cdb7ea
Reviewed-on: https://chromium-review.googlesource.com/747381
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512929}
parent b98dec1d
......@@ -228,6 +228,62 @@ TEST_P(GLES2DecoderLostContextTest, TextureDestroyAfterLostFromMakeCurrent) {
ClearCurrentDecoderError();
}
TEST_P(GLES2DecoderLostContextTest, QueryDestroyAfterLostFromMakeCurrent) {
InitState init;
init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync";
init.gl_version = "2.0";
init.has_alpha = true;
init.request_alpha = true;
init.bind_generates_resource = true;
InitDecoder(init);
const GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef);
GenHelper<GenQueriesEXTImmediate>(kNewClientId);
BeginQueryEXT begin_cmd;
begin_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, kNewClientId,
shared_memory_id_, kSharedMemoryOffset);
EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
QueryManager* query_manager = decoder_->GetQueryManager();
ASSERT_TRUE(query_manager != nullptr);
QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
ASSERT_TRUE(query != nullptr);
EXPECT_FALSE(query->IsPending());
EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation();
EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0))
.WillOnce(Return(kGlSync))
.RetiresOnSaturation();
#if DCHECK_IS_ON()
EXPECT_CALL(*gl_, IsSync(kGlSync))
.WillOnce(Return(GL_TRUE))
.RetiresOnSaturation();
#endif
EndQueryEXT end_cmd;
end_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, 1);
EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
#if DCHECK_IS_ON()
EXPECT_CALL(*gl_, IsSync(kGlSync)).Times(0).RetiresOnSaturation();
#endif
EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(0).RetiresOnSaturation();
// Force context lost for MakeCurrent().
EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(false));
// Expect the group to be lost.
EXPECT_CALL(*mock_decoder_, MarkContextLost(error::kUnknown)).Times(1);
decoder_->MakeCurrent();
EXPECT_TRUE(decoder_->WasContextLost());
EXPECT_EQ(error::kMakeCurrentFailed, GetContextLostReason());
ClearCurrentDecoderError();
ResetDecoder();
}
TEST_P(GLES2DecoderLostContextTest, LostFromResetAfterMakeCurrent) {
Init(true); // with robustness
InSequence seq;
......
......@@ -482,8 +482,7 @@ void CommandsCompletedQuery::Resume() {
void CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) {
if (fence_ && fence_->ResetSupported()) {
fence_->ResetState();
}
else {
} else {
fence_.reset(gl::GLFence::Create());
}
DCHECK(fence_);
......@@ -509,6 +508,8 @@ void CommandsCompletedQuery::Destroy(bool have_context) {
if (have_context && !IsDeleted()) {
fence_.reset();
MarkAsDeleted();
} else if (fence_ && !have_context) {
fence_->Invalidate();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment