Skip to content

Commit

Permalink
Roll SwiftShader, ANGLE, use SwANGLE in test harnesses (flutter#33814)
Browse files Browse the repository at this point in the history
Roll Swiftshader, ANGLE, and Vulkan deps.

Updates license bot for new locations of licenses and new files
in roll.

Converts unit test harnesses to use SwANGLE, which is the
supported way of using SwiftShader as a software backend for GLES.

Updates goldens due to swiftshader changes.

Fixes up include paths to avoid directly including third_party
code by that name, which is unlikely to work in other build
environments.

Includes upstream patches to ANGLE and SwiftShader to build in our
windows environments, as well as patches to Skia to support
defining the location of VulkanMemoryAllocator and a patch to ANGLE
to support opting into a newer version of VMA.
  • Loading branch information
dnfield authored Jun 23, 2022
1 parent 9c9ef56 commit 08416ce
Show file tree
Hide file tree
Showing 29 changed files with 373 additions and 197 deletions.
41 changes: 12 additions & 29 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '09b25535a092e89d817a2808e7745c8d111c0be5',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '87d5dcb98983da54257f6f39d3beee2989cb0e47',

# Fuchsia compatibility
#
Expand All @@ -137,26 +137,12 @@ deps = {
'src/third_party/shaderc':
Var('github_git') + '/google/shaderc.git' + '@' + '948660cccfbbc303d2590c7f44a4cee40b66fdd6',

'src/third_party/glslang':
Var('github_git') + '/KhronosGroup/glslang.git' + '@' + '9431c53c84c14fa9e9cd37678262ebba55c62c87',

'src/third_party/spirv_tools':
Var('github_git') + '/KhronosGroup/SPIRV-Tools.git' + '@' + '1020e394cb1267332d58497150d2b024371a8e41',

'src/third_party/spirv_headers':
Var('github_git') + '/KhronosGroup/SPIRV-Headers.git' + '@' + '85b7e00c7d785962ffe851a177c84353d037dcb6',

'src/third_party/spirv_cross':
Var('github_git') + '/KhronosGroup/SPIRV-Cross.git' + '@' + '418542eaefdb609f548d25a1e3962fb69d80da63',
'src/third_party/vulkan-deps':
Var('chromium_git') + '/vulkan-deps' + '@' + '23b710f1a0b3c44d51035c6400a554415f95d9c6',

'src/third_party/flatbuffers':
Var('github_git') + '/google/flatbuffers.git' + '@' + '967df08b1dbddc62f867464c2e0d58d8027438ad',

# Chromium-style
#
# As part of integrating with Fuchsia, we should eventually remove all these
# Chromium-style dependencies.

'src/third_party/icu':
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '12de966fcbe1d1a48dba310aee63807856ffeee8',

Expand Down Expand Up @@ -472,26 +458,19 @@ deps = {
'src/third_party/pyyaml':
Var('fuchsia_git') + '/third_party/pyyaml.git' + '@' + '25e97546488eee166b1abb229a27856cecd8b7ac',

# Upstream Khronos Vulkan Headers (v1.1.130)
'src/third_party/vulkan-headers':
Var('github_git') + '/KhronosGroup/Vulkan-Headers.git' + '@' + '0e57fc1cfa56a203efe43e4dfb9b3c9e9b105593',

# Skia VMA dependency.
'src/third_party/externals/vulkanmemoryallocator':
Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git' + '@' + '7de5cc00de50e71a3aab22dea52fbb7ff4efceb6',

# Upstream Khronos Vulkan Headers are part of vulkan-deps
# Downstream Fuchsia Vulkan Headers (v1.2.198)
'src/third_party/fuchsia-vulkan':
Var('fuchsia_git') + '/third_party/Vulkan-Headers.git' + '@' + '32640ad82ef648768c706c9bf828b77123a09bc2',

'src/third_party/swiftshader':
Var('swiftshader_git') + '/SwiftShader.git' + '@' + 'd4130e9ac3675dadbec8442dc2310a80ea4ddfb2',
Var('swiftshader_git') + '/SwiftShader.git' + '@' + 'bea8d2471bd912220ba59032e0738f3364632657',

'src/third_party/angle':
Var('github_git') + '/google/angle.git' + '@' + 'acdec48addfdff315efff293be0d5e2e37e8e560',
Var('chromium_git') + '/angle/angle.git' + '@' + '3faaded8234b31dea24c929e40e33089a34a9aa5',

'src/third_party/angle/third_party/vulkan-deps/vulkan-headers/src':
Var('fuchsia_git') + '/third_party/Vulkan-Headers.git' + '@' + '5de4e8fab88ef0bd6994d9ddbcc864e3179b9e79',
'src/third_party/vulkan_memory_allocator':
Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator' + '@' + '7de5cc00de50e71a3aab22dea52fbb7ff4efceb6',

'src/third_party/abseil-cpp':
Var('chromium_git') + '/chromium/src/third_party/abseil-cpp.git' + '@' + '2d8c1340f0350828f1287c4eaeebefcf317bcfc9',
Expand Down Expand Up @@ -687,6 +666,10 @@ deps = {
},
}

recursedeps = [
'src/third_party/vulkan-deps',
]

hooks = [
{
# Generate the Dart SDK's .dart_tool/package_confg.json file.
Expand Down
281 changes: 181 additions & 100 deletions ci/licenses_golden/licenses_third_party

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 62f85bbfe0c4ce501a865747f7bb099e
Signature: 0be7d6e5107b5c14bae7579aafdcbb7e

1 change: 1 addition & 0 deletions examples/vulkan_glfw/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ executable("vulkan_glfw") {
deps = [
"//flutter/shell/platform/embedder:embedder",
"//third_party/glfw",
"//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers",
]
}
4 changes: 3 additions & 1 deletion impeller/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import("//flutter/impeller/tools/impeller.gni")
import("//flutter/shell/version/version.gni")

impeller_component("compiler_lib") {
include_dirs = [ "//third_party/vulkan-deps/spirv-cross/src/" ]

sources = [
"code_gen_template.h",
"compiler.cc",
Expand Down Expand Up @@ -77,7 +79,7 @@ generated_file("impellerc_license") {
"",
"### spirv_cross",
"",
read_file("//third_party/spirv_cross/LICENSE", "string"),
read_file("//third_party/vulkan-deps/spirv-cross/src/LICENSE", "string"),
]
}

Expand Down
4 changes: 2 additions & 2 deletions impeller/compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "impeller/compiler/source_options.h"
#include "impeller/compiler/types.h"
#include "shaderc/shaderc.hpp"
#include "third_party/spirv_cross/spirv_msl.hpp"
#include "third_party/spirv_cross/spirv_parser.hpp"
#include "spirv_msl.hpp"
#include "spirv_parser.hpp"

namespace impeller {
namespace compiler {
Expand Down
4 changes: 2 additions & 2 deletions impeller/compiler/compiler_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "third_party/spirv_cross/spirv_glsl.hpp"
#include "third_party/spirv_cross/spirv_msl.hpp"
#include "spirv_glsl.hpp"
#include "spirv_msl.hpp"

namespace impeller {
namespace compiler {
Expand Down
4 changes: 2 additions & 2 deletions impeller/compiler/reflector.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "impeller/compiler/compiler_backend.h"
#include "impeller/compiler/runtime_stage_data.h"
#include "inja/inja.hpp"
#include "third_party/spirv_cross/spirv_msl.hpp"
#include "third_party/spirv_cross/spirv_parser.hpp"
#include "spirv_msl.hpp"
#include "spirv_parser.hpp"

namespace impeller {
namespace compiler {
Expand Down
2 changes: 1 addition & 1 deletion impeller/compiler/runtime_stage_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "flutter/fml/macros.h"
#include "flutter/fml/mapping.h"
#include "impeller/compiler/types.h"
#include "third_party/spirv_cross/spirv_parser.hpp"
#include "spirv_parser.hpp"

namespace impeller {
namespace compiler {
Expand Down
4 changes: 2 additions & 2 deletions impeller/compiler/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include "flutter/fml/macros.h"
#include "shaderc/shaderc.hpp"
#include "third_party/spirv_cross/spirv_cross.hpp"
#include "third_party/spirv_cross/spirv_msl.hpp"
#include "spirv_cross.hpp"
#include "spirv_msl.hpp"

namespace impeller {
namespace compiler {
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impeller_component("gles") {
"texture_gles.h",
]

if (!is_android) {
if (!is_android && !is_fuchsia) {
public_configs = [ ":gles_config" ]
sources += [
"//third_party/angle/include/GLES2/gl2.h",
Expand Down
9 changes: 6 additions & 3 deletions lib/spirv/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import("//flutter/testing/testing.gni")

if (enable_unittests) {
executable("spirv_assembler") {
include_dirs = [ "//third_party/vulkan-deps/spirv-tools/src/include/" ]

sources = [ "spirv_assembler.cc" ]

configs += [ "//third_party/swiftshader_flutter:spvtools_public_config" ]
configs +=
[ "//third_party/vulkan-deps/spirv-tools/src:spvtools_public_config" ]

deps = [
"//third_party/swiftshader_flutter:spvtools",
"//third_party/swiftshader_flutter:spvtools_val",
"//third_party/vulkan-deps/spirv-tools/src:spvtools",
"//third_party/vulkan-deps/spirv-tools/src:spvtools_val",
]
}
}
2 changes: 1 addition & 1 deletion lib/spirv/test/spirv_assembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <iostream>
#include <vector>

#include "third_party/swiftshader/third_party/SPIRV-Tools/include/spirv-tools/libspirv.hpp"
#include "spirv-tools/libspirv.hpp"

namespace fs = std::filesystem;

Expand Down
6 changes: 3 additions & 3 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ if (enable_unittests) {
# TODO(63837): This test is hard-coded to use a TestGLSurface so it cannot run on fuchsia.
sources += [ "shell_io_manager_unittests.cc" ]

# Swiftshader only supports x86/64. Only needed on non-Fuchsia platforms.
if (shell_enable_vulkan && (target_cpu == "x86" || target_cpu == "x64")) {
deps += [ "//third_party/swiftshader_flutter:swiftshader_vulkan" ]
# Swiftshader only needed on non-Fuchsia platforms.
if (shell_enable_vulkan) {
deps += [ "//third_party/swiftshader" ]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion shell/gpu/gpu_surface_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "fml/trace_event.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkSize.h"
#include "third_party/swiftshader/include/vulkan/vulkan_core.h"
#include "vulkan/vulkan_core.h"

namespace flutter {

Expand Down
5 changes: 4 additions & 1 deletion shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ if (enable_unittests) {
"tests/embedder_unittests_gl.cc",
]

deps += [ "//flutter/testing:opengl" ]
deps += [
"//flutter/testing:opengl",
"//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers",
]
}

if (test_enable_metal) {
Expand Down
Binary file modified shell/platform/embedder/fixtures/dpr_noxform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/dpr_xform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified shell/platform/embedder/fixtures/gradient_xform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion shell/platform/embedder/tests/embedder_config_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "flutter/shell/platform/embedder/embedder.h"
#include "tests/embedder_test_context.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/swiftshader/include/vulkan/vulkan_core.h"
#include "vulkan/vulkan_core.h"

#ifdef SHELL_ENABLE_GL
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_gl.h"
Expand Down
26 changes: 16 additions & 10 deletions testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ if (enable_unittests) {
"//flutter/vulkan",
]

# SwiftShader only supports x86/x86_64
if (target_cpu == "x86" || target_cpu == "x64") {
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps += [ "//third_party/swiftshader_flutter:swiftshader_vulkan" ]
if (!is_fuchsia) {
deps += [ "//third_party/swiftshader" ]
configs += [ "//third_party/swiftshader:swiftshader_config" ]
}
}

Expand Down Expand Up @@ -215,10 +214,8 @@ if (is_mac || is_ios) {
}
}

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

source_set("opengl") {
testonly = true
Expand All @@ -234,7 +231,16 @@ source_set("opengl") {
]

if (use_swiftshader) {
configs += [ "//third_party/swiftshader_flutter:swiftshader_config" ]
deps += [ "//third_party/swiftshader_flutter:swiftshader_gl" ]
configs -= [ "//build/config/clang:extra_warnings" ]
configs += [
"//flutter/vulkan:vulkan_config", # for swiftshader
"//third_party/angle:gl_prototypes",
"//third_party/swiftshader:swiftshader_config",
]
deps += [
"//third_party/angle:libEGL_static",
"//third_party/angle:libGLESv2_static",
"//third_party/swiftshader",
]
}
}
5 changes: 5 additions & 0 deletions testing/lsan_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ leak:fl_message_codec_decode_message
# At the time of writing, this only amounts to 4 allocations totaling 512 bytes
# worth of leaks.
leak:g_realloc


# ANGLE's egl impelementation uses annotations that our LSAN setup does
# not respect. Ignore leaks from egl::*
leak:egl::*
23 changes: 17 additions & 6 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import argparse
import glob
import errno
import multiprocessing
import os
import re
Expand Down Expand Up @@ -182,10 +183,20 @@ def RunEngineExecutable(

unstripped_exe = os.path.join(build_dir, 'exe.unstripped', executable_name)
env = os.environ.copy()
# We cannot run the unstripped binaries directly when coverage is enabled.
if IsLinux() and os.path.exists(unstripped_exe) and not coverage:
# Some tests depend on the EGL/GLES libraries placed in the build directory.
env['LD_LIBRARY_PATH'] = os.path.join(build_dir, 'lib.unstripped')
if IsLinux():
env['LD_LIBRARY_PATH'] = build_dir
env['VK_DRIVER_FILES'] = os.path.join(build_dir, 'vk_swiftshader_icd.json')
if os.path.exists(unstripped_exe):
try:
os.symlink(
os.path.join(build_dir, 'lib.unstripped', 'libvulkan.so.1'),
os.path.join(build_dir, 'exe.unstripped', 'libvulkan.so.1')
)
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
raise
elif IsMac():
env['DYLD_LIBRARY_PATH'] = build_dir
else:
Expand Down Expand Up @@ -879,7 +890,7 @@ def RunEngineTasksInParallel(tasks):
if len(failures) > 0:
print("The following commands failed:")
for task, exn in failures:
print("%s\n" % str(task))
print("%s\n%s\n" % (str(task), str(exn)))
raise Exception()


Expand Down Expand Up @@ -1000,7 +1011,7 @@ def main():
]
process = subprocess.Popen(command, stdout=subprocess.PIPE)
for line in process.stdout:
key, _, value = line.decode('ascii').strip().partition("=")
key, _, value = line.decode('utf8').strip().partition("=")
os.environ[key] = value
process.communicate() # Avoid pipe deadlock while waiting for termination.

Expand Down
2 changes: 1 addition & 1 deletion testing/sanitizer_suppressions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ UBSAN_SUPPRESSIONS_FILE="${TESTING_DIRECTORY}/ubsan_suppressions.txt"
export UBSAN_OPTIONS="suppressions=${UBSAN_SUPPRESSIONS_FILE}"
echo "Using Undefined Behavior suppressions in ${UBSAN_SUPPRESSIONS_FILE}"

export ASAN_OPTIONS="symbolize=1:detect_leaks=1"
export ASAN_OPTIONS="symbolize=1:detect_leaks=1:intercept_tls_get_addr=0"
export ASAN_SYMBOLIZER_PATH="${BUILDTOOLS_DIRECTORY}/clang/bin/llvm-symbolizer"
Loading

0 comments on commit 08416ce

Please sign in to comment.