Last Comment Bug 686083 - No way to switch between GL implementations for WebGL
: No way to switch between GL implementations for WebGL
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Canvas: WebGL (show other bugs)
: unspecified
: x86 All
: -- normal (vote)
: mozilla10
Assigned To: Jeff Gilbert [:jgilbert]
:
Mentors:
: 723074 (view as bug list)
Depends on:
Blocks: 615976 689822
  Show dependency treegraph
 
Reported: 2011-09-09 19:15 PDT by Jeff Gilbert [:jgilbert]
Modified: 2012-02-01 08:05 PST (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Adds pref "wgl.prefer-fbo" (def: false) (1.42 KB, patch)
2011-09-15 16:34 PDT, Jeff Gilbert [:jgilbert]
no flags Details | Diff | Splinter Review
Adds wgl.prefer-fbo and cgl.prefer-fbo (3.16 KB, patch)
2011-09-27 15:54 PDT, Jeff Gilbert [:jgilbert]
no flags Details | Diff | Splinter Review
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo (3.16 KB, patch)
2011-09-27 15:55 PDT, Jeff Gilbert [:jgilbert]
jacob.benoit.1: review+
Details | Diff | Splinter Review
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo (without tabs) (3.20 KB, patch)
2011-10-17 03:43 PDT, Jeff Gilbert [:jgilbert]
no flags Details | Diff | Splinter Review
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo (3.17 KB, patch)
2011-10-18 12:03 PDT, Jeff Gilbert [:jgilbert]
jgilbert: review+
Details | Diff | Splinter Review

Description Jeff Gilbert [:jgilbert] 2011-09-09 19:15:57 PDT
The implementations are tried in order, falling back to the next in line if an implementation fails to initialize. If one's system supports the first implementation, it's not possible to try other (later) implementations even if they are also supported by the system.

For windows, the order is:
ANGLE+EGL
WGL (PBuffers)
WGL (FBOs)
Comment 1 Jeff Gilbert [:jgilbert] 2011-09-09 19:16:54 PDT
A way of disabling each implementation would allow implementations below it to be tested.
Comment 2 Benoit Jacob [:bjacob] (mostly away) 2011-09-09 19:46:26 PDT
We have webgl.prefer_native_gl in about:config, but we don't have a way of selecting between WGL+PBuffers and WGL+FBOs. But I think this is a bit too internal to warrant a pref. If you think this is useful, maybe the right balance is to make it a hidden pref: query it in c++ code like any other pref, but don't list it in all.js so that it doesn't show up in about:config unless the user explicitly created it.
Comment 3 Jeff Gilbert [:jgilbert] 2011-09-11 02:42:21 PDT
A hidden pref was my thought. It would help with testing and assuring that all the branches pass conformance tests while making changes.
Comment 4 Jeff Gilbert [:jgilbert] 2011-09-15 16:34:37 PDT
Created attachment 560487 [details] [diff] [review]
Adds pref "wgl.prefer-fbo" (def: false)

Simple patch. Just adds a hidden pref called "wgl.prefer-fbo" which defaults to false (usually, we try PBuffers first, and only use FBOs if PBuffers fails to initialize). When enabled, it skips trying PBuffers, and tries FBOs.
Comment 5 Jeff Gilbert [:jgilbert] 2011-09-27 15:54:09 PDT
There's a need for a parallel pref for Mac's CGL path, so I added "cgl.prefer-fbo" to enable that.
Comment 6 Jeff Gilbert [:jgilbert] 2011-09-27 15:54:49 PDT
Created attachment 562893 [details] [diff] [review]
Adds wgl.prefer-fbo and cgl.prefer-fbo
Comment 7 Jeff Gilbert [:jgilbert] 2011-09-27 15:55:58 PDT
Created attachment 562895 [details] [diff] [review]
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo
Comment 8 Jeff Gilbert [:jgilbert] 2011-09-27 20:27:03 PDT
Try run: https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=bb7dd7636b4c
Comment 9 Jeff Gilbert [:jgilbert] 2011-10-17 03:38:37 PDT
Comment on attachment 562895 [details] [diff] [review]
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo

>From: Jeff Gilbert <jgilbert@mozilla.com>
>Fix for 686083: Adds method to disable GL implementations
>
>diff --git a/gfx/thebes/GLContextProviderCGL.mm b/gfx/thebes/GLContextProviderCGL.mm
>--- a/gfx/thebes/GLContextProviderCGL.mm
>+++ b/gfx/thebes/GLContextProviderCGL.mm
>@@ -41,16 +41,17 @@
> #include <OpenGL/gl.h>
> #include <AppKit/NSOpenGL.h>
> #include "gfxASurface.h"
> #include "gfxImageSurface.h"
> #include "gfxQuartzSurface.h"
> #include "gfxPlatform.h"
> #include "gfxFailure.h"
> #include "prenv.h"
>+#include "mozilla/Preferences.h"
> 
> namespace mozilla {
> namespace gl {
> 
> static PRBool gUseDoubleBufferedWindows = PR_TRUE;
> 
> class CGLLibrary
> {
>@@ -553,26 +554,31 @@ CreateOffscreenFBOContext(const gfxIntSi
>     return glContext.forget();
> }
> 
> already_AddRefed<GLContext>
> GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
>                                       const ContextFormat& aFormat)
> {
>     nsRefPtr<GLContextCGL> glContext;
>-
>-    glContext = CreateOffscreenPBufferContext(aSize, aFormat);
>-    if (glContext &&
>-        glContext->Init())
>+	
>+    NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
>+    PRBool preferFBOs = Preferences::GetBool("cgl.prefer-fbo", PR_FALSE);
>+    if (!preferFBOs)
>     {
>-        glContext->mOffscreenSize = aSize;
>-        glContext->mOffscreenActualSize = aSize;
>-
>-        return glContext.forget();
>-    }
>+        glContext = CreateOffscreenPBufferContext(aSize, aFormat);
>+        if (glContext &&
>+            glContext->Init())
>+        {
>+            glContext->mOffscreenSize = aSize;
>+            glContext->mOffscreenActualSize = aSize;
>+    
>+            return glContext.forget();
>+        }
>+    }
> 
>     // try a FBO as second choice
>     glContext = CreateOffscreenFBOContext(aSize, aFormat);
>     if (glContext &&
>         glContext->Init() &&
>         glContext->ResizeOffscreenFBO(aSize))
>     {
>         return glContext.forget();
>diff --git a/gfx/thebes/GLContextProviderWGL.cpp b/gfx/thebes/GLContextProviderWGL.cpp
>--- a/gfx/thebes/GLContextProviderWGL.cpp
>+++ b/gfx/thebes/GLContextProviderWGL.cpp
>@@ -43,16 +43,18 @@
> #include "gfxImageSurface.h"
> #include "gfxPlatform.h"
> #include "gfxWindowsSurface.h"
> 
> #include "gfxCrashReporterUtils.h"
> 
> #include "prenv.h"
> 
>+#include "mozilla/Preferences.h"
>+
> namespace mozilla {
> namespace gl {
> 
> WGLLibrary sWGLLibrary;
> 
> static HWND gSharedWindow = 0;
> static HDC gSharedWindowDC = 0;
> static HGLRC gSharedWindowGLContext = 0;
>@@ -611,17 +613,20 @@ GLContextProviderWGL::CreateOffscreen(co
>     if (!sWGLLibrary.EnsureInitialized()) {
>         return nsnull;
>     }
> 
>     nsRefPtr<GLContextWGL> glContext;
> 
>     // Always try to create a pbuffer context first, because we
>     // want the context isolation.
>-    if (sWGLLibrary.fCreatePbuffer &&
>+    NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
>+    PRBool preferFBOs = Preferences::GetBool("wgl.prefer-fbo", PR_FALSE);
>+    if (!preferFBOs &&
>+        sWGLLibrary.fCreatePbuffer &&
>         sWGLLibrary.fChoosePixelFormat)
>     {
>         glContext = CreatePBufferOffscreenContext(aSize, aFormat);
>     }
> 
>     // If it failed, then create a window context and use a FBO.
>     if (!glContext) {
>         glContext = CreateWindowOffscreenContext(aSize, aFormat);
Comment 10 Jeff Gilbert [:jgilbert] 2011-10-17 03:40:14 PDT
Derp, that didn't do what I thought it would do.

There are some tabs which snuck in to the patch. Will reupload shortly.
Comment 11 Jeff Gilbert [:jgilbert] 2011-10-17 03:43:23 PDT
Created attachment 567414 [details] [diff] [review]
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo (without tabs)

Here's the patch with the tabs fixed.
Comment 12 Jeff Gilbert [:jgilbert] 2011-10-18 12:03:37 PDT
Created attachment 567826 [details] [diff] [review]
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo

Carryover r+ from bjacob, updated to include conversion from PRBool to bool.
Comment 13 Benoit Jacob [:bjacob] (mostly away) 2011-10-19 12:12:34 PDT
http://hg.mozilla.org/integration/mozilla-inbound/rev/30454fc8f442
Comment 14 Benoit Jacob [:bjacob] (mostly away) 2011-10-19 12:40:27 PDT
Re-landed with proper commit message (sorry, should have checked that):
http://hg.mozilla.org/integration/mozilla-inbound/rev/f5f1228fc7ab
Comment 15 Marco Bonardo [::mak] (Away 6-20 Aug) 2011-10-20 03:02:47 PDT
https://hg.mozilla.org/mozilla-central/rev/f5f1228fc7ab
Comment 16 Jeff Gilbert [:jgilbert] 2012-02-01 08:05:06 PST
*** Bug 723074 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.