Commit 446ae0b1 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Avoid state restoration if context lost

crbug.com/1061442 suggests that it is unwise to do a virtual context
switch after the underlying context is lost. This CL prevents that.

Bug: 1061442
Change-Id: I7143836d0591c2a7f0a291b66f60b4f46d84c5f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231285Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775208}
parent d05779b4
......@@ -87,10 +87,12 @@ void GLContextVirtual::SetSafeToForceGpuSwitch() {
}
unsigned int GLContextVirtual::CheckStickyGraphicsResetStatus() {
// Don't pretend we know which one of the virtual contexts was responsible.
unsigned int reset_status = shared_context_->CheckStickyGraphicsResetStatus();
return reset_status == GL_NO_ERROR ? GL_NO_ERROR
: GL_UNKNOWN_CONTEXT_RESET_ARB;
if (reset_status == GL_NO_ERROR)
return GL_NO_ERROR;
shared_context_->MarkVirtualContextLost();
// Don't pretend we know which one of the virtual contexts was responsible.
return GL_UNKNOWN_CONTEXT_RESET_ARB;
}
void GLContextVirtual::SetUnbindFboOnMakeCurrent() {
......
......@@ -392,6 +392,9 @@ bool GLContext::MakeVirtuallyCurrent(
GLContext* virtual_context, GLSurface* surface) {
if (!ForceGpuSwitchIfNeeded())
return false;
if (virtual_context_lost_)
return false;
bool switched_real_contexts = GLContext::GetRealCurrent() != this;
if (switched_real_contexts || !surface->IsCurrent()) {
GLSurface* current_surface = GLSurface::GetCurrent();
......@@ -401,6 +404,7 @@ bool GLContext::MakeVirtuallyCurrent(
if (switched_real_contexts || !current_surface ||
!virtual_context->IsCurrent(surface)) {
if (!MakeCurrent(surface)) {
virtual_context_lost_ = true;
return false;
}
}
......@@ -441,6 +445,7 @@ bool GLContext::MakeVirtuallyCurrent(
virtual_context->SetCurrent(surface);
if (!surface->OnMakeCurrent(virtual_context)) {
LOG(ERROR) << "Could not make GLSurface current.";
virtual_context_lost_ = true;
return false;
}
return true;
......
......@@ -277,6 +277,8 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
void DestroyBackpressureFences();
#endif
void MarkVirtualContextLost() { virtual_context_lost_ = true; }
private:
friend class base::RefCounted<GLContext>;
......@@ -309,6 +311,9 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
bool state_dirtied_externally_ = false;
std::unique_ptr<GLStateRestorer> state_restorer_;
std::unique_ptr<GLVersionInfo> version_info_;
// This bit allows us to avoid virtual context state restoration in the case
// where this underlying context becomes lost. https://crbug.com/1061442
bool virtual_context_lost_ = false;
#if defined(OS_MACOSX)
std::map<uint64_t, std::unique_ptr<GLFence>> backpressure_fences_;
......
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