Skip to content
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

Merged
merged 1 commit into from Nov 11, 2019
Merged

Conversation

BastiaanOlij
Copy link
Contributor

@BastiaanOlij BastiaanOlij commented Nov 10, 2019

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.

@BastiaanOlij BastiaanOlij requested review from reduz and a team as code owners November 10, 2019 10:06
@BastiaanOlij BastiaanOlij changed the title WIP: Add MSAA mode for Quest Add MSAA mode for Quest Nov 10, 2019
@@ -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");
Copy link
Contributor Author

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?

Copy link
Contributor

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.

@BastiaanOlij
Copy link
Contributor Author

@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 :)

@clayjohn clayjohn self-requested a review November 10, 2019 16:31
@@ -1182,10 +1182,13 @@ class RasterizerStorageGLES2 : public RasterizerStorage {
struct External {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Comment on lines +5167 to +5172
// 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
Copy link
Contributor

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.

Copy link
Contributor Author

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");
Copy link
Contributor

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.

@akien-mga akien-mga merged commit 4b8feff into godotengine:master Nov 11, 2019
@akien-mga
Copy link
Member

Thanks!

NeoSpark314 added a commit to NeoSpark314/godot that referenced this pull request Nov 16, 2019
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.
victordomiciano pushed a commit to JavaryGames/godot that referenced this pull request Dec 3, 2019
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.
@BastiaanOlij BastiaanOlij deleted the msaa_ext_modes branch February 27, 2020 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants