Bug 1523728 - Add gl.allow-high-power:true, webgl.default-low-power:false. r=lsalzman

Also, if "Use hardware acceleration when available" is disabled, restrict webgl to the igpu.

Differential Revision: https://phabricator.services.mozilla.com/D19059

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Gilbert 2019-02-07 22:35:50 +00:00
parent 9c9113ab81
commit 092d1d6c89
4 changed files with 22 additions and 2 deletions

View file

@ -9,6 +9,7 @@
#include <queue>
#include "AccessCheck.h"
#include "gfxConfig.h"
#include "gfxContext.h"
#include "gfxCrashReporterUtils.h"
#include "gfxPattern.h"
@ -483,6 +484,10 @@ bool WebGLContext::CreateAndInitGL(
case dom::WebGLPowerPreference::Low_power:
break;
case dom::WebGLPowerPreference::High_performance:
flags |= gl::CreateContextFlags::HIGH_POWER;
break;
// Eventually add a heuristic, but for now default to high-performance.
// We can even make it dynamic by holding on to a
// ForceDiscreteGPUHelperCGL iff we decide it's a high-performance
@ -491,12 +496,18 @@ bool WebGLContext::CreateAndInitGL(
// - Many draw calls
// - Same origin with root page (try to stem bleeding from WebGL
// ads/trackers)
case dom::WebGLPowerPreference::High_performance:
default:
flags |= gl::CreateContextFlags::HIGH_POWER;
if (!gfxPrefs::WebGLDefaultLowPower()) {
flags |= gl::CreateContextFlags::HIGH_POWER;
}
break;
}
// If "Use hardware acceleration when available" option is disabled:
if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
flags &= ~gl::CreateContextFlags::HIGH_POWER;
}
#ifdef XP_MACOSX
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
nsString vendorID, deviceID;

View file

@ -225,6 +225,9 @@ static already_AddRefed<GLContextCGL> CreateOffscreenFBOContext(CreateContextFla
std::vector<NSOpenGLPixelFormatAttribute> attribs;
if (!gfxPrefs::GLAllowHighPower()) {
flags &= ~CreateContextFlags::HIGH_POWER;
}
if (flags & CreateContextFlags::ALLOW_OFFLINE_RENDERER ||
!(flags & CreateContextFlags::HIGH_POWER)) {
// This is really poorly named on Apple's part, but "AllowOfflineRenderers" means

View file

@ -558,6 +558,7 @@ class gfxPrefs final {
// Use vsync events generated by hardware
DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true);
DECL_GFX_PREF(Live, "gl.allow-high-power", GLAllowHighPower, bool, true);
DECL_GFX_PREF(Live, "gl.ignore-dx-interop2-blacklist", IgnoreDXInterop2Blacklist, bool, false);
DECL_GFX_PREF(Live, "gl.msaa-level", MSAALevel, uint32_t, 2);
#if defined(XP_MACOSX)
@ -595,6 +596,8 @@ class gfxPrefs final {
DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabledDoNotUseDirectly, bool, false);
// Instead, use gfxConfig::IsEnabled(Feature::HW_COMPOSITING).
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false);
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false);
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false);
@ -790,6 +793,7 @@ class gfxPrefs final {
DECL_GFX_PREF(Live, "webgl.angle.force-warp", WebGLANGLEForceWARP, bool, false);
DECL_GFX_PREF(Live, "webgl.bypass-shader-validation", WebGLBypassShaderValidator, bool, true);
DECL_GFX_PREF(Live, "webgl.can-lose-context-in-foreground", WebGLCanLoseContextInForeground, bool, true);
DECL_GFX_PREF(Live, "webgl.default-low-power", WebGLDefaultLowPower, bool, false);
DECL_GFX_PREF(Live, "webgl.default-no-alpha", WebGLDefaultNoAlpha, bool, false);
DECL_GFX_PREF(Live, "webgl.disable-angle", WebGLDisableANGLE, bool, false);
DECL_GFX_PREF(Live, "webgl.disable-wgl", WebGLDisableWGL, bool, false);

View file

@ -4836,6 +4836,7 @@ pref("gl.multithreaded", true);
#endif
pref("gl.ignore-dx-interop2-blacklist", false);
pref("gl.use-tls-is-current", 0);
pref("gl.allow-high-power", true);
#ifdef XP_MACOSX
pref("webgl.1.allow-core-profiles", true);
@ -4850,6 +4851,7 @@ pref("webgl.min_capability_mode", false);
pref("webgl.disable-extensions", false);
pref("webgl.msaa-force", false);
pref("webgl.prefer-16bpp", false);
pref("webgl.default-low-power", false);
pref("webgl.default-no-alpha", false);
pref("webgl.force-layers-readback", false);
pref("webgl.force-index-validation", 0);