Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@luckysmg
Copy link
Contributor

@luckysmg luckysmg commented Dec 13, 2022

List which issues are fixed by this PR. You must list at least one issue.
flutter/flutter#116815

Now, every EntityPass will create a single LazyGlyphAtlas to use in Canvas::DrawTextFrame, but it seems that there is no need for creating a LazyGlyphAtlas for per EntityPass, and I think maybe we can create a single LazyGlyphAtlas to reuse it across EntityPass.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@luckysmg luckysmg marked this pull request as draft December 13, 2022 12:30
@luckysmg luckysmg marked this pull request as ready for review December 13, 2022 13:35
@luckysmg luckysmg changed the title Reuse LazyGlyphAtlas [Impeller] Reuse LazyGlyphAtlas Dec 13, 2022
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

I'm not sure that I understand the change that this PR is trying to make.

LazyGlyphAtlas is attached to the entity pass allowing it to be used across multiple text content canvas operations. Moving it to the canvas makes it harder to reuse.

@luckysmg
Copy link
Contributor Author

luckysmg commented Dec 14, 2022

Hi @jonahwilliams
Now, per EntityPass will create a LazyGlyphAtlas. (If there are two EntityPass, will create two LazyGlyphAtlas).
If we move it to canvas, multiple EntityPass can reuse this single LazyGlyphAtlas. LMK if I missed something O(∩_∩)O

@jonahwilliams
Copy link
Contributor

Oh I see, sorry I misunderstood. yes that will accomplish reuse.

We're going to end up with a few more objects that can be shared across entity pass, the tesselator to start with, and at some point some sort of geometry cache too. Is canvas.cc a reasonable place to put these for now, or should we create a separate class to hold them @chinmaygarde ?

@luckysmg luckysmg changed the title [Impeller] Reuse LazyGlyphAtlas [Impeller] Share LazyGlyphAtlas across EntityPass Dec 16, 2022
@zanderso
Copy link
Member

zanderso commented Feb 2, 2023

From PR review triage: @jonahwilliams Do you have any thoughts about this PR?

@jonahwilliams
Copy link
Contributor

Old comment stands:

We're going to end up with a few more objects that can be shared across entity pass, the tesselator to start with, and at some point some sort of geometry cache too. Is canvas.cc a reasonable place to put these for now, or should we create a separate class to hold them @chinmaygarde ?

@zanderso
Copy link
Member

zanderso commented Feb 6, 2023

Thanks @jonahwilliams. Sounds like this one is waiting for an answer from @chinmaygarde

@chinmaygarde
Copy link
Member

I think it was setup this way because we expected to use an atlas per pass with the passes being setup concurrently from multiple threads. This will get in the way of that effort but we can rework that when the time comes.

@jonahwilliams
Copy link
Contributor

That seems like a reason to hold off on this. I think what I'd like to know is if we have multiple passes (due to a platform view), does each pass collect glyphs for only their own pass - or all passes?

If its the former, we might not want to make this change.

@luckysmg
Copy link
Contributor Author

luckysmg commented Feb 7, 2023

I think what I'd like to know is if we have multiple passes (due to a platform view), does each pass collect glyphs for only their own pass - or all passes?

Sorry for my poor knowledge about that. Emm but why do platform views need to collect glyphs for only in their pass ?

@jonahwilliams
Copy link
Contributor

not the platform view, but when there is a platform view in the tree the scene is divided in two. I'm unsure if each part collects glyphs individually or not

@luckysmg
Copy link
Contributor Author

luckysmg commented Feb 7, 2023

Got you. I m also not very sure on that........ @chinmaygarde maybe more know about this? Would you mind sharing your thought on that. O(∩_∩)O

@jonahwilliams
Copy link
Contributor

I can do some research into that later this week. Either way, I'd be a bit concerned that the different passes would step on each other if they shared a glyph atlas. The only way to make that work would be to collect the glyphs for all passes up front.

@chinmaygarde
Copy link
Member

Thinking a bit more about this, I don't think this is the model we want to go with for multiple passes. For one, this will make encoding multiple passes concurrently harder. But I am also not sure how this works when we submit one pass but keep adding to the texture atlas referenced by it for subsequent passes.

Closing this but will keep it referenced in the icebox for when we think about improving atlas management.

@jonahwilliams
Copy link
Contributor

I think we should revisit this. its true it may not be the ideal behavior when platform views are involved, but actually today we're doing much worse than we should when there are multiple entity passes because we end up re-creating the glyph atlas N times per frame. this is part of the issue in flutter/flutter#121476

So LGTM to me, if @chinmaygarde is OK with it

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@jonahwilliams
Copy link
Contributor

@luckysmg if you're able to update the tests I think we can land this.

@chinmaygarde
Copy link
Member

sgtm

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2023
@auto-submit auto-submit bot merged commit 2211a31 into flutter:main Feb 28, 2023
@luckysmg luckysmg deleted the reuse_lazy_glyph_atlas branch February 28, 2023 02:38
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants