-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for MetalANGLE on UIKit (OpenGL ES to Metal API translation layer) #4333
Conversation
Our toolchain manages by itself the choice, but seems logical for users unfamiliar with kivy-ios to add a mini-guide about how to start using the
|
This adds SDL_VIDEO_METALANGLE to SDL_config.h.in but doesn't touch |
src/video/SDL_sysvideo.h
Outdated
@@ -402,7 +402,7 @@ struct SDL_VideoDevice | |||
struct SDL_EGL_VideoData *egl_data; | |||
#endif | |||
|
|||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 | |||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 || SDL_VIDEO_METALANGLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better approach would be to do a similar thing to the EGL
, CGL
, GLX
, etc. opengl context backend defines (you can see some examples by looking at how SDL_VIDEO_OPENGL_EGL
is used) – I don't think code here needs to care whether metal-ANGLE is used to create the OpenGL ES context, since it's just an implementation of the OpenGL ES API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, and it makes sense.
I'm going for a SDL_VIDEO_OPENGL_METALANGLE
if it looks nice.
@@ -46,6 +46,14 @@ | |||
#include "SDL_opengles2.h" | |||
#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ | |||
|
|||
#if SDL_VIDEO_METALANGLE | |||
#include <MetalANGLE/GLES2/gl2.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these headers needed here if the code is changed to keep SDL_VIDEO_OPENGL_ES2
defined instead of making it mutually exclusive with the metal-angle backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be merged inside the SDL_opengles2.h
file, with a #if SDL_VIDEO_OPENGL_METALANGLE #else ...
|
||
#include "../SDL_sysvideo.h" | ||
|
||
extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files have a lot of duplicate code. I wonder if it might be cleaner to merge it all into SDL_uikitopengles
etc. with a couple #ifdefs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, there's a lot of duplicated code (especially for the header files), but, instead src/video/uikit/SDL_uikitmetalangleview.m
is going to be definitely cleaner into a separate file.
I will try to merge the two implementations when changing SDL_VIDEO_METALANGLE
to SDL_VIDEO_OPENGL_METALANGLE
unless it makes sense to have both on the same file.
src/video/uikit/SDL_uikitwindow.m
Outdated
@@ -370,6 +375,13 @@ - (void)layoutSubviews | |||
info->info.uikit.colorbuffer = glview.drawableRenderbuffer; | |||
info->info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer; | |||
} else { | |||
#elif SDL_VIDEO_METALANGLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the metal-angle view code is able to be merged into SDL_uikitopenglview
using a couple defines in key places, this codepath shouldn't be needed anymore.
I don't remember how MoltenVK is integrated into SDL's build process but it's probably worth looking at that to see if the two can be made consistent with each other. It'd be weird to have two context backends not using the same integration process (I'm not sure whether it would make more sense to do what MoltenVK is doing, or to change what MoltenVK is doing to match this change.) |
From what I understand MetalANGLE is a fork of ANGLE. Is it going to be upstreamed any time in the foreseeable future? If so, is there anything this change can do to make the transition easier from SDL's side when it happens? SDL has ANGLE integration on a few other platforms. |
Upstream ANGLE has the Metal renderer in progress according to the readme and only OpenGL ES 2.0 is supported right now. OpenGL ES 3.0 is in progress currently. |
Yes, The most important one, at this time, is:
So yes, there's a small chance, but seems it's not happening in the near future (unfortunately). |
@slime73, some updates:
|
We're going to watch upstream ANGLE (not MetalANGLE) to decide when iOS support is ready and deal with it then. |
Description
This PR adds support for
MetalANGLE
provided "window" for iOS / iPadOS.It keeps the "standard way" to instantiate a view on iOS by using the deprecated OpenGLES Apple own implementation, but adds a way to support OpenGL views also after the (not still known) removal date.
I don't expect a merge as-is, but the code We ( https://github.com/kivy/kivy-ios ) have used for our specific implementation is quite stable and tested, so it was worth to share it and start a discussion about the future. (See the related PR on kivy-ios: kivy/kivy-ios#448)
Existing Issue(s)