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
Metal Support for iOS #4593
Comments
So one big issue... Metal is not supported on all iOS devices. Basically it is any iOS device with an A7 GPU or higher. This means iPhone 5c, iPhone 5, iPhone 4S, and iPhone 4 which make up over 30% of iPhones out there do not support Metal. Same sort of picture on the iPad side with lots of popular devices not supporting Metal. This means we have two choices:
I'm leaning towards waiting myself. |
See
|
@tomspilman Should probably wait until late 2016 or later then to integrate Metal with MonoGame iOS / Mac. Hopefully Apple says something about Vulkan by then and we figure out what the new MonoGame API will be to use the next generation graphics APIs. |
Hi. Any news out there? Best regards |
Nothing new here. I bet Apple will hold off on dropping GL for a bit, there'd be outrage if they didn't. |
I am worried about this as well. I expect first thing that will happen is Apple disallowing new games using OpenGL. That could happen in the next 6 to 12 months IMO. Then maybe a year later they could consider hiding OGL games on new Apple devices. Then maybe after that totally delisting OGL games. But i could be 100% wrong on that. We will be tackling this soon as we have a OGL game that needs the same fix. |
A better option should be to not use Metal, but instead use Vulkan and MoltenVK. Metal is only used on Mac and iOS and we have pretty much no one who likes using them from the core dev team. |
I thought Apple was disallowing MoltenVK also thought it was a closed source paid project. Seems like maybe all that has changed? I'm good with a Vulkan implementation as i'm doing one now as well. So we're covered. |
MoltenVK has been updated to be compliant with the iOS cert (it was using non public surfaces but that's now fixed and games using MoltenVK are being accepted). |
Thanks for your feedback. Over the last couple of days, I' ve tried a few things and I have found a good emergency plan for me. I tested a few frameworks and it seems that apple's SceneKit could fill the gap on iOS. In MG my 3D models are exported to X-Files and then compiled to XNB-Files with the pipeline tool. With SceneKit, I have to export the original 3D-Model to a COLLADA File Format (dae). These collada-files could easily rendered natively with SceneKit. It seams that SceneKit has a similar ligning system, like MG. To be platform independent we need a monogame-adapter for iOS, which is based on SceneKit. But perhaps the MoltenVK/Vulkan plan is still a better idea. |
Is there an update on Metal? Looks like most other frameworks support Metal fully. The performance implications means Metal is quite important in iOS. Is there any help needed here? I am impressed WWDC21 (and 20) didn't mention anything about the depreciation surprisingly. But I doubt that will remain true in the coming months or year. |
FYI #7523 (comment) |
Hi, this thread seems to be focused mainly on implementing Metal for iOS, which got me wondering if support for Metal on macOS is being planned. If that wasn't the case, my guess is it would mean that Mac would still run on OpenGL. That however, would mean anything requiring a version of OpenGL newer than 4.1 (for example Compute Shaders), wouldn't be possible, which is kinda worrying |
@SimonDarksideJ @mrhelmut @harry-cpp I would like to take steps towards this. Here is a high-level plan:
|
@Mindfulplays Thank you for taking an interest in this task. We've actually been discussing Metal support internally over the last week and have decided that we are not gonna support Metal directly, and instead, we will be supporting it using Vulkan. Vulkan on Apple platforms is actually MoltenVK, which is a Vulkan to Metal conversion layer. We also have a partial Vulkan implementation already and are working on merging it into the main repo, so there are some starting points for that as well :)
Awesome work, and much appreciated! The graphics tests are currently not runnable on the GitHub Action bots, however, we are in the process of bringing back our old graphics test bots online. They should come back some time during December, and once back, I'l help with getting your PR merged and running on them. |
@harry-cpp That's great news! MoltenVK should solve both Android/iOS. I wonder if adding tests on mobile might help validate that effort (I am in the process of doing so). @tomspilman if there is any help needed on the VK front I am happy to help. I will take a look at other iOS/mobile stuff meanwhile (if there are specific ones that I can participate please let me know, not just mobile). Thanks again! |
Is this Vulkan implementation built around the Compute Shader PR (#7533) or is it a completely separate effort. I ask because that PR is based on the ShaderConductor PR (#7345) and a goal there was to set the groundwork for supporting Vulkan & Metal.
Just asking in case work is being duplicated. |
Hi Tom @tomspilman ,
I am also curious if the plan is to move all DesktopGL targets to be MoltenVk in the future? (Which seems totaly fine - but would 'DX' go through MoltenVK too?) Mostly questions for you folks for the next board meeting. thanks! |
Apple deprecated OpenGL a long time ago, and there is a valid chance that in the not-so-distant future they ban OpenGL from their certification process. We should move to Metal/Vulkan as soon as possible. SPIR-V has the advantage to be an intermediate language that nearly all modern shader compilers can work with, and that includes all gaming consoles. There would be a great advantage to modernize the shading pipeline to have a SPIR-V intermediate layer. This would unify all platforms under the same flag and ease maintenance. Also, an HLSL to MSL compiler is likely to use SPIR-V internally anyway. Using MoltenVK over Metal directly is a shortcut to reuse the upcoming desktop Vulkan target. It avoids the need to write an entirely new backend (with possibly its set of own bugs) for just one platform and ease maintenance by having only one backend to maintain for multiple targets. Though if anyone wishes to contribute a Metal implementation, it would be welcomed. It's the same principle that today with DesktopGL and Android sharing the same code, except that in the future DesktopVK will share its code with both Android and iOS to ease maintenance. MoltenVK is a Metal implementation of Vulkan, it translates Vulkan calls into Metal ones. You can see it as a driver, it's not an API. We would only have to maintain a Vulkan backend and the use of MoltenVK will be transparent. MoltenVK and Metal are specific to the Apple ecosystem, it can't replace Direct3D. |
Can't +1 this enough.
Agreed, seems very reasonable. Minor quibble: HLSL->MSL is possible with the new Apple Metal Shader Converter. DXC tools from MSFT (very useful for converting dxbc->dxil etc) which forms the basis for the metal shader converter. Even MojoShader has support for MSL directly (no SPIR-V routing) - if we update FYI, I have an initial MG+Metal version I have been working on: metal shader converter/DXC tools integrate 'seamlessly' into the MGFXC pipeline (and the final metal programs for the default MG effects such as sprite/basic etc work with the MG codebase) and many of the
If I understand correctly: First implement Vulkan implement as DesktopGL replacement (macOS/Win/Linux + Android). Once that works, MoltenVK for Metal could come in later. Is this a correct understanding? Meanwhile, I have a Metal implementation for MG cooking up like I mentioned above - no promises yet - but it feels like I have a good understanding/resolution for the large unknowns on iOS/macOS/etc (shader compilation, for instance). I hope MoltenVK or Metal-raw replaces the current mobile-GL implementation soon. |
I see some misunderstandings is going on in regards to Vulkan on macOS. You just write your app using Vulkan and compile your hlsl shaders to spir-v using dxc, thats it, no extra steps is needed for getting your app running on macOS. There is no macOS or iOS or Apple specific stuff that we will need to maintain for this graphics backend. See https://vulkan-tutorial.com/Development_environment#page_MacOS on a bit more details. |
MoltenVK has got some limitations, see the portability extension VK_KHR_portability_subset and the others difference in MoltenVK documentation. And besides the possible Metal bugs, there will be spirv-cross and MoltenVK bugs too. |
I have made progress in my Metal implementation:
Putting this out there in case there is interest for this ? @harry-cpp Yes, point taken. I am mostly talking about mac catalyst / Universal binaries which are moving in the direction of iOS - Metal-only with more stringent limitations being enforced by Apple over time (BTW MoltenVK is fine for mac catalyst). |
Closing this one in favor of centralizing discussions in #4571 |
This is an offspring of the discussion in #4571.
We need to implement a new Metal backend for iOS devices under our existing XNA style API. The tasks would include:
The text was updated successfully, but these errors were encountered: