diff --git a/extensions/EGL_ANGLE_platform_angle_opengl.txt b/extensions/EGL_ANGLE_platform_angle_opengl.txt index 9768638f9..52ef4ee27 100644 --- a/extensions/EGL_ANGLE_platform_angle_opengl.txt +++ b/extensions/EGL_ANGLE_platform_angle_opengl.txt @@ -10,6 +10,7 @@ Contributors Shannon Woods, Google Geoff Lang, Google + Courtney Goeltzenleuchter, Google Contacts @@ -21,7 +22,7 @@ Status Version - Version 3, 2014-11-26 + Version 4, 2018-05-17 Number @@ -37,7 +38,9 @@ Dependencies Overview - This extension enables selection of OpenGL display types. + This extension enables selection of OpenGL display types and, + for OpenGL ES display types, allows the application to pass + in a handle to the EGL library to use. New Types @@ -54,6 +57,10 @@ New Tokens EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E + Accepted as an attribute name in the argument of + eglGetPlatformDisplayEXT: + EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE 0x3480 + Additions to the EGL Specification None. @@ -69,6 +76,13 @@ New Behavior API, EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE and EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE can be used. + To pass in a handle to the system EGL library, use the attribute + EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE. If EGL_PLATFORM_ANGLE_TYPE_ANGLE + is not equal to EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE, an + EGL_BAD_ATTRIBUTE is generated. If the handle provided with + EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE is not a valid EGL handle, + behaviour is undefined. + Issues None @@ -82,3 +96,5 @@ Revision History EGL_ANGLE_platform_angle spec to EGL_ANGLE_platform_angle_opengl. Version 3, 2014-11-26 (Geoff Lang) - Updated enum values. + Version 4, 2018-05-17 (Courtney Goeltzenleuchter) + - Add attribute for specifying underlying EGL library. diff --git a/include/EGL/eglext_angle.h b/include/EGL/eglext_angle.h index 56cef42ec..2b22616d2 100644 --- a/include/EGL/eglext_angle.h +++ b/include/EGL/eglext_angle.h @@ -69,6 +69,7 @@ #define EGL_ANGLE_platform_angle_opengl 1 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E +#define EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE 0x3480 #endif /* EGL_ANGLE_platform_angle_opengl */ #ifndef EGL_ANGLE_platform_angle_null diff --git a/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp b/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp index 8698a96bb..9ebb6ee32 100644 --- a/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp +++ b/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.cpp @@ -32,8 +32,18 @@ FunctionsEGLDL::~FunctionsEGLDL() { } -egl::Error FunctionsEGLDL::initialize(EGLNativeDisplayType nativeDisplay, const char *libName) +egl::Error FunctionsEGLDL::initialize(EGLNativeDisplayType nativeDisplay, + const char *libName, + void *eglHandle) { + + if (eglHandle) + { + // If the handle is provided, use it. + // Caller has already dlopened the vendor library. + nativeEGLHandle = eglHandle; + } + if (!nativeEGLHandle) { nativeEGLHandle = dlopen(libName, RTLD_NOW); diff --git a/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h b/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h index e8ee24655..e959aaa2c 100644 --- a/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h +++ b/src/libANGLE/renderer/gl/egl/FunctionsEGLDL.h @@ -20,7 +20,7 @@ class FunctionsEGLDL : public FunctionsEGL FunctionsEGLDL(); ~FunctionsEGLDL() override; - egl::Error initialize(EGLNativeDisplayType nativeDisplay, const char *libName); + egl::Error initialize(EGLNativeDisplayType nativeDisplay, const char *libName, void *eglHandle); void *getProcAddress(const char *name) const override; private: diff --git a/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp b/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp index 5d6ed1ed7..5ec5ced1f 100644 --- a/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp +++ b/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp @@ -11,11 +11,11 @@ #include "common/debug.h" #include "libANGLE/Display.h" #include "libANGLE/Surface.h" -#include "libANGLE/renderer/gl/renderergl_utils.h" -#include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h" #include "libANGLE/renderer/gl/egl/FunctionsEGLDL.h" #include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h" #include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h" +#include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h" +#include "libANGLE/renderer/gl/renderergl_utils.h" namespace { @@ -45,7 +45,9 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) { FunctionsEGLDL *egl = new FunctionsEGLDL(); mEGL = egl; - ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), GetEGLPath())); + void *eglHandle = reinterpret_cast(display->getAttributeMap().get( + EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE, 0)); + ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), GetEGLPath(), eglHandle)); gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion); ASSERT(eglVersion >= gl::Version(1, 4)); diff --git a/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp b/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp index 0f37cb811..7d88c677a 100644 --- a/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp +++ b/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp @@ -459,7 +459,7 @@ egl::Error DisplayOzone::initialize(egl::Display *display) // with a .1 suffix) while Angle only installs libEGL.so. FunctionsEGLDL *egl = new FunctionsEGLDL(); mEGL = egl; - ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1")); + ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1", nullptr)); const char *necessaryExtensions[] = { "EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context", diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp index 86bd8aa75..de8c98de9 100644 --- a/src/libANGLE/validationEGL.cpp +++ b/src/libANGLE/validationEGL.cpp @@ -304,6 +304,7 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, Optional majorVersion; Optional minorVersion; Optional deviceType; + Optional eglHandle; for (const auto &curAttrib : attribMap) { @@ -400,6 +401,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, } break; + case EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE: + if (value != EGL_DONT_CARE) + { + eglHandle = value; + } + break; + default: break; } @@ -460,6 +468,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, "only supports Vulkan 1.0."; } } + + if (eglHandle.valid() && platformType != EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE && + platformType != EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) + { + return EglBadAttribute() << "EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE requires a " + "device type of EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE."; + } } else if (platform == EGL_PLATFORM_DEVICE_EXT) {