No way to switch between GL implementations for WebGL

RESOLVED FIXED in mozilla10

Status

()

Core
Canvas: WebGL
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: jgilbert, Assigned: jgilbert)

Tracking

unspecified
mozilla10
x86
All
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 4 obsolete attachments)

(Assignee)

Description

6 years ago
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)
(Assignee)

Comment 1

6 years ago
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.
(Assignee)

Comment 3

6 years ago
A hidden pref was my thought. It would help with testing and assuring that all the branches pass conformance tests while making changes.
(Assignee)

Comment 4

6 years ago
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.
Attachment #560487 - Flags: review?(bjacob)
(Assignee)

Updated

6 years ago
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
(Assignee)

Comment 5

6 years ago
There's a need for a parallel pref for Mac's CGL path, so I added "cgl.prefer-fbo" to enable that.
(Assignee)

Comment 6

6 years ago
Created attachment 562893 [details] [diff] [review]
Adds wgl.prefer-fbo and cgl.prefer-fbo
Attachment #562893 - Flags: review?
(Assignee)

Comment 7

6 years ago
Created attachment 562895 [details] [diff] [review]
Adds hidden prefs wgl.prefer-fbo and cgl.prefer-fbo
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)
(Assignee)

Updated

6 years ago
Blocks: 689822
(Assignee)

Comment 8

6 years ago
Try run: https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=bb7dd7636b4c
(Assignee)

Updated

6 years ago
Blocks: 615976
Attachment #562895 - Flags: review?(bjacob) → review+
(Assignee)

Comment 9

6 years ago
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);
(Assignee)

Comment 10

6 years ago
Derp, that didn't do what I thought it would do.

There are some tabs which snuck in to the patch. Will reupload shortly.
(Assignee)

Comment 11

6 years ago
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.
(Assignee)

Comment 12

6 years ago
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.
Attachment #562895 - Attachment is obsolete: true
Attachment #567414 - Attachment is obsolete: true
Attachment #567826 - Flags: review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/30454fc8f442
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
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
(Assignee)

Updated

6 years ago
Duplicate of this bug: 723074
You need to log in before you can comment on or make changes to this bug.