-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract backend-specific code in ShellTestPlatformView #56722
Extract backend-specific code in ShellTestPlatformView #56722
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). 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. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
case BackendType::kMetalBackend: | ||
return std::make_unique<ShellTestPlatformViewMetal>( | ||
return CreatePlatformViewMetal( | ||
delegate, task_runners, vsync_clock, create_vsync_waiter, | ||
shell_test_external_view_embedder, is_gpu_disabled_sync_switch); |
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.
Instead of instantiating all the backend-specific stuff here, the implementations are now in the appropriate shell_test_platform_view_metal.mm
or shell_test_platform_view_vulkan.cc
etc. file, with fallback implementations in this file for any backends that are disabled.
FlutterDarwinContextMetalSkia* skia_context; | ||
FlutterDarwinContextMetalImpeller* impeller_context; | ||
id<MTLTexture> offscreen_texture; | ||
}; |
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.
No longer necessary -- these fields are now directly on ShellTestPlatformViewMetal
in the header.
skia_context_ = [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]; | ||
FML_CHECK(skia_context_.mainContext); | ||
device = skia_context_.device; | ||
} |
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.
In a followup patch I'll replace the separate impeller_context_
and skia_context_
fields with a std::variant
since we never use both.
Converting to draft while I work out what's made the UI tests (and a fuchsia test) sad. |
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. |
@@ -32,28 +21,18 @@ std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::Create( | |||
// Make this fully runtime configurable | |||
switch (backend) { | |||
case BackendType::kDefaultBackend: |
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.
Ugh. Worked out the issue. kDefaultBackend
is relying on falling through to a backend that is not #ifdef
'ed out.
I'll kill this enum value and replace it with a function that returns the appropriate actual backend rather that using this trick in every single switch statement on this enum.
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.
Sent #56744 for that cleanup.
34b7c2d
to
54d9b3d
Compare
`kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In flutter#56722 we split backends out into separate translation units, and remove the `#ifdef`s which means we can't rely on this trick anymore.
`kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In flutter#56722 we split backends out into separate translation units, and remove the `#ifdef`s which means we can't rely on this trick anymore.
`kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In flutter#56722 we split backends out into separate translation units, and remove the `#ifdef`s which means we can't rely on this trick anymore.
`kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In flutter#56722 we split backends out into separate translation units, and remove the `#ifdef`s which means we can't rely on this trick anymore.
…6744) `kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In #56722 we split backends out into separate translation units, and ideally should remove the `#ifdef`s, which means we can't rely on this trick anymore. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
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.
You have a merge conflict, but RSLGTM
Ah yep! Rebased locally on top of this one #56744. Will push when I get back to the computer. |
Moves code specific to each graphics backend into the (existing) translation unit associated with that backend. Previously, we could not include any Objective-C types in shell_test_platform_view_metal.h, since that file was included into shell_test_platform_view.cc, which is pure C++. To work around this, we had encapsulated Objective-C Metal types in a `DarwinContextMetal` struct hidden in the implementation file with a pointer to it forward-declared in the header. We now use Metal types directly in the header, without the workarounds. Issue: flutter/flutter#158998 Issue: flutter/flutter#137801
54d9b3d
to
43422f6
Compare
…159345) flutter/engine@6f941c9...202506d 2024-11-22 [email protected] [Impeller] cache and reuse openGL framebuffer attachments. (flutter/engine#56746) 2024-11-22 [email protected] Roll Skia from 700e685861c8 to e7caf38140ce (25 revisions) (flutter/engine#56756) 2024-11-22 [email protected] Roll Dart SDK from c1106f7e4cde to 141291fd570d (1 revision) (flutter/engine#56748) 2024-11-22 [email protected] [engine] more consistently flush dart event loop, run vsync callback immediately (flutter/engine#56738) 2024-11-22 [email protected] Extract backend-specific code in ShellTestPlatformView (flutter/engine#56722) 2024-11-22 [email protected] Eliminate ShellTestPlatformView::BackendType::kDefaultBackendType (flutter/engine#56744) 2024-11-22 [email protected] Roll Skia from 2614590b4f32 to 700e685861c8 (1 revision) (flutter/engine#56725) 2024-11-22 [email protected] Roll Dart SDK from b36e4d731d67 to c1106f7e4cde (12 revisions) (flutter/engine#56742) 2024-11-22 [email protected] [Impeller] libImpeller: A C++ wrapper to the Impeller API. (flutter/engine#56682) 2024-11-21 [email protected] [Impeller] Run simulator tests with Impeller enabled. (flutter/engine#56740) 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] 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
…visions) (#159345)" (#159360) <!-- start_original_pr_link --> Reverts: #159345 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: hannah-hyj <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: tree is red on " Linux_build_test flutter_gallery__transition_perf_hybrid" after engine auto roll <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: engine-flutter-autoroll <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {fluttergithubbot} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: flutter/engine@6f941c9...202506d 2024-11-22 [email protected] [Impeller] cache and reuse openGL framebuffer attachments. (flutter/engine#56746) 2024-11-22 [email protected] Roll Skia from 700e685861c8 to e7caf38140ce (25 revisions) (flutter/engine#56756) 2024-11-22 [email protected] Roll Dart SDK from c1106f7e4cde to 141291fd570d (1 revision) (flutter/engine#56748) 2024-11-22 [email protected] [engine] more consistently flush dart event loop, run vsync callback immediately (flutter/engine#56738) 2024-11-22 [email protected] Extract backend-specific code in ShellTestPlatformView (flutter/engine#56722) 2024-11-22 [email protected] Eliminate ShellTestPlatformView::BackendType::kDefaultBackendType (flutter/engine#56744) 2024-11-22 [email protected] Roll Skia from 2614590b4f32 to 700e685861c8 (1 revision) (flutter/engine#56725) 2024-11-22 [email protected] Roll Dart SDK from b36e4d731d67 to c1106f7e4cde (12 revisions) (flutter/engine#56742) 2024-11-22 [email protected] [Impeller] libImpeller: A C++ wrapper to the Impeller API. (flutter/engine#56682) 2024-11-21 [email protected] [Impeller] Run simulator tests with Impeller enabled. (flutter/engine#56740) 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] 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 <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <[email protected]>
…159364) flutter/engine@6f941c9...f776c3a 2024-11-22 [email protected] Roll Skia from e7caf38140ce to c3d9596a93f8 (2 revisions) (flutter/engine#56765) 2024-11-22 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[engine] more consistently flush dart event loop, run vsync callback immediately (#56738)" (flutter/engine#56767) 2024-11-22 [email protected] Roll Dart SDK from 8b65a7a628e2 to eb01a0430f72 (2 revisions) (flutter/engine#56764) 2024-11-22 [email protected] [Impeller] delete Impeller sim opt out. (flutter/engine#56706) 2024-11-22 [email protected] [Impeller] Ensure that SnapshotControllerImpeller has a rendering context before creating the snapshot (flutter/engine#56743) 2024-11-22 [email protected] [DisplayList] migrate DlColorSource objects to Impeller geometry (flutter/engine#56735) 2024-11-22 [email protected] [Impeller] libImpeller: Tinker on the README. (flutter/engine#56761) 2024-11-22 [email protected] [Impeller] dont create temp vec for discard. (flutter/engine#56759) 2024-11-22 [email protected] Roll Fuchsia Linux SDK from zhFzwYCH-N_wasTnM... to D5CBHuB2c-v3Zai-c... (flutter/engine#56757) 2024-11-22 [email protected] Roll Dart SDK from 141291fd570d to 8b65a7a628e2 (1 revision) (flutter/engine#56755) 2024-11-22 [email protected] [Impeller] cache and reuse openGL framebuffer attachments. (flutter/engine#56746) 2024-11-22 [email protected] Roll Skia from 700e685861c8 to e7caf38140ce (25 revisions) (flutter/engine#56756) 2024-11-22 [email protected] Roll Dart SDK from c1106f7e4cde to 141291fd570d (1 revision) (flutter/engine#56748) 2024-11-22 [email protected] [engine] more consistently flush dart event loop, run vsync callback immediately (flutter/engine#56738) 2024-11-22 [email protected] Extract backend-specific code in ShellTestPlatformView (flutter/engine#56722) 2024-11-22 [email protected] Eliminate ShellTestPlatformView::BackendType::kDefaultBackendType (flutter/engine#56744) 2024-11-22 [email protected] Roll Skia from 2614590b4f32 to 700e685861c8 (1 revision) (flutter/engine#56725) 2024-11-22 [email protected] Roll Dart SDK from b36e4d731d67 to c1106f7e4cde (12 revisions) (flutter/engine#56742) 2024-11-22 [email protected] [Impeller] libImpeller: A C++ wrapper to the Impeller API. (flutter/engine#56682) 2024-11-21 [email protected] [Impeller] Run simulator tests with Impeller enabled. (flutter/engine#56740) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from zhFzwYCH-N_w to D5CBHuB2c-v3 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] 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
…utter/engine#56744) `kDefaultBackendType` is intended to make life easier for authors of tests, but in any switch statement where it's used (currently just a single location), we rely on ordering it first and `#ifdef`ing out all backends that aren't available. Instead, we define a static function that returns the default that callers can invoke instead. This avoids relinace on case ordering and fallthrough. In flutter/engine#56722 we split backends out into separate translation units, and ideally should remove the `#ifdef`s, which means we can't rely on this trick anymore. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…e#56722) Moves code specific to each graphics backend into the (existing) translation unit associated with that backend. Previously, we could not include any Objective-C types in `shell_test_platform_view_metal.h`, since that file was included into `shell_test_platform_view.cc`, which is pure C++. To work around this, we had encapsulated Objective-C Metal types in a `DarwinContextMetal` struct hidden in the implementation file with a pointer to it forward-declared in the header. We now use Metal types directly in the header, without the workarounds. Issue: flutter#158998 Issue: flutter#137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Moves code specific to each graphics backend into the (existing) translation unit associated with that backend.
Previously, we could not include any Objective-C types in
shell_test_platform_view_metal.h
, since that file was included intoshell_test_platform_view.cc
, which is pure C++. To work around this, we had encapsulated Objective-C Metal types in aDarwinContextMetal
struct hidden in the implementation file with a pointer to it forward-declared in the header.We now use Metal types directly in the header, without the workarounds.
Issue: flutter/flutter#158998
Issue: flutter/flutter#137801
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.