diff options
author | Jan Arve Saether <jan-arve.saether@qt.io> | 2016-10-25 16:56:02 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2016-10-28 11:02:43 +0000 |
commit | 780105f9062dec350bbe2a6800c40db3e6382578 (patch) | |
tree | a93a0febd9c0c19636d4077415761e6b01b25392 /src/angle | |
parent | 1ad6ae21f015ead3dcc4bed21a988f0d7d5d0d2d (diff) |
Merge ANGLE's libEGL and libGLESv2 into QtANGLE
This is needed in order to be able to specify a custom location of
the ANGLE libs, and enables us to perform a LoadLibrary of ANGLE libs
by just having the absolute path to QtANGLE.dll as the argument to
LoadLibrary().
Previously, we had two ANGLE libraries: libEGL and libGLESv2. libEGL hard
linked against libGLESv2. If we wanted to load libEGL from a custom
location, we couldn't load libEGL by calling LoadLibrary with the absolute
path to libEGL, because libEGL had problems finding libGLESv2. One
solution to that could have been to call SetDllDirectory() with the path
to the ANGLE libs before calling LoadLibrary("libEGL.dll"). Since the DLL
directory would point to both ANGLE libs, this would ensure that the libGLESv2
was also found. Unfortunately, this approach is not thread safe
(SetDllDirectory will affect all subsequent LoadLibrary(Ex) from the same
process). Therefore, we chose to merge the two libraries into one to
circumvent the whole problem.
At the same time, this patch also enables loading of two different ANGLE
libraries into the same process at once without renaming them: This was
not possible before because libEGL hard linked to libGLESv2.dll. When
libGLESv2.dll was already loaded, the second instance of libEGL would
simply link against the already loaded version of libGLESv2.dll.
This behavior is documented in the LoadLibraryEx documentation on MSDN:
"If the string specifies a module name without a path and more than one
loaded module has the same base name and extension, the function returns a
handle to the module that was loaded first."
Change-Id: Ic1d886ba802be72ddcf01235bafaedcef662762e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/angle')
-rw-r--r-- | src/angle/src/QtANGLE/QtANGLE.pro (renamed from src/angle/src/libGLESv2/libGLESv2.pro) | 65 | ||||
-rw-r--r-- | src/angle/src/libEGL/libEGL.pro | 26 | ||||
-rw-r--r-- | src/angle/src/src.pro | 2 |
3 files changed, 61 insertions, 32 deletions
diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/QtANGLE/QtANGLE.pro index b699ae159a..ee3111b6ee 100644 --- a/src/angle/src/libGLESv2/libGLESv2.pro +++ b/src/angle/src/QtANGLE/QtANGLE.pro @@ -1,10 +1,59 @@ CONFIG += simd no_batch include(../common/common.pri) +TARGET=$$qtLibraryTarget($${LIBQTANGLE_NAME}) DEF_FILE_TARGET=$${TARGET} -TARGET=$$qtLibraryTarget($${LIBGLESV2_NAME}) INCLUDEPATH += $$OUT_PWD/.. $$ANGLE_DIR/src/libANGLE +!build_pass { + # Merge libGLESv2 and libEGL .def files located under $$ANGLE_DIR into QtANGLE$${SUFFIX}.def + DEF_FILES = \ + libGLESv2/libGLESv2 \ + libEGL/libEGL + + SUFFIX = + for (DEBUG_RELEASE, $$list(0 1)) { + DEF_MERGED = \ + "LIBRARY $${LIBQTANGLE_NAME}$$SUFFIX" \ + EXPORTS + mingw: SUFFIX = $${SUFFIX}_mingw32 + PASS = 0 + MAX_ORDINAL = 0 + + for (DEF_FILE, DEF_FILES) { + DEF_FILE_PATH = $$ANGLE_DIR/src/$$DEF_FILE$${SUFFIX}.def + DEF_SRC = $$cat($$DEF_FILE_PATH, lines) + DEF_MERGED += \ + ";" \ + "; Generated from:" \ + "; $$DEF_FILE_PATH" + + for (line, DEF_SRC) { + !contains(line, "(LIBRARY.*|EXPORTS)") { + LINESPLIT = $$split(line, @) + !count(LINESPLIT, 1) { + equals(PASS, 1) { + # In the second .def file we must allocate new ordinals in order + # to not clash with the ordinals from the first file. We then start off + # from MAX_ORDINAL + 1 and increase sequentially + MAX_ORDINAL = $$num_add($$MAX_ORDINAL, 1) + line = $$section(line, @, 0, -2)@$$MAX_ORDINAL + } else { + ORDINAL = $$last(LINESPLIT) + greaterThan(ORDINAL, $$MAX_ORDINAL): \ + MAX_ORDINAL = $$ORDINAL + } + } + DEF_MERGED += $$line + } + } + PASS = 1 + } + write_file($${LIBQTANGLE_NAME}$${SUFFIX}.def, DEF_MERGED)|error() + SUFFIX = "d" + } +} + # Remember to adapt tools/configure/configureapp.cpp if the Direct X version changes. !winrt: \ LIBS_PRIVATE += -ld3d9 @@ -234,7 +283,8 @@ SOURCES += \ $$ANGLE_DIR/src/libGLESv2/entry_points_gles_3_0.cpp \ $$ANGLE_DIR/src/libGLESv2/entry_points_gles_3_0_ext.cpp \ $$ANGLE_DIR/src/libGLESv2/global_state.cpp \ - $$ANGLE_DIR/src/libGLESv2/libGLESv2.cpp + $$ANGLE_DIR/src/libGLESv2/libGLESv2.cpp \ + $$ANGLE_DIR/src/libEGL/libEGL.cpp SSE2_SOURCES += $$ANGLE_DIR/src/libANGLE/renderer/d3d/loadimageSSE2.cpp @@ -361,8 +411,8 @@ angle_d3d11 { } !static { - DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${DEF_FILE_TARGET}.def - mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${DEF_FILE_TARGET}_mingw32.def + DEF_FILE = $$PWD/$${DEF_FILE_TARGET}.def + mingw: equals(QT_ARCH, i386): DEF_FILE = $$PWD/$${DEF_FILE_TARGET}_mingw32.def } else { DEFINES += DllMain=DllMain_ANGLE # prevent symbol from conflicting with the user's DllMain } @@ -610,5 +660,10 @@ gles3_headers.files = \ $$ANGLE_DIR/include/GLES3/gl3ext.h \ $$ANGLE_DIR/include/GLES3/gl3platform.h gles3_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/GLES3 -INSTALLS += khr_headers gles2_headers +egl_headers.files = \ + $$ANGLE_DIR/include/EGL/egl.h \ + $$ANGLE_DIR/include/EGL/eglext.h \ + $$ANGLE_DIR/include/EGL/eglplatform.h +egl_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/EGL +INSTALLS += khr_headers gles2_headers egl_headers angle_d3d11: INSTALLS += gles3_headers diff --git a/src/angle/src/libEGL/libEGL.pro b/src/angle/src/libEGL/libEGL.pro deleted file mode 100644 index 860b60735e..0000000000 --- a/src/angle/src/libEGL/libEGL.pro +++ /dev/null @@ -1,26 +0,0 @@ -include(../common/common.pri) -DEF_FILE_TARGET=$${TARGET} -TARGET=$$qtLibraryTarget($${LIBEGL_NAME}) -winrt: LIBS_PRIVATE += -ld3d11 - -LIBS_PRIVATE += -ldxguid -L$$QT_BUILD_TREE/lib -l$$qtLibraryTarget($${LIBGLESV2_NAME}) - -DEFINES += GL_APICALL= GL_GLEXT_PROTOTYPES= EGLAPI= LIBEGL_IMPLEMENTATION - -HEADERS += \ - $$ANGLE_DIR/src/libEGL/resource.h - -SOURCES += \ - $$ANGLE_DIR/src/libEGL/libEGL.cpp - -!static { - DEF_FILE = $$ANGLE_DIR/src/libEGL/$${DEF_FILE_TARGET}.def - mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libEGL/$${DEF_FILE_TARGET}_mingw32.def -} - -egl_headers.files = \ - $$ANGLE_DIR/include/EGL/egl.h \ - $$ANGLE_DIR/include/EGL/eglext.h \ - $$ANGLE_DIR/include/EGL/eglplatform.h -egl_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/EGL -INSTALLS += egl_headers diff --git a/src/angle/src/src.pro b/src/angle/src/src.pro index d1f5f57591..77c3ee7198 100644 --- a/src/angle/src/src.pro +++ b/src/angle/src/src.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += compiler libGLESv2 libEGL +SUBDIRS += compiler QtANGLE CONFIG += ordered |