Commit 8ba5cf99 by Maksim Sisov Committed by Commit Bot

Add EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE

This CL adds a new attribute that helps to identify lower platform angle should use. We identified several different use cases that ANGLE must comply with when choose a display implementation. Please refer to the Support Matrix for EGL_ANGLE_platform_angle table Bug: chromium:1084458 Change-Id: I6ea3d5081012ddf450f1c641343d1ba1a673483b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2210151 Commit-Queue: Michael Spang <spang@chromium.org> Reviewed-by: 's avatarMichael Spang <spang@chromium.org>
parent 98865915
...@@ -81,6 +81,13 @@ New Tokens ...@@ -81,6 +81,13 @@ New Tokens
EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A
EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x345E EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x345E
Accepted as values for the EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE
attribute:
EGL_PLATFORM_X11_EXT 0x31D5
EGL_PLATFORM_DEVICE_EXT 0x313F
EGL_PLATFORM_SURFACELESS_MESA 0x31DD
Additions to the EGL Specification Additions to the EGL Specification
None. None.
...@@ -137,6 +144,12 @@ New Behavior ...@@ -137,6 +144,12 @@ New Behavior
default setting depends on the implementation. Any value other than these default setting depends on the implementation. Any value other than these
will result in an error. will result in an error.
EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE is an additional optional
attribute that helps ANGLE to identify what native underlaying platform
it should use. If no display matching the requested type of native platform
found, EGL_NO_DISPLAY should be returned. if no <attrib_list> is specified
to eglGetPlatformDisplayEXT, ANGLE is free to make the choice.
Issues Issues
1) Should the validation layers default to on, off, or no guarantee? 1) Should the validation layers default to on, off, or no guarantee?
...@@ -161,3 +174,5 @@ Revision History ...@@ -161,3 +174,5 @@ Revision History
- Add a debug layers enabled attribute to control runtime validation. - Add a debug layers enabled attribute to control runtime validation.
Version 5, 2017-12-28 (Jamie Madill) Version 5, 2017-12-28 (Jamie Madill)
- Expose device type selection. - Expose device type selection.
Version 6, 2020-05-28 (Maksim Sisov)
- Add EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE attribute.
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x345E #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x345E
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348F
#endif /* EGL_ANGLE_platform_angle */ #endif /* EGL_ANGLE_platform_angle */
#ifndef EGL_ANGLE_platform_angle_d3d #ifndef EGL_ANGLE_platform_angle_d3d
......
...@@ -55,13 +55,12 @@ ...@@ -55,13 +55,12 @@
# elif defined(ANGLE_PLATFORM_IOS) # elif defined(ANGLE_PLATFORM_IOS)
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h" # include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
# elif defined(ANGLE_PLATFORM_LINUX) # elif defined(ANGLE_PLATFORM_LINUX)
# include "libANGLE/renderer/gl/egl/DisplayEGL.h"
# if defined(ANGLE_USE_GBM) # if defined(ANGLE_USE_GBM)
# include "libANGLE/renderer/gl/egl/gbm/DisplayGbm.h" # include "libANGLE/renderer/gl/egl/gbm/DisplayGbm.h"
# else # endif
# include "libANGLE/renderer/gl/egl/DisplayEGL.h" # if defined(ANGLE_USE_X11)
# if defined(ANGLE_USE_X11) # include "libANGLE/renderer/gl/glx/DisplayGLX.h"
# include "libANGLE/renderer/gl/glx/DisplayGLX.h"
# endif
# endif # endif
# elif defined(ANGLE_PLATFORM_ANDROID) # elif defined(ANGLE_PLATFORM_ANDROID)
# include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h" # include "libANGLE/renderer/gl/egl/android/DisplayAndroid.h"
...@@ -221,8 +220,18 @@ EGLAttrib GetDeviceTypeFromEnvironment() ...@@ -221,8 +220,18 @@ EGLAttrib GetDeviceTypeFromEnvironment()
return EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE; return EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
} }
EGLAttrib GetPlatformTypeFromEnvironment()
{
#if defined(ANGLE_USE_X11) && !defined(ANGLE_USE_OZONE)
return EGL_PLATFORM_X11_EXT;
#else
return 0;
#endif
}
rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
EGLAttrib deviceType, EGLAttrib deviceType,
EGLAttrib platformType,
const DisplayState &state) const DisplayState &state)
{ {
ASSERT(displayType != EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE); ASSERT(displayType != EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
...@@ -253,21 +262,30 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, ...@@ -253,21 +262,30 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
# elif defined(ANGLE_PLATFORM_IOS) # elif defined(ANGLE_PLATFORM_IOS)
impl = new rx::DisplayEAGL(state); impl = new rx::DisplayEAGL(state);
# elif defined(ANGLE_PLATFORM_LINUX) # elif defined(ANGLE_PLATFORM_LINUX)
# if defined(ANGLE_USE_OZONE) # if defined(ANGLE_USE_GBM)
// This might work but has never been tried, so disallow for now. if (platformType == 0)
impl = nullptr; {
# else // If platformType is unknown, use DisplayGbm now. In the future, it should use
// DisplayEGL letting native EGL decide what display to use.
impl = new rx::DisplayGbm(state);
break;
}
# endif
if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_EGL_ANGLE) if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_EGL_ANGLE)
{ {
impl = new rx::DisplayEGL(state); impl = new rx::DisplayEGL(state);
break;
} }
# if defined(ANGLE_USE_X11)
else else
{ {
impl = new rx::DisplayGLX(state); # if defined(ANGLE_USE_X11)
} if (platformType == EGL_PLATFORM_X11_EXT)
# endif {
impl = new rx::DisplayGLX(state);
break;
}
# endif # endif
}
# elif defined(ANGLE_PLATFORM_ANDROID) # elif defined(ANGLE_PLATFORM_ANDROID)
// No GL support on this platform, fail display creation. // No GL support on this platform, fail display creation.
impl = nullptr; impl = nullptr;
...@@ -286,19 +304,29 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, ...@@ -286,19 +304,29 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
impl = new rx::DisplayWGL(state); impl = new rx::DisplayWGL(state);
# elif defined(ANGLE_PLATFORM_LINUX) # elif defined(ANGLE_PLATFORM_LINUX)
# if defined(ANGLE_USE_GBM) # if defined(ANGLE_USE_GBM)
impl = new rx::DisplayGbm(state); if (platformType == 0)
# else {
// If platformType is unknown, use DisplayGbm now. In the future, it should use
// DisplayEGL letting native EGL decide what display to use.
impl = new rx::DisplayGbm(state);
break;
}
# endif
if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_EGL_ANGLE) if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_EGL_ANGLE)
{ {
impl = new rx::DisplayEGL(state); impl = new rx::DisplayEGL(state);
break;
} }
# if defined(ANGLE_USE_X11)
else else
{ {
impl = new rx::DisplayGLX(state); # if defined(ANGLE_USE_X11)
} if (platformType == EGL_PLATFORM_X11_EXT)
# endif {
impl = new rx::DisplayGLX(state);
break;
}
# endif # endif
}
# elif defined(ANGLE_PLATFORM_ANDROID) # elif defined(ANGLE_PLATFORM_ANDROID)
impl = new rx::DisplayAndroid(state); impl = new rx::DisplayAndroid(state);
# else # else
...@@ -316,10 +344,13 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, ...@@ -316,10 +344,13 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
impl = rx::CreateVulkanWin32Display(state); impl = rx::CreateVulkanWin32Display(state);
} }
# elif defined(ANGLE_PLATFORM_LINUX) # elif defined(ANGLE_PLATFORM_LINUX)
if (rx::IsVulkanXcbDisplayAvailable()) # if defined(ANGLE_USE_X11)
if (platformType == EGL_PLATFORM_X11_EXT && rx::IsVulkanXcbDisplayAvailable())
{ {
impl = rx::CreateVulkanXcbDisplay(state); impl = rx::CreateVulkanXcbDisplay(state);
break;
} }
# endif
# elif defined(ANGLE_PLATFORM_ANDROID) # elif defined(ANGLE_PLATFORM_ANDROID)
if (rx::IsVulkanAndroidDisplayAvailable()) if (rx::IsVulkanAndroidDisplayAvailable())
{ {
...@@ -452,6 +483,40 @@ DisplayState::DisplayState(EGLNativeDisplayType nativeDisplayId) ...@@ -452,6 +483,40 @@ DisplayState::DisplayState(EGLNativeDisplayType nativeDisplayId)
DisplayState::~DisplayState() {} DisplayState::~DisplayState() {}
// Note that ANGLE support on Ozone platform is limited. Our prefered support Matrix for
// EGL_ANGLE_platform_angle on Linux and Ozone/Linux/Fuchsia platforms should be the following:
//
// |--------------------------------------------------------|
// | ANGLE type | DEVICE type | PLATFORM type | Display |
// |--------------------------------------------------------|
// | OPENGL | EGL | ANY | EGL |
// | OPENGL | HARDWARE | X11_EXT | GLX |
// | OPENGLES | HARDWARE | X11_EXT | GLX |
// | OPENGLES | EGL | ANY | EGL |
// | VULKAN | HARDWARE | X11_EXT | VkXcb |
// | VULKAN | SWIFTSHADER | X11_EXT | VkXcb |
// | OPENGLES | HARDWARE | SURFACELESS_MESA | EGL* |
// | OPENGLES | HARDWARE | DEVICE_EXT | EGL |
// | VULKAN | HARDWARE | SURFACELESS_MESA | VkBase** |
// | VULKAN | SWIFTSHADER | SURFACELESS_MESA | VkBase** |
// |--------------------------------------------------------|
//
// * No surfaceless support yet.
// ** Not implemented yet.
//
// |-----------------------------------------------|
// | OS | BUILD type | Default PLATFORM type |
// |-----------------------------------------------|
// | Linux | X11 | X11_EXT |
// | Linux | Ozone | SURFACELESS_MESA |
// | Fuchsia | Ozone | FUCHSIA*** |
// |-----------------------------------------------|
//
// *** Chosen implicitly. No EGLAttrib available.
//
// For more details, please refer to
// https://docs.google.com/document/d/1XjHiDZQISq1AMrg_l1TX1_kIKvDpU76hidn9i4cAjl8/edit?disco=AAAAJl9V_YY
//
// static // static
Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay, Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay,
const AttributeMap &attribMap) const AttributeMap &attribMap)
...@@ -486,8 +551,10 @@ Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay ...@@ -486,8 +551,10 @@ Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay
EGLAttrib displayType = display->mAttributeMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE); EGLAttrib displayType = display->mAttributeMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
EGLAttrib deviceType = display->mAttributeMap.get(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); EGLAttrib deviceType = display->mAttributeMap.get(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
EGLAttrib platformType =
display->mAttributeMap.get(EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE);
rx::DisplayImpl *impl = rx::DisplayImpl *impl =
CreateDisplayFromAttribs(displayType, deviceType, display->getState()); CreateDisplayFromAttribs(displayType, deviceType, platformType, display->getState());
if (impl == nullptr) if (impl == nullptr)
{ {
// No valid display implementation for these attributes // No valid display implementation for these attributes
...@@ -673,6 +740,12 @@ void Display::updateAttribsFromEnvironment(const AttributeMap &attribMap) ...@@ -673,6 +740,12 @@ void Display::updateAttribsFromEnvironment(const AttributeMap &attribMap)
deviceType = GetDeviceTypeFromEnvironment(); deviceType = GetDeviceTypeFromEnvironment();
mAttributeMap.insert(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, deviceType); mAttributeMap.insert(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, deviceType);
} }
EGLAttrib platformType = attribMap.get(EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE, 0);
if (platformType == 0)
{
platformType = GetPlatformTypeFromEnvironment();
mAttributeMap.insert(EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE, platformType);
}
} }
Error Display::initialize() Error Display::initialize()
...@@ -1420,7 +1493,7 @@ static ClientExtensions GenerateClientExtensions() ...@@ -1420,7 +1493,7 @@ static ClientExtensions GenerateClientExtensions()
extensions.x11Visual = true; extensions.x11Visual = true;
#endif #endif
#if defined(ANGLE_PLATFORM_LINUX) && !defined(ANGLE_USE_GBM) #if defined(ANGLE_PLATFORM_LINUX)
extensions.platformANGLEDeviceTypeEGLANGLE = true; extensions.platformANGLEDeviceTypeEGLANGLE = true;
#endif #endif
......
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