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

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 August 19, 2020 21:34
@freiling freiling force-pushed the freiling-skp-warmup branch from 8cd322f to b9f6146 Compare September 3, 2020 21:27
@freiling freiling force-pushed the freiling-skp-warmup branch 2 times, most recently from 47ae5c2 to 85b7ce9 Compare September 15, 2020 00:55
@chinmaygarde chinmaygarde added the Work in progress (WIP) Not ready (yet) for review! label Oct 1, 2020
@freiling freiling force-pushed the freiling-skp-warmup branch 7 times, most recently from 626596c to 8d1126f Compare October 27, 2020 18:21
@freiling freiling removed the Work in progress (WIP) Not ready (yet) for review! label 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-skp-warmup branch 2 times, most recently from 0dc5b34 to 46d6fdb Compare October 27, 2020 19:56
#if defined(OS_FUCHSIA)
#include "lib/sys/cpp/component_context.h"
#include "third_party/skia/include/ports/SkFontMgr_fuchsia.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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(
Copy link
Contributor

Choose a reason for hiding this comment

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

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-skp-warmup branch from 46d6fdb to d9a50db Compare October 27, 2020 22:46
Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

Looks good from the Flutter side with some minor nits.

namespace flutter {

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

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add a new line here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

std::string filename = "test";

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

Choose a reason for hiding this comment

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

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);.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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

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)

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-skp-warmup branch from 7f78a28 to 1b152e0 Compare October 30, 2020 22:09
@freiling
Copy link
Contributor Author

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-skp-warmup branch from 1b152e0 to cd1fe95 Compare November 3, 2020 23:31
@freiling freiling added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Nov 5, 2020
@fluttergithubbot fluttergithubbot merged commit 3105db8 into flutter:master 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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 5, 2020
chaselatta pushed a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants