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/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]( 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"; 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