Commit 390900a0 by Courtney Goeltzenleuchter Committed by Commit Bot

Add support for EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE

To support ANGLE for Android need a way to tell ANGLE what library to call when using GL backend. Bug: angleproject:2418 Test: test-opengl-gl2_copyTexImage Change-Id: Ie00251b0672a036db4720e1e5b269f66a30a03da Reviewed-on: https://chromium-review.googlesource.com/1066822 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c1651618
...@@ -10,6 +10,7 @@ Contributors ...@@ -10,6 +10,7 @@ Contributors
Shannon Woods, Google Shannon Woods, Google
Geoff Lang, Google Geoff Lang, Google
Courtney Goeltzenleuchter, Google
Contacts Contacts
...@@ -21,7 +22,7 @@ Status ...@@ -21,7 +22,7 @@ Status
Version Version
Version 3, 2014-11-26 Version 4, 2018-05-17
Number Number
...@@ -37,7 +38,9 @@ Dependencies ...@@ -37,7 +38,9 @@ Dependencies
Overview 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 New Types
...@@ -54,6 +57,10 @@ New Tokens ...@@ -54,6 +57,10 @@ New Tokens
EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E
Accepted as an attribute name in the <attrib_list> argument of
eglGetPlatformDisplayEXT:
EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE 0x3480
Additions to the EGL Specification Additions to the EGL Specification
None. None.
...@@ -69,6 +76,13 @@ New Behavior ...@@ -69,6 +76,13 @@ New Behavior
API, EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE and API, EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE and
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE can be used. 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 Issues
None None
...@@ -82,3 +96,5 @@ Revision History ...@@ -82,3 +96,5 @@ Revision History
EGL_ANGLE_platform_angle spec to EGL_ANGLE_platform_angle_opengl. EGL_ANGLE_platform_angle spec to EGL_ANGLE_platform_angle_opengl.
Version 3, 2014-11-26 (Geoff Lang) Version 3, 2014-11-26 (Geoff Lang)
- Updated enum values. - Updated enum values.
Version 4, 2018-05-17 (Courtney Goeltzenleuchter)
- Add attribute for specifying underlying EGL library.
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#define EGL_ANGLE_platform_angle_opengl 1 #define EGL_ANGLE_platform_angle_opengl 1
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E
#define EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE 0x3480
#endif /* EGL_ANGLE_platform_angle_opengl */ #endif /* EGL_ANGLE_platform_angle_opengl */
#ifndef EGL_ANGLE_platform_angle_null #ifndef EGL_ANGLE_platform_angle_null
......
...@@ -32,8 +32,18 @@ FunctionsEGLDL::~FunctionsEGLDL() ...@@ -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) if (!nativeEGLHandle)
{ {
nativeEGLHandle = dlopen(libName, RTLD_NOW); nativeEGLHandle = dlopen(libName, RTLD_NOW);
......
...@@ -20,7 +20,7 @@ class FunctionsEGLDL : public FunctionsEGL ...@@ -20,7 +20,7 @@ class FunctionsEGLDL : public FunctionsEGL
FunctionsEGLDL(); FunctionsEGLDL();
~FunctionsEGLDL() override; ~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; void *getProcAddress(const char *name) const override;
private: private:
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/Surface.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/FunctionsEGLDL.h"
#include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h" #include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h"
#include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h" #include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h"
#include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
namespace namespace
{ {
...@@ -45,7 +45,9 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) ...@@ -45,7 +45,9 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
{ {
FunctionsEGLDL *egl = new FunctionsEGLDL(); FunctionsEGLDL *egl = new FunctionsEGLDL();
mEGL = egl; mEGL = egl;
ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), GetEGLPath())); void *eglHandle = reinterpret_cast<void *>(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); gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion);
ASSERT(eglVersion >= gl::Version(1, 4)); ASSERT(eglVersion >= gl::Version(1, 4));
......
...@@ -459,7 +459,7 @@ egl::Error DisplayOzone::initialize(egl::Display *display) ...@@ -459,7 +459,7 @@ egl::Error DisplayOzone::initialize(egl::Display *display)
// with a .1 suffix) while Angle only installs libEGL.so. // with a .1 suffix) while Angle only installs libEGL.so.
FunctionsEGLDL *egl = new FunctionsEGLDL(); FunctionsEGLDL *egl = new FunctionsEGLDL();
mEGL = egl; mEGL = egl;
ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1")); ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1", nullptr));
const char *necessaryExtensions[] = { const char *necessaryExtensions[] = {
"EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context", "EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context",
......
...@@ -304,6 +304,7 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, ...@@ -304,6 +304,7 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform,
Optional<EGLAttrib> majorVersion; Optional<EGLAttrib> majorVersion;
Optional<EGLAttrib> minorVersion; Optional<EGLAttrib> minorVersion;
Optional<EGLAttrib> deviceType; Optional<EGLAttrib> deviceType;
Optional<EGLAttrib> eglHandle;
for (const auto &curAttrib : attribMap) for (const auto &curAttrib : attribMap)
{ {
...@@ -400,6 +401,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, ...@@ -400,6 +401,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform,
} }
break; break;
case EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE:
if (value != EGL_DONT_CARE)
{
eglHandle = value;
}
break;
default: default:
break; break;
} }
...@@ -460,6 +468,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, ...@@ -460,6 +468,13 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform,
"only supports Vulkan 1.0."; "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) else if (platform == EGL_PLATFORM_DEVICE_EXT)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment