kivy-ios icon indicating copy to clipboard operation
kivy-ios copied to clipboard

[WIP] MetalANGLE support?

Open misl6 opened this issue 4 years ago • 10 comments

Apple deprecated OpenGLES.framework since iOS 12.

This is a first-stage testing and migration to MetalANGLE, a OpenGL ES to Metal API translation layer.

It's something I'm going to work on weekends, I hope is going to be ready for when Apple will remove support for opengles.

TODO:

  • [ ] Test, test, test, test, and test again
  • [x] Wait for glGenerateMipmap fix or disable mipmap
  • [x] Cleanup

KNOWN ISSUES:

misl6 avatar Apr 18 '20 15:04 misl6

Tested over touchtracer and showcase and works fine with mipmapping disabled.

misl6 avatar Apr 25 '20 16:04 misl6

  • :heavy_check_mark: mipmap issue got fixed thanks to @kakashidinho (The author of MetalANGLE).
  • :mailbox: I proposed to the SDL2 team a migration to MetalANGLE.framework in order to not rely on my patched repo in the future.
  • :factory: Updated toolchain to automagically include embedded frameworks inside the project

Testing it's still appreciated

misl6 avatar Apr 26 '20 10:04 misl6

Update:

  • I had to add a fix in order to remove the un-needed archs from MetalANGLE.framework/MetalANGLE because Apple Store Validation was refusing Universal frameworks.

  • ~~Now it seems failing with this error: https://github.com/kakashidinho/metalangle/issues/13~~ (fixed via https://github.com/kakashidinho/metalangle/commit/1964ec02f475dc210300313d543f2cd8f96de9bb)

misl6 avatar May 23 '20 10:05 misl6

If this is merged, I noticed that XCode fails to build the app because the target is iOS 8.1+ and Metal is only supported on iOS 12+

mbrockman1 avatar Sep 24 '20 14:09 mbrockman1

@mbrockman1 It's not merged yet. You're using it for some specific reason or just for testing?

misl6 avatar Sep 24 '20 16:09 misl6

@misl6 Only for testing. You are a legend for setting this up by the way. If it is helpful, I could identify all the problems I had from start to finish in making the app using your branch.

mbrockman1 avatar Sep 24 '20 17:09 mbrockman1

@mbrockman1 Sounds good to have some testing and reporting!

FYI: I'm not expecting to remove the WIP tag and requesting for a merge until at least one of these two conditions are met:

  1. Apple removes support for OpenGL

  2. An intuitive and recipe oriented method for selecting OpenGL vs MetalANGLE during compilation is available.

I was working on the 2nd option, but then I had to stop due to lack of free time.

Apart of that, feel free to send bug reports or suggestions!

misl6 avatar Sep 24 '20 18:09 misl6

I posted this in discord. I was using a blend of your pull request plus the latest Kivy-iOS master to attempt to release an app. Here is a list of the problems and how I revolved them:

- Had to hard code Python.h and initconfig.h in Xcode
*fix: https://www.reddit.com/r/kivy/comments/gr1zep/xcode_validate_fails_cant_find_pythonh/*

- Line 1473 & 1477 of kivy-ios/toolchain.py was causing an import error
Import xcassets => from .tools.external import xcassets

- Had issues with icon generation to the point where I had to make my own and put them into the assets folder. I dont know if it is related to xcassets import or not.

- The MetalAngle branch worked well, only thing that needed adjustment was increase the target deployment to iOS 12+ from iOS 8.1+ because that is when Metal started support.

- Missing purpose string for NSCamera fixed by following this: https://stackoverflow.com/questions/44690075/xcode-missing-info-plist-key-for-nscamerausagedescription/49439492#49439492

- Had to specify “-exportOptionsPlist” but regardless buildozer iOS release didnt work so I had to release it via Xcode. Link: https://github.com/kivy/kivy-ios/issues/326#issuecomment-451656753

- Had to cut iPad support due to this issue: https://forum.defold.com/t/error-itms-90474-invalid-bundle-ipad-multitasking-support-requires-these-orientations/56128

mbrockman1 avatar Sep 24 '20 19:09 mbrockman1

FYI, MetalANGLE requires iOS min version 9.0 not 12.0. You can set deployment target 9.0 and it should still work (although it will fallback to native OpenGL on pre iOS 11.0 devices but from application point of view everything will work the same)

kakashidinho avatar Sep 24 '20 19:09 kakashidinho

Some updates:

  • I did a complete rework of the SDL2 code, so it could hopefully get merged into the SDL2 upstream, I will submit a PR ASAP.
  • Now We share the same SDL codebase for both MetalANGLE and OpenGLES versions of SDL2 provided views.
  • Our user is able to select the needed (by default it's still OpenGLES) SDL2 by using an environment variable (export KIVYIOS_USE_METALANGLE=1)
  • Now We're downloading the provided binaries for MetalANGLEwithout building them. (Definitely faster, but that behavior could be changed if someone have some concerns about it)

What is unsupported right now:

  • Due to how Apple Framework are managed, at this time (due to lack of time) We're unable to build for both iOS and iOS Simulator without the intervention of the user, by default, the toolchain selects iOS. This could be easily managed by creating an xcframework

Will add a specific section for "Building with MetalANGLE.framework in README.md after the SDL PR.

misl6 avatar Apr 25 '21 12:04 misl6