Bug 1339256 - Double-check robustness. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 07 Mar 2017 14:10:09 -0800
changeset 496211 bf521165d8c04c856c8218998ce52220e257bff4
parent 496210 189e4e3017f93f6d4b6c6ac56c05fe401bdd4c29
child 496212 3b5877718f5b8e623bc166e1fe26f43771be1881
push id48558
push userbmo:jgilbert@mozilla.com
push dateFri, 10 Mar 2017 00:02:25 +0000
reviewersdaoshengmu
bugs1339256
milestone55.0a1
Bug 1339256 - Double-check robustness. - r=daoshengmu MozReview-Commit-ID: 20csUTf7q6e
gfx/gl/GLContext.cpp
gfx/gl/GLDefs.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1004,16 +1004,21 @@ GLContext::InitWithPrefixImpl(const char
     {
         NS_ERROR("GLContext requires support for framebuffer objects.");
         return false;
     }
     MOZ_RELEASE_ASSERT(mSymbols.fBindFramebuffer, "GFX: mSymbols.fBindFramebuffer zero or not set.");
 
     ////////////////
 
+    const auto err = mSymbols.fGetError();
+    MOZ_RELEASE_ASSERT(!err);
+    if (err)
+        return false;
+
     LoadMoreSymbols(prefix, trygl);
 
     ////////////////////////////////////////////////////////////////////////////
 
     raw_fGetIntegerv(LOCAL_GL_VIEWPORT, mViewportRect);
     raw_fGetIntegerv(LOCAL_GL_SCISSOR_BOX, mScissorRect);
     raw_fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
     raw_fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mMaxCubeMapTextureSize);
@@ -1141,25 +1146,39 @@ GLContext::LoadMoreSymbols(const char* p
                                                               GLFeature feature)
     {
         const bool useCore = this->IsFeatureProvidedByCoreSymbols(feature);
         const auto list = useCore ? coreList : extList;
         return fnLoadForFeature(list, feature);
     };
 
     if (IsSupported(GLFeature::robustness)) {
+        const auto resetStrategy = GetIntAs<GLuint>(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",
                                                                 "GetGraphicsResetStatusARB",
                                                                 "GetGraphicsResetStatusKHR",
                                                                 "GetGraphicsResetStatusEXT",
                                                                 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)) {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fFenceSync,      { "FenceSync",      nullptr } },
             { (PRFuncPtr*) &mSymbols.fIsSync,         { "IsSync",         nullptr } },
             { (PRFuncPtr*) &mSymbols.fDeleteSync,     { "DeleteSync",     nullptr } },
             { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "ClientWaitSync", nullptr } },
--- a/gfx/gl/GLDefs.h
+++ b/gfx/gl/GLDefs.h
@@ -76,16 +76,18 @@
 #define LOCAL_WGL_ACCESS_WRITE_DISCARD                  0x0002
 
 // GL_KHR_robustness
 #define LOCAL_GL_CONTEXT_ROBUST_ACCESS                  0x90F3
 
 // 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
 #define LOCAL_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB  0x00000002
 #define LOCAL_GL_CONTEXT_ROBUST_ACCESS_BIT_ARB          0x00000004
 
 #endif