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

Conversation

@jonahwilliams
Copy link
Contributor

All geometries were incrementing the shared_ptr usage count which shows up in profiles. Instead expose a Tessellator reference like we do with HostBuffer.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

looking good, just one c++ style comment


std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
return tessellator_;
Tessellator& ContentContext::GetTessellator() const {
Copy link
Member

Choose a reason for hiding this comment

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

This should be const Tessellator& ContentContext::GetTessellator() const or Tessellator& ContentContext::GetTessellator()

https://google.github.io/styleguide/cppguide.html#Use_of_const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tessellator methods are non const because it stores an allocation arena we use.

Copy link
Member

Choose a reason for hiding this comment

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

So Tessellator& ContentContext::GetTessellator()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah?

Copy link
Member

Choose a reason for hiding this comment

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

That's not what's there, you have a const method returning a non-const ref =)

Copy link
Member

Choose a reason for hiding this comment

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

Declare methods to be const unless they alter the logical state of the object (or enable the user to modify that state, e.g., by returning a non-const reference, but that's rare), or they can't safely be invoked concurrently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that is what that means. The ContextVK is const, the tessellator is not. same with the host buffer?

Copy link
Member

@gaaclarke gaaclarke Oct 31, 2024

Choose a reason for hiding this comment

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

Constness should be transitive where if X is a aggregate of Y and Z and you have a const X, you should only be able to get a const Y& and const Z&.

There are already instances where this isn't the case here and admittedly Context is an odd grab bag of state. I was suggesting it if it's easy to do, otherwise this is fine since it doesn't regress what was already there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If that is an important policy to enforce, then it really needs to enforced via lints or the compiler.


std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
return tessellator_;
Tessellator& ContentContext::GetTessellator() const {
Copy link
Member

@gaaclarke gaaclarke Oct 31, 2024

Choose a reason for hiding this comment

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

Constness should be transitive where if X is a aggregate of Y and Z and you have a const X, you should only be able to get a const Y& and const Z&.

There are already instances where this isn't the case here and admittedly Context is an odd grab bag of state. I was suggesting it if it's easy to do, otherwise this is fine since it doesn't regress what was already there.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 31, 2024
@auto-submit auto-submit bot merged commit cf294fa into flutter:main Oct 31, 2024
@jonahwilliams jonahwilliams deleted the shared_ptr_tessellator branch October 31, 2024 00:42
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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants