Skip to content
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

SKP based shader warmup #20643

Merged
merged 4 commits into from Nov 5, 2020
Merged

Conversation

@freiling
Copy link
Contributor

@freiling freiling commented Aug 19, 2020

Description

This PR implements SKP based shader warmup within the flutter engine on fuchsia.

Tests

Each commit comes with tests for the contents of that commit. The font tests are disabled because it fails due to https://bugs.chromium.org/p/skia/issues/detail?id=10404 but I left it in so it can be re-enabled when the fix is integrated. Includes new test suites for flutter::AssetManager and flutter_runner::Engine because no tests existed for these classes.

@auto-assign auto-assign bot requested a review from flar Aug 19, 2020
@freiling freiling force-pushed the freiling:freiling-skp-warmup branch from 8cd322f to b9f6146 Sep 3, 2020
@freiling freiling force-pushed the freiling:freiling-skp-warmup branch 2 times, most recently from 47ae5c2 to 85b7ce9 Sep 15, 2020
@freiling freiling force-pushed the freiling:freiling-skp-warmup branch 7 times, most recently from 626596c to 8d1126f Oct 23, 2020
@freiling freiling requested review from arbreng, liyuqian and chinmaygarde Oct 27, 2020
@freiling freiling changed the title [WIP] SKP shader warmup SKP based shader warmup Oct 27, 2020
@freiling freiling force-pushed the freiling:freiling-skp-warmup branch 2 times, most recently from 0dc5b34 to 46d6fdb Oct 27, 2020

#if defined(OS_FUCHSIA)
#include "lib/sys/cpp/component_context.h"
#include "third_party/skia/include/ports/SkFontMgr_fuchsia.h"

This comment has been minimized.

@arbreng

arbreng Oct 27, 2020
Contributor

You need an #endif here or the namespace declarations are stripped out, this will cause problems on non-fuchsia builds

This comment has been minimized.

@freiling

freiling Oct 28, 2020
Author Contributor

this ifdef block wraps basically the entire file including the close braces on the namespace. I'll take an action item to comment the endif with "// defined(OS_FUCHSIA)" though

on_create_rasterizer = [this](flutter::Shell& shell) {
FML_DCHECK(surface_producer_);

WarmupSkps(

This comment has been minimized.

@arbreng

arbreng Oct 27, 2020
Contributor

I highly recommend wrapping all of the logic you're adding in a config flag

Otherwise a revert will make you very sad :(

@freiling freiling force-pushed the freiling:freiling-skp-warmup branch from 46d6fdb to d9a50db Oct 27, 2020
Copy link
Contributor

@liyuqian liyuqian left a comment

Looks good from the Flutter side with some minor nits.

#include "include/core/SkStream.h"
#include "include/core/SkTypeface.h"

namespace flutter {

sk_sp<SkData> SerializeTypefaceWithoutData(SkTypeface* typeface, void* ctx) {
return typeface->serialize(SkTypeface::SerializeBehavior::kDontIncludeData);

This comment has been minimized.

@liyuqian

liyuqian Oct 28, 2020
Contributor

I wonder why the old line didn't work. I guess they should both save space, so is it because typeface->serialize(SkTypeface::SerializeBehavior::kDontIncludeData) somehow interfered with the Fuchsia typeface while SkData::MakeEmpty() won't?

Is this line also the reason why we need DeserializeTypefaceWithoutData?

This comment has been minimized.

@freiling

freiling Oct 30, 2020
Author Contributor

This commit is from a while back so I don't 100% remember. IIRC even serializing typefaces with SerializeBehavior::kDontIncludeData caused the deserialized SkPictures to not be renderable (or maybe failed to deserialize, i dont quite remember) and talking with the Skia people about it I was advised that if all I wanted to do was warm up shaders they could vend be a special standin typeface which warms up all the typeface shaders and had me file https://bugs.chromium.org/p/skia/issues/detail?id=10404 for it. So basically this just serialized nothing and then on the deserialize path creates the default typeface. Once that skia feature is in DeserializeTypefaceWithoutData will return the special warmup typeface rather than the default typeface.

mapping->GetSize());

ASSERT_TRUE(result == filename);
}

This comment has been minimized.

@liyuqian

liyuqian Oct 28, 2020
Contributor

Nit: add a new line here.

This comment has been minimized.

@freiling

freiling Oct 30, 2020
Author Contributor

Done

std::string filename = "test";

bool success = fml::WriteAtomically(asset_dir_fd, filename.c_str(),
fml::DataMapping(filename));

This comment has been minimized.

@liyuqian

liyuqian Oct 28, 2020
Contributor

Nit: maybe create std::string content = "test" and write it into the file, so we'll have ASSERT_TRUE(result == content); which is less confusing than ASSERT_TRUE(result == filename);.

This comment has been minimized.

@freiling

freiling Oct 30, 2020
Author Contributor

Done

@freiling freiling force-pushed the freiling:freiling-skp-warmup branch 2 times, most recently from 303c999 to 7f78a28 Oct 28, 2020
@chinmaygarde
Copy link
Member

@chinmaygarde chinmaygarde commented Oct 29, 2020

The test failure in presubmit looks related to this patch:

Assertion failed: image && image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV 
(../../third_party/mesa/src/intel/vulkan/genX_cmd_buffer.c: transition_color_buffer: 1126)
freiling added 3 commits Jul 21, 2020
Asset Manager.

Gives Asset Manager the ability to find files matching a specific
pattern and uses that functionality to implement an entry point in
PersistantCache which retreives mappings for all skp files in the Asset
Bundle.
Make Engine load all .skp files from persistent cache and draw them on
an offscreen surface to warm up shaders.
@freiling freiling force-pushed the freiling:freiling-skp-warmup branch from 7f78a28 to 1b152e0 Oct 30, 2020
@freiling
Copy link
Contributor Author

@freiling freiling commented Oct 30, 2020

The test failure in presubmit looks related to this patch:

Assertion failed: image && image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV 
(../../third_party/mesa/src/intel/vulkan/genX_cmd_buffer.c: transition_color_buffer: 1126)

I'm not seeing this test, do you have a link or instructions on how to get to it?

@freiling freiling force-pushed the freiling:freiling-skp-warmup branch from 1b152e0 to cd1fe95 Nov 3, 2020
@fluttergithubbot fluttergithubbot merged commit 3105db8 into flutter:master Nov 5, 2020
16 checks passed
16 checks passed
Linux Android AOT Engine
Details
Linux Android Debug Engine
Details
Linux Android Scenarios
Details
Linux Fuchsia
Details
Linux Host Engine
Details
Mac Android AOT Engine
Details
Mac Android Debug Engine
Details
Mac Host Engine
Details
Mac iOS Engine
Details
WIP Ready for review
Details
Windows Android AOT Engine
Details
Windows Host Engine
Details
build_and_test_linux_unopt_debug Task Summary
Details
cla/google All necessary CLAs are signed
licenses_check Task Summary
Details
luci-engine
Details
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 5, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 5, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 5, 2020
chaselatta added a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.