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

Vulkan Mobile - MSAA resolve breaks on some systems if no transparent objects are rendered. #81910

Closed
BastiaanOlij opened this issue Sep 19, 2023 · 6 comments · Fixed by #84169

Comments

@BastiaanOlij
Copy link
Contributor

Godot version

4.0 dev e3e2528

System information

Android

Issue description

When enabling MSAA on Android with the Vulkan Mobile renderer the screen can end up black. This is not happening on all devices so this seems driver related.

Was able to reproduce this on a Quest Pro and with experimenting found the cause. It's possible this effects certain brands of phones as well.

Depending on what is being rendered, the mobile renderer will attempt to use as many subpasses to perform the rendering as possible to keep data in tile memory for as long as possible. The issue appears if 3 or 4 subpasses are used and MSAA is enabled.

For illustration we'll use a 4 subpass scenario. The 4 subpasses will be:

  • Rendering opaque objects to MSAA buffer
  • Rendering our background sky
  • Rendering our transparent objects to MSAA buffer and resolve to non MSAA buffer
  • Perform tonemapping and exposure on non MSAA buffer and output to render target.

The issue happens in the 3rd pass. If there are no transparent objects, even though we trigger our 3rd subpass and should thus finish with a resolve, the pass is skipped in its entirety. The resolve does not happen, and our rendering is lost.

Steps to reproduce

Create a new project, set MSAA to 2x, enable OpenXR and enable stereo shaders.
Add an environment and light
Add an XROrigin and XRCamera
Add some opaque geometry
Add some code to the root node:

func _ready():
	var xr_interface = XRServer.find_interface("OpenXR")
	if xr_interface and xr_interface.is_initialized():
		get_viewport().use_xr = true

Install the openxr loader plugin
ENABLE THE PLUGIN!!
Setup android export with the correct loader selected, OpenXR enabled and using gradlew build
Install android templates
Run project

Should give a nice black screen

Add a transparent object visible to the camera

Rendering works fine.

(Make it small, child it to the camera, and we have a workaround)

Minimal reproduction project

See instructions above.

@Zireael07
Copy link
Contributor

Related to #73384 ?

@BastiaanOlij
Copy link
Contributor Author

@Zireael07 very likely the same issue. It's easy to verify by just adding a 3D mesh with a transparent material. If things suddenly work it's the same bug.

@BastiaanOlij
Copy link
Contributor Author

Ok, I can confirm this does not break on all phones. It works properly on my Pixel 6

@BastiaanOlij
Copy link
Contributor Author

BastiaanOlij commented Sep 20, 2023

And it also works correctly on a Samsung S21 Exynos (so also MALI)...

@darksylinc
Copy link
Contributor

OK two things:

  1. Because MSAA barriers are incorrectly setup for MSAA, any MSAA bug is just a symptom of that. We should treat anything that enables MSAA as broken in Godot 4 until it's fixed.
  2. I actually recall an old mobile driver bug in which an empty clear pass would fail to do the job correctly. However the driver version has to be quite old, I don't think that's what's happening here.

@BastiaanOlij
Copy link
Contributor Author

@darksylinc it's very possible its due to the barriers though on mobile the situation is a lot simpler than on Forward+. That said, it works correctly on other GPUs, it's only failing on Adreno, so thats weird.

All in all, agree that we should fix the barrier issues first and then see where we stand. That said, your idea of not having separate subpasses for opaque, sky and transparent but just merging them into a single pass would make a world of difference too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants