From 3672cb1c5e46f7e0359d9ec376679f582e128476 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Tue, 7 Mar 2017 14:10:09 -0800 Subject: [PATCH] Bug 1339256 - Double-check robustness. - r=daoshengmu MozReview-Commit-ID: 20csUTf7q6e --- gfx/gl/GLContext.cpp | 21 ++++++++++++++++++++- gfx/gl/GLDefs.h | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index 22d85c1f514e..c0a6f5aa60fd 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -1009,6 +1009,11 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl) //////////////// + const auto err = mSymbols.fGetError(); + MOZ_RELEASE_ASSERT(!err); + if (err) + return false; + LoadMoreSymbols(prefix, trygl); //////////////////////////////////////////////////////////////////////////// @@ -1145,6 +1150,14 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl) return fnLoadForFeature(list, feature); }; + if (IsSupported(GLFeature::robustness)) { + const auto resetStrategy = GetIntAs(LOCAL_GL_RESET_NOTIFICATION_STRATEGY); + if (resetStrategy != LOCAL_GL_LOSE_CONTEXT_ON_RESET) { + MOZ_ASSERT(resetStrategy == LOCAL_GL_NO_RESET_NOTIFICATION); + NS_WARNING("Robustness supported, but not active!"); + MarkUnsupported(GLFeature::robustness); + } + } if (IsSupported(GLFeature::robustness)) { const SymLoadStruct symbols[] = { { (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatus", @@ -1154,7 +1167,13 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl) nullptr } }, END_SYMBOLS }; - fnLoadForFeature(symbols, GLFeature::sync); + if (fnLoadForFeature(symbols, GLFeature::robustness)) { + const auto status = mSymbols.fGetGraphicsResetStatus(); + MOZ_ALWAYS_TRUE(!status); + + const auto err = mSymbols.fGetError(); + MOZ_ALWAYS_TRUE(!err); + } } if (IsSupported(GLFeature::sync)) { diff --git a/gfx/gl/GLDefs.h b/gfx/gl/GLDefs.h index 10b6782e192f..a46c201b78df 100644 --- a/gfx/gl/GLDefs.h +++ b/gfx/gl/GLDefs.h @@ -81,7 +81,9 @@ // Others #define LOCAL_EGL_PRESERVED_RESOURCES 0x3030 #define LOCAL_EGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define LOCAL_GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define LOCAL_GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define LOCAL_GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define LOCAL_GL_NO_RESET_NOTIFICATION 0x8261 #define LOCAL_GL_CONTEXT_LOST 0x9242 #define LOCAL_GL_CONTEXT_FLAGS_ARB 0x2094 #define LOCAL_GL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001