Make MSAA in GLES2 work with external textures for VR #33444
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR undoes @NeoSpark314 s change and changes the MSAA logic so the scene gets rendered into Godots properly setup MSAA buffers and then does the MSAA resolve into the external texture instead of the normal forward buffer. This means MSAA now works on all platforms including desktop.
This is not all sunshine and daisies though. While this does correctly implement the MSAA logic as intended by Godot it removes an important optimisation for the Quest.
The ideal situation for the Quest is for the external texture to be a properly set up MSAA render target and for the _post_process to be skipped completely. The MSAA resolve will happen when the Oculus SDK applies the lens distortion shader to render the final output.
It is my opinion that should be a project in its own right and instead of using Godots MSAA logic, to turn off MSAA in Godot and instead have the plugin drive this fully. This does mean that the plugin needs to be aware whether the GLES2, GLES3 or Vulkan driver is active and some how inform Godot of the fact that a MSAA capable depth buffer is needed for the external fbo. Alternatively one options that was suggested is to have the plugin setup the FBO completely and just provide an FBO to Godot instead of a texture id (or a struct with all info as the texture id may still be needed).
Bugsquad edit: Reverts and supersedes #33291, fixes #33188.