From b49114bad6ac9348110352187e678d7b07420cbc Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 22 Dec 2015 15:53:51 -0600 Subject: [PATCH] GLContext: Keep track of robust access support for WasLost --- src/xenia/ui/gl/gl_context.cc | 21 ++++++++++++--------- src/xenia/ui/gl/gl_context.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/xenia/ui/gl/gl_context.cc b/src/xenia/ui/gl/gl_context.cc index cc40e161d..7a3da67c1 100644 --- a/src/xenia/ui/gl/gl_context.cc +++ b/src/xenia/ui/gl/gl_context.cc @@ -133,16 +133,15 @@ bool GLContext::Initialize(GLContext* share_context) { return false; } - bool robust_access_supported = false; if (GLEW_ARB_robustness) { - robust_access_supported = true; + robust_access_supported_ = true; } int context_flags = 0; if (FLAGS_gl_debug) { context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB; } - if (robust_access_supported) { + if (robust_access_supported_) { context_flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB; } @@ -156,7 +155,7 @@ bool GLContext::Initialize(GLContext* share_context) { WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, - robust_access_supported ? WGL_LOSE_CONTEXT_ON_RESET_ARB : 0, + robust_access_supported_ ? WGL_LOSE_CONTEXT_ON_RESET_ARB : 0, 0}; glrc_ = wglCreateContextAttribsARB( @@ -207,15 +206,12 @@ std::unique_ptr GLContext::CreateOffscreen( { GraphicsContextLock context_lock(parent_context); - bool robust_access_supported = false; - if (GLEW_ARB_robustness) { - robust_access_supported = true; - } - int context_flags = 0; if (FLAGS_gl_debug) { context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB; } + + bool robust_access_supported = parent_context->robust_access_supported_; if (robust_access_supported) { context_flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB; } @@ -245,6 +241,8 @@ std::unique_ptr GLContext::CreateOffscreen( new_context->glrc_ = new_glrc; new_context->dc_ = GetDC(HWND(parent_context->target_window_->native_handle())); + new_context->robust_access_supported_ = + parent_context->robust_access_supported_; if (!new_context->MakeCurrent()) { FatalGLError("Could not make new GL context current."); return nullptr; @@ -473,6 +471,11 @@ void GLContext::ClearCurrent() { } bool GLContext::WasLost() { + if (!robust_access_supported_) { + // Can't determine if we lost the context. + return false; + } + if (context_lost_) { return true; } diff --git a/src/xenia/ui/gl/gl_context.h b/src/xenia/ui/gl/gl_context.h index 120ad4c03..a60e2d4ed 100644 --- a/src/xenia/ui/gl/gl_context.h +++ b/src/xenia/ui/gl/gl_context.h @@ -83,6 +83,7 @@ class GLContext : public GraphicsContext { std::unique_ptr immediate_drawer_; bool context_lost_ = false; + bool robust_access_supported_ = false; }; } // namespace gl