-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Fallback to no index buffer when tesselation count is large, split up nonZero contours. #46282
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). 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. |
This comment was marked as off-topic.
This comment was marked as off-topic.
954531e
to
30682b5
Compare
impeller/tessellator/tessellator.cc
Outdated
polyline.points.data() + start_point_index, // | ||
sizeof(Point), // | ||
end_point_index - start_point_index // | ||
if (polyline.contours.size() > 30 && fill_type == FillType::kNonZero) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider pulling 30 out to a named constant, and as much as might be possible, explain why 30 was chosen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also add a comment about not using indices since there is a lot of code to read through to understand that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comments here.
impeller/tessellator/tessellator.cc
Outdated
} | ||
} else { | ||
std::vector<Point> points; | ||
std::vector<uint16_t> indices; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value is generated, but never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
impeller/tessellator/tessellator.cc
Outdated
polyline.points.data() + start_point_index, // | ||
sizeof(Point), // | ||
end_point_index - start_point_index // | ||
if (polyline.contours.size() > 30 && fill_type == FillType::kNonZero) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also add a comment about not using indices since there is a lot of code to read through to understand that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, awesome surprising performance results. The only thing that should change is the overloaded parameter that can mean 2 different things.
impeller/tessellator/tessellator.cc
Outdated
return Result::kTessellationError; | ||
} | ||
|
||
int vertexItemCount = tessGetVertexCount(tessellator) * kVertexSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int vertexItemCount = tessGetVertexCount(tessellator) * kVertexSize; | |
int vertex_item_count = tessGetVertexCount(tessellator) * kVertexSize; |
These variable names don't conform to the c++ style guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
Tessellator t; | ||
PathBuilder builder = {}; | ||
for (auto i = 0; i < 60; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a hardcoded 60, you can use the variable you created now to make this test a bit more robust to changes in that number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -48,10 +49,16 @@ GeometryResult FillPathGeometry::GetPositionBuffer( | |||
size_t indices_count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name here belies the fact that it actually can represent 2 different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
impeller/tessellator/tessellator.h
Outdated
using BuilderCallback = std::function<bool(const float* vertices, | ||
size_t vertices_size, | ||
const uint16_t* indices, | ||
size_t indices_size)>; | ||
size_t vertex_or_index_count)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overloading this variable doesn't seem prudent. Can't it just be indices_size and be zero if indices == nullptr
? We didn't need vertex count in the past
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this is overloaded is a bit of an issue yes, I should just fix it. Really the problem is that these variables aren't counts, they are the value to multiply with sizeof(float)/sizeof(uint16_t) to compute offsets. But I just make them counts, then this problem goes away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Co-authored-by: gaaclarke <[email protected]>
Co-authored-by: gaaclarke <[email protected]>
…nt is large, split up nonZero contours. (flutter/engine#46282)
…nt is large, split up nonZero contours. (flutter/engine#46282)
…nt is large, split up nonZero contours. (flutter/engine#46282)
…nt is large, split up nonZero contours. (flutter/engine#46282)
…sions) (#135637) Manual roll Flutter Engine from f70f65f7a622 to be32dcc9117a (31 revisions) Manual roll requested by [email protected] Cannot build log URL because revision "be32dcc9117a" is invalid: Luci builds of "Linux linux_unopt" for be32dcc9117a462760cb52c18d0d050f067f2463 was STARTED 2023-09-28 [email protected] Rollback Dart SDK to 3.2.0-119. (flutter/engine#46339) 2023-09-28 [email protected] [canvaskit] Do not double-apply ImageFilter transform to children (flutter/engine#46336) 2023-09-28 [email protected] Reland "Reverts "[ios] Fix app extension not able to find assets from… (flutter/engine#46329) 2023-09-27 [email protected] Revert "[Impeller] Fixes stroke path geometry that can draw outside o… (flutter/engine#46334) 2023-09-27 [email protected] Roll Fuchsia Mac SDK from jQHACBU4Fi2wMElkm... to U334SygIkffMJVmdu... (flutter/engine#46333) 2023-09-27 [email protected] Roll Skia from 952e8dd66560 to b048b468d641 (1 revision) (flutter/engine#46332) 2023-09-27 [email protected] [Impeller] Destroy all per-thread command pools tied to a context before deleting the context (flutter/engine#46286) 2023-09-27 [email protected] Roll Skia from d78aba2524b3 to 952e8dd66560 (1 revision) (flutter/engine#46331) 2023-09-27 [email protected] [Impeller] Match Skia gradient clamping behavior (and document). (flutter/engine#44825) 2023-09-27 [email protected] Roll Dart SDK from 97647bb1666b to 80a965ee48ab (1 revision) (flutter/engine#46330) 2023-09-27 [email protected] Roll Skia from ff5474eed6b4 to d78aba2524b3 (3 revisions) (flutter/engine#46327) 2023-09-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ios] Fix app extension not able to find assets from unloaded bundle" (flutter/engine#46328) 2023-09-27 [email protected] [Windows] Improve logic to update swap intervals (flutter/engine#46172) 2023-09-27 [email protected] [Impeller] Fallback to no index buffer when tesselation count is large, split up nonZero contours. (flutter/engine#46282) 2023-09-27 [email protected] Roll Skia from 4731ccd6342c to ff5474eed6b4 (1 revision) (flutter/engine#46325) 2023-09-27 [email protected] Declare native wrapper classes in Fuchsia packages as base classes (flutter/engine#46305) 2023-09-27 [email protected] Remove fuchsia from recipes cq. (flutter/engine#46324) 2023-09-27 [email protected] Roll Dart SDK from c2a455113e39 to 97647bb1666b (1 revision) (flutter/engine#46323) 2023-09-27 [email protected] [macOS] Synchronise modifiers from mouse events for RawKeyboard (flutter/engine#46230) 2023-09-27 [email protected] Roll Fuchsia Linux SDK from Lg6FR6iDnZeV6y-E8... to 6Y22MutFhgL7ua18F... (flutter/engine#46322) 2023-09-27 [email protected] Roll Skia from 2991bb799d3f to 4731ccd6342c (1 revision) (flutter/engine#46321) 2023-09-27 [email protected] Declare native wrapper classes in the GPU package as base classes (flutter/engine#46304) 2023-09-27 [email protected] Do not call DrawTextBlob for performance overlay text when using Impeller (flutter/engine#46307) 2023-09-27 [email protected] Update to use GrDirectContexts::MakeGL (flutter/engine#46308) 2023-09-27 [email protected] Roll Skia from 0f4f31127ac5 to 2991bb799d3f (1 revision) (flutter/engine#46319) 2023-09-27 [email protected] Roll Skia from fc629215398f to 0f4f31127ac5 (1 revision) (flutter/engine#46318) 2023-09-27 [email protected] Roll Dart SDK from 6c4eb86ecd25 to c2a455113e39 (1 revision) (flutter/engine#46317) 2023-09-27 [email protected] Roll Fuchsia Mac SDK from OMrTgAfDg9PKXTzq0... to jQHACBU4Fi2wMElkm... (flutter/engine#46314) 2023-09-27 [email protected] Roll Skia from 960325c13009 to fc629215398f (1 revision) (flutter/engine#46313) 2023-09-27 [email protected] Roll Skia from 76aecbaea259 to 960325c13009 (2 revisions) (flutter/engine#46311) 2023-09-27 [email protected] Roll Dart SDK from 7c3588c05f87 to 6c4eb86ecd25 (3 revisions) (flutter/engine#46310) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Lg6FR6iDnZeV to 6Y22MutFhgL7 fuchsia/sdk/core/mac-amd64 from OMrTgAfDg9PK to U334SygIkffM If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose ...
…sions) (flutter#135637) Manual roll Flutter Engine from f70f65f7a622 to be32dcc9117a (31 revisions) Manual roll requested by [email protected] Cannot build log URL because revision "be32dcc9117a" is invalid: Luci builds of "Linux linux_unopt" for be32dcc9117a462760cb52c18d0d050f067f2463 was STARTED 2023-09-28 [email protected] Rollback Dart SDK to 3.2.0-119. (flutter/engine#46339) 2023-09-28 [email protected] [canvaskit] Do not double-apply ImageFilter transform to children (flutter/engine#46336) 2023-09-28 [email protected] Reland "Reverts "[ios] Fix app extension not able to find assets from… (flutter/engine#46329) 2023-09-27 [email protected] Revert "[Impeller] Fixes stroke path geometry that can draw outside o… (flutter/engine#46334) 2023-09-27 [email protected] Roll Fuchsia Mac SDK from jQHACBU4Fi2wMElkm... to U334SygIkffMJVmdu... (flutter/engine#46333) 2023-09-27 [email protected] Roll Skia from 952e8dd66560 to b048b468d641 (1 revision) (flutter/engine#46332) 2023-09-27 [email protected] [Impeller] Destroy all per-thread command pools tied to a context before deleting the context (flutter/engine#46286) 2023-09-27 [email protected] Roll Skia from d78aba2524b3 to 952e8dd66560 (1 revision) (flutter/engine#46331) 2023-09-27 [email protected] [Impeller] Match Skia gradient clamping behavior (and document). (flutter/engine#44825) 2023-09-27 [email protected] Roll Dart SDK from 97647bb1666b to 80a965ee48ab (1 revision) (flutter/engine#46330) 2023-09-27 [email protected] Roll Skia from ff5474eed6b4 to d78aba2524b3 (3 revisions) (flutter/engine#46327) 2023-09-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ios] Fix app extension not able to find assets from unloaded bundle" (flutter/engine#46328) 2023-09-27 [email protected] [Windows] Improve logic to update swap intervals (flutter/engine#46172) 2023-09-27 [email protected] [Impeller] Fallback to no index buffer when tesselation count is large, split up nonZero contours. (flutter/engine#46282) 2023-09-27 [email protected] Roll Skia from 4731ccd6342c to ff5474eed6b4 (1 revision) (flutter/engine#46325) 2023-09-27 [email protected] Declare native wrapper classes in Fuchsia packages as base classes (flutter/engine#46305) 2023-09-27 [email protected] Remove fuchsia from recipes cq. (flutter/engine#46324) 2023-09-27 [email protected] Roll Dart SDK from c2a455113e39 to 97647bb1666b (1 revision) (flutter/engine#46323) 2023-09-27 [email protected] [macOS] Synchronise modifiers from mouse events for RawKeyboard (flutter/engine#46230) 2023-09-27 [email protected] Roll Fuchsia Linux SDK from Lg6FR6iDnZeV6y-E8... to 6Y22MutFhgL7ua18F... (flutter/engine#46322) 2023-09-27 [email protected] Roll Skia from 2991bb799d3f to 4731ccd6342c (1 revision) (flutter/engine#46321) 2023-09-27 [email protected] Declare native wrapper classes in the GPU package as base classes (flutter/engine#46304) 2023-09-27 [email protected] Do not call DrawTextBlob for performance overlay text when using Impeller (flutter/engine#46307) 2023-09-27 [email protected] Update to use GrDirectContexts::MakeGL (flutter/engine#46308) 2023-09-27 [email protected] Roll Skia from 0f4f31127ac5 to 2991bb799d3f (1 revision) (flutter/engine#46319) 2023-09-27 [email protected] Roll Skia from fc629215398f to 0f4f31127ac5 (1 revision) (flutter/engine#46318) 2023-09-27 [email protected] Roll Dart SDK from 6c4eb86ecd25 to c2a455113e39 (1 revision) (flutter/engine#46317) 2023-09-27 [email protected] Roll Fuchsia Mac SDK from OMrTgAfDg9PKXTzq0... to jQHACBU4Fi2wMElkm... (flutter/engine#46314) 2023-09-27 [email protected] Roll Skia from 960325c13009 to fc629215398f (1 revision) (flutter/engine#46313) 2023-09-27 [email protected] Roll Skia from 76aecbaea259 to 960325c13009 (2 revisions) (flutter/engine#46311) 2023-09-27 [email protected] Roll Dart SDK from 7c3588c05f87 to 6c4eb86ecd25 (3 revisions) (flutter/engine#46310) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Lg6FR6iDnZeV to 6Y22MutFhgL7 fuchsia/sdk/core/mac-amd64 from OMrTgAfDg9PK to U334SygIkffM If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose ...
…e, split up nonZero contours. (#46282) See example app in flutter/flutter#135458 Because tessellation is generally nlogn best case (with allocation complexity as well), we can actually make it faster by breaking it into smaller pieces. For non zero fill modes, the contours can be tessellated individually without losing fidelity. In cases where this isn't possible, we need to check if we exceed the max uint16 index and fall back to no index buffer. Fixes flutter/flutter#135458 I Benchmarked signing my name. ### Before worst raster time 3+ seconds. Visual glitches  ### After worst raster time 30 ms, looks correct (though my signature is still wrong) 
Forgot about the winding order. partially reverts #46282 See flutter/flutter#138598 Reopens flutter/flutter#135458
Forgot about the winding order. partially reverts flutter#46282 See flutter/flutter#138598 Reopens flutter/flutter#135458
Forgot about the winding order. partially reverts flutter#46282 See flutter/flutter#138598 Reopens flutter/flutter#135458
See example app in flutter/flutter#135458
Because tessellation is generally nlogn best case (with allocation complexity as well), we can actually make it faster by breaking it into smaller pieces. For non zero fill modes, the contours can be tessellated individually without losing fidelity.
In cases where this isn't possible, we need to check if we exceed the max uint16 index and fall back to no index buffer.
Fixes flutter/flutter#135458
I Benchmarked signing my name.
Before
worst raster time 3+ seconds. Visual glitches
After
worst raster time 30 ms, looks correct (though my signature is still wrong)