-
-
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
Skip swapchain logic if there is nothing to present (Android OpenXR) #84244
Skip swapchain logic if there is nothing to present (Android OpenXR) #84244
Conversation
4c9a60d
to
d780436
Compare
This may make #74754 unnecessary |
d780436
to
fa496b1
Compare
Tested on Quest 3. Both debug and release templates are working with your test case. |
1e145f2
to
8fa5aab
Compare
Just some extra info here for reviewers and the production team. This was always an annoyance on Quest 2 and Pro, but on Quest 3 without this fix you can't run a Vulkan game. So far the feedback I've had is that compatibility works fine. I should be able to test this myself soon and add some extra feedback. |
8a37149
to
c4882fc
Compare
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 to me. I tested locally on a non-XR project and can't see any regressions.
Would be good to hear from someone with a Quest 3 about whether this fixes the issue we are having there.
I've had feedback from several users on the XR discord that it does, but they don't tent to come here on github. |
If this is wanted for 4.2 and 4.1 cherrypicks, a dedicated PR with the current version would likely need to be made against the |
If this issue really is preventing Quest 3 from using Vulkan (I have a Quest 3 - I'll try to test this when I have a chance :-)), then I think we really should try to get a version of this PR cherry-picked into 4.2. Most folks deploying to Quest are using the compatibility renderer (myself included), but having Vulkan supported on Quest 1, Quest 2, Quest Pro, but not Quest 3, would be unfortunate. |
Hm, I'm not entirely sure how to trigger the Quest 3 issue. Using Godot 4.2-stable (so without this PR), I tried switching one of my projects from gl_compatibility to mobile, and I ran it 3 times on the Quest 3 (only playing for about 20-30 seconds each time) and everything seemed to work fine. And there were no messages in the log like those described in issue #74963 Is this something that only happens some percentage of the time? Or, only after the app runs for awhile? Or, maybe it depends on certain setup from the test project? Anyway, I'm happy to try testing again, but I'm not sure I fully understand what the critical Quest 3 issue is :-/ |
drivers/vulkan/vulkan_context.cpp
Outdated
@@ -2473,7 +2477,7 @@ Error VulkanContext::swap_buffers() { | |||
return OK; | |||
} | |||
|
|||
// print_line("swapbuffers?"); | |||
// print_line("swap_buffers"); |
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.
// print_line("swap_buffers"); | |
//print_line("swap_buffers"); |
Commented code, as we're already modifying
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'll fix this up after the rebase
Weird, it's pretty consistent for me. Interestingly enough @RandomShaper PR does prevent the crash as well, but the error spam remains a problem. Or maybe another fix snuck in since I last tested this that prevents the crash. All in all it's still a good fix as we're never presenting this swapchain, there is extra overhead we're removing, both memory wise and performance wise. |
I assume this still needs a rebase? |
c4882fc
to
85fe843
Compare
It did since Pedros PR was merged :) should be all good now |
85fe843
to
901624b
Compare
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 otherwise! 🎉
@@ -764,6 +763,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { | |||
blit_to_screen_list[vp->viewport_to_screen].push_back(blits[b]); | |||
} | |||
} | |||
RSG::rasterizer->end_viewport(p_swap_buffers && blits.size() > 0); |
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.
RSG::rasterizer->end_viewport(p_swap_buffers && blits.size() > 0); | |
RSG::rasterizer->end_viewport(p_swap_buffers && !blits.is_empty()); |
Optional style suggestion
There's a warning/error with MSVC:
|
This is because that class hasn't been updated and the override has just two arguments instead of three |
901624b
to
1c0c7c6
Compare
Oops, forgot about that. Added the property but didn't do anything with this. The scenario where this would be set to false really only happens on Android (and possibly iOS/VisionPro some day) so there doesn't need to be a DX12 implementation. @RandomShaper I'm guessing we could skip the |
If there's no expectation it will be called with |
1c0c7c6
to
d6caa69
Compare
Done! |
Thanks! |
This PR is not cherry-pickable because it's based on the codebase after #83452 (and D3D12). A separate PR needs to be made for the 4.2 branch. |
When we are running XR in standalone mode (e.g. OpenXR on Android such as Quest, Lynx, ML2, etc) output to screen is handled by OpenXR however Godot still creates and attempts to display it's build in swapchain for normal output. This is causing a bundle of issues from warnings being spammed (suboptimal swapchain), outright failures (device lost), to simply an empty swapchain overwriting whatever was rendered to screen by OpenXR.
This PR solves that issue by having Godot skip it's normal output if nothing is being blit to screen (e.g. there is no output because the output has been redirected).
Testing so far has removed the issues I was having on Quest Pro, awaiting feedback to see if this solves more serious issues on Quest 3 and ML2. It also shaved 1ms of overhead per frame.
For GLES3 I had to introduce a proper
end_viewport
to get the logic to work correctly.Test project:
https://www.dropbox.com/scl/fi/htl04po1ylfex3k64e1c9/TestXRv2.zip?rlkey=l7t9nmpwtlt44o5ogbib3xr8w&dl=0
(requires android build templates to be compiled and installed)
Fixes #74963