b=603367; use ANGLE for WebGL on Win32; r=bjacob

This commit is contained in:
Vladimir Vukicevic 2010-12-03 14:44:01 -08:00
Родитель e0abd11e7a
Коммит 199a2dadd1
6 изменённых файлов: 115 добавлений и 47 удалений

Просмотреть файл

@ -405,6 +405,14 @@
@BINPATH@/components/@DLL_PREFIX@mozgnome@DLL_SUFFIX@
#endif
; ANGLE on Win32
#ifdef XP_WIN32
#ifndef HAVE_64BIT_OS
@BINPATH@/libEGL.dll
@BINPATH@/libGLESv2.dll
#endif
#endif
; [Browser Chrome Files]
@BINPATH@/chrome/browser@JAREXT@
@BINPATH@/chrome/browser.manifest

Просмотреть файл

@ -177,6 +177,8 @@ MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@
MOC= @MOC@
MOZ_NSS_PATCH = @MOZ_NSS_PATCH@
MOZ_WEBGL = @MOZ_WEBGL@
MOZ_ANGLE = @MOZ_ANGLE@
MOZ_DIRECTX_SDK_PATH = @MOZ_DIRECTX_SDK_PATH@
MOZ_JAVAXPCOM = @MOZ_JAVAXPCOM@
JAVA_INCLUDE_PATH="@JAVA_INCLUDE_PATH@"

Просмотреть файл

@ -6314,6 +6314,51 @@ if test -n "${MOZ_JAVAXPCOM}"; then
fi
fi
dnl ========================================================
dnl = ANGLE OpenGL->D3D translator for WebGL
dnl = * only applies to win32
dnl = * enabled by default (shipping build); requires explicit --disable to disable
dnl ========================================================
MOZ_ANGLE=
MOZ_DIRECTX_SDK_PATH=
case "$target_os" in
*msvc*|*mks*|*cygwin*|*mingw*)
MOZ_ANGLE=1
;;
esac
if test -n "$MOZ_ANGLE"; then
MOZ_ARG_DISABLE_BOOL(angle,
[ --disable-angle Disable building of ANGLE for WebGL->D3D translation],
MOZ_ANGLE=,
MOZ_ANGLE=1)
if test -n "$MOZ_ANGLE"; then
if test -z "$_WIN32_MSVC"; then
AC_MSG_ERROR([Building ANGLE requires MSVC. To build without ANGLE, reconfigure with --disable-angle.])
fi
AC_CHECK_HEADER(d3dx9.h, [], [MOZ_ANGLE=])
if test -z "$MOZ_ANGLE"; then
# Try again, but try to get the SDK path from the registry. We're going to hardcode
# the February 2010 SDK, since that's the one that's installed on the tinderboxen.
MOZ_DIRECTX_SDK_PATH=`reg query 'HKLM\Software\Microsoft\DirectX\Microsoft DirectX SDK (February 2010)' //v InstallPath | grep REG_SZ | sed 's, *, ,g' | cut -d' ' -f4`
if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
if test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h && test -f "$MOZ_DIRECTX_SDK_PATH"/lib/x86/dxguid.lib ; then
AC_MSG_WARN([Found DirectX SDK in registry, using $MOZ_DIRECTX_SDK])
MOZ_ANGLE=1
fi
fi
fi
if test -z "$MOZ_ANGLE"; then
AC_MSG_WARN([Couldn't find d3dx9.h in your INCLUDE path, needed for ANGLE. Please install the February 2010 DirectX SDK, or make another version available in your LIB and INCLUDE path env variables. To explicitly build without ANGLE, reconfigure with --disable-angle.])
AC_MSG_WARN([This will become an error in the future.])
fi
fi
fi
dnl ========================================================
dnl = Breakpad crash reporting (on by default on supported platforms)
dnl ========================================================
@ -8920,6 +8965,8 @@ AC_SUBST(MOZ_SPELLCHECK)
AC_SUBST(MOZ_USER_DIR)
AC_SUBST(MOZ_CRASHREPORTER)
AC_SUBST(MOZ_UPDATER)
AC_SUBST(MOZ_ANGLE)
AC_SUBST(MOZ_DIRECTX_SDK_PATH)
AC_SUBST(ENABLE_STRIP)
AC_SUBST(PKG_SKIP_STRIP)

Просмотреть файл

@ -316,12 +316,14 @@ WebGLContext::SetContextOptions(nsIPropertyBag *aOptions)
// enforce that if stencil is specified, we also give back depth
newOpts.depth |= newOpts.stencil;
#if 0
LogMessage("aaHint: %d stencil: %d depth: %d alpha: %d premult: %d\n",
newOpts.antialiasHint ? 1 : 0,
newOpts.stencil ? 1 : 0,
newOpts.depth ? 1 : 0,
newOpts.alpha ? 1 : 0,
newOpts.premultipliedAlpha ? 1 : 0);
#endif
if (mOptionsFrozen && newOpts != mOptions) {
// Error if the options are already frozen, and the ones that were asked for
@ -398,8 +400,14 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
// Get some prefs for some preferred/overriden things
PRBool forceOSMesa = PR_FALSE;
PRBool preferEGL = PR_FALSE;
PRBool preferOpenGL = PR_FALSE;
prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
prefService->GetBoolPref("webgl.prefer_egl", &preferEGL);
prefService->GetBoolPref("webgl.prefer_gl", &preferOpenGL);
if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
preferEGL = PR_TRUE;
}
// Ask GfxInfo about what we should use
PRBool useOpenGL = PR_TRUE;
@ -424,6 +432,13 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
}
// allow forcing GL and not EGL/ANGLE
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL")) {
preferEGL = PR_FALSE;
useANGLE = PR_FALSE;
useOpenGL = PR_TRUE;
}
// if we're forcing osmesa, do it first
if (forceOSMesa) {
gl = gl::GLContextProviderOSMesa::CreateOffscreen(gfxIntSize(width, height), format);
@ -435,24 +450,8 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
#ifdef XP_WIN
// On Windows, we may have a choice of backends, including straight
// OpenGL, D3D through ANGLE via EGL, or straight EGL/GLES2.
// We don't differentiate the latter two yet, but we allow for
// a env var to try EGL first, instead of last; there's also a pref,
// the env var being set overrides the pref
if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
preferEGL = PR_TRUE;
}
// force opengl instead of EGL/ANGLE
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL")) {
preferEGL = PR_FALSE;
useANGLE = PR_FALSE;
useOpenGL = PR_TRUE;
}
// if we want EGL, try it first
if (!gl && (preferEGL || useANGLE)) {
// if we want EGL, try it now
if (!gl && (preferEGL || useANGLE) && !preferOpenGL) {
gl = gl::GLContextProviderEGL::CreateOffscreen(gfxIntSize(width, height), format);
if (gl && !InitAndValidateGL()) {
gl = nsnull;

Просмотреть файл

@ -132,10 +132,12 @@ include $(topsrcdir)/config/rules.mk
CXXFLAGS := $(filter-out -pedantic,$(CXXFLAGS))
CFLAGS := $(filter-out -pedantic,$(CFLAGS))
ifdef _MSC_VER
# disabled for now, but we should be building it in the future once
# bug 529938 is fixed
#BUILD_ANGLE = 1
ifdef MOZ_ANGLE
# ANGLE only on Win32 for now, the solution isn't set up
# for 64-bit yet.
ifndef HAVE_64BIT_OS
BUILD_ANGLE = 1
endif
endif
ifdef BUILD_ANGLE
@ -145,6 +147,11 @@ else
ANGLE_DIR = Release
endif
ifdef MOZ_DIRECTX_SDK_PATH
INCLUDE := $(INCLUDE);$(MOZ_DIRECTX_SDK_PATH)\include
LIB := $(LIB);$(MOZ_DIRECTX_SDK_PATH)\lib\x86
endif
ANGLE_DEP_PATTERNS = \
src/common/*.cpp src/common/*.h \
src/compiler/*.cpp src/compiler/*.h \
@ -155,20 +162,23 @@ ANGLE_DEP_PATTERNS = \
ANGLE_DEPS = $(filter-out Gen_glslang.cpp Gen_glslang_tab.cpp glslang_tab.h,$(wildcard $(ANGLE_DEP_PATTERNS)))
libs:: angle-build/libGLESv2.dll angle-build/libEGL.dll
$(INSTALL) $(IFLAGS2) angle-build/libGLESv2.dll angle-build/libEGL.dll $(DIST)/bin
libs:: libGLESv2.dll libEGL.dll
$(INSTALL) $(IFLAGS2) libGLESv2.dll libEGL.dll $(DIST)/bin
angle-build/libGLESv2.dll angle-build/libEGL.dll: $(GLOBAL_DEPS) $(ANGLE_DEPS)
@echo "=== Building ANGLE via devenv.exe ==="
@rm -rf angle-build
@mkdir angle-build
@cp -r $(srcdir)/src $(srcdir)/include angle-build
@(cd angle-build/src \
# we don't want this to attempt to parallel-build these dlls;
# building one will build both.
libGLESv2.dll: libEGL.dll
libEGL.dll: $(GLOBAL_DEPS) $(ANGLE_DEPS)
@(echo "=== Building ANGLE via devenv.exe ===" \
&& rm -rf angle-build && mkdir angle-build \
&& cp -r $(srcdir)/src $(srcdir)/include angle-build \
&& cd angle-build/src \
&& echo "Upgrading solution..." \
&& devenv angle.sln //upgrade \
&& echo "Building solution, target $(ANGLE_DIR)|Win32..." \
&& devenv angle.sln //useenv //build "$(ANGLE_DIR)|Win32" \
&& echo "Copying dlls..." \
&& cp $(ANGLE_DIR)/*.dll ..)
&& cp $(ANGLE_DIR)/*.dll ../..)
endif

Просмотреть файл

@ -78,9 +78,9 @@ typedef void *EGLNativeWindowType;
#elif defined(XP_WIN)
#include <nsServiceManagerUtils.h>
#include <nsIPrefBranch.h>
#include <nsILocalFile.h>
#include "nsServiceManagerUtils.h"
#include "nsIPrefBranch.h"
#include "nsILocalFile.h"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
@ -282,26 +282,26 @@ public:
}
#ifdef XP_WIN
// ANGLE is an addon currently, so we have to do a bit of work
// to find the directory; the addon sets this on startup/shutdown.
// Allow for explicitly specifying the location of libEGL.dll and
// libGLESv2.dll.
do {
nsCOMPtr<nsIPrefBranch> prefs = do_GetService("@mozilla.org/preferences-service;1");
nsCOMPtr<nsILocalFile> angleFile, glesv2File;
nsCOMPtr<nsILocalFile> eglFile, glesv2File;
if (!prefs)
break;
nsresult rv = prefs->GetComplexValue("gfx.angle.egl.path",
NS_GET_IID(nsILocalFile),
getter_AddRefs(angleFile));
if (NS_FAILED(rv) || !angleFile)
getter_AddRefs(eglFile));
if (NS_FAILED(rv) || !eglFile)
break;
nsCAutoString s;
// note that we have to load the libs in this order, because libEGL.dll
// depends on libGLESv2.dll, but is not in our search path.
// depends on libGLESv2.dll, but is not/may not be in our search path.
nsCOMPtr<nsIFile> f;
angleFile->Clone(getter_AddRefs(f));
eglFile->Clone(getter_AddRefs(f));
glesv2File = do_QueryInterface(f);
if (!glesv2File)
break;
@ -313,18 +313,20 @@ public:
if (!glesv2lib)
break;
angleFile->Append(NS_LITERAL_STRING("libEGL.dll"));
angleFile->Load(&mEGLLibrary);
eglFile->Append(NS_LITERAL_STRING("libEGL.dll"));
eglFile->Load(&mEGLLibrary);
} while (false);
#endif
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB);
if (!mEGLLibrary) {
NS_WARNING("Couldn't load EGL LIB.");
return PR_FALSE;
}
}
if (!mEGLLibrary) {
NS_WARNING("Couldn't load EGL LIB.");
return PR_FALSE;
}
#define SYMBOL(name) \
{ (PRFuncPtr*) &f##name, { "egl" #name, NULL } }