-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Compute ContextContentOptions key via bit manipulating (instead of hashing each property). #48902
Conversation
gaaclarke
left a comment
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.
Nice find. We should change the bool conversions and add static_asserts to be safe.
| static_cast<uint64_t>(o.primitive_type) << 24 | // | ||
| static_cast<uint64_t>(o.color_attachment_pixel_format) << 16 | // | ||
| // bools | ||
| static_cast<uint64_t>(o.has_stencil_attachment) << 2 | |
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 approach for the bools is correct.
| static_cast<uint64_t>(o.has_stencil_attachment) << 2 | | |
| (o.has_stencil_attachment ? 1 : 0) << 2 |
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
| o.primitive_type, o.color_attachment_pixel_format, | ||
| o.has_stencil_attachment, o.wireframe, o.is_for_rrect_blur_clear); | ||
| constexpr uint64_t operator()(const ContentContextOptions& o) const { | ||
| return static_cast<uint64_t>(o.sample_count) << 56 | // |
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.
nit: I think this would be a bit easier to read if you count up instead of down.
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
| o.primitive_type, o.color_attachment_pixel_format, | ||
| o.has_stencil_attachment, o.wireframe, o.is_for_rrect_blur_clear); | ||
| constexpr uint64_t operator()(const ContentContextOptions& o) const { | ||
| return static_cast<uint64_t>(o.sample_count) << 56 | // |
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.
All of this is predicated on those fields being 8bits so you should add static_asserts here.
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
|
Otherwise LGTM (fyi I'm OOO today so might have to approve tomorrow) |
bdero
left a comment
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!
gaaclarke
left a comment
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!
| static_assert(sizeof(o.primitive_type) == 1); | ||
| static_assert(sizeof(o.color_attachment_pixel_format) == 1); | ||
|
|
||
| return static_cast<uint64_t>(o.is_for_rrect_blur_clear ? 1u : 0u) << 0 | |
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.
fyi you can get rid of these static casts if you use uint64_t literals. I think its 1llu? something like that.
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
…lating (instead of hashing each property). (flutter/engine#48902)
…lating (instead of hashing each property). (flutter/engine#48902)
…140090) flutter/engine@fc32677...9f7004e 2023-12-13 [email protected] [Impeller] Made the new blur work on devices without the decal address mode (flutter/engine#48899) 2023-12-13 [email protected] Allow tests to run on macOS 13 (flutter/engine#48894) 2023-12-13 [email protected] [Impeller] Compute ContextContentOptions key via bit manipulating (instead of hashing each property). (flutter/engine#48902) 2023-12-13 [email protected] Roll Skia from f3401c6186c1 to 69c02c9d56b2 (1 revision) (flutter/engine#48992) 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 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
The hash function we use for pipeline hashncash is actually pretty slow. Since all of the properties we hash on fit in 64 bits, we can compute a hash value directly. From local benchmarking this is about twice as fast, which still leaves quite a bit of room for future improvement (faster hashmap? not using a hashmap at all?)