godot
godot copied to clipboard
Metal: Add support for 2017 era iOS devices
Closes #99682
Add support for Apple4 GPUs.
Tier 2 argument buffers are required for read / write texture support, specifically for iOS, so this PR introduces support for generating shaders and binding without argument buffers for devices that only support Tier 1 argument buffers.
Tier 2 argument buffer support raises the minimum Apple GPU family from A11 (2017) to A13 (2019).
Should be fine and expected. We list A12 as min. supported for Vulkan. And I have already opened https://github.com/godotengine/godot-docs/pull/10325 to mention Metal and D3D12 with A13 listed as min. for Metal (based on Metal 3 supported devices page).
Old devices are supposed to use Compatibility renderer.
Tier 2 argument buffer support raises the minimum Apple GPU family from A11 (2017) to A13 (2019).
Should be fine and expected. We list A12 as min. supported for Vulkan. And I have already opened godotengine/godot-docs#10325 to mention Metal and D3D12 with A13 listed as min. for Metal (based on Metal 3 supported devices page).
Old devices are supposed to use Compatibility renderer.
In practice, I'm afraid this might make it somewhat difficult for users to use the Metal renderer in production for iOS games.
That would mean that they either:
- Cut off all iOS devices before 2019. Not sure what the market usage numbers are for older devices but 5 years for iOS devices isn't too crazy, people often praise them for their longevity.
- Have to make their game fallback properly to Compatibility, which kinda works for simple projects but may not work for the projects that would choose to use Forward+ or Mobile renderers.
And we have to keep in mind that Compatibility is OpenGL and this is deprecated on all Apple devices and the drivers are bitrotting. That leaves Apple devices in a weird limbo where only the high end (recent) devices are properly supported.
Cut off all iOS devices before 2019. Not sure what the market usage numbers are for older devices but 5 years for iOS devices isn't too crazy, people often praise them for their longevity.
I currently use the iPhone XR from 2018. Which is what I discovered this issue on. @stuartcarnie is looking into a separate fix for older ones such as mine.
Have to make their game fallback properly to Compatibility, which kinda works for simple projects but may not work for the projects that would choose to use Forward+ or Mobile renderers.
Couldn't we just fall back to using Vulkan instead of Metal? Instead of falling back to compatibility? Vulkan works just fine on my iPhone XR. Performance is even good with Forward+.
@akien-mga I'll have to implement a separate PR to disable argument buffers, as that will be a reasonable amount of work. Doing so will allow us to support mobile devices back to 2017 (as that is the earliest that supported image cube textures, required by Godot).
Unfortunately, SPIRV-Cross does not work well (has bugs) with tier 1 argument buffers on iOS, when it has to fall back to a mix of classic and argument buffers if the pipeline contains writable textures.
@stuartcarnie are we removing argument buffers entirely? Or adding a boolean / flag to indicate whether the device supports it and fall back to something else when the device is old?
@stuartcarnie are we removing argument buffers entirely? Or adding a boolean / flag to indicate whether the device supports it and fall back to something else when the device is old?
No, it will be a fallback for older devices, as argument buffers are more performant.
@stuartcarnie Does this PR also fall back to vulkan for iOS devices older than 2017?
Or is there a separate work in progress for that?
Vulkan won't work on devices prior to 2017 either, as Godot requires image cube map textures, which are only supported on 2017 devices and beyond.
Gotcha. Does it fall back to compatibility from metal then?
To put it another way, there should be no reason to require Vulkan / MoltenVK over Metal for Apple mobile devices, as they support the same range of devices.
For desktop, Vulkan / MoltenVK is required for x86 hardware.
Gotcha. Does it fall back to compatibility from metal then?
Not sure – would have to ask the rendering team if that is the case.
Thanks!
@stuartcarnie I got around to testing this in my fork. It appears to fix the black screen! However, I encountered this new error:
validateComputeFunctionArguments:1083: failed assertion `Compute Function(main0): argument src_particles[0] from buffer(4) with offset(0) and length(16) has space for 16 bytes, but argument has a length(128).'
It doesn't seem to have any impact that I can yet notice. It may be something I did wrong in my fork as well. I'll test with vanilla godot master to see if anything changes. Thank you again for all of the hard work you did on this!
@TCROC thanks for reporting your issue; I've created #100764 to track it, as I have reproduced it. Fix coming soon.
Thanks @stuartcarnie ! I look forward to testing it out! :)