From 1f1471c9b7b5456df2ec3e5c81d60e0c5bf9e3db Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 20 Feb 2020 15:07:34 -0800 Subject: [PATCH 1/3] Hook up PersistentCache to ShellTestPlatformViewVulkan --- shell/common/shell_test_platform_view_vulkan.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shell/common/shell_test_platform_view_vulkan.cc b/shell/common/shell_test_platform_view_vulkan.cc index 7c91656789765..5dedabebae0b8 100644 --- a/shell/common/shell_test_platform_view_vulkan.cc +++ b/shell/common/shell_test_platform_view_vulkan.cc @@ -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 context = GrContext::MakeVulkan(backend_context); + GrContextOptions options; + if (PersistentCache::cache_sksl()) { + options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL; + } + PersistentCache::MarkStrategySet(); + options.fPersistentCache = PersistentCache::GetCacheForProcess(); + + sk_sp context = GrContext::MakeVulkan(backend_context, options); if (context == nullptr) { FML_DLOG(ERROR) << "Failed to create GrContext"; From 1a24307982ce95f079c62d788e1bdb4881947c60 Mon Sep 17 00:00:00 2001 From: Forrest Reiling Date: Thu, 14 May 2020 23:02:03 +0000 Subject: [PATCH 2/3] [vulkan][fuchsia] enable vulkan without swiftshader in fuchsia tests on arm64 --- shell/common/BUILD.gn | 28 ++++++++++++++++------------ testing/BUILD.gn | 27 +++++++++++++++------------ 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 71eac2a2dcc13..0f442ceb74785 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -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) { diff --git a/testing/BUILD.gn b/testing/BUILD.gn index 1ff8ee97f2f6a..1fbfa4b3d3874 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn @@ -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 From fe6061f1f9a4d58008002b148e5e83752df68afc Mon Sep 17 00:00:00 2001 From: Forrest Reiling Date: Fri, 15 May 2020 22:31:53 +0000 Subject: [PATCH 3/3] [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. --- shell/common/persistent_cache_unittests.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shell/common/persistent_cache_unittests.cc b/shell/common/persistent_cache_unittests.cc index 8dc4a1e2a30fa..cae8d18fb98f5 100644 --- a/shell/common/persistent_cache_unittests.cc +++ b/shell/common/persistent_cache_unittests.cc @@ -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](