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

Conversation

@bdero
Copy link
Member

@bdero bdero commented May 30, 2023

Part of flutter/flutter#112230.

Now seemed like the right time to sneak this in:

  • We have large desktop refactors on the horizon (multi-window).
  • We're starting to land optimizations that complicate the surface behavior such as wide gamut and dirty regions.
  • We have plans to migrate the iOS embedder to use the embedder API ([iOS] Migrate to embedder API flutter#112232).

Screenshot 2023-05-30 at 6 59 48 PM

@bdero bdero self-assigned this May 30, 2023
@bdero bdero changed the title [Impeller] Add Impeller support in the embedder API [Impeller] Add Impeller Metal support in the embedder API May 30, 2023
@bdero bdero force-pushed the bdero/impeller-embedder branch from d108909 to 2f0eac6 Compare May 30, 2023 11:40
@loic-sharma
Copy link
Member

loic-sharma commented May 30, 2023

/cc @dkwingsmt, this may be interesting for your macOS multi-view work.

@dkwingsmt
Copy link
Contributor

@loic-sharma Thanks! They look good to me (in terms of multi-view macOS).

@bdero bdero force-pushed the bdero/impeller-embedder branch 2 times, most recently from 3fee72d to 20bc270 Compare May 31, 2023 02:16
@bdero bdero requested review from chinmaygarde and zanderso May 31, 2023 02:21
@bdero bdero force-pushed the bdero/impeller-embedder branch 3 times, most recently from 028ef29 to 9521b3c Compare May 31, 2023 04:04
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool! I left a few comments with nits and suggestions. But lgtm otherwise.

void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context,
std::unique_ptr<SurfaceFrame> frame) {
void ExternalViewEmbedder::SubmitFrame(
GrDirectContext* context,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, that's a bit unfortunate. But we can clean this up later.

}

std::unique_ptr<Surface> EmbedderSurfaceMetalImpeller::CreateGPUSurface() API_AVAILABLE(ios(13.0)) {
if (@available(iOS 13.0, *)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point of this availability guard. There is no call here that the compiler will complain about. And we support targets below 13.0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, this is because I just duplicated the Skia variation and modified relevant parts. Removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out we need the check because CAMetalLayer is iOS 13+

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs say 8.0. Perhaps its the iOS simulator?
Screenshot 2023-05-31 at 10 38 34 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just the simulator

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should copy this sort of macro into formats_mtl and use it for the availability check. https://github.com/google/skia/blob/a8c3132457176d453c063247eaa6e2cab1cb700e/include/gpu/mtl/GrMtlTypes.h#L28

Copy link
Member

@chinmaygarde chinmaygarde May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So:

#if TARGET_OS_SIMULATOR
#define IMPELLER_METAL_AVAILABLE @available(macos(10.11), ios(13.0))
#else  // TARGET_OS_SIMULATOR
#define IMPELLER_METAL_AVAILABLE @available(macos(10.11), ios(8.0))
#endif  // TARGET_OS_SIMULATOR

Or, have macros for IMPELLER_MACOS_METAL_VERSION, IMPELLER_IOS_METAL_VERSION set to the appropriate versions.

dl_builder.SetTransform(&surface_transformation_);
slice_->render_into(&dl_builder);

auto dispatcher = impeller::DlDispatcher();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha. I've been trying to making this the default in the engine but it seems so counter to convention. My reasoning is that auto foo = FooType{}; makes it impossible to have foo uninitialized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the dl_builder above uses the other style? Just use the same style everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also prefer auto foo = ..., but tend to heavily bias towards whatever's nearby.

FML_DCHECK(aiks_context_);
FML_DCHECK(!render_surface_);
} else {
FML_CHECK(render_surface_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DCHECK turned to CHECK. Perhaps keep them the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

"embedder_external_texture_metal.mm",
"embedder_surface_metal.h",
"embedder_surface_metal.mm",
"embedder_surface_metal_impeller.h",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing, (in a later patch is fine) I suggest converting the impeller::EmbedderTest fixture to be a parameterized fixture with the impeller parameterization setting up a context object with the right flag set. Then in the setup, you can skip the test on non-supported backends. The updates should be minimal. Likely just patching the TEST_F calls and instantiating the suite. But you'd double your test coverage.

Just a thought. And we can attempt this in a follow up patch.

@bdero bdero force-pushed the bdero/impeller-embedder branch 3 times, most recently from f801790 to 6d69561 Compare May 31, 2023 07:30
@bdero
Copy link
Member Author

bdero commented May 31, 2023

We're still not building Impeller with Fuchsia. I'm pulling on that thread now that the AiksContext is being lugged around everywhere.

@chinmaygarde
Copy link
Member

now that the AiksContext is being lugged around everywhere.

We've resorted to forward declaring these. See the rasterizer.

@bdero
Copy link
Member Author

bdero commented May 31, 2023

We've resorted to forward declaring these.

Yes that seems like the smart choice. I didn't have to pull very far for a sense of foreboding to wash over me.

@bdero bdero force-pushed the bdero/impeller-embedder branch from db021cd to 248415c Compare June 1, 2023 18:55
@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 1, 2023
@auto-submit auto-submit bot merged commit 052e226 into flutter:main Jun 1, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 2, 2023
…128089)

flutter/engine@3a453f2...02d6fbb

2023-06-01 [email protected] [Impeller] Emplace directly into host buffer (avoid VBB) for text data (flutter/engine#42484)
2023-06-01 [email protected] Ensure PlatformView engine life cycle callbacks are invoked (flutter/engine#42491)
2023-06-01 [email protected] Roll Skia from c408e8e9cc96 to 082a7d1f72f7 (8 revisions) (flutter/engine#42496)
2023-06-01 [email protected] [Windows - TextInput] Insert new line only when TextInputAction.newline (flutter/engine#42244)
2023-06-01 [email protected] Revert "Move clang tidy v2 build to prod." (flutter/engine#42495)
2023-06-01 [email protected] Add myself to AUTHORS (flutter/engine#42406)
2023-06-01 [email protected] [Impeller] Add Impeller Metal support in the embedder API (flutter/engine#42411)
2023-06-01 [email protected] Support DisposalMethod::kRestorePrevious in MultiFrameCodec and fix the apng problem. (flutter/engine#42153)
2023-06-01 [email protected] Fix crash getting spell-check suggestions (flutter/engine#42466)
2023-06-01 [email protected] Fix lint in rectangle packer (flutter/engine#42489)
2023-06-01 [email protected] Wait for GL command completion in the ExternalTextureGLRefreshedTooOften test (flutter/engine#42438)
2023-06-01 [email protected] Reland "[web] Remove the JS API for url strategy (#42134)" (flutter/engine#42486)
2023-06-01 [email protected] Roll Skia from f5bc3d12f0eb to c408e8e9cc96 (9 revisions) (flutter/engine#42487)
2023-06-01 [email protected] Clean up Skia includes around SkSurfaceCharacterization (flutter/engine#42485)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 3, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 3, 2023
bdero added a commit that referenced this pull request Jun 3, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 4, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 5, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 5, 2023
bdero added a commit that referenced this pull request Jun 5, 2023
zanderso added a commit that referenced this pull request Jun 6, 2023
zanderso added a commit that referenced this pull request Jun 6, 2023
… API (#42411)" (#42593)

Reverts #42545

Not sure if this is needed, but getting a revert started for the
regression noted here:
#42545 (comment).
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 6, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 6, 2023
bdero added a commit to bdero/flutter-engine that referenced this pull request Jun 7, 2023
bdero added a commit that referenced this pull request Jun 7, 2023
…42411) (#42597)

This reverts commit
350a12b
+ fixes bugs.

Reworked the surface wrapping to use a valid descriptor when wrapping
the drawable.
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 e: impeller embedder Related to the embedder API platform-android platform-ios

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants