Skip to content

Commit 65c7890

Browse files
Refactored MakeCurrent for EAGL and EAGL iOS drivers
Refactored Frame/Render buffers creation for an EGL Window Surface Added partial support for destroying frame/renders buffers when Window Surface is destroyed Updated READMEs
1 parent a493bd5 commit 65c7890

File tree

9 files changed

+350
-136
lines changed

9 files changed

+350
-136
lines changed

README-DEV.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@
33
## TODO LibEGL Bug Priority List:
44

55
- None yet :)
6+
- EAGLIOS_DestroyWindow must call windowsurfacehelper_destroyFrameBuffer
7+
- EGLSurface backed with EAGLSurface and EAGLContext is inconsistent as soon as EAGLSurface and EAGLContext are not current.
8+
The frame/color/depth buffers content lives in the EAGLContext. Should EAGLSharegroup bound to EAGLSurface be used to store frame/color/depth buffer ?
9+
- Due to this bug, the framebuffer and related renderbuffers are leaking. See "EAGLIOS_DestroyWindow: Leak when destroying an EGL WindowSurface" msg
610

711
## TODO LibEGL Feature Priority List:
812

913
- Add EGL_SWAP_BEHAVIOR_PRESERVED_BIT support. See EGL 1.4 Table 3.2
1014
Surface swap is EGL_BUFFER_DESTROYED for now ? See iOS support EGL_BUFFER_RETAINED via kEAGLDrawablePropertyRetainedBacking too
1115
- Add support for rotation. See EGL 1.4 - Section 3.9.1 Native Window Resizing
16+
- Add support for Multisampling
1217

1318
## TODO Uncategorised List:
1419

1520
- When are OpenGL ES buffers associated to EGLSurface deleted ?
1621
- Memory Leak: App starts with 8.5Mb without EGL. Running the demo + unit test consumes more 16Mb. When the demo stops, the memory consumption is higher than 8.5Mb. Some resources are not deleted
1722
- eglMakeCurrent(EGLDisplay dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) -> are FB/CB etc cleared ??? Should they ?
23+
- Split Samples from UT Xcode projects
24+
- Can add support for GLKView (currently only CEAGLLayer supported) ?
1825

1926
## TODO Code Cleanup Priority List:
2027

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ is supported in this implementation.
139139
| eglQueryAPI | Supported | |
140140
| eglQueryContext | Supported | |
141141
| eglSurfaceAttrib | Planned | |
142-
| eglMakeCurrent | Partially supported | |
142+
| eglMakeCurrent | Partially supported | `EGLSurface read` and `EGLSurface draw` must be the same |
143143
| eglGetCurrentContext | Supported | |
144144
| eglGetCurrentSurface | Supported | |
145145
| eglGetCurrentDisplay | Supported | |

include/EGL/drivers/eagl/egl_eagl_driver.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@ typedef void (*EAGLDESTROYCONTEXTPROC)( _EAGLWindow *dpy, struct EAGL_egl_contex
7676

7777
/**
7878
* Make EGLContext current a native EGL Context
79-
* \param EAGL_dpy
80-
* \param EAGL_conf
81-
* \param EAGL_ctx_shared
82-
* \param attrib_list
79+
* \param dpy,
80+
* \param EAGL_dsurf
81+
* \param EAGL_rsurf
8382
* \param EAGL_ctx
83+
* \param EAGL_odsurf
84+
* \param EAGL_orsurf
85+
* \param EAGL_octx
8486
* \return Non NULL instance IFF initialization succeeded only.
8587
*/
86-
typedef EGLBoolean (*EAGLMAKECURRENTPROC)(_EAGLWindow *dpy, struct EAGL_egl_surface* surface, struct EAGL_egl_context* ctx, _OpenGLESAPI* api);
88+
typedef EGLBoolean (*EAGLMAKECURRENTPROC)(_EAGLWindow *dpy,
89+
struct EAGL_egl_surface* EAGL_dsurf,
90+
struct EAGL_egl_surface* EAGL_rsurf,
91+
struct EAGL_egl_context* EAGL_ctx,
92+
struct EAGL_egl_surface *EAGL_odsurf,
93+
struct EAGL_egl_surface *EAGL_orsurf,
94+
struct EAGL_egl_context *EAGL_octx);
8795
/**
8896
* Swap buffers
8997
* \param EAGL_dpy
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**************************************************************************
2+
* MIT LICENSE
3+
*
4+
* Copyright (c) 2013-2014, David Andreoletti <http://davidandreoletti.com>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
**************************************************************************/
24+
25+
#ifndef INCLUDE_EGL_DRIVERS_EAGL_IOS_EGL_EAGL_IOS_WINDOWSURFACEHELPER_H_
26+
#define INCLUDE_EGL_DRIVERS_EAGL_IOS_EGL_EAGL_IOS_WINDOWSURFACEHELPER_H_
27+
28+
#include "EGL/drivers/eagl/opengles/opengles_ios.h"
29+
#include "EGL/drivers/eagl/egl_eagl_typedefs.h"
30+
#include "EGL/drivers/eagl/egl_eagl_context.h"
31+
32+
bool windowsurfacehelper_createFrameBuffer(struct EAGL_egl_context* context, _EAGLSurface* surface,
33+
_OpenGLESAPI* api);
34+
35+
bool windowsurfacehelper_destroyFrameBuffer(struct EAGL_egl_context* context, _EAGLSurface* surface,
36+
_OpenGLESAPI* api);
37+
38+
bool windowsurfacehelper_makeFrameBufferCurrent(struct EAGL_egl_context* context, _EAGLSurface* surface,
39+
_OpenGLESAPI* api);
40+
41+
#endif // INCLUDE_EGL_DRIVERS_EAGL_IOS_EGL_EAGL_IOS_WINDOWSURFACEHELPER_H_

proj/proj.ios/eglapi-core-lib/eglapi-core-lib.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
F6794D0218DD7980002B8AFF /* EAGLIOSSurface.m in Sources */ = {isa = PBXBuildFile; fileRef = F6794CFE18DD7980002B8AFF /* EAGLIOSSurface.m */; };
123123
F6794D0318DD7980002B8AFF /* EAGLIOSWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6794CFF18DD7980002B8AFF /* EAGLIOSWindow.mm */; };
124124
F6794D0518DD802F002B8AFF /* egl_eagl_ios_config.h in Headers */ = {isa = PBXBuildFile; fileRef = F6794D0418DD802F002B8AFF /* egl_eagl_ios_config.h */; };
125+
F6A2745618DE877B003304B2 /* egl_eagl_ios_windowsurfacehelper.h in Headers */ = {isa = PBXBuildFile; fileRef = F6A2745518DE877B003304B2 /* egl_eagl_ios_windowsurfacehelper.h */; };
126+
F6A2745818DE87DE003304B2 /* egl_eagl_ios_windowsurfacehelper.m in Sources */ = {isa = PBXBuildFile; fileRef = F6A2745718DE87DE003304B2 /* egl_eagl_ios_windowsurfacehelper.m */; };
125127
F6F66B48189F4FE1008636CE /* eglplatform.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C7A86F78172B8B2300739D0D /* eglplatform.h */; };
126128
F6F66B49189F57D3008636CE /* eglmesaext.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C7A86F74172B8B2300739D0D /* eglmesaext.h */; };
127129
F6F66B4B18A109BE008636CE /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C784D397171457B10086C69F /* OpenGLES.framework */; };
@@ -277,6 +279,8 @@
277279
F6794CFE18DD7980002B8AFF /* EAGLIOSSurface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EAGLIOSSurface.m; path = ios/EAGLIOSSurface.m; sourceTree = "<group>"; };
278280
F6794CFF18DD7980002B8AFF /* EAGLIOSWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = EAGLIOSWindow.mm; path = ios/EAGLIOSWindow.mm; sourceTree = "<group>"; };
279281
F6794D0418DD802F002B8AFF /* egl_eagl_ios_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = egl_eagl_ios_config.h; sourceTree = "<group>"; };
282+
F6A2745518DE877B003304B2 /* egl_eagl_ios_windowsurfacehelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = egl_eagl_ios_windowsurfacehelper.h; sourceTree = "<group>"; };
283+
F6A2745718DE87DE003304B2 /* egl_eagl_ios_windowsurfacehelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = egl_eagl_ios_windowsurfacehelper.m; path = ios/egl_eagl_ios_windowsurfacehelper.m; sourceTree = "<group>"; };
280284
F6F8047618D556E9009F64C0 /* opengles3_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opengles3_ios.h; sourceTree = "<group>"; };
281285
F6F8047818D55716009F64C0 /* opengles3_ios.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = opengles3_ios.c; sourceTree = "<group>"; };
282286
/* End PBXFileReference section */
@@ -312,6 +316,7 @@
312316
C70713CE1821D5620020806A /* ios */ = {
313317
isa = PBXGroup;
314318
children = (
319+
F6A2745718DE87DE003304B2 /* egl_eagl_ios_windowsurfacehelper.m */,
315320
F6794CFC18DD7980002B8AFF /* egl_eagl_ios_driver.m */,
316321
F6794CFD18DD7980002B8AFF /* EAGLIOSContext.m */,
317322
F6794CFE18DD7980002B8AFF /* EAGLIOSSurface.m */,
@@ -574,6 +579,7 @@
574579
F639689018AAF7110076C110 /* ios */ = {
575580
isa = PBXGroup;
576581
children = (
582+
F6A2745518DE877B003304B2 /* egl_eagl_ios_windowsurfacehelper.h */,
577583
F6794D0418DD802F002B8AFF /* egl_eagl_ios_config.h */,
578584
F6794CF218DD7945002B8AFF /* egl_eagl_ios_driver.h */,
579585
F6794CF318DD7945002B8AFF /* EAGLIOSContext.h */,
@@ -628,6 +634,7 @@
628634
F61BCB2C18CF4E480015D31E /* opengles1_ios.h in Headers */,
629635
C7A86F86172B8B2300739D0D /* egldisplay.h in Headers */,
630636
C7A86F87172B8B2300739D0D /* egldriver.h in Headers */,
637+
F6A2745618DE877B003304B2 /* egl_eagl_ios_windowsurfacehelper.h in Headers */,
631638
C7A86F88172B8B2300739D0D /* eglext.h in Headers */,
632639
C7A86F89172B8B2300739D0D /* eglglobals.h in Headers */,
633640
C7A86F8A172B8B2300739D0D /* eglimage.h in Headers */,
@@ -798,6 +805,7 @@
798805
buildActionMask = 2147483647;
799806
files = (
800807
C709B8C21706818800FBCA04 /* eglapi.m in Sources */,
808+
F6A2745818DE87DE003304B2 /* egl_eagl_ios_windowsurfacehelper.m in Sources */,
801809
C7A86FA7172B8B3600739D0D /* eglapi.c in Sources */,
802810
F6794D0118DD7980002B8AFF /* EAGLIOSContext.m in Sources */,
803811
C7A86FA8172B8B3600739D0D /* eglarray.c in Sources */,

samples/samples.ios/Sample1/proj/proj.ios/Sample1/AppDelegate.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ - (void) sample: (id) param {
5151
TestPlatform p = {0};
5252
iosInitializeWithDefault(&p);
5353
run_samples(&p);
54-
run_unit_tests(&p);
54+
// run_unit_tests(&p);
5555
iosDestroyWithDefault(&p);
5656
}
5757

src/EGL/drivers/eagl/egl_eagl.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ static EGLBoolean _checkSurfaceAttribMatchConfigAttrib(_EGLSurface* surf, _EGLCo
297297
return EGL_FALSE;
298298
}
299299

300-
ret = EAGL_drv->MakeCurrent(EAGL_dpy->Window, EAGL_dsurf, EAGL_ctx, &EAGL_ctx->OpenGLESAPI);
300+
struct EAGL_egl_surface *EAGL_odsurf = EAGL_egl_surface(old_dsurf);
301+
struct EAGL_egl_surface *EAGL_orsurf = EAGL_egl_surface(old_rsurf);
302+
struct EAGL_egl_context *EAGL_octx = EAGL_egl_context(old_ctx);
303+
304+
ret = EAGL_drv->MakeCurrent(EAGL_dpy->Window, EAGL_dsurf, EAGL_rsurf, EAGL_ctx, EAGL_odsurf, EAGL_orsurf, EAGL_octx);
301305

302306
if (ret) {
303307
if (_eglPutSurface(old_dsurf))

0 commit comments

Comments
 (0)