-
Notifications
You must be signed in to change notification settings - Fork 6k
Enable dirty region management within the Embedder API #35022
Conversation
iskakaushik
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.
Left some initial feedback.
…tiple damage rectangles.
|
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 on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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. |
| typedef void (*FlutterFrameBufferWithDamageCallback)( | ||
| void* /* user data */, | ||
| const intptr_t /* fbo id */, | ||
| FlutterDamage* /* existing damage */); |
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.
@chinmaygarde this is an out parameter, the embedder populates this struct, but it has a list of rects in it. Do you have any recommendations of how the embedder can supply a buffer for the engine to fill out?
shell/platform/embedder/embedder.h
Outdated
| /// responsible for providing populate_existing_damage_callback with the FBO's | ||
| /// ID. Not specifying populate_existing_damage_callback will result in full | ||
| /// repaint (i.e. rendering all the pixels on the screen at every frame). | ||
| FlutterFrameBufferWithDamageCallback populate_existing_damage_callback; |
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.
remove: _callback at the end.
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.
Sounds good! I updated the name to populate_existing_damage.
iskakaushik
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.
minor rename suggestion, but LGTM otherwise
The changes proposed in this PR enable dirty region management within the Embedder API for OpenGL rendering backends. That is, embedders will only render the regions that changed in between frames rather than rendering the entire screen every time. These changes provide a framework for reducing raster time and energy consumption across all embedders using the Flutter Embedder API, immediately affecting OpenGL-based embedders such as the ones implemented for Linux and Windows platforms. In the future, after support for Metal is added, MacOS platforms should also be benefitted.
The implementation adds a new struct, FlutterDamage, to the Embedder API and updates the present and FBO callbacks to handle the necessary information for dirty region management. More specifically to OpenGL, the Embedder GL Surface and the GL Skia GPU have been updated to take damaged regions into account.
The relevant tests have been included inside the embedder_unittests_gl files.
I also ran a local benchmark using this implementation of the embedder with partial repaint within an example of a screen with a loading spinner in the center. The version not using partial repaint had an average present time of 4,171μs/frame while the version using partial repaint had an average present time of 2,457μs/frame.
Pre-launch Checklist
writing and running engine tests.
///).