[Impeller] generate stroke vertices into point arena.#56390
[Impeller] generate stroke vertices into point arena.#56390auto-submit[bot] merged 7 commits intoflutter:mainfrom
Conversation
|
|
||
| arc.ToLinearPathComponents(scale, [&vtx_builder, &vtx, forward_normal, | ||
| position](const Point& point) { | ||
| Scalar line_count = std::ceilf(ComputeCubicSubdivisions(scale, arc)); |
There was a problem hiding this comment.
From profiling, calling ToLinearPathComponents with a closure triggers a heap allocation on Android.
There was a problem hiding this comment.
Bummer, we could get away with it by eliminating all captures and passing in a pointer to something on the stack. This isn't a request to make that change, but I think it's better to keep the abstraction since it's used in multiple locations.
std::tuple<Foo, Bar, Baz> info = {foo, bar, baz};
arc.ToLinearPathComponents<decltype(info)>(
scale,
info,
[](const Point"& point, const decltype(info)& info) {
auto vtx = info.position + point;
//...
});| vtx.position = position + (-point * direction).Reflect(middle_normal); | ||
| vtx_builder.AppendVertex(vtx.position); | ||
| }); | ||
| CubicPathComponent arc(start_offset, start_handle, middle_handle, middle); |
There was a problem hiding this comment.
Same here,
From profiling, calling ToLinearPathComponents with a closure triggers a heap allocation on Android.
|
|
||
| namespace { | ||
|
|
||
| template <typename VertexWriter> |
There was a problem hiding this comment.
Removed template code as its unused, we only have a single implementation.
This comment was marked as outdated.
This comment was marked as outdated.
gaaclarke
left a comment
There was a problem hiding this comment.
LGTM, code looks good, I just have some nits on documentation and a suggestion on how to keep the abstraction we already had (up to you if you want to do that though).
impeller/entity/entity_unittests.cc
Outdated
| Path path = builder.TakePath(); | ||
| auto geom = Geometry::MakeStrokePath(path, /*stroke_width=*/10); | ||
|
|
||
| ContentContext content_context(GetContext(), nullptr); |
There was a problem hiding this comment.
| ContentContext content_context(GetContext(), nullptr); | |
| ContentContext content_context(GetContext(), /*typographer_context=*/nullptr); |
impeller/entity/entity_unittests.cc
Outdated
| content_context.GetContext()->GetResourceAllocator()); | ||
|
|
||
| auto render_target = | ||
| allocator.CreateOffscreen(*content_context.GetContext(), {10, 10}, 1); |
There was a problem hiding this comment.
| allocator.CreateOffscreen(*content_context.GetContext(), {10, 10}, 1); | |
| allocator.CreateOffscreen(*content_context.GetContext(), /*size=*/{10, 10}, /*mip_count=*/1); |
impeller/entity/entity_unittests.cc
Outdated
| EXPECT_NE(*(written_data + kPointArenaSize - 2), Point(0, 0)); | ||
| EXPECT_NE(*(written_data + kPointArenaSize - 1), Point(0, 0)); | ||
| EXPECT_NE(*(written_data + kPointArenaSize), Point(0, 0)); | ||
| EXPECT_NE(*(written_data + kPointArenaSize + 1), Point(0, 0)); | ||
| EXPECT_NE(*(written_data + kPointArenaSize + 2), Point(0, 0)); | ||
| EXPECT_NE(*(written_data + kPointArenaSize + 3), Point(0, 0)); |
There was a problem hiding this comment.
Can we switch these to EXPECT_EQ assertions? Not being Point(0,0) leaves a lot of possibilities.
There was a problem hiding this comment.
Since this is stroke tessellation the generated points are floating point values like 43.22132 ...
I could do a CLOSE_TO or something like that though. As long as they are in the ballpark
| } | ||
| } | ||
|
|
||
| size_t GetUsedSize() const { return offset_; } |
There was a problem hiding this comment.
It's worth documenting what this is supposed to return in a docstring since it's up to the client of this class to do the correct math with this and the oversized buffer's size.
There was a problem hiding this comment.
Actually, we could probably change this to just return offset_ + oversized_buffer_.size() to avoid the weirdness.
There was a problem hiding this comment.
We need both numbers to split up the memcp correctly
| class PositionWriter { | ||
| public: | ||
| explicit PositionWriter(std::vector<Point>& points) | ||
| : points_(points), oversized_(0) {} |
There was a problem hiding this comment.
| : points_(points), oversized_(0) {} | |
| : points_(points), oversized_() {} |
| class PositionWriter { | ||
| public: | ||
| explicit PositionWriter(std::vector<Point>& points) | ||
| : points_(points), oversized_(0) {} |
There was a problem hiding this comment.
| : points_(points), oversized_(0) {} | |
| : points_(points), oversized_(0) { | |
| FML_DCHECK(points.size() >= kPointArenaSize); | |
| } |
|
|
||
| arc.ToLinearPathComponents(scale, [&vtx_builder, &vtx, forward_normal, | ||
| position](const Point& point) { | ||
| Scalar line_count = std::ceilf(ComputeCubicSubdivisions(scale, arc)); |
There was a problem hiding this comment.
Bummer, we could get away with it by eliminating all captures and passing in a pointer to something on the stack. This isn't a request to make that change, but I think it's better to keep the abstraction since it's used in multiple locations.
std::tuple<Foo, Bar, Baz> info = {foo, bar, baz};
arc.ToLinearPathComponents<decltype(info)>(
scale,
info,
[](const Point"& point, const decltype(info)& info) {
auto vtx = info.position + point;
//...
});| .transform = entity.GetShaderTransform(pass), | ||
| .mode = GeometryResult::Mode::kPreventOverdraw}; | ||
| } | ||
| FML_LOG(ERROR) << "Oversized"; |
There was a problem hiding this comment.
Stray log? It's worth keeping a comment here.
| const std::vector<Point>& oversized_data = | ||
| position_writer.GetOveriszedBuffer(); | ||
| BufferView buffer_view = host_buffer.Emplace( | ||
| nullptr, |
There was a problem hiding this comment.
| nullptr, | |
| /*buffer=*/nullptr, |
flutter/engine@58ac1da...b36ca33 2024-11-06 [email protected] [skwasm] Fix empty backdrop drawing. (flutter/engine#56385) 2024-11-06 [email protected] [Impeller] generate stroke vertices into point arena. (flutter/engine#56390) 2024-11-06 [email protected] [Impeller] Do not capture the temporary ImpellerMapping struct pointer when storing release callbacks in libImpeller (flutter/engine#56411) 2024-11-06 6844906[email protected] Roll ICU from 9408c6fd4a39 to 4239b1559d11 (2 revisions) (flutter/engine#56407) 2024-11-06 [email protected] iOS,macOS: Add Obj-C cflags to all Obj-C targets (flutter/engine#56386) 2024-11-06 [email protected] Roll Skia from afaed8923682 to cf33c4e96e81 (5 revisions) (flutter/engine#56408) 2024-11-06 [email protected] Manual roll Dart SDK from 1c1d0420539f to d456f613465a (6 revisions) (flutter/engine#56406) 2024-11-06 [email protected] [Impeller] Avoid errors due to triangle fans usage on Molten. (flutter/engine#56321) 2024-11-06 [email protected] Roll Skia from b4df8dda7ffc to afaed8923682 (14 revisions) (flutter/engine#56404) 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] 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 To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…#56390) Heap allocation is extremely expensive on Android. We can speed up the stroke tessellation by allocation a large arena and using that to write vertices. If the vertices would overflow, we switch to a dynamically allocated vector.
Heap allocation is extremely expensive on Android.
We can speed up the stroke tessellation by allocation a large arena and using that to write vertices. If the vertices would overflow, we switch to a dynamically allocated vector.