-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Add Impeller Metal support in the embedder API #42411
Conversation
d108909 to
2f0eac6
Compare
|
/cc @dkwingsmt, this may be interesting for your macOS multi-view work. |
|
@loic-sharma Thanks! They look good to me (in terms of multi-view macOS). |
3fee72d to
20bc270
Compare
028ef29 to
9521b3c
Compare
chinmaygarde
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.
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, |
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.
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, *)) { |
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 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.
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.
Whoops, this is because I just duplicated the Skia variation and modified relevant parts. Removed.
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.
It turns out we need the check because CAMetalLayer is iOS 13+
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.
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.
Yeah, it's just the simulator
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 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
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.
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(); |
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.
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.
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.
But the dl_builder above uses the other style? Just use the same style everywhere?
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. 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_); |
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.
DCHECK turned to CHECK. Perhaps keep them the same?
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.
Fixed.
shell/platform/embedder/BUILD.gn
Outdated
| "embedder_external_texture_metal.mm", | ||
| "embedder_surface_metal.h", | ||
| "embedder_surface_metal.mm", | ||
| "embedder_surface_metal_impeller.h", |
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 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.
f801790 to
6d69561
Compare
|
We're still not building Impeller with Fuchsia. I'm pulling on that thread now that the |
We've resorted to forward declaring these. See the rasterizer. |
Yes that seems like the smart choice. I didn't have to pull very far for a sense of foreboding to wash over me. |
bac7d09 to
db021cd
Compare
db021cd to
248415c
Compare
…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
…utter#42411)" This reverts commit 052e226.
…utter#42411)" This reverts commit 052e226.
…2411)" (#42532) This reverts commit 052e226. Expected to resolve flutter/flutter#128145
…utter#42411) This reverts commit 05f958c.
…utter#42411) This reverts commit 05f958c.
…utter#42411) This reverts commit 05f958c.
…2411) (#42545) This reverts commit 05f958c. Original PR: #42411 Part of flutter/flutter#112230.
… API (#42411)" (#42593) Reverts #42545 Not sure if this is needed, but getting a revert started for the regression noted here: #42545 (comment).
…lutter#42411) This reverts commit 350a12b.
…lutter#42411) This reverts commit 350a12b.
…lutter#42411) This reverts commit 350a12b.

Part of flutter/flutter#112230.
Now seemed like the right time to sneak this in: