-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix a HwProgram leak related to depth variant pre-caching (#8276)
* fix a HwProgram leak related to depth variant pre-caching Materials that don't use a custom depth can share the same program for all depth variants. We take advantage of that by pre-caching the depths variants when a program is loaded. The depth variants themselves are owned by the default material which is created first. When a material is destroyed it skips deletion of those variants which will be truly destroyed when the default material is destroyed. Unfortunately, the default material doesn't contain all depth variants, in particular, it doesn't have the VSM ones (because it's an unlit material). On top of that, the way it pre-cached depth variant had a bug that made it miss some picking variants. Because of that, these variants were skipped during material destruction but never actually destroyed, since the default material didn't know anything about them. This PR fixes this by making the pre-caching completely lazy. When any material needs such a "precacheable" variant, it first checks if the default material has it. If not, it creates the variant, caches it locally and forwards it to the default material, which implicitly becomes the owner. Just like before newly created material precache everything the default material already has. With this mechanism, it's impossible to have a depth variant without it also existing in the default material. This also simplify the non-public invalidate() method, which doesn't need to populate the pre-cached programs, since this will happen naturally when needed. There was also another issue where post-process materials were handled like regular materials. This didn't cause an problem but was inefficient since these only have a handful of variants. * Update filament/src/details/Material.cpp Co-authored-by: Powei Feng <[email protected]> --------- Co-authored-by: Powei Feng <[email protected]>
- Loading branch information
1 parent
98585bd
commit 64eb27a
Showing
5 changed files
with
198 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.