Commit 12ce8f68 by Kenneth Russell Committed by Commit Bot

Upstream WebKit's iOS port of ANGLE.

Added the EAGL backend authored by Dean Jackson from Apple, and the refactoring changes needed to support it side-by-side with the macOS backend. Ran "git cl format" against these diffs. Defined the EGL_ANGLE_device_eagl extension and allocated an enum out of ANGLE's reserved range. The iOS backend is not yet included in any of the GN files. Bug: angleproject:4263 Change-Id: I631c32930433c03bb16a242955ffedf55174bb29 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1987278Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJames Darpinian <jdarpinian@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
parent 7a37d3ac
Name
ANGLE_device_eagl
Name Strings
EGL_ANGLE_device_eagl
Contributors
Dean Jackson (dino 'at' apple.com)
Ken Russell (kbr 'at' google.com)
Contact
Ken Russell (kbr 'at' google.com)
Status
Draft
Version
Version 1, January 3, 2020
Number
EGL Extension #XXX
Extension Type
EGL device extension
Dependencies
This extension is written against the language of EGL 1.5 as
modified by EGL_EXT_device_query.
EGL_EXT_device_query is required.
Overview
ANGLE on iOS internally uses an OpenGL ES context allocated via EAGL.
This extension defines a mapping from an EGL device to the underlying
EAGLContext, after it's been queried from an EGL display.
IP Status
No known claims.
New Types
None.
New Procedures and Functions
None.
New Tokens
Accepted as a queried <attribute> in eglQueryDeviceAttribEXT:
EGL_EAGL_CONTEXT_ANGLE 0x348C
Add a new section 2.1.3 (EAGL Devices) after 2.1.2 (Devices)
On iOS the underlying EAGLContext can be queried from the EGL device. The
intented purpose is to allow applications to create new EAGLContexts which
share resources with this one.
Changes to section 3.2 (Devices)
Replace the paragraph immediately following the prototype for
eglQueryDeviceAttribEXT:
<attribute> must be EGL_EAGL_CONTEXT_ANGLE. On success, EGL_TRUE is
returned, and a valid EAGLContext corresponding to the EGL device is
returned in <value>. This object is compatible with OpenGL ES and EAGL API
functions. If the EGL device is not currently associated with an
EAGLContext, EGL_BAD_ATTRIBUTE is returned, and <value> is left unchanged.
Issues
None
Revision History
Version 1, January 3, 2020 (Ken Russell)
- Initial Draft
...@@ -274,6 +274,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithFrameTokenANGLE(EGLDisplay dpy, ...@@ -274,6 +274,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithFrameTokenANGLE(EGLDisplay dpy,
#endif #endif
#endif /* EGL_ANGLE_swap_with_frame_token */ #endif /* EGL_ANGLE_swap_with_frame_token */
#ifndef EGL_ANGLE_device_eagl
#define EGL_ANGLE_device_eagl 1
#define EGL_EAGL_CONTEXT_ANGLE 0x348C
#endif
// clang-format on // clang-format on
#endif // INCLUDE_EGL_EGLEXT_ANGLE_ #endif // INCLUDE_EGL_EGLEXT_ANGLE_
...@@ -185,6 +185,7 @@ IGNORED_INCLUDES = { ...@@ -185,6 +185,7 @@ IGNORED_INCLUDES = {
b'libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h', b'libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h',
b'libANGLE/renderer/gl/glx/DisplayGLX.h', b'libANGLE/renderer/gl/glx/DisplayGLX.h',
b'libANGLE/renderer/gl/cgl/DisplayCGL.h', b'libANGLE/renderer/gl/cgl/DisplayCGL.h',
b'libANGLE/renderer/gl/eagl/DisplayEAGL.h',
b'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h', b'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h',
b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h', b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h',
b'libANGLE/renderer/gl/wgl/DisplayWGL.h', b'libANGLE/renderer/gl/wgl/DisplayWGL.h',
......
...@@ -118,8 +118,15 @@ ...@@ -118,8 +118,15 @@
# include <TargetConditionals.h> # include <TargetConditionals.h>
# if TARGET_OS_OSX # if TARGET_OS_OSX
# define ANGLE_PLATFORM_MACOS 1 # define ANGLE_PLATFORM_MACOS 1
# elif TARGET_OS_IOS # elif TARGET_OS_IPHONE
# define ANGLE_PLATFORM_IOS 1 # define ANGLE_PLATFORM_IOS 1
# define GLES_SILENCE_DEPRECATION
# if TARGET_OS_SIMULATOR
# define ANGLE_PLATFORM_IOS_SIMULATOR 1
# endif
# if TARGET_OS_MACCATALYST
# define ANGLE_PLATFORM_MACCATALYST
# endif
# endif # endif
#endif #endif
......
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SystemInfo_ios.cpp: implementation of the iOS-specific parts of SystemInfo.h
#include "common/platform.h"
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
# include "gpu_info_util/SystemInfo_internal.h"
namespace angle
{
bool GetSystemInfo(SystemInfo *info)
{
{
// TODO(anglebug.com/4275): Get the actual system version.
info->machineModelVersion = "0.0";
}
return true;
}
} // namespace angle
#endif // defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// SystemInfo_mac.mm: implementation of the Mac-specific parts of SystemInfo.h // SystemInfo_macos.mm: implementation of the macOS-specific parts of SystemInfo.h
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_PLATFORM_MACOS #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "gpu_info_util/SystemInfo_internal.h" # include "gpu_info_util/SystemInfo_internal.h"
...@@ -244,4 +244,4 @@ bool GetSystemInfo(SystemInfo *info) ...@@ -244,4 +244,4 @@ bool GetSystemInfo(SystemInfo *info)
} // namespace angle } // namespace angle
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -1007,6 +1007,9 @@ struct DeviceExtensions ...@@ -1007,6 +1007,9 @@ struct DeviceExtensions
// EGL_ANGLE_device_cgl // EGL_ANGLE_device_cgl
bool deviceCGL = false; bool deviceCGL = false;
// EGL_ANGLE_device_eagl
bool deviceEAGL = false;
}; };
struct ClientExtensions struct ClientExtensions
......
...@@ -52,8 +52,10 @@ ...@@ -52,8 +52,10 @@
# include "libANGLE/renderer/gl/wgl/DisplayWGL.h" # include "libANGLE/renderer/gl/wgl/DisplayWGL.h"
# elif defined(ANGLE_USE_X11) # elif defined(ANGLE_USE_X11)
# include "libANGLE/renderer/gl/glx/DisplayGLX.h" # include "libANGLE/renderer/gl/glx/DisplayGLX.h"
# elif defined(ANGLE_PLATFORM_APPLE) # elif defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h" # include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
# elif defined(ANGLE_PLATFORM_IOS)
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
# elif defined(ANGLE_USE_OZONE) # elif defined(ANGLE_USE_OZONE)
# include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h" # include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h"
# elif defined(ANGLE_PLATFORM_ANDROID) # elif defined(ANGLE_PLATFORM_ANDROID)
...@@ -241,8 +243,10 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, const DisplaySt ...@@ -241,8 +243,10 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, const DisplaySt
impl = new rx::DisplayWGL(state); impl = new rx::DisplayWGL(state);
# elif defined(ANGLE_USE_X11) # elif defined(ANGLE_USE_X11)
impl = new rx::DisplayGLX(state); impl = new rx::DisplayGLX(state);
# elif defined(ANGLE_PLATFORM_APPLE) # elif defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
impl = new rx::DisplayCGL(state); impl = new rx::DisplayCGL(state);
# elif defined(ANGLE_PLATFORM_IOS)
impl = new rx::DisplayEAGL(state);
# elif defined(ANGLE_USE_OZONE) # elif defined(ANGLE_USE_OZONE)
// This might work but has never been tried, so disallow for now. // This might work but has never been tried, so disallow for now.
impl = nullptr; impl = nullptr;
......
...@@ -1008,7 +1008,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -1008,7 +1008,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, RequireExt<&Extensions::sRGB>, NeverSupported); AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, RequireExt<&Extensions::sRGB>, NeverSupported);
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, AlwaysSupported, RequireES<2, 0>, NeverSupported);
#else
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, NeverSupported); AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, NeverSupported);
#endif
// Unsized integer formats // Unsized integer formats
// |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | // |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_PLATFORM_MACOS #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/cgl/DeviceCGL.h" # include "libANGLE/renderer/gl/cgl/DeviceCGL.h"
...@@ -58,4 +58,4 @@ void DeviceCGL::generateExtensions(egl::DeviceExtensions *outExtensions) const ...@@ -58,4 +58,4 @@ void DeviceCGL::generateExtensions(egl::DeviceExtensions *outExtensions) const
} // namespace rx } // namespace rx
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_PLATFORM_MACOS #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h" # include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
...@@ -82,10 +82,7 @@ egl::Error DisplayCGL::initialize(egl::Display *display) ...@@ -82,10 +82,7 @@ egl::Error DisplayCGL::initialize(egl::Display *display)
std::vector<CGLPixelFormatAttribute> attribs; std::vector<CGLPixelFormatAttribute> attribs;
attribs.push_back(kCGLPFAOpenGLProfile); attribs.push_back(kCGLPFAOpenGLProfile);
attribs.push_back(static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_3_2_Core)); attribs.push_back(static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_3_2_Core));
if (mSupportsGPUSwitching) attribs.push_back(kCGLPFAAllowOfflineRenderers);
{
attribs.push_back(kCGLPFAAllowOfflineRenderers);
}
attribs.push_back(static_cast<CGLPixelFormatAttribute>(0)); attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
GLint nVirtualScreens = 0; GLint nVirtualScreens = 0;
CGLChoosePixelFormat(attribs.data(), &mPixelFormat, &nVirtualScreens); CGLChoosePixelFormat(attribs.data(), &mPixelFormat, &nVirtualScreens);
...@@ -295,7 +292,7 @@ egl::Error DisplayCGL::restoreLostDevice(const egl::Display *display) ...@@ -295,7 +292,7 @@ egl::Error DisplayCGL::restoreLostDevice(const egl::Display *display)
bool DisplayCGL::isValidNativeWindow(EGLNativeWindowType window) const bool DisplayCGL::isValidNativeWindow(EGLNativeWindowType window) const
{ {
NSObject *layer = reinterpret_cast<NSObject *>(window); NSObject *layer = (__bridge NSObject *)window;
return [layer isKindOfClass:[CALayer class]]; return [layer isKindOfClass:[CALayer class]];
} }
...@@ -448,4 +445,4 @@ void DisplayCGL::populateFeatureList(angle::FeatureList *features) ...@@ -448,4 +445,4 @@ void DisplayCGL::populateFeatureList(angle::FeatureList *features)
} }
} }
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_PLATFORM_MACOS #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.h" # include "libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.h"
...@@ -335,4 +335,4 @@ bool IOSurfaceSurfaceCGL::hasEmulatedAlphaChannel() const ...@@ -335,4 +335,4 @@ bool IOSurfaceSurfaceCGL::hasEmulatedAlphaChannel() const
} // namespace rx } // namespace rx
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#include "libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h" #include "libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h"
#include "common/platform.h" #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
#ifdef ANGLE_PLATFORM_MACOS
# include "common/debug.h" # include "common/debug.h"
# include "libANGLE/renderer/gl/FramebufferGL.h" # include "libANGLE/renderer/gl/FramebufferGL.h"
...@@ -143,4 +141,4 @@ FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::Context * ...@@ -143,4 +141,4 @@ FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::Context *
} // namespace rx } // namespace rx
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#include "libANGLE/renderer/gl/cgl/RendererCGL.h" #include "libANGLE/renderer/gl/cgl/RendererCGL.h"
#include "common/platform.h" #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
#ifdef ANGLE_PLATFORM_MACOS
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h" # include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
...@@ -32,4 +30,4 @@ WorkerContext *RendererCGL::createWorkerContext(std::string *infoLog) ...@@ -32,4 +30,4 @@ WorkerContext *RendererCGL::createWorkerContext(std::string *infoLog)
} // namespace rx } // namespace rx
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_PLATFORM_MACOS #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h" # include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h"
...@@ -153,7 +153,7 @@ WindowSurfaceCGL::WindowSurfaceCGL(const egl::SurfaceState &state, ...@@ -153,7 +153,7 @@ WindowSurfaceCGL::WindowSurfaceCGL(const egl::SurfaceState &state,
: SurfaceGL(state), : SurfaceGL(state),
mSwapLayer(nil), mSwapLayer(nil),
mCurrentSwapId(0), mCurrentSwapId(0),
mLayer(reinterpret_cast<CALayer *>(layer)), mLayer((__bridge CALayer *)layer),
mContext(context), mContext(context),
mFunctions(renderer->getFunctions()), mFunctions(renderer->getFunctions()),
mStateManager(renderer->getStateManager()), mStateManager(renderer->getStateManager()),
...@@ -339,4 +339,4 @@ FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::Context *c ...@@ -339,4 +339,4 @@ FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::Context *c
} // namespace rx } // namespace rx
#endif // ANGLE_PLATFORM_MACOS #endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ContextEAGL:
// iOS-specific subclass of ContextGL.
//
#include "libANGLE/renderer/gl/eagl/ContextEAGL.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
namespace rx
{
ContextEAGL::ContextEAGL(const gl::State &state,
gl::ErrorSet *errorSet,
const std::shared_ptr<RendererGL> &renderer)
: ContextGL(state, errorSet, renderer)
{}
} // namespace rx
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ContextEAGL:
// iOS-specific subclass of ContextGL.
//
#ifndef LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
class ContextEAGL : public ContextGL
{
public:
ContextEAGL(const gl::State &state,
gl::ErrorSet *errorSet,
const std::shared_ptr<RendererGL> &renderer);
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DeviceEAGL.cpp: EAGL implementation of egl::Device
#import "common/platform.h"
#if defined(ANGLE_PLATFORM_IOS)
# include "libANGLE/renderer/gl/eagl/DeviceEAGL.h"
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
# include <EGL/eglext.h>
namespace rx
{
DeviceEAGL::DeviceEAGL() {}
DeviceEAGL::~DeviceEAGL() {}
egl::Error DeviceEAGL::initialize()
{
return egl::NoError();
}
egl::Error DeviceEAGL::getAttribute(const egl::Display *display, EGLint attribute, void **outValue)
{
DisplayEAGL *displayImpl = GetImplAs<DisplayEAGL>(display);
switch (attribute)
{
case EGL_EAGL_CONTEXT_ANGLE:
*outValue = displayImpl->getEAGLContext();
break;
default:
return egl::EglBadAttribute();
}
return egl::NoError();
}
EGLint DeviceEAGL::getType()
{
return 0;
}
void DeviceEAGL::generateExtensions(egl::DeviceExtensions *outExtensions) const
{
outExtensions->deviceEAGL = true;
}
} // namespace rx
#endif // defined(ANGLE_PLATFORM_IOS)
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DeviceEAGL.h: EAGL implementation of egl::Device
#ifndef LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
#include "libANGLE/Device.h"
#include "libANGLE/renderer/DeviceImpl.h"
namespace rx
{
class DeviceEAGL : public DeviceImpl
{
public:
DeviceEAGL();
~DeviceEAGL() override;
egl::Error initialize() override;
egl::Error getAttribute(const egl::Display *display,
EGLint attribute,
void **outValue) override;
EGLint getType() override;
void generateExtensions(egl::DeviceExtensions *outExtensions) const override;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DisplayEAGL.h: EAGL implementation of egl::Display
#ifndef LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
#include "libANGLE/renderer/gl/DisplayGL.h"
#ifdef __OBJC__
@class EAGLContext;
typedef EAGLContext *EAGLContextObj;
#else
typedef void *EAGLContextObj;
#endif
namespace rx
{
class WorkerContext;
class DisplayEAGL : public DisplayGL
{
public:
DisplayEAGL(const egl::DisplayState &state);
~DisplayEAGL() override;
egl::Error initialize(egl::Display *display) override;
void terminate() override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
ContextImpl *createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs) override;
egl::ConfigSet generateConfigs() override;
bool testDeviceLost() override;
egl::Error restoreLostDevice(const egl::Display *display) override;
bool isValidNativeWindow(EGLNativeWindowType window) const override;
egl::Error validateClientBuffer(const egl::Config *configuration,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs) const override;
DeviceImpl *createDevice() override;
std::string getVendorString() const override;
egl::Error waitClient(const gl::Context *context) override;
egl::Error waitNative(const gl::Context *context, EGLint engine) override;
gl::Version getMaxSupportedESVersion() const override;
EAGLContextObj getEAGLContext() const;
WorkerContext *createWorkerContext(std::string *infoLog);
void initializeFrontendFeatures(angle::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
private:
egl::Error makeCurrentSurfaceless(gl::Context *context) override;
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
std::shared_ptr<RendererGL> mRenderer;
egl::Display *mEGLDisplay;
EAGLContextObj mContext;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
struct __IOSurface;
typedef __IOSurface *IOSurfaceRef;
namespace egl
{
class AttributeMap;
} // namespace egl
namespace rx
{
class DisplayEAGL;
class FunctionsGL;
class StateManagerGL;
class IOSurfaceSurfaceEAGL : public SurfaceGL
{
public:
IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
EAGLContextObj cglContext,
EGLClientBuffer buffer,
const egl::AttributeMap &attribs);
~IOSurfaceSurfaceEAGL() override;
egl::Error initialize(const egl::Display *display) override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error unMakeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer) override;
egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
static bool validateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs);
FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) override;
bool hasEmulatedAlphaChannel() const override;
private:
angle::Result initializeAlphaChannel(const gl::Context *context, GLuint texture);
EAGLContextObj mEAGLContext;
IOSurfaceRef mIOSurface;
int mWidth;
int mHeight;
int mPlane;
int mFormatIndex;
bool mAlphaInitialized;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PBufferSurfaceEAGL.cpp: an implementation of egl::Surface for PBuffers for the EAGL backend,
// currently implemented using renderbuffers
#import "common/platform.h"
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h"
# include "common/debug.h"
# include "libANGLE/renderer/gl/FramebufferGL.h"
# include "libANGLE/renderer/gl/FunctionsGL.h"
# include "libANGLE/renderer/gl/RendererGL.h"
# include "libANGLE/renderer/gl/StateManagerGL.h"
namespace rx
{
PbufferSurfaceEAGL::PbufferSurfaceEAGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height)
: SurfaceGL(state),
mWidth(width),
mHeight(height),
mFunctions(renderer->getFunctions()),
mStateManager(renderer->getStateManager()),
mColorRenderbuffer(0),
mDSRenderbuffer(0)
{}
PbufferSurfaceEAGL::~PbufferSurfaceEAGL()
{
if (mColorRenderbuffer != 0)
{
mFunctions->deleteRenderbuffers(1, &mColorRenderbuffer);
mColorRenderbuffer = 0;
}
if (mDSRenderbuffer != 0)
{
mFunctions->deleteRenderbuffers(1, &mDSRenderbuffer);
mDSRenderbuffer = 0;
}
}
egl::Error PbufferSurfaceEAGL::initialize(const egl::Display *display)
{
mFunctions->genRenderbuffers(1, &mColorRenderbuffer);
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, mWidth, mHeight);
mFunctions->genRenderbuffers(1, &mDSRenderbuffer);
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mDSRenderbuffer);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mWidth, mHeight);
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::makeCurrent(const gl::Context *context)
{
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::swap(const gl::Context *context)
{
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height)
{
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer)
{
ERR() << "PbufferSurfaceEAGL::bindTexImage";
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error PbufferSurfaceEAGL::releaseTexImage(const gl::Context *context, EGLint buffer)
{
UNIMPLEMENTED();
return egl::NoError();
}
void PbufferSurfaceEAGL::setSwapInterval(EGLint interval) {}
EGLint PbufferSurfaceEAGL::getWidth() const
{
return mWidth;
}
EGLint PbufferSurfaceEAGL::getHeight() const
{
return mHeight;
}
EGLint PbufferSurfaceEAGL::isPostSubBufferSupported() const
{
UNIMPLEMENTED();
return EGL_FALSE;
}
EGLint PbufferSurfaceEAGL::getSwapBehavior() const
{
return EGL_BUFFER_PRESERVED;
}
FramebufferImpl *PbufferSurfaceEAGL::createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state)
{
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
GLuint framebuffer = 0;
functions->genFramebuffers(1, &framebuffer);
stateManager->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
functions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
mColorRenderbuffer);
functions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
mDSRenderbuffer);
return new FramebufferGL(state, framebuffer, true, false);
}
} // namespace rx
#endif // defined(ANGLE_PLATFORM_IOS)
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PBufferSurfaceEAGL.h: an implementation of egl::Surface for PBuffers for the EAGL backend,
// currently implemented using renderbuffers
#ifndef LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
namespace rx
{
class FunctionsGL;
class RendererGL;
class StateManagerGL;
class PbufferSurfaceEAGL : public SurfaceGL
{
public:
PbufferSurfaceEAGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLint width,
EGLint height);
~PbufferSurfaceEAGL() override;
egl::Error initialize(const egl::Display *display) override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer) override;
egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) override;
private:
unsigned mWidth;
unsigned mHeight;
// TODO(geofflang): Don't store these, they are potentially specific to a single GL context.
// http://anglebug.com/2464
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
GLuint mColorRenderbuffer;
GLuint mDSRenderbuffer;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RendererEAGL.cpp: Implements the class methods for RendererEAGL.
#import "common/platform.h"
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
# include "libANGLE/renderer/gl/eagl/RendererEAGL.h"
namespace rx
{
RendererEAGL::RendererEAGL(std::unique_ptr<FunctionsGL> functions,
const egl::AttributeMap &attribMap,
DisplayEAGL *display)
: RendererGL(std::move(functions), attribMap, display), mDisplay(display)
{}
RendererEAGL::~RendererEAGL() {}
WorkerContext *RendererEAGL::createWorkerContext(std::string *infoLog)
{
return mDisplay->createWorkerContext(infoLog);
}
} // namespace rx
#endif // defined(ANGLE_PLATFORM_IOS)
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RendererEAGL.h: implements createWorkerContext for RendererGL.
#ifndef LIBANGLE_RENDERER_GL_EAGL_RENDEREREAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_RENDEREREAGL_H_
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
class DisplayEAGL;
class RendererEAGL : public RendererGL
{
public:
RendererEAGL(std::unique_ptr<FunctionsGL> functions,
const egl::AttributeMap &attribMap,
DisplayEAGL *display);
~RendererEAGL() override;
private:
WorkerContext *createWorkerContext(std::string *infoLog) override;
DisplayEAGL *mDisplay;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_GLX_RENDERERGLX_H_
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// WindowSurfaceEAGL.h: EAGL implementation of egl::Surface
#ifndef LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
#define LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
#ifdef __OBJC__
@class EAGLContext;
typedef EAGLContext *EAGLContextObj;
#else
typedef void *EAGLContextObj;
#endif
@class CALayer;
struct __IOSurface;
typedef __IOSurface *IOSurfaceRef;
// WebKit's build process requires that every Objective-C class name has the prefix "Web".
@class WebSwapLayer;
namespace rx
{
class DisplayEAGL;
class FramebufferGL;
class FunctionsGL;
class RendererGL;
class StateManagerGL;
struct SharedSwapState
{
struct SwapTexture
{
GLuint texture;
unsigned int width;
unsigned int height;
uint64_t swapId;
};
SwapTexture textures[3];
// This code path is not going to be used by Chrome so we take the liberty
// to use pthreads directly instead of using mutexes and condition variables
// via the Platform API.
pthread_mutex_t mutex;
// The following members should be accessed only when holding the mutex
// (or doing construction / destruction)
SwapTexture *beingRendered;
SwapTexture *lastRendered;
SwapTexture *beingPresented;
};
class WindowSurfaceEAGL : public SurfaceGL
{
public:
WindowSurfaceEAGL(const egl::SurfaceState &state,
RendererGL *renderer,
EGLNativeWindowType layer,
EAGLContextObj context);
~WindowSurfaceEAGL() override;
egl::Error initialize(const egl::Display *display) override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer) override;
egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
void setSwapInterval(EGLint interval) override;
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) override;
private:
WebSwapLayer *mSwapLayer;
SharedSwapState mSwapState;
uint64_t mCurrentSwapId;
CALayer *mLayer;
EAGLContextObj mContext;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
GLuint mDSRenderbuffer;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
...@@ -1284,7 +1284,7 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1284,7 +1284,7 @@ void GenerateCaps(const FunctionsGL *functions,
extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") || extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") ||
functions->hasGLESExtension("GL_EXT_texture_sRGB_decode"); functions->hasGLESExtension("GL_EXT_texture_sRGB_decode");
#if defined(ANGLE_PLATFORM_APPLE) #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
VendorID vendor = GetVendorID(functions); VendorID vendor = GetVendorID(functions);
if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0)) if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
{ {
......
...@@ -129,7 +129,7 @@ libangle_gpu_info_util_libpci_sources = ...@@ -129,7 +129,7 @@ libangle_gpu_info_util_libpci_sources =
libangle_gpu_info_util_x11_sources = [ "src/gpu_info_util/SystemInfo_x11.cpp" ] libangle_gpu_info_util_x11_sources = [ "src/gpu_info_util/SystemInfo_x11.cpp" ]
libangle_gpu_info_util_mac_sources = [ "src/gpu_info_util/SystemInfo_mac.mm" ] libangle_gpu_info_util_mac_sources = [ "src/gpu_info_util/SystemInfo_macos.mm" ]
libangle_includes = [ libangle_includes = [
"include/angle_gl.h", "include/angle_gl.h",
......
...@@ -301,6 +301,15 @@ EGLBoolean EGLAPIENTRY EGL_QueryDeviceAttribEXT(EGLDeviceEXT device, ...@@ -301,6 +301,15 @@ EGLBoolean EGLAPIENTRY EGL_QueryDeviceAttribEXT(EGLDeviceEXT device,
} }
error = dev->getAttribute(attribute, value); error = dev->getAttribute(attribute, value);
break; break;
case EGL_EAGL_CONTEXT_ANGLE:
if (!dev->getExtensions().deviceEAGL)
{
thread->setError(EglBadAttribute(), GetDebug(), "eglQueryDeviceAttribEXT",
GetDeviceIfValid(dev));
return EGL_FALSE;
}
error = dev->getAttribute(attribute, value);
break;
case EGL_CGL_CONTEXT_ANGLE: case EGL_CGL_CONTEXT_ANGLE:
case EGL_CGL_PIXEL_FORMAT_ANGLE: case EGL_CGL_PIXEL_FORMAT_ANGLE:
if (!dev->getExtensions().deviceCGL) if (!dev->getExtensions().deviceCGL)
......
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