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

Merge passes in Vulkan mobile renderer #84169

Merged

Conversation

BastiaanOlij
Copy link
Contributor

@BastiaanOlij BastiaanOlij commented Oct 30, 2023

After various discussions with @darksylinc, did the work to merge passes that didn't need to be separate subpasses in the mobile renderer. This greatly simplifies things.

There are now 3 scenarios:

  1. The most optimal scenario is where Opaque, sky and transparent all run in a single subpass, and tonemapping runs in a second subpass. In this approach our 3D buffer is never written out to texture memory and the only output is our render target
  2. The slightly less optimal scenario is where Opaque, sky and transparent all run in a single pass. Tonemapping runs in a separate pass. This will happen if: MSAA, glow or DOF are enabled.
  3. The least optimal scenario is where Opaque and sky run in a single pass, transparent runs in a separate pass and finally tonemapping runs in a separate pass. This will happen if reading from screen texture or depth texture is enabled.

This PR also has an optimalisation that when the background is copied from canvas, this no longer happens in a separate pass, but becomes the first step in the opaque pass.

Fixes #82175
Fixes #81910
Fixes #83481

@BastiaanOlij BastiaanOlij added enhancement topic:rendering topic:xr topic:3d cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Oct 30, 2023
@BastiaanOlij BastiaanOlij added this to the 4.3 milestone Oct 30, 2023
@BastiaanOlij BastiaanOlij self-assigned this Oct 30, 2023
@BastiaanOlij BastiaanOlij requested a review from a team as a code owner October 30, 2023 01:41
@BastiaanOlij BastiaanOlij force-pushed the vulkan_mobile_merge_passes branch 4 times, most recently from 820ca4f to 6cf3c13 Compare October 30, 2023 02:40
@BastiaanOlij
Copy link
Contributor Author

I'll be adding some before/after timing info as soon as I have recharged some phones :)

I suspect this will have no impact on desktop GPUs, but in theory there should be a measurable difference on phones and standalone VR hardware.

@BastiaanOlij
Copy link
Contributor Author

BastiaanOlij commented Oct 31, 2023

Testing scene on Samsung S21 MALI

Master
MSAA 3D off off on on
Glow off on off on
GPU time 9 - 14ms 19-23ms 11-13 ms 19-23 ms
This PR
MSAA 3D off off on on
Glow off on off on
GPU time 9 - 12ms 18-22ms 10-12 ms 19-24 ms

I'm not surprised by these results, according to ARM MALI implements subpasses well.

Test project used (could use something better):
TestMSAA.zip

@BastiaanOlij
Copy link
Contributor Author

Testing scene on Quest Pro

Master
MSAA 3D off off on on
Glow off on off on
GPU time 9 - 10ms 15-16ms 19-20 ms 27-29 ms
This PR
MSAA 3D off off on on
Glow off on off on
GPU time 9 - 10ms 15-16ms 16-17 ms 20-22 ms

Totally not what I was expecting...

Test project used:
https://www.dropbox.com/scl/fi/pcm5xo42zi4xt0ksf62cx/TestXR.zip?rlkey=cpogyt2w70frgkadvg0ofottp&dl=0
(requires installation of appropriate android templates but otherwise configured for Quest)

@BastiaanOlij
Copy link
Contributor Author

I'm wondering if #82175 was really a bug, so might try and "unfix" that and see if that actually works. In theory we should be able to render MSAA in a pass, resolve it, and then do tonemapping in a subpass, which should result in no data being written our to MSAA or 3D buffers, only to our render target.

@BastiaanOlij
Copy link
Contributor Author

After doing some more testing with this, found out the conclusion in 82175 was indeed wrong, the problems were due to the transparent subpass getting skipped on Adreno hardware and MSAA thus not getting resolved, not because MSAA doesn't work with the subpass approach.

Merging the passes already solves the Adreno issue so I've undone the exception and we now use the 2-subpass approach with MSAA enabled.

@darksylinc this could use a review from you. I know that there is more to MSAA especially on Forward+, but for Mobile all scenarios are now working and I think this would be a good thing to merge ASAP once our merge window for 4.3 is open (really wish this had ended up in 4.2 as it solves a number of issues people are currently running into in VR).
@clayjohn could use your stamp of approval too :)

@clayjohn
Copy link
Member

clayjohn commented Dec 4, 2023

Testing a modified version of the TPS demo with this PR. I am seeing a slight GPU time regression (~16mspd -> ~18mspf) using intel integrated graphics.

I'll investigate a bit more as it is not obvious where that regression would come from, especially on desktop hardware

@BastiaanOlij
Copy link
Contributor Author

Testing a modified version of the TPS demo with this PR. I am seeing a slight GPU time regression (~16mspd -> ~18mspf) using intel integrated graphics.

I'll investigate a bit more as it is not obvious where that regression would come from, especially on desktop hardware

Indeed, weird, seeing it should do less, not more ;)

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again from clean builds and I can't reproduce the regression anymore.

The code looks good to me and feels a lot cleaner, so this is a nice win

@Alex2782
Copy link
Contributor

Alex2782 commented Dec 7, 2023

Fixes #83481

tested only my 'minimal reproduction project' (comment)

@YuriSizov
Copy link
Contributor

Needs a rebase, and then can be merged!

@warent
Copy link

warent commented Dec 13, 2023

Any chance of merging this one in soon before conflicts are introduced?

@akien-mga
Copy link
Member

@warent There are conflicts already, as pointed out 5 days ago :) So it can't be merged.

But be assured that we keep track of approved and ready to merge rendering PRs, there are just many of them with interdependencies which we need to merge in a specific order. Clay is managing that.

@BastiaanOlij BastiaanOlij force-pushed the vulkan_mobile_merge_passes branch from 60a9612 to 22cd145 Compare December 15, 2023 22:51
@BastiaanOlij
Copy link
Contributor Author

Sorry, missed the last bit of feedback, its been a bit of a weird week. Should all be ok now.

@clayjohn
Copy link
Member

Great! Should be good to merge now

@YuriSizov YuriSizov merged commit ef94545 into godotengine:master Dec 16, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@RomanMatl
Copy link

Are there some updates on this issue? I am still able to reproduce it with v4.3.stable.official [77dcf97] :(

@clayjohn
Copy link
Member

Are there some updates on this issue? I am still able to reproduce it with v4.3.stable.official [77dcf97] :(

Did you mean to post on this PR? This isn't a bug report, this is a PR that was merged a year ago. There won't be any updates since it was already merged

@RomanMatl
Copy link

Ah, sorry wrong tab 😅. Wanted to post here #86098

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