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 specialization for directional light split blend and fog to mobile renderer. #99978

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

DarioSamo
Copy link
Contributor

@DarioSamo DarioSamo commented Dec 3, 2024

Optimizes some paths that can be easily derived by looking at the global scene configuration and adds them as specialization constants to the shaders to help eliminated dead code.

  • Multiple optional parameters on fog. This takes out at least three branches that are commonly unused with the default configuration.
  • Whether to blend directional light PSSM splits together. This takes out an entire chunk of shadow sampling code that goes unused if the feature is unused. This led to a significant improvement when directional lights are used.

AMD Ryzen 7950 HD Integrated GPU
master: ~20.42 ms
more-mobile-scs: ~19.77 ms


Contributed by W4 Games. 🍀

@DarioSamo DarioSamo requested a review from a team as a code owner December 3, 2024 18:18
@DarioSamo DarioSamo changed the title Add specialization for directional light split blend and fog. Add specialization for directional light split blend and fog to mobile renderer. Dec 3, 2024
@clayjohn clayjohn added this to the 4.4 milestone Dec 4, 2024
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.

Looks good to me. I was able to reproduce the performance benefit in a scene with nothing but a light, a sky, and one default cylinder mesh.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

I wonder if this would be relevant to Forward+ as well, although I presume the performance gain will be lower on a dedicated GPU.

@clayjohn
Copy link
Member

clayjohn commented Dec 5, 2024

I wonder if this would be relevant to Forward+ as well, although I presume the performance gain will be lower on a dedicated GPU.

It might be. We really need to take the time and evaluate what specializations to use in the Forward+ renderer.

For mobile, we are finding that removing pretty much every uniform branch is helpful. For Desktop it will be less helpful and therefore the cost of switching PSOs all the time might outweight the benefit. So we need to evaluate it separately.

@Repiteo Repiteo merged commit 8c8bfce into godotengine:master Dec 5, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 5, 2024

Thanks!

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.

4 participants