-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Openxr KHR metal enable #98872
base: master
Are you sure you want to change the base?
Openxr KHR metal enable #98872
Conversation
I know this is a work-in-progress and not finished, but I wanted to share my experience in testing it so far! When I first tried using the Meta XR Simulator with this PR on my M2 Mac Mini, it would crash with this stacktrace: So, then I tried:
I'm not sure if the MoltenVK update was actually required. However, I don't actually see anything rendered in either the Godot window, or the XR Simulator window (like I do when using Vulkan). Anyway, I'm looking forward to testing this again as it progresses! |
That's pretty much what I experienced as well, I couldn't get it to work with 69, it did stop crashing with 71 beta (which has MoltenVK linked in statically if I understand correctly). I am still at a loss on why we're not getting output however, I think we need @stuartcarnie input here. |
a11c88b
to
ead587a
Compare
@stuartcarnie @dsnopek I think I figured out what we're missing and why this is not working. I finally managed to get Xcode playing ball (thanks @clayjohn !!). OpenXR requires us to create our swapchain using an Off course, our renderer uses a normal non sRGB texture format because we do our own sRGB conversion in a shader (which btw on Metal/Apple is a problem because Apple uses a different display gamma compared to what we use, thats been a constant bane for graphics artists and webdesigners for decades :P ). Our rendering pipeline is thus being constructed using I did try to see if I could go down the same route as we do with Vulkan (behind the scenes) and create a shared texture with the format |
b1c0315
to
fb1ca10
Compare
On OpenGL, we're able to create the swapchain with an sRGB format, but then disable the automatic conversion to sRGB (via Is there a way to do that in Vulkan or Metal too? |
In Vulkan you do this by creating a texture view for the non-sRGB format and attaching that to the framebuffer, you do that by calling I tried forcing that here as well but to no avail though talking to @stuartcarnie I got the impression the same applies to Metal. |
fb1ca10
to
a117dab
Compare
The latest version of this PR (which includes PR #99905) is working for me on my Mac Mini, with Meta's XR Simulator 71.0.0-beta.2! Rendering works, and I can move the camera and hands around, and see it update in the XR Simulator window |
I'm pretty convinced the issue I'm having is localised to my Mac. likely an old version of the Vulkan SDK still kicking around (the XR simulator is still using MoltenVK). |
color_swapchain_format = usable_swapchain_formats[0]; // just use the first one and hope for the best... | ||
print_line("Couldn't find usable color swap chain format, using", get_swapchain_format_name(color_swapchain_format), "instead."); | ||
color_swapchain_format = supported_swapchain_formats[0]; // just use the first one and hope for the best... |
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.
Why does this switch from usable_swapchain_format[0]
to supported_swapchain_format[0]
? This would seem to mean we could select a swapchain format the OpenXR runtime supports, but which we don't think should be used for the color swapchain. I think with this we could end up trying to use a depth format for the color swapchain, or something like that?
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.
Thats actually a bug fix. If none of the swapchain formats we want is supported, we were chosing the first swapchain format we want (which we know is not supported), so it would fail to create the swapchain (because it's not supported).
So I changed it that if none of the swapchain formats we want is supported, we choose the first supported swapchain format, and hope for the best.
Honestly, there is a part of me that feels we should just fail in this situation.
a117dab
to
3024eef
Compare
This PR adds support for the metal backend to our OpenXR module.
Depends on: #98803
This can be tested using Metas XR simulator on Mac: https://github.com/Oculus-VR/homebrew-repo/blob/main/meta-xr-simulator.md
Issues still to be resolved: