-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new display_list_benchmarks test suite #29562
Conversation
Sample output from a benchmarking run (currently only
|
The basic idea here is to create a unit test for each raster op that:
Using a templated I haven't yet figured out a good way to handle setting attributes for each test, but I am actively working on that. For example, we'd like to be able to run the |
I'm guessing this is all run on the host for now. Do we have a way to run it on some mobile devices as well? |
So we don't currently run any of the engine unittests on device. In theory it shouldn't be too hard, but the infrastructure just isn't there right now. |
c8e60ab
to
b195c62
Compare
b195c62
to
e38f624
Compare
b3bef36
to
7752af3
Compare
I think this is ready for a first pass at reviewing. |
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 seem to have lost a bunch of comments here during a browser reload, so I'm submitting them as comments (to hopefully bring them back into view) and then resuming the review.
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.
About the only functional problem is that there may be overflow on some of the drawImage tests depending on the draw counts compared to the bitmap sizes.
I'm also a little wary of the way that the vertices are constructed leading to degenerate triangles.
Other than that, the rest is just a bunch of nits.
flow/display_list_benchmarks.cc
Outdated
else | ||
colors.push_back(SK_ColorBLUE); | ||
} | ||
break; |
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.
N/2+1 vertices
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.
For fan mode you could generate N points and have N+1 vertices.
flow/display_list_benchmarks.cc
Outdated
vertices.push_back(center); | ||
colors.push_back(i % 2 ? SK_ColorBLUE : SK_ColorCYAN); | ||
} | ||
break; |
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.
As written, that for loop produces N/2*2 = N vertices. My proposal above would generate N/2+N/4 vertices for strips and N+N/2 for regular triangles.
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.
If you adopt my proposals then you might use 2N/3 points for strips and N/3 for triangles (rounding up?).
flow/display_list_benchmarks.cc
Outdated
// Each vertex colour will alternate through Red, Green, Blue and Cyan. | ||
sk_sp<SkVertices> GetTestVertices(SkPoint center, | ||
float radius, | ||
size_t vertex_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.
Would it be better to measure the number of triangles instead of vertices? The triangles represent work done, the vertices represent efficiency of packing.
And, ugh, when I went to investigate this I couldn't find a vertex count getter in SkVertices, meaning that we currently have no way of estimating any of this even if we collect the data on it... :(
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 think it's better to look at the vertex count because that's the data we actually input. We will need to figure out a way to either grab it, or approximate it. It looks like SkVertices::approximateSize()
is a half-decent first-order approximation, as it returns an approximation for the total number of bytes used by the SkVertices
object and all the data arrays. If we just subtract the size of the SkVertices
object from that then we will have an approximation of the vertex 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.
We can also grab the vertex count from Vertices.cc
in dart:ui
: https://github.com/flutter/engine/blob/main/lib/ui/painting/vertices.cc#L61
It's a little annoying to have to plumb through that count ourselves but I think it's better than trying to calculate the number of triangles.
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.
We'll eventually get to that and flatten all of the Sk structures into the DL, but for now we rely on the data we can grab from the Sk objects.
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.
We can't grab the triangle count either, so I think it makes more sense to vary the vertex count to get an idea of that.
4054319
to
1756b64
Compare
I've rebased this branch off the latest The only review comment that still needs to be addressed is the |
20a35d0
to
b722781
Compare
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 - some comments about work that you can consider or not or do at a later date, but nothing blocking.
} | ||
if (rect.bottom() > canvas_size) { | ||
rect.offset(0, -canvas_size); | ||
} |
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.
Suggestion for future work. Create a bouncing rect class that automates this process.
…crobenchmark all the rasterops defined in our DisplayList format on both CPU and GPU canvases.
Clean up test definitions, add missing ones Add labels to test definitions
fdda757
to
fb7675e
Compare
No functional change. Makes the display list subsystem easier to navigate as the major classes are in their own TUs. Also avoids importing unnecessary headers when the previous kitchen sink header was imported. I've tried to remove all display list related imports and start from scratch but I may have missed some files. Minor structs and classes (like the ones in utils, ops, etc..) still don't get their own TUs though. There were [two](flutter#29562) [related](flutter#30484) changes being made to this subsystem that have since landed. So I don't think I am stepping on anyones toes with the reorganization. Happy to incorporate any work-in-progress changes being made to the this subsystem before submitting.
No functional change. Makes the display list subsystem easier to navigate as the major classes are in their own TUs. Also avoids importing unnecessary headers when the previous kitchen sink header was imported. I've tried to remove all display list related imports and start from scratch but I may have missed some files. Minor structs and classes (like the ones in utils, ops, etc..) still don't get their own TUs though. There were [two](flutter#29562) [related](flutter#30484) changes being made to this subsystem that have since landed. So I don't think I am stepping on anyones toes with the reorganization. Happy to incorporate any work-in-progress changes being made to the this subsystem before submitting.
…30487) No functional change. Makes the display list subsystem easier to navigate as the major classes are in their own TUs. Also avoids importing unnecessary headers when the previous kitchen sink header was imported. I've tried to remove all display list related imports and start from scratch but I may have missed some files. Minor structs and classes (like the ones in utils, ops, etc..) still don't get their own TUs though. There were [two](#29562) [related](#30484) changes being made to this subsystem that have since landed. So I don't think I am stepping on anyones toes with the reorganization. Happy to incorporate any work-in-progress changes being made to the this subsystem before submitting.
This is an initial work in progress for adding a new microbenchmarks suite that'll allow us to get an idea of the relative cost of each raster op defined in our DisplayList format.