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

Make SKSL caching test work on Fuchsia on arm64 #18572

Merged
merged 3 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
}

Expand All @@ -263,6 +263,10 @@ if (enable_unittests) {
if (!defined(defines)) {
defines = []
}

if (test_enable_vulkan) {
defines += [ "SHELL_ENABLE_VULKAN" ]
}
}

if (is_fuchsia) {
Expand Down
5 changes: 5 additions & 0 deletions shell/common/persistent_cache_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand Down
10 changes: 9 additions & 1 deletion shell/common/shell_test_platform_view_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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";
Expand Down
27 changes: 15 additions & 12 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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
Expand Down