Closed Bug 686083 Opened 13 years ago Closed 13 years ago

No way to switch between GL implementations for WebGL

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: jgilbert, Assigned: jgilbert)

References

Details

Attachments

(1 file, 4 obsolete files)

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)
A way of disabling each implementation would allow implementations below it to be tested.
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.
A hidden pref was my thought. It would help with testing and assuring that all the branches pass conformance tests while making changes.
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.
Attachment #560487 - Flags: review?(bjacob)
OS: Windows 7 → All
Summary: No way to switch between GL implementations for WebGL on Windows → No way to switch between GL implementations for WebGL
There's a need for a parallel pref for Mac's CGL path, so I added "cgl.prefer-fbo" to enable that.
Attachment #562893 - Flags: review?
Attachment #560487 - Attachment is obsolete: true
Attachment #562893 - Attachment is obsolete: true
Attachment #560487 - Flags: review?(bjacob)
Attachment #562893 - Flags: review?
Attachment #562895 - Flags: review?(bjacob)
Blocks: 689822
Blocks: 615976
Attachment #562895 - Flags: review?(bjacob) → review+
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);
Derp, that didn't do what I thought it would do.

There are some tabs which snuck in to the patch. Will reupload shortly.
Here's the patch with the tabs fixed.
Carryover r+ from bjacob, updated to include conversion from PRBool to bool.
Attachment #562895 - Attachment is obsolete: true
Attachment #567414 - Attachment is obsolete: true
Attachment #567826 - Flags: review+
Re-landed with proper commit message (sorry, should have checked that):
http://hg.mozilla.org/integration/mozilla-inbound/rev/f5f1228fc7ab
https://hg.mozilla.org/mozilla-central/rev/f5f1228fc7ab
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: