Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 12ce8f6

Browse files
kenrussellCommit Bot
authored andcommitted
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/+/1987278 Reviewed-by: Shahbaz Youssefi <[email protected]> Reviewed-by: Jonah Ryan-Davis <[email protected]> Reviewed-by: James Darpinian <[email protected]> Commit-Queue: Kenneth Russell <[email protected]>
1 parent 7a37d3a commit 12ce8f6

32 files changed

+1946
-30
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Name
2+
3+
ANGLE_device_eagl
4+
5+
Name Strings
6+
7+
EGL_ANGLE_device_eagl
8+
9+
Contributors
10+
11+
Dean Jackson (dino 'at' apple.com)
12+
Ken Russell (kbr 'at' google.com)
13+
14+
Contact
15+
16+
Ken Russell (kbr 'at' google.com)
17+
18+
Status
19+
20+
Draft
21+
22+
Version
23+
24+
Version 1, January 3, 2020
25+
26+
Number
27+
28+
EGL Extension #XXX
29+
30+
Extension Type
31+
32+
EGL device extension
33+
34+
Dependencies
35+
36+
This extension is written against the language of EGL 1.5 as
37+
modified by EGL_EXT_device_query.
38+
39+
EGL_EXT_device_query is required.
40+
41+
Overview
42+
43+
ANGLE on iOS internally uses an OpenGL ES context allocated via EAGL.
44+
This extension defines a mapping from an EGL device to the underlying
45+
EAGLContext, after it's been queried from an EGL display.
46+
47+
IP Status
48+
49+
No known claims.
50+
51+
New Types
52+
53+
None.
54+
55+
New Procedures and Functions
56+
57+
None.
58+
59+
New Tokens
60+
61+
Accepted as a queried <attribute> in eglQueryDeviceAttribEXT:
62+
63+
EGL_EAGL_CONTEXT_ANGLE 0x348C
64+
65+
Add a new section 2.1.3 (EAGL Devices) after 2.1.2 (Devices)
66+
67+
On iOS the underlying EAGLContext can be queried from the EGL device. The
68+
intented purpose is to allow applications to create new EAGLContexts which
69+
share resources with this one.
70+
71+
Changes to section 3.2 (Devices)
72+
73+
Replace the paragraph immediately following the prototype for
74+
eglQueryDeviceAttribEXT:
75+
76+
<attribute> must be EGL_EAGL_CONTEXT_ANGLE. On success, EGL_TRUE is
77+
returned, and a valid EAGLContext corresponding to the EGL device is
78+
returned in <value>. This object is compatible with OpenGL ES and EAGL API
79+
functions. If the EGL device is not currently associated with an
80+
EAGLContext, EGL_BAD_ATTRIBUTE is returned, and <value> is left unchanged.
81+
82+
Issues
83+
84+
None
85+
86+
Revision History
87+
88+
Version 1, January 3, 2020 (Ken Russell)
89+
- Initial Draft

include/EGL/eglext_angle.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithFrameTokenANGLE(EGLDisplay dpy,
274274
#endif
275275
#endif /* EGL_ANGLE_swap_with_frame_token */
276276

277+
#ifndef EGL_ANGLE_device_eagl
278+
#define EGL_ANGLE_device_eagl 1
279+
#define EGL_EAGL_CONTEXT_ANGLE 0x348C
280+
#endif
281+
277282
// clang-format on
278283

279284
#endif // INCLUDE_EGL_EGLEXT_ANGLE_

scripts/export_targets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def pre(k):
185185
b'libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h',
186186
b'libANGLE/renderer/gl/glx/DisplayGLX.h',
187187
b'libANGLE/renderer/gl/cgl/DisplayCGL.h',
188+
b'libANGLE/renderer/gl/eagl/DisplayEAGL.h',
188189
b'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h',
189190
b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h',
190191
b'libANGLE/renderer/gl/wgl/DisplayWGL.h',

src/common/platform.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@
118118
# include <TargetConditionals.h>
119119
# if TARGET_OS_OSX
120120
# define ANGLE_PLATFORM_MACOS 1
121-
# elif TARGET_OS_IOS
121+
# elif TARGET_OS_IPHONE
122122
# define ANGLE_PLATFORM_IOS 1
123+
# define GLES_SILENCE_DEPRECATION
124+
# if TARGET_OS_SIMULATOR
125+
# define ANGLE_PLATFORM_IOS_SIMULATOR 1
126+
# endif
127+
# if TARGET_OS_MACCATALYST
128+
# define ANGLE_PLATFORM_MACCATALYST
129+
# endif
123130
# endif
124131
#endif
125132

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style license that can be
4+
// found in the LICENSE file.
5+
//
6+
7+
// SystemInfo_ios.cpp: implementation of the iOS-specific parts of SystemInfo.h
8+
9+
#include "common/platform.h"
10+
11+
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
12+
13+
# include "gpu_info_util/SystemInfo_internal.h"
14+
15+
namespace angle
16+
{
17+
18+
bool GetSystemInfo(SystemInfo *info)
19+
{
20+
{
21+
// TODO(anglebug.com/4275): Get the actual system version.
22+
info->machineModelVersion = "0.0";
23+
}
24+
25+
return true;
26+
}
27+
28+
} // namespace angle
29+
30+
#endif // defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
// found in the LICENSE file.
55
//
66

7-
// SystemInfo_mac.mm: implementation of the Mac-specific parts of SystemInfo.h
7+
// SystemInfo_macos.mm: implementation of the macOS-specific parts of SystemInfo.h
88

99
#include "common/platform.h"
1010

11-
#ifdef ANGLE_PLATFORM_MACOS
11+
#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
1212

1313
# include "gpu_info_util/SystemInfo_internal.h"
1414

@@ -244,4 +244,4 @@ bool GetSystemInfo(SystemInfo *info)
244244

245245
} // namespace angle
246246

247-
#endif // ANGLE_PLATFORM_MACOS
247+
#endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)

src/libANGLE/Caps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,9 @@ struct DeviceExtensions
10071007

10081008
// EGL_ANGLE_device_cgl
10091009
bool deviceCGL = false;
1010+
1011+
// EGL_ANGLE_device_eagl
1012+
bool deviceEAGL = false;
10101013
};
10111014

10121015
struct ClientExtensions

src/libANGLE/Display.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252
# include "libANGLE/renderer/gl/wgl/DisplayWGL.h"
5353
# elif defined(ANGLE_USE_X11)
5454
# include "libANGLE/renderer/gl/glx/DisplayGLX.h"
55-
# elif defined(ANGLE_PLATFORM_APPLE)
55+
# elif defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
5656
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
57+
# elif defined(ANGLE_PLATFORM_IOS)
58+
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
5759
# elif defined(ANGLE_USE_OZONE)
5860
# include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h"
5961
# elif defined(ANGLE_PLATFORM_ANDROID)
@@ -241,8 +243,10 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, const DisplaySt
241243
impl = new rx::DisplayWGL(state);
242244
# elif defined(ANGLE_USE_X11)
243245
impl = new rx::DisplayGLX(state);
244-
# elif defined(ANGLE_PLATFORM_APPLE)
246+
# elif defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
245247
impl = new rx::DisplayCGL(state);
248+
# elif defined(ANGLE_PLATFORM_IOS)
249+
impl = new rx::DisplayEAGL(state);
246250
# elif defined(ANGLE_USE_OZONE)
247251
// This might work but has never been tried, so disallow for now.
248252
impl = nullptr;

src/libANGLE/formatutils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
10081008
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
10091009
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);
10101010
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);
1011+
#if defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)
1012+
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);
1013+
#else
10111014
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);
1015+
#endif
10121016

10131017
// Unsized integer formats
10141018
// |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |

src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "common/platform.h"
1010

11-
#ifdef ANGLE_PLATFORM_MACOS
11+
#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
1212

1313
# include "libANGLE/renderer/gl/cgl/DeviceCGL.h"
1414

@@ -58,4 +58,4 @@ void DeviceCGL::generateExtensions(egl::DeviceExtensions *outExtensions) const
5858

5959
} // namespace rx
6060

61-
#endif // ANGLE_PLATFORM_MACOS
61+
#endif // defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)

0 commit comments

Comments
 (0)