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
Add MSAA mode for Quest #33518
Add MSAA mode for Quest #33518
Conversation
313f4ed
to
6b2885c
Compare
@@ -3186,7 +3186,7 @@ void Viewport::_bind_methods() { | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background"); | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally"); | |||
ADD_GROUP("Rendering", ""); | |||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x"), "set_msaa", "get_msaa"); | |||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,External 2x,External 4x"), "set_msaa", "get_msaa"); |
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.
Should we just call these Quest 2x and Quest 4x?
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.
Added another comment above about naming.
6b2885c
to
d357cbd
Compare
@akien-mga you'll need to make a call on the fact we're adding a new feature after the feature freeze, I think this one is worth it :) |
@@ -1182,10 +1182,13 @@ class RasterizerStorageGLES2 : public RasterizerStorage { | |||
struct External { |
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.
Unrelated to this PR, but the use of the term External
might introduce confusion with GL_TEXTURE_EXTERNAL_OES
textures.
Might be worth removing the confusing by renaming the struct in another PR.
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.
Well I got there first ! :P
J/k but it is interesting, I never really got why that extension is called TEXTURE_EXTERNAL, from what I understand it simply allows the texture to be shared amongst processes so one process could be writing say camera data into it (ARCore) while another process uses it to render. What the underlying magic is that makes it special I'm not sure.
But the external texture feature in ARVR is a different thing and was added a while back, here we refer to a render texture supplied externally by a plugin. I'm all for a better name but we should apply it across the board, not just this struct but also the method call in the ARVR plugin should be renamed (seeing we use a struct of function pointers changing the name of a pointer won't have that much impact). I suggest though that we do this in Godot 4, I've been wanting to rename all the ARVR objects to XR, might aswell do a bunch of improvements in the naming of things.
// This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature | ||
// of the GPU we can do a single render pass by rendering directly into our texture chains | ||
// texture and apply MSAA as we render. | ||
|
||
// On any other hardware these two modes are ignored and we do not have any MSAA, | ||
// the normal MSAA modes need to be used to enable our two pass approach |
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.
@BastiaanOlij There's no actual check that prevent this from actually being used on other Android devices, correct? By this I mean if an hardware manufacturer decides to follow Oculus's approach, there's nothing preventing a plugin for that hardware to leverage this logic.
So maybe we should leave the naming and description generic enough for Android devices.
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.
Nope, but it does only work on Android atm. I tried using it on desktop but it turns out there is a specific extention on Quest that allows us to do this.
I'm not sure what would be the best name, we shouldn't make it too broad or else people are going to try and use it on normal Android devices while this only works with the VR plugins.
@@ -3186,7 +3186,7 @@ void Viewport::_bind_methods() { | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background"); | |||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally"); | |||
ADD_GROUP("Rendering", ""); | |||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x"), "set_msaa", "get_msaa"); | |||
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,External 2x,External 4x"), "set_msaa", "get_msaa"); |
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.
Added another comment above about naming.
d357cbd
to
4e23431
Compare
Thanks! |
A new external MSAA setting was introduced in godotengine#33518 that fixed issues on GLES2 and Oculus Mobile VR. To avoid misunderstanding it was suggested by @BastiaanOlij and discussed on discord to rename it to AndroidVR.
A new external MSAA setting was introduced in godotengine#33518 that fixed issues on GLES2 and Oculus Mobile VR. To avoid misunderstanding it was suggested by @BastiaanOlij and discussed on discord to rename it to AndroidVR.
Due to performance issues we want to do a single pass render on the Quest. The Quest has a wonderful feature where we can directly render into the textures supplied by the Oculus SDK and have MSAA applied as long as we set our frame buffer up correctly.
There was a previous hacked version that attempted to do the same but broke the Rift plugin and potentially also the OpenXR drivers.
This PR introduces two new MSAA modes specific to the Quest and only work with the GLES2 driver (the GLES3 drivers effects setup make this approach impossible as far as I can tell so they just behave as the normal MSAA 2x and 4x modes).
When these modes are chosen Godot does not build its MSAA buffers instead setting up the FBO for the external texture correctly.
If these new modes are used on anything but Quest hardware MSAA remains turned off.
As we're already rendering to the external texture it now simply skips all the extra logic in post and the Quest does its thing.