-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Implement Fallback to Vulkan for MoltenVK #102341
base: master
Are you sure you want to change the base?
Implement Fallback to Vulkan for MoltenVK #102341
Conversation
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.
Looks good! One required change to resolve a memory leak.
platform/ios/display_server_ios.mm
Outdated
rendering_context = nullptr; | ||
bool failed = true; | ||
#if defined(VULKAN_ENABLED) | ||
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan"); |
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 there any iOS devices that support MoltenVK, but not our Metal 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.
Probably no, it's the opposite if I remember, A11 for Metal and A12 for Vulkan. And on macOS, every Apple Silicon device support both MoltenVK and Metal, and we do not have x86 Metal support.
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.
That's correct – I did additional work in #99820 ensures A11 Bionic support for Metal, which is better than we had for MoltenVK.
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.
So the only use case is fallback from Vulkan to Metal on A11, assuming it will work (most likely MotenVK will crash instead).
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.
@bruvzg that's a good point! We actually want the reverse; fallback to Metal from Vulkan, although I don't know if MoltenVK fails if the device is below A12?
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 do not have anything to test it on, but from previous experience it's either crash on init or will start normally and fail during shader compilation. I do not think I have ever seen rendering_context
creation fail in any conditions other than completely missing support for specific rendering backend (like no Vulkan on ARM/Windows).
Presumably we still want the feature; however, the code could be implemented a little differently to match the behaviour of our implementation.
In other words,
rendering_driver = p_rendering_driver;
#if defined(RD_ENABLED)
#if defined(VULKAN_ENABLED)
#if defined(__x86_64__)
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
// Metal rendering driver not available on Intel
if (fallback_to_vulkan && rendering_driver == "metal") {
rendering_driver = "vulkan";
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
}
#endif
if (rendering_driver == "vulkan") {
... |
All fixed I think |
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.
LGTM!
Co-authored-by: Stuart Carnie <[email protected]>
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.
Code looks good to me.
I'm wondering if we should get this in for |
Implemented
fallback_to_vulkan
in macOS