Skip to content

Commit

Permalink
Enable DisplayList benchmarks to be built on Android (#31268)
Browse files Browse the repository at this point in the history
  • Loading branch information
George Wright authored Feb 8, 2022
1 parent c490e48 commit 6f99a71
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 78 deletions.
5 changes: 4 additions & 1 deletion benchmarking/benchmarking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
#include "benchmarking.h"

#include "flutter/fml/backtrace.h"
#include "flutter/fml/build_config.h"
#include "flutter/fml/command_line.h"
#include "flutter/fml/icu_util.h"

namespace benchmarking {

int Main(int argc, char** argv) {
fml::InstallCrashHandler();
#if !defined(FML_OS_ANDROID)
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);
benchmark::Initialize(&argc, argv);
std::string icudtl_path =
cmd.GetOptionValueWithDefault("icu-data-file-path", "icudtl.dat");
fml::icu::InitializeICU(icudtl_path);
#endif
benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
return 0;
}
Expand Down
117 changes: 61 additions & 56 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,51 +55,76 @@ fixtures_location("display_list_benchmarks_fixtures") {
assets_dir = "$target_gen_dir/"
}

if (enable_unittests) {
executable("display_list_benchmarks") {
testonly = true
source_set("display_list_benchmarks_source") {
testonly = true

sources = [
"display_list_benchmarks.cc",
"display_list_benchmarks.h",
]

deps = [
":display_list",
":display_list_benchmarks_fixtures",
"//flutter/benchmarking",
"//flutter/common/graphics",
"//flutter/fml",
"//flutter/testing:skia",
"//flutter/testing:testing_lib",
"//third_party/dart/runtime:libdart_jit", # for tracing
"//third_party/skia",
]

defines = []

sources = [
"display_list_benchmarks.cc",
"display_list_benchmarks.h",
if (is_android) {
libs = [
"android",
"EGL",
"GLESv2",
]
}

# We only do software benchmarks on non-mobile platforms
if (!is_android && !is_ios) {
sources += [
"display_list_benchmarks_software.cc",
"display_list_benchmarks_software.h",
]
defines += [ "ENABLE_SOFTWARE_BENCHMARKS" ]
}

# iOS and Fuchsia don't support OpenGL
if (!is_fuchsia && !is_ios) {
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
sources += [
"display_list_benchmarks_gl.cc",
"display_list_benchmarks_gl.h",
]
deps += [ "//flutter/testing:opengl" ]
}

deps = [
":display_list",
":display_list_benchmarks_fixtures",
"//flutter/benchmarking",
"//flutter/common/graphics",
"//flutter/fml",
"//flutter/testing:skia",
"//flutter/testing:testing_lib",
"//third_party/dart/runtime:libdart_jit", # for tracing
"//third_party/skia",
if (is_mac || is_ios) {
defines += [ "ENABLE_METAL_BENCHMARKS" ]
sources += [
"display_list_benchmarks_metal.cc",
"display_list_benchmarks_metal.h",
]
deps += [ "//flutter/testing:metal" ]
}

defines = [ "ENABLE_SOFTWARE_BENCHMARKS" ]

if (!is_fuchsia) {
defines += [ "ENABLE_OPENGL_BENCHMARKS" ]
sources += [
"display_list_benchmarks_gl.cc",
"display_list_benchmarks_gl.h",
]
deps += [ "//flutter/testing:opengl" ]
}

if (is_mac) {
defines += [ "ENABLE_METAL_BENCHMARKS" ]
sources += [
"display_list_benchmarks_metal.cc",
"display_list_benchmarks_metal.h",
]
deps += [ "//flutter/testing:metal" ]
}
# Don't snapshot test results on mobile platforms
if (is_android || is_ios) {
defines += [ "BENCHMARKS_NO_SNAPSHOT" ]
}
}

executable("display_list_benchmarks") {
testonly = true

deps = [ ":display_list_benchmarks_source" ]
}

if (is_ios) {
shared_library("ios_display_list_benchmarks") {
testonly = true
Expand All @@ -116,29 +141,9 @@ if (is_ios) {
]
ldflags =
[ "-Wl,-install_name,@rpath/libios_display_list_benchmarks.dylib" ]
defines = [
"BENCHMARKS_NO_SNAPSHOT",
"ENABLE_METAL_BENCHMARKS",
]
sources = [
"display_list_benchmarks.cc",
"display_list_benchmarks.h",
"display_list_benchmarks_metal.cc",
"display_list_benchmarks_metal.h",
]

deps = [
":display_list",
":display_list_benchmarks_fixtures",
":display_list_benchmarks_source",
"//flutter/benchmarking:benchmarking_library",
"//flutter/common/graphics",
"//flutter/fml",
"//flutter/testing:metal",
"//flutter/testing:skia",
"//flutter/testing:testing_lib",
"//third_party/benchmark",
"//third_party/dart/runtime:libdart_jit", # for tracing
"//third_party/skia",
]
}
}
46 changes: 25 additions & 21 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,6 @@ if (enable_unittests) {
}
}

# SwiftShader only supports x86/x86_64
if (target_cpu == "x86" || target_cpu == "x64") {
source_set("opengl") {
testonly = true

configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]

sources = [
"test_gl_surface.cc",
"test_gl_surface.h",
]

deps = [
":skia",
"//flutter/fml",
"//third_party/swiftshader_flutter:swiftshader_gl",
]
}
}

test_fixtures("testing_fixtures") {
fixtures = []
}
Expand Down Expand Up @@ -205,7 +185,7 @@ if (enable_unittests) {
# is exercised on platforms where Metal itself is available.
#
# On iOS, this is enabled to allow for Metal tests to run within a test app
if (enable_unittests || is_ios) {
if (is_mac || is_ios) {
source_set("metal") {
if (shell_enable_metal) {
sources = [
Expand All @@ -231,3 +211,27 @@ if (enable_unittests || is_ios) {
testonly = true
}
}

# We only use SwiftShader on unittests and
# SwiftShader only supports x86/x86_64
use_swiftshader =
enable_unittests && (target_cpu == "x86" || target_cpu == "x64")

source_set("opengl") {
testonly = true

sources = [
"test_gl_surface.cc",
"test_gl_surface.h",
]

deps = [
":skia",
"//flutter/fml",
]

if (use_swiftshader) {
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps += [ "//third_party/swiftshader_flutter:swiftshader_gl" ]
}
}

0 comments on commit 6f99a71

Please sign in to comment.