Make SKSL caching test work on Fuchsia on arm64 (#18572)

* Hook up PersistentCache to ShellTestPlatformViewVulkan

* [vulkan][fuchsia] enable vulkan without swiftshader in fuchsia tests on arm64

* [vulkan][fuchsia] Disable second half of ShellTest.CacheSkSLWorks on
vulkan backend

GrContext::precompileShader() is not implemented for vulkan contexts, so
dont run the portion of this test that depends on that behavior on
Vulkan.

Co-authored-by: George Wright <gw280@google.com>
This commit is contained in:
freiling 2020-06-11 18:45:23 -07:00 committed by GitHub
parent ac809b48cb
commit e1c622b4aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 25 deletions

View File

@ -223,21 +223,21 @@ if (enable_unittests) {
defines += [ "SHELL_ENABLE_GL" ]
}
}
if (test_enable_vulkan) {
sources += [
"shell_test_platform_view_vulkan.cc",
"shell_test_platform_view_vulkan.h",
]
if (test_enable_vulkan) {
sources += [
"shell_test_platform_view_vulkan.cc",
"shell_test_platform_view_vulkan.h",
]
public_deps += [
"//flutter/shell/gpu:gpu_surface_vulkan",
"//flutter/testing:vulkan",
"//flutter/vulkan",
]
public_deps += [
"//flutter/shell/gpu:gpu_surface_vulkan",
"//flutter/testing:vulkan",
"//flutter/vulkan",
]
defines += [ "SHELL_ENABLE_VULKAN" ]
}
defines += [ "SHELL_ENABLE_VULKAN" ]
}
}
@ -263,6 +263,10 @@ if (enable_unittests) {
if (!defined(defines)) {
defines = []
}
if (test_enable_vulkan) {
defines += [ "SHELL_ENABLE_VULKAN" ]
}
}
if (is_fuchsia) {

View File

@ -99,12 +99,17 @@ TEST_F(ShellTest, CacheSkSLWorks) {
firstFrameLatch.Wait();
WaitForIO(shell.get());
// Shader precompilation from SKSL is not implemented on the Skia Vulkan
// backend so don't run the second half of this test on Vulkan. This can get
// removed if SKSL precompilation is implemented in the Skia Vulkan backend.
#if !defined(SHELL_ENABLE_VULKAN)
// To check that all shaders are precompiled, verify that no new skp is dumped
// due to shader compilations.
int old_skp_count = skp_count;
skp_count = 0;
fml::VisitFilesRecursively(dir.fd(), skp_visitor);
ASSERT_EQ(skp_count, old_skp_count);
#endif // !defined(SHELL_ENABLE_VULKAN)
// Remove all files generated
fml::FileVisitor remove_visitor = [&remove_visitor](

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "flutter/shell/common/shell_test_platform_view_vulkan.h"
#include "flutter/shell/common/persistent_cache.h"
#include "flutter/vulkan/vulkan_utilities.h"
namespace flutter {
@ -105,7 +106,14 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
return false;
}
sk_sp<GrContext> context = GrContext::MakeVulkan(backend_context);
GrContextOptions options;
if (PersistentCache::cache_sksl()) {
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
}
PersistentCache::MarkStrategySet();
options.fPersistentCache = PersistentCache::GetCacheForProcess();
sk_sp<GrContext> context = GrContext::MakeVulkan(backend_context, options);
if (context == nullptr) {
FML_DLOG(ERROR) << "Failed to create GrContext";

View File

@ -98,6 +98,21 @@ source_set("fixture_test") {
}
if (enable_unittests) {
source_set("vulkan") {
testonly = true
deps = [
":skia",
"//flutter/fml",
]
# SwiftShader only supports x86/x64_64
if (target_cpu == "x86" || target_cpu == "x64") {
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps += [ "//third_party/swiftshader_flutter:swiftshader_vulkan" ]
}
}
# SwiftShader only supports x86/x64_64
if (target_cpu == "x86" || target_cpu == "x64") {
source_set("opengl") {
@ -117,18 +132,6 @@ if (enable_unittests) {
]
}
source_set("vulkan") {
testonly = true
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps = [
":skia",
"//flutter/fml",
"//third_party/swiftshader_flutter:swiftshader_vulkan",
]
}
# All targets on all platforms should be able to use the Metal utilities. On
# platforms where Metal is not available, the tests must be skipped or
# implemented to use another available client rendering API. This is usually