-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
[opengl3] Prevent viewport's render buffers getting out of sync with render target when resized by XR interface #64513
Conversation
255dd88
to
db764b9
Compare
Not entirely sure if the changes is safe. It is totally possible the viewport size is set correctly before the XRInterface has a chance to update the viewport count, this was why get_viewport_count() was always called, it would check if the viewport count is now being overridden by the XRInterface. Also note that I rewrote a lot of this logic in #63901 though I do not think it deals with you issue, it will require you to redo your PR I think. |
It's updating the render target and buffers if either the size OR the view count changes. In _viewport_set_size(vp, xr_size.width, xr_size.height, xr_interface->get_view_count()); ... and in if (p_viewport->size != new_size || p_viewport->view_count != p_view_count) { So, assuming I'm understanding your concern correctly, I think this should be safe?
Ok, thanks! I'll keep an eye on that one and rebase my PR once it's merged. |
I just tested these changes with OpenXR, and everything seemed to work fine there too! I used the Oculus runtime with the Quest 2 over Air Link. |
c606f09
to
f0f16e8
Compare
I can't re-test this in an HTML5 export after the latest rebases, because 3D rendering is currently broken (see issue #65304), but this has a positive effect even when testing with the @BastiaanOlij @clayjohn I'd appreciate it if you guys could give this some review! Thanks :-) |
Hmmm, I'm wondering if we're going about this the wrong way. The whole issue happens because if Maybe we should move part of this logic out of the render server and into the viewport logic itself. I.E. if This also solves issues with the GDScript side of the engine not knowing the true size of the viewport in XR mode. |
Btw @dsnopek, the issue you're describing with the screen going black was one that we encountered in Godot 3 as well. Godots main viewport gets resized when you resize the screen, this logic should be disabled if the main viewport is set to 'use_xr'. |
Thanks for the feedback!
Hm. You know this code much better than me, I'd need to spend some time digging into the viewport code to imagine how that'd work - I'll try to dig into it soon. But we need to make sure to also rebuild the render buffers if the view count changes too.
I think in this case it's simpler than that. When XR is enabled it's just going down a different code path that doesn't lead to the render buffers getting remade. This bug could actually be fixed just by adding |
I just made PR #65524 which attempts the approach described by Bastiaan above. I still personally like the bug fix here better, but I'm happy to go which ever way is deemed best :-) |
…render target when resized by XR interface
f0f16e8
to
39e9a36
Compare
Per Bastiaan on RocketChat, he'd prefer the other approach, so this one is superseded by #65524 |
I've been working on getting WebXR working with Godot 4 (see draft PR #64514), and I've encountered an issue where switching to XR leads to the viewport's render buffers getting out of sync with the render target in GLES3. This is because we need to run
_configure_3d_render_buffers()
after the render target has been resized, so that it uses the new texture from the render target - otherwise the render buffers still have the old texture attached.There was this comment:
viewport_set_size()
calls to_configure_3d_render_buffers()
, so if this code did useviewport_set_size()
, this problem wouldn't have existed! So, I made an private_viewport_set_size()
that takes theViewport
pointer, which can be used here and by the publicviewport_set_size()
, reducing code duplication.However, just this on its own would have led to
_configure_3d_render_buffers()
getting called every frame when using XR (which means destroying and re-creating the render buffers every frame) so I refactored a bunch of code to make it only resize the render target and call_configure_3d_render_buffers()
if the size or view count has actually changed. This is why theRendererViewport::Viewport::get_view_count()
function has turned into theRendererViewport::Viewport::view_count
variable.Hopefully, that all makes sense! But I'd be happy to discuss further :-)