Bug 912196. Add support for ANGLE D3D11 path. r=jgilbert
There are currently problems with the color format chosen
which breaks MSAA resolution. But we might as well land this
now.
--- a/gfx/gl/GLConsts.h
+++ b/gfx/gl/GLConsts.h
@@ -5182,16 +5182,18 @@
#define LOCAL_EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
#define LOCAL_EGL_CORE_NATIVE_ENGINE 0x305B
#define LOCAL_EGL_COVERAGE_BUFFERS_NV 0x30E0
#define LOCAL_EGL_COVERAGE_SAMPLES_NV 0x30E1
#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
#define LOCAL_EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
+#define LOCAL_EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2)
+#define LOCAL_EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3)
#define LOCAL_EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
#define LOCAL_EGL_DEPTH_ENCODING_NONE_NV 0
#define LOCAL_EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
#define LOCAL_EGL_DEPTH_ENCODING_NV 0x30E2
#define LOCAL_EGL_DEPTH_SIZE 0x3025
#define LOCAL_EGL_DISCARD_SAMPLES_ARM 0x3286
#define LOCAL_EGL_DISPLAY_SCALING 10000
#define LOCAL_EGL_DMA_BUF_PLANE0_FD_EXT 0x3272
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1735,20 +1735,19 @@ GLContext::UpdatePixelFormat()
#ifdef DEBUG
const SurfaceCaps& caps = Caps();
MOZ_ASSERT(!caps.any, "Did you forget to DetermineCaps()?");
MOZ_ASSERT(caps.color == !!format.red);
MOZ_ASSERT(caps.color == !!format.green);
MOZ_ASSERT(caps.color == !!format.blue);
- MOZ_ASSERT(caps.alpha == !!format.alpha);
-
// These we either must have if they're requested, or
// we can have if they're not.
+ MOZ_ASSERT(caps.alpha == !!format.alpha || !caps.alpha);
MOZ_ASSERT(caps.depth == !!format.depth || !caps.depth);
MOZ_ASSERT(caps.stencil == !!format.stencil || !caps.stencil);
MOZ_ASSERT(caps.antialias == (format.samples > 1));
#endif
mPixelFormat = new PixelBufferFormat(format);
}
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -227,17 +227,39 @@ GLLibraryEGL::EnsureInitialized()
GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0]);
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID,
"Couldn't find eglQueryStringImplementationANDROID");
#endif
- mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY);
+ mEGLDisplay = nullptr;
+
+#ifdef XP_WIN
+ // XXX we have no way of knowing if this is ANGLE, or if we're just using
+ // a native EGL on windows. We don't really do the latter right now, so
+ // let's assume it is ANGLE, and try our special types.
+
+ // D3D11 ANGLE only works with OMTC; there's a bug in the non-OMTC layer
+ // manager, and it's pointless to try to fix it. We also don't try D3D11
+ // ANGLE if the layer manager is prefering D3D9 (hrm, do we care?)
+ if (gfxPrefs::LayersOffMainThreadCompositionEnabled() &&
+ !gfxPrefs::LayersPreferD3D9())
+ {
+ if (gfxPrefs::WebGLANGLEForceD3D11()) {
+ mEGLDisplay = fGetDisplay(LOCAL_EGL_D3D11_ONLY_DISPLAY_ANGLE);
+ } else if (gfxPrefs::WebGLANGLETryD3D11()) {
+ mEGLDisplay = fGetDisplay(LOCAL_EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE);
+ }
+ }
+#endif
+
+ if (!mEGLDisplay)
+ mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY);
if (!fInitialize(mEGLDisplay, nullptr, nullptr))
return false;
const char *vendor = (const char*) fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR);
if (vendor && (strstr(vendor, "TransGaming") != 0 || strstr(vendor, "Google Inc.") != 0)) {
mIsANGLE = true;
}
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -299,16 +299,18 @@ private:
DECL_GFX_PREF(Live, "layout.event-regions.enabled", LayoutEventRegionsEnabled, bool, false);
DECL_GFX_PREF(Once, "layout.paint_rects_separately", LayoutPaintRectsSeparately, bool, true);
DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false);
DECL_GFX_PREF(Live, "ui.click_hold_context_menus.delay", UiClickHoldContextMenusDelay, int32_t, 500);
DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false);
+ DECL_GFX_PREF(Once, "webgl.angle.try-d3d11", WebGLANGLETryD3D11, bool, false);
+ DECL_GFX_PREF(Once, "webgl.angle.force-d3d11", WebGLANGLEForceD3D11, bool, false);
DECL_GFX_PREF(Once, "layers.stereo-video.enabled", StereoVideoEnabled, bool, false);
public:
// Manage the singleton:
static gfxPrefs& GetSingleton()
{
MOZ_ASSERT(!sInstanceHasBeenDestroyed, "Should never recreate a gfxPrefs instance!");
if (!sInstance) {
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -472,16 +472,20 @@ gfxWindowsPlatform::CreateDevice(nsRefPt
decltype(D3D10CreateDevice1)* createD3DDevice =
(decltype(D3D10CreateDevice1)*) GetProcAddress(d3d10module, "D3D10CreateDevice1");
if (!createD3DDevice)
return E_FAIL;
nsRefPtr<ID3D10Device1> device;
HRESULT hr =
createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
+#ifdef DEBUG
+ // This isn't set because of bug 1078411
+ // D3D10_CREATE_DEVICE_DEBUG |
+#endif
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
static_cast<D3D10_FEATURE_LEVEL1>(kSupportedFeatureLevels[featureLevelIndex]),
D3D10_1_SDK_VERSION, getter_AddRefs(device));
// If we fail here, the DirectX version or video card probably
// changed. We previously could use 10.1 but now we can't
// anymore. Revert back to doing a 10.0 check first before