Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Add EGL Surface backing store #43683

Merged
merged 30 commits into from
Aug 8, 2024

Conversation

ardera
Copy link
Contributor

@ardera ardera commented Jul 14, 2023

Allows using an EGL surface as a flutter backing store. Way more convenient for GBM than hacking gbm bo's into GL FBOs.

This resolves flutter/flutter#58363

Currently, the embedder API assumes that the compositor (if it exists) will let flutter render into FBOs or Textures and then composite the whole thing onto the actual (EGL) window surface. I think this assumption is also documented a bit in flutter/flutter#38466

However, in my case, I want let the hardware do the composition (using the linux KMS API), and render each flutter layer into it's own EGL surface.

It's possible to hack around this by creating your own GBM BOs, importing those as EGL images, then importing those as GL Render Buffers and attaching those to GL FBOs and that works (tested it). However, that's basically reimplementing 50% of the whole GBM/EGL "window" system integration for no reason.

This PR adds:

  1. To the embedder API:
    • a new kind of OpenGL Backing store: FlutterOpenGLSurface
      • consisting of just a make_current and destruction callback (plus userdata)
      • the make_current callback should make the target surface current, i.e. eglMakeCurrent(..., surf, surf)
      • will be called by the engine before rendering onto the backing store
  2. Some wiring to call make_current before rendering into the backing store

TODO:

  • Actually handle the return value of the make current callback
  • Tests

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

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.

@chinmaygarde
Copy link
Member

I think this direction is sound if you want to wrap up the remaining TODO items.

@chinmaygarde
Copy link
Member

Is this good for a review? This is still marked as WIP so not sure if you are still tinkering on it.

@ardera
Copy link
Contributor Author

ardera commented Jul 28, 2023

@chinmaygarde The implementation is done and won't change anymore (unless we find any flaws). Just doesn't have any tests yet

Btw, I noticed adding new fields to any of the specific, versioned backing store variants (FlutterOpenGLSurface, FlutterMetalTexture) technically violates the ABI stability rules, right? Because they're (indirectly) embedded into FlutterBackingStore by value. The only reason it doesn't matter is because there's no member after the embedded structs in FlutterBackingStore, of which the offset could change incompatibly

@chinmaygarde
Copy link
Member

Are you planning on adding tests or is this good for review?

Re. the ABI stuff, yeah we are getting away with it because we haven't anything to the end of the FlutterBackingStore struct (and can't).

@ardera
Copy link
Contributor Author

ardera commented Aug 14, 2023

I'm currently on vacation, so next week 👍

@chinmaygarde
Copy link
Member

Take your time! Just putting the WIP tag so triagers don't bother you.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

@cbracken
Copy link
Member

@ardera is this still work in progress?

@ardera
Copy link
Contributor Author

ardera commented Nov 1, 2023

@cbracken yep it is

reworking the testing infrastructure to account for multiple EGL surfaces was a bit more work than I thought originally, so just didn't get to it now

@jonahwilliams
Copy link
Member

Hey @ardera, are you still working on this?

@ardera ardera force-pushed the embedder-egl-surface-backing-stores branch from 34b8315 to 19c3701 Compare January 8, 2024 14:15
@ardera
Copy link
Contributor Author

ardera commented Jan 8, 2024

@jonahwilliams Sorry, here it is. The tests mostly assume there's only a single OpenGL surface, so I kinda had to fight against the test framework a bit lol. It's ready for review now.

@ardera ardera changed the title [wip] Add EGL Surface backing store Add EGL Surface backing store Jan 8, 2024
@cbracken
Copy link
Member

@ardera this appears to be failing tests due to what appears to be memory leak (possibly among other things). Once this gets to the state where all tests are passing, we can take another look.

@ardera ardera force-pushed the embedder-egl-surface-backing-stores branch 2 times, most recently from 20122e9 to eafe147 Compare February 21, 2024 15:22
@ardera
Copy link
Contributor Author

ardera commented Feb 21, 2024

@cbracken This is ready for review now.

@vially
Copy link
Contributor

vially commented Apr 10, 2024

Just to add another data-point, I'm currently working on migrating flutter-rs to the FlutterCompositor API and the EGL surface backing store (added as part of this pull-request) would make the implementation a lot simpler.

So thanks a lot for working on this @ardera and I'm looking forward to using it through the embedder API (once this pull-request lands).

@goderbauer
Copy link
Member

(triage): I spoke to @cbracken and he is going to take another look at this.

ardera and others added 19 commits August 6, 2024 11:29
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
Co-authored-by: Chris Bracken <chris@bracken.jp>
@ardera ardera force-pushed the embedder-egl-surface-backing-stores branch from 3da2938 to d315fdc Compare August 6, 2024 11:29
@ardera
Copy link
Contributor Author

ardera commented Aug 6, 2024

I added a SetCurrentResult struct and migrated all the code to that. Is it ready to merge? @chinmaygarde @cbracken

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 8, 2024
@auto-submit auto-submit bot merged commit c25cf09 into flutter:main Aug 8, 2024
27 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 8, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 8, 2024
…153124)

flutter/engine@387f6f3...ef820aa

2024-08-08 jonahwilliams@google.com [Impeller] perform final blit and gpu end frame tracing earlier. (flutter/engine#54452)
2024-08-08 hanneswinkler2000@web.de Add EGL Surface backing store (flutter/engine#43683)
2024-08-08 jason-simmons@users.noreply.github.com Fix include of GrVkImageInfo header for the Fuchsia build (flutter/engine#54449)
2024-08-08 skia-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from AYS3tfC91ZRfdmIL0... to TXbf0oL9XzQ8vcHJP... (flutter/engine#54448)

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 jsimmons@google.com,rmistry@google.com,zra@google.com 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
DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
…lutter#153124)

flutter/engine@387f6f3...ef820aa

2024-08-08 jonahwilliams@google.com [Impeller] perform final blit and gpu end frame tracing earlier. (flutter/engine#54452)
2024-08-08 hanneswinkler2000@web.de Add EGL Surface backing store (flutter/engine#43683)
2024-08-08 jason-simmons@users.noreply.github.com Fix include of GrVkImageInfo header for the Fuchsia build (flutter/engine#54449)
2024-08-08 skia-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from AYS3tfC91ZRfdmIL0... to TXbf0oL9XzQ8vcHJP... (flutter/engine#54448)

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 jsimmons@google.com,rmistry@google.com,zra@google.com 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
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…lutter#153124)

flutter/engine@387f6f3...ef820aa

2024-08-08 jonahwilliams@google.com [Impeller] perform final blit and gpu end frame tracing earlier. (flutter/engine#54452)
2024-08-08 hanneswinkler2000@web.de Add EGL Surface backing store (flutter/engine#43683)
2024-08-08 jason-simmons@users.noreply.github.com Fix include of GrVkImageInfo header for the Fuchsia build (flutter/engine#54449)
2024-08-08 skia-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from AYS3tfC91ZRfdmIL0... to TXbf0oL9XzQ8vcHJP... (flutter/engine#54448)

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 jsimmons@google.com,rmistry@google.com,zra@google.com 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App
Projects
None yet
Development

Successfully merging this pull request may close these issues.

for the embedder, allow backing stores to be EGL window surfaces
6 participants