Bug 1427088 - Don't rely on glGetStringi just because it exists. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 08 Jan 2018 12:35:04 -0800
changeset 452617 722f664d592a2a9a6439260362e951dc76ceb950
parent 452616 65df1e9c2132d65af3c5bff54c0d63fbd205a6aa
child 452618 453a923a261c9ef664778e7c548cffd18b3abcf1
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaoshengmu
bugs1427088
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427088 - Don't rely on glGetStringi just because it exists. - r=daoshengmu MozReview-Commit-ID: Gmf6phqDOTK
gfx/gl/GLContext.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1651,38 +1651,41 @@ GLContext::DebugCallback(GLenum source,
 
 void
 GLContext::InitExtensions()
 {
     MOZ_ASSERT(IsCurrent());
 
     std::vector<nsCString> driverExtensionList;
 
-    if (mSymbols.fGetStringi) {
-        GLuint count = 0;
-        GetUIntegerv(LOCAL_GL_NUM_EXTENSIONS, &count);
-        for (GLuint i = 0; i < count; i++) {
-            // This is UTF-8.
-            const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS, i);
-
-            // We CANNOT use nsDependentCString here, because the spec doesn't guarantee
-            // that the pointers returned are different, only that their contents are.
-            // On Flame, each of these index string queries returns the same address.
-            driverExtensionList.push_back(nsCString(rawExt));
+    [&]() {
+        if (mSymbols.fGetStringi) {
+            GLuint count = 0;
+            if (GetPotentialInteger(LOCAL_GL_NUM_EXTENSIONS, (GLint*)&count)) {
+                for (GLuint i = 0; i < count; i++) {
+                    // This is UTF-8.
+                    const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS, i);
+
+                    // We CANNOT use nsDependentCString here, because the spec doesn't guarantee
+                    // that the pointers returned are different, only that their contents are.
+                    // On Flame, each of these index string queries returns the same address.
+                    driverExtensionList.push_back(nsCString(rawExt));
+                }
+                return;
+            }
         }
-    } else {
-        MOZ_ALWAYS_TRUE(!fGetError());
+
         const char* rawExts = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
-        MOZ_ALWAYS_TRUE(!fGetError());
-
         if (rawExts) {
             nsDependentCString exts(rawExts);
             SplitByChar(exts, ' ', &driverExtensionList);
         }
-    }
+    }();
+    const auto err = fGetError();
+    MOZ_ALWAYS_TRUE(!err);
 
     const bool shouldDumpExts = ShouldDumpExts();
     if (shouldDumpExts) {
         printf_stderr("%i GL driver extensions: (*: recognized)\n",
                       (uint32_t)driverExtensionList.size());
     }
 
     MarkBitfieldByStrings(driverExtensionList, shouldDumpExts, sExtensionNames,