From b6a705c3d63d61c8e58ef040e577775d73eca5bd Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 5 Mar 2025 20:28:10 +0900 Subject: [PATCH 01/14] [Tizen] Cherrypicks from flutter-3.27.1 of flutter-tizen/engine --- DEPS | 2 +- engine/src/flutter/common/config.gni | 4 +-- .../src/flutter/display_list/testing/BUILD.gn | 3 +- engine/src/flutter/impeller/tools/args.gni | 5 ++-- engine/src/flutter/shell/config.gni | 2 +- engine/src/flutter/testing/BUILD.gn | 2 +- engine/src/flutter/tools/gn | 30 +++++++------------ .../src/flutter/txt/src/txt/platform_linux.cc | 2 +- 8 files changed, 20 insertions(+), 30 deletions(-) diff --git a/DEPS b/DEPS index da7f37dd2fac3..6bfb973880649 100644 --- a/DEPS +++ b/DEPS @@ -124,7 +124,7 @@ vars = { "checkout_llvm": False, # Setup Git hooks by default. - 'setup_githooks': True, + 'setup_githooks': False, # When this is true, the Flutter Engine's configuration files and scripts for # RBE will be downloaded from CIPD. This option is only usable by Googlers. diff --git a/engine/src/flutter/common/config.gni b/engine/src/flutter/common/config.gni index 318d305bd37fc..f3b3c15534a2f 100644 --- a/engine/src/flutter/common/config.gni +++ b/engine/src/flutter/common/config.gni @@ -157,6 +157,4 @@ if (flutter_prebuilt_dart_sdk) { # TODO: We can't build the engine artifacts for arm (32-bit) right now; # see https://github.com/flutter/flutter/issues/74322. build_engine_artifacts = - flutter_build_engine_artifacts && !is_android && - (current_toolchain == host_toolchain || - (is_linux && !is_chromeos && current_cpu != "arm") || is_mac || is_win) + flutter_build_engine_artifacts && current_toolchain == host_toolchain diff --git a/engine/src/flutter/display_list/testing/BUILD.gn b/engine/src/flutter/display_list/testing/BUILD.gn index 8e1a0536126fd..37390f8aad457 100644 --- a/engine/src/flutter/display_list/testing/BUILD.gn +++ b/engine/src/flutter/display_list/testing/BUILD.gn @@ -31,7 +31,8 @@ surface_provider_include_software = !is_android && !is_ios # But, since benchmarks do not run on Windows and rendertests only # runs on SW by default, this restriction currently only limits the # ability to manually cross-check OpenGL on Windows for rendertests -surface_provider_include_gl = !is_fuchsia && !is_ios && !is_win && !is_mac +surface_provider_include_gl = + !is_fuchsia && !is_ios && !is_win && !is_mac && !is_linux # TODO (https://github.com/flutter/flutter/issues/107357): # impeller_enable_vulkan currently requires skia to not use VMA, which in turn diff --git a/engine/src/flutter/impeller/tools/args.gni b/engine/src/flutter/impeller/tools/args.gni index 543fc38382572..28d077ab49af6 100644 --- a/engine/src/flutter/impeller/tools/args.gni +++ b/engine/src/flutter/impeller/tools/args.gni @@ -18,9 +18,8 @@ declare_args() { enable_unittests) && target_os != "fuchsia" # Whether the Vulkan backend is enabled. - impeller_enable_vulkan = - (is_linux || is_win || is_android || is_mac || is_qnx || - enable_unittests) && target_os != "fuchsia" + impeller_enable_vulkan = (is_win || is_android || is_mac || + enable_unittests) && target_os != "fuchsia" } # Arguments that are combinations of other arguments by default but which can diff --git a/engine/src/flutter/shell/config.gni b/engine/src/flutter/shell/config.gni index 3f498d2c044f7..9ad466439ee2e 100644 --- a/engine/src/flutter/shell/config.gni +++ b/engine/src/flutter/shell/config.gni @@ -17,6 +17,6 @@ declare_args() { test_enable_metal = shell_enable_metal # The Vulkan unittests are combined with the GL unittests. - test_enable_vulkan = is_fuchsia || shell_enable_gl + test_enable_vulkan = is_fuchsia test_enable_software = shell_enable_software } diff --git a/engine/src/flutter/testing/BUILD.gn b/engine/src/flutter/testing/BUILD.gn index 1a21ac33669be..48b902554e139 100644 --- a/engine/src/flutter/testing/BUILD.gn +++ b/engine/src/flutter/testing/BUILD.gn @@ -53,7 +53,7 @@ source_set("testing") { if (enable_unittests && is_linux) { # So that we can call gtk_init in main(). - configs += [ "//flutter/shell/platform/linux/config:gtk" ] + # configs += [ "//flutter/shell/platform/linux/config:gtk" ] } public_deps = [ ":testing_lib" ] diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 2443a9fd85890..82afbdf22c85e 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -89,18 +89,7 @@ def to_command_line(gn_args): def is_host_build(args): - # If target_os == None, then this is a host build. - if args.target_os is None: - return True - # For linux arm64 builds, we cross compile from x64 hosts, so the - # target_os='linux' and linux-cpu='arm64' - if args.target_os == 'linux' and args.linux_cpu == 'arm64': - return True - # The Mac and host targets are redundant. Again, necessary to disambiguate - # during cross-compilation. - if args.target_os == 'mac': - return True - return False + return args.target_os is None # Determines whether a prebuilt Dart SDK can be used instead of building one. @@ -518,7 +507,7 @@ def to_gn_args(args): # does not exist. Further, we set the 'host_cpu' so that it shares the # bitwidth of the 32-bit arm target. if sys.platform.startswith( - ('cygwin', 'win')) and args.target_os == 'android' and gn_args['target_cpu'] == 'arm': + ('cygwin', 'win')) and args.target_os != 'win' and gn_args['target_cpu'] == 'arm': gn_args['host_cpu'] = 'x86' gn_args['current_cpu'] = 'x86' @@ -629,7 +618,7 @@ def to_gn_args(args): else: gn_args['skia_use_gl'] = args.target_os != 'fuchsia' - if sys.platform == 'darwin' and args.target_os not in ['android', 'fuchsia']: + if sys.platform == 'darwin' and args.target_os not in ['android', 'fuchsia', 'linux']: # OpenGL is deprecated on macOS > 10.11. # This is not necessarily needed but enabling this until we have a way to # build a macOS metal only shell and a gl only shell. @@ -640,7 +629,7 @@ def to_gn_args(args): # Enable Vulkan on all platforms except for iOS. This is just # to save on mobile binary size, as there's no reason the Vulkan embedder # features can't work on these platforms. - if gn_args['target_os'] not in ['ios', 'mac']: + if gn_args['target_os'] not in ['ios', 'mac', 'linux']: gn_args['skia_use_vulkan'] = True gn_args['skia_use_vma'] = False gn_args['shell_enable_vulkan'] = True @@ -739,13 +728,17 @@ def to_gn_args(args): # Enable pointer compression on 64-bit mobile targets. iOS is excluded due to # its inability to allocate address space without allocating memory. - if args.target_os in ['android'] and gn_args['target_cpu'] in ['x64', 'arm64']: + if args.target_os in ['android', 'linux'] and gn_args['target_cpu'] in ['x64', 'arm64']: gn_args['dart_use_compressed_pointers'] = True if args.target_os == 'fuchsia': gn_args['gn_configs_path'] = '//flutter/build/config/fuchsia/gn_configs.gni' gn_args['fuchsia_gn_sdk'] = '//flutter/tools/fuchsia/gn-sdk' + # Don't use the default Linux sysroot when buliding for Linux on macOS. + if sys.platform == 'darwin' and args.target_os == 'linux': + gn_args['use_default_linux_sysroot'] = False + # Flags for Dart features: if args.use_mallinfo2: gn_args['dart_use_mallinfo2'] = args.use_mallinfo2 @@ -771,9 +764,8 @@ def to_gn_args(args): # gen_snapshot, but the build defines otherwise make it look like the build is # for a host Windows build and make GN think we will be building ANGLE. # Angle is not used on Mac hosts as there are no tests for the OpenGL backend. - if is_host_build(args) or (args.target_os == 'android' and get_host_os() == 'win'): - # Don't include git commit information. - gn_args['angle_enable_commit_id'] = False + if (is_host_build(args) and gn_args['host_os'] != 'mac') or (args.target_os == 'linux' and + get_host_os() == 'win'): # Do not build unnecessary parts of the ANGLE tree. gn_args['angle_build_all'] = False gn_args['angle_has_astc_encoder'] = False diff --git a/engine/src/flutter/txt/src/txt/platform_linux.cc b/engine/src/flutter/txt/src/txt/platform_linux.cc index 667b26d6fb1d2..a20febd4bb6f2 100644 --- a/engine/src/flutter/txt/src/txt/platform_linux.cc +++ b/engine/src/flutter/txt/src/txt/platform_linux.cc @@ -20,7 +20,7 @@ namespace txt { std::vector GetDefaultFontFamilies() { - return {"Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", "Arial"}; + return {"TizenDefaultFont", "SamsungOneUI"}; } sk_sp GetDefaultFontManager(uint32_t font_initialization_data) { From 777f34a94d8c267280ba204159b71f1a128d88d4 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 5 Mar 2025 20:50:28 +0900 Subject: [PATCH 02/14] [Tizen] Add CI related files --- .github/workflows/build-docker.yml | 21 ++ .github/workflows/build.yml | 313 ++++++++++++++++++ engine/src/flutter/ci/tizen/.gitignore | 3 + engine/src/flutter/ci/tizen/Dockerfile | 32 ++ engine/src/flutter/ci/tizen/arm.patch | 15 + engine/src/flutter/ci/tizen/build_llvm.sh | 45 +++ .../src/flutter/ci/tizen/generate_sysroot.py | 151 +++++++++ 7 files changed, 580 insertions(+) create mode 100644 .github/workflows/build-docker.yml create mode 100644 .github/workflows/build.yml create mode 100644 engine/src/flutter/ci/tizen/.gitignore create mode 100644 engine/src/flutter/ci/tizen/Dockerfile create mode 100644 engine/src/flutter/ci/tizen/arm.patch create mode 100755 engine/src/flutter/ci/tizen/build_llvm.sh create mode 100755 engine/src/flutter/ci/tizen/generate_sysroot.py diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 0000000000000..62267c3bbf820 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,21 @@ +name: Build Docker + +on: [workflow_dispatch] + +jobs: + builder: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v5 + with: + context: ci/tizen + file: ci/tizen/Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/build-engine:latest diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000..34d2bdd939119 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,313 @@ +name: Build + +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + container: + image: ghcr.io/flutter-tizen/build-engine:latest + credentials: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + strategy: + matrix: + arch: [arm, arm64, x86] + mode: [debug, release, profile] + include: + - arch: arm + triple: arm-linux-gnueabi + - arch: arm64 + triple: aarch64-linux-gnu + - arch: x86 + triple: i686-linux-gnu + exclude: + - arch: x86 + mode: release + - arch: x86 + mode: profile + + steps: + - uses: actions/checkout@v4 + with: + path: flutter + fetch-depth: 1 + + - uses: actions/cache@v4 + with: + path: /tizen_tools/sysroot + key: sysroot + + - name: Install depot_tools + run: | + git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + echo "$PWD/depot_tools" >> $GITHUB_PATH + export PATH="$PWD/depot_tools:$PATH" + # Install ninja + apt install ninja-build + + - name: Run gclient sync + run: | + cd flutter + gclient config --unmanaged https://github.com/flutter-tizen/flutter + sed -i "s/'flutter'/'.'/g" ./.gclient + gclient setdep --var=download_dart_sdk=False --var=download_android_deps=False --var=download_fuchsia_deps=False --deps-file=DEPS + gclient sync -v --no-history --shallow + + - name: Generate sysroot + run: flutter/engine/src/flutter/ci/tizen/generate_sysroot.py --out /tizen_tools/sysroot + + - name: Build + run: | + cd flutter + # Ignore unsupported linker option. + sed -i "/-Wl,--undefined-version/d" engine/src/build/config/compiler/BUILD.gn + + engine/src/flutter/tools/gn \ + --target-os linux \ + --linux-cpu ${{ matrix.arch }} \ + --no-goma \ + --target-toolchain /tizen_tools/toolchains \ + --target-sysroot /tizen_tools/sysroot/${{ matrix.arch }} \ + --target-triple ${{ matrix.triple }} \ + --runtime-mode ${{ matrix.mode }} \ + --enable-fontconfig \ + --disable-desktop-embeddings \ + --target-dir build + cd engine/src + ninja -C out/build flutter_engine_library + cp -f flutter/third_party/icu/flutter/icudtl.dat out/build + + - name: Build gen_snapshot + if: ${{ matrix.mode != 'debug' }} + run: | + cd flutter + ninja -C engine/src/out/build clang_x64/gen_snapshot + + - uses: actions/upload-artifact@v4 + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }} + path: | + flutter/engine/src/out/build/libflutter_engine.so + flutter/engine/src/out/build/icudtl.dat + if-no-files-found: error + + - uses: actions/upload-artifact@v4 + if: ${{ github.event_name == 'push' }} + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_symbols + path: flutter/engine/src/out/build/so.unstripped/libflutter_engine.so + if-no-files-found: error + + - uses: actions/upload-artifact@v4 + if: ${{ matrix.mode != 'debug' }} + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_linux-x64 + path: flutter/engine/src/out/build/clang_x64/gen_snapshot + if-no-files-found: error + + windows-build: + runs-on: windows-latest + + strategy: + matrix: + arch: [arm, arm64] + mode: [release, profile] + + steps: + - name: Run git checkout + run: | + mkdir C:\workspace\flutter + cd C:\workspace\flutter + git config --global core.autocrlf true + git init --quiet + git remote add origin https://github.com/${{ github.repository }} + git fetch --depth 1 origin ${{ github.sha }} + git checkout FETCH_HEAD + + - name: Environment setup + run: | + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -Force + echo "DEPOT_TOOLS_WIN_TOOLCHAIN=0" >> $Env:GITHUB_ENV + echo "GYP_MSVS_OVERRIDE_PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise" >> $Env:GITHUB_ENV + echo "WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10" >> $Env:GITHUB_ENV + + - name: Install depot_tools + run: | + Invoke-WebRequest -Uri https://storage.googleapis.com/chrome-infra/depot_tools.zip -OutFile depot_tools.zip + 7z x -y -o"C:\workspace\depot_tools" .\depot_tools.zip + echo "C:\workspace\depot_tools" >> $Env:GITHUB_PATH + + - name: Run gclient sync + working-directory: C:\workspace\flutter + shell: powershell + run: | + gclient config --unmanaged https://github.com/flutter-tizen/flutter + (Get-Content ".gclient") | ForEach-Object { $_ -replace "'flutter'","'.'" } | Set-Content ".gclient" + # TODO(jsuya) : pipes deprecated in python 3.13. (https://dart-review.googlesource.com/c/sdk/+/307620) + (Get-Content "engine/src/build/vs_toolchain.py") | ForEach-Object { $_ -replace 'import pipes','' } | Set-Content "engine/src/build/vs_toolchain.py" + gclient setdep --var=download_dart_sdk=False --var=download_android_deps=False --var=download_fuchsia_deps=False --deps-file=DEPS + gclient sync -v --no-history --shallow + + - name: Build + working-directory: C:\workspace\flutter\engine\src + run: | + python3 .\flutter\tools\gn ` + --linux ` + --linux-cpu=${{ matrix.arch }} ` + --runtime-mode=${{ matrix.mode }} ` + --no-goma ` + --target-dir build + # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 + C:\workspace\flutter\engine\src\flutter/third_party/ninja/ninja -C .\out\build gen_snapshot + + - uses: actions/upload-artifact@v4 + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_windows-x64 + path: C:\workspace\flutter\engine\src\out\build\gen_snapshot.exe + if-no-files-found: error + + macos-build: + runs-on: macos-latest + + strategy: + matrix: + arch: [arm, arm64] + mode: [release, profile] + + steps: + - uses: actions/checkout@v4 + with: + path: flutter + fetch-depth: 1 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install depot_tools + run: | + git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + echo "$PWD/depot_tools" >> $GITHUB_PATH + + - name: Run gclient sync + run: | + cd flutter + gclient config --unmanaged https://github.com/flutter-tizen/flutter + sed -i '' "s/'flutter'/'.'/g" .gclient + gclient setdep --var=download_dart_sdk=False --var=download_android_deps=False --var=download_fuchsia_deps=False --deps-file=DEPS + gclient sync -v --no-history --shallow + + - name: Build + run: | + cd flutter + # Change host_toolchain to mac/clang_arm64. + sed -i "" "s|//build/toolchain/linux:clang_$host_cpu|//build/toolchain/mac:clang_$host_cpu|g" engine/src/build/config/BUILDCONFIG.gn + + # Pass dummy values to prevent using the default (Linux) toolchain. + engine/src/flutter/tools/gn \ + --linux \ + --linux-cpu=${{ matrix.arch }} \ + --no-goma \ + --target-toolchain _ \ + --target-sysroot _ \ + --target-triple _ \ + --runtime-mode=${{ matrix.mode }} \ + --disable-desktop-embeddings \ + --target-dir build + cd engine/src + # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 + flutter/third_party/ninja/ninja -C out/build clang_arm64/gen_snapshot + + - uses: actions/upload-artifact@v4 + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_darwin-arm64 + path: flutter/engine/src/out/build/clang_arm64/gen_snapshot + if-no-files-found: error + + macos-intel-build: + runs-on: macos-13 + + strategy: + matrix: + arch: [arm, arm64] + mode: [release, profile] + + steps: + - uses: actions/checkout@v4 + with: + path: flutter + fetch-depth: 1 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install depot_tools + run: | + git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + echo "$PWD/depot_tools" >> $GITHUB_PATH + + - name: Run gclient sync + run: | + cd flutter + gclient config --unmanaged https://github.com/flutter-tizen/flutter + sed -i '' "s/'flutter'/'.'/g" .gclient + gclient setdep --var=download_dart_sdk=False --var=download_android_deps=False --var=download_fuchsia_deps=False --deps-file=DEPS + gclient sync -v --no-history --shallow + + - name: Build + run: | + cd flutter + # Change host_toolchain to mac/clang_x64. + sed -i "" "s|//build/toolchain/linux:clang_$host_cpu|//build/toolchain/mac:clang_$host_cpu|g" engine/src/build/config/BUILDCONFIG.gn + + # Pass dummy values to prevent using the default (Linux) toolchain. + engine/src/flutter/tools/gn \ + --linux \ + --linux-cpu=${{ matrix.arch }} \ + --no-goma \ + --target-toolchain _ \ + --target-sysroot _ \ + --target-triple _ \ + --runtime-mode=${{ matrix.mode }} \ + --disable-desktop-embeddings \ + --target-dir build + cd engine/src + # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 + flutter/third_party/ninja/ninja -C out/build clang_x64/gen_snapshot + + - uses: actions/upload-artifact@v4 + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_darwin-x64 + path: flutter/engine/src/out/build/clang_x64/gen_snapshot + if-no-files-found: error + + release: + needs: [build] + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + + - name: Create archives + run: | + for name in tizen-*; do + 7z a $name.zip ./$name/* + done + + - name: Set variables + run: | + echo "SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV + echo "VERSION=$(echo "${{ github.ref_name }}" | cut -d'-' -f2)" >> $GITHUB_ENV + + - uses: softprops/action-gh-release@v2 + with: + name: ${{ env.VERSION }} (${{ env.SHORT_SHA }}) + tag_name: ${{ env.SHORT_SHA }} + target_commitish: ${{ github.sha }} + files: tizen-*.zip + body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/engine/src/flutter/ci/tizen/.gitignore b/engine/src/flutter/ci/tizen/.gitignore new file mode 100644 index 0000000000000..c23e7e850155f --- /dev/null +++ b/engine/src/flutter/ci/tizen/.gitignore @@ -0,0 +1,3 @@ +/llvm-project*/ +/toolchains*/ +/sysroot/ diff --git a/engine/src/flutter/ci/tizen/Dockerfile b/engine/src/flutter/ci/tizen/Dockerfile new file mode 100644 index 0000000000000..f5d0f1fc5520f --- /dev/null +++ b/engine/src/flutter/ci/tizen/Dockerfile @@ -0,0 +1,32 @@ +############################### +### Stage for building LLVM ### +############################### + +FROM ubuntu:22.04 AS llvm + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y git zip build-essential cmake ninja-build clang-11 && \ + apt-get clean + +COPY build_llvm.sh . + +RUN /build_llvm.sh + + +############################## +### Create a release image ### +############################## + +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y binutils-arm-linux-gnueabi binutils-aarch64-linux-gnu binutils-i686-linux-gnu && \ + apt-get install -y git curl pkg-config ca-certificates python3 python3-pip rpm2cpio cpio && \ + apt-get clean + +# Copy build artifacts from the previous stage. +COPY --from=llvm /toolchains/ /tizen_tools/toolchains/ diff --git a/engine/src/flutter/ci/tizen/arm.patch b/engine/src/flutter/ci/tizen/arm.patch new file mode 100644 index 0000000000000..1dabb3f2803d4 --- /dev/null +++ b/engine/src/flutter/ci/tizen/arm.patch @@ -0,0 +1,15 @@ +diff --git a/usr/include/asm-arm/hwcap.h b/usr/include/asm-arm/hwcap.h +index da85060..adaf619 100644 +--- a/usr/include/asm-arm/hwcap.h ++++ b/usr/include/asm-arm/hwcap.h +@@ -26,5 +26,10 @@ + #define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */ + #define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) + ++#define HWCAP2_AES (1 << 0) ++#define HWCAP2_PMULL (1 << 1) ++#define HWCAP2_SHA1 (1 << 2) ++#define HWCAP2_SHA2 (1 << 3) ++#define HWCAP2_CRC32 (1 << 4) + + #endif /* __ASMARM_HWCAP_H */ diff --git a/engine/src/flutter/ci/tizen/build_llvm.sh b/engine/src/flutter/ci/tizen/build_llvm.sh new file mode 100755 index 0000000000000..507395cea8363 --- /dev/null +++ b/engine/src/flutter/ci/tizen/build_llvm.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set -e + +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +OUTPUT_DIR="$SCRIPT_DIR/toolchains" +cd "$SCRIPT_DIR" + +# Check out the LLVM project source code. +if [ -d llvm-project ]; then + echo "The directory already exists. Skipping download." + cd llvm-project +else + mkdir llvm-project + cd llvm-project + git init + git remote add origin https://github.com/llvm/llvm-project.git + git fetch --depth=1 origin llvmorg-17.0.6 + git checkout FETCH_HEAD +fi + +# Run the ninja build. +mkdir -p build && cd build +cmake -G Ninja \ + -DCLANG_VENDOR="Tizen" \ + -DLLVM_ENABLE_PROJECTS="clang" \ + -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \ + -DCMAKE_C_COMPILER=clang-11 \ + -DCMAKE_CXX_COMPILER=clang++-11 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$OUTPUT_DIR" \ + ../llvm +ninja install -j$(nproc) + +# Create symbolic links to binutils. +# See build/toolchain/custom/BUILD.gn for more information. +cd "$OUTPUT_DIR/bin" +for name in ar readelf nm strip; do + ln -sf llvm-$name arm-linux-gnueabi-$name + ln -sf llvm-$name aarch64-linux-gnu-$name + ln -sf llvm-$name i686-linux-gnu-$name +done diff --git a/engine/src/flutter/ci/tizen/generate_sysroot.py b/engine/src/flutter/ci/tizen/generate_sysroot.py new file mode 100755 index 0000000000000..c4bdc51f347cf --- /dev/null +++ b/engine/src/flutter/ci/tizen/generate_sysroot.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +# Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import argparse +import os +import re +import shutil +import subprocess +import sys +import urllib.parse +import urllib.request +from pathlib import Path + +base_packages = [ + 'gcc', + 'glibc', + 'glibc-devel', + 'libgcc', + 'libstdc++', + 'linux-glibc-devel', + 'zlib-devel', +] + +unified_packages = [ + 'fontconfig', + 'fontconfig-devel', + 'freetype2-devel', + 'libpng-devel', +] + + +def generate_sysroot(sysroot: Path, api_version: float, arch: str, quiet=False): + if arch == 'arm': + tizen_arch = 'armv7l' + elif arch == 'arm64': + tizen_arch = 'aarch64' + elif arch == 'x86': + tizen_arch = 'i686' + else: + sys.exit('Unknown arch: ' + arch) + + base_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Base/latest/repos/standard/packages'.format( + api_version, api_version + ) + unified_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Unified/latest/repos/standard/packages'.format( + api_version, api_version + ) + + # Retrieve html documents. + documents = {} + for url in ['{}/{}'.format(base_repo, tizen_arch), '{}/{}'.format(base_repo, 'noarch'), + '{}/{}'.format(unified_repo, tizen_arch), '{}/{}'.format(unified_repo, 'noarch')]: + request = urllib.request.Request(url) + with urllib.request.urlopen(request) as response: + documents[url] = response.read().decode('utf-8') + + # Download packages. + download_path = sysroot / '.rpms' + download_path.mkdir(exist_ok=True) + existing_rpms = [f for f in download_path.iterdir() if f.suffix == '.rpm'] + + for package in base_packages + unified_packages: + quoted = urllib.parse.quote(package) + pattern = re.escape(quoted) + '-\\d+\\.[\\d_\\.]+-[\\d\\.]+\\..+\\.rpm' + + if any([re.match(pattern, rpm.name) for rpm in existing_rpms]): + continue + + for parent, doc in documents.items(): + match = re.search('.+?'.format(pattern), doc) + if match: + rpm_url = '{}/{}'.format(parent, match.group(1)) + break + + if match: + if not quiet: + print('Downloading ' + rpm_url) + urllib.request.urlretrieve(rpm_url, download_path / match.group(1)) + else: + sys.exit('Could not find a package named ' + package) + + # Extract files. + for rpm in [f for f in download_path.iterdir() if f.suffix == '.rpm']: + command = 'rpm2cpio {} | cpio -idum --quiet'.format(rpm) + subprocess.run(command, shell=True, cwd=sysroot, check=True) + + # Create symbolic links. + asm = sysroot / 'usr' / 'include' / 'asm' + if not asm.exists(): + os.symlink('asm-' + arch, asm) + pkgconfig = sysroot / 'usr' / 'lib' / 'pkgconfig' + if arch == 'arm64' and not pkgconfig.exists(): + os.symlink('../lib64/pkgconfig', pkgconfig) + + # Copy objects required by the linker, such as crtbeginS.o and libgcc.a. + if arch == 'arm64': + libpath = sysroot / 'usr' / 'lib64' + else: + libpath = sysroot / 'usr' / 'lib' + subprocess.run('cp gcc/*/*/*.o gcc/*/*/*.a .', shell=True, cwd=libpath, check=True) + + # Apply a patch if applicable. + patch = Path(__file__).parent / '{}.patch'.format(arch) + if patch.is_file(): + command = 'patch -p1 -s -d {} < {}'.format(sysroot, patch) + subprocess.run(command, shell=True, check=True) + + +def main(): + # Check dependencies. + for dep in ['rpm2cpio', 'cpio', 'git']: + if not shutil.which(dep): + sys.exit('{} is not installed. To install, run:\n' + ' sudo apt install {}'.format(dep, dep)) + + # Parse arguments. + parser = argparse.ArgumentParser(description='Tizen sysroot generator') + parser.add_argument('-o', '--out', metavar='PATH', type=str, help='Path to the output directory') + parser.add_argument('-f', '--force', action='store_true', help='Force re-downloading of packages') + parser.add_argument('-q', '--quiet', action='store_true', help='Suppress log output') + parser.add_argument( + '--api-version', + metavar='VER', + default=6.0, + type=float, + help='Target API version (defaults to 6.0)' + ) + args = parser.parse_args() + + if args.out: + outpath = Path(args.out) + else: + outpath = Path(__file__).parent / 'sysroot' + outpath.mkdir(exist_ok=True) + + for arch in ['arm', 'arm64', 'x86']: + sysroot = outpath / arch + if args.force and sysroot.is_dir(): + shutil.rmtree(sysroot) + sysroot.mkdir(exist_ok=True) + + if not args.quiet: + print('Generating sysroot for {}...'.format(arch)) + generate_sysroot(sysroot.resolve(), args.api_version, arch, args.quiet) + + +# Execute only if run as a script. +if __name__ == '__main__': + main() From 7f3820bed00fa2a4d36f6e081379a1f215a76a43 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 12 Mar 2025 12:56:12 +0900 Subject: [PATCH 03/14] [Tizen][impeller] Disable gles3 compile --- engine/src/flutter/impeller/tools/shaders.gni | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/engine/src/flutter/impeller/tools/shaders.gni b/engine/src/flutter/impeller/tools/shaders.gni index cfa20993ade3a..5cc971da7495a 100644 --- a/engine/src/flutter/impeller/tools/shaders.gni +++ b/engine/src/flutter/impeller/tools/shaders.gni @@ -111,22 +111,6 @@ template("impeller_shaders") { } analyze = analyze } - - gles3_shaders = "gles3_$target_name" - - impeller_shaders_gles(gles3_shaders) { - name = invoker.name - require_framebuffer_fetch = require_framebuffer_fetch - gles_language_version = 300 - is_300 = true - analyze = false - if (defined(invoker.gles_exclusions)) { - shaders = invoker.shaders - invoker.gles_exclusions - } else { - shaders = invoker.shaders - } - analyze = analyze - } } if (impeller_enable_vulkan) { @@ -160,10 +144,7 @@ template("impeller_shaders") { } if (enable_opengles) { - public_deps += [ - ":$gles3_shaders", - ":$gles_shaders", - ] + public_deps += [ ":$gles_shaders" ] } if (impeller_enable_vulkan) { From 4940501fa3d802f000cf1d84492f64722a4f7ce3 Mon Sep 17 00:00:00 2001 From: Xiaowei Guan Date: Tue, 18 Mar 2025 15:03:44 +0900 Subject: [PATCH 04/14] [Tizen] Support EmbedderExternalTextureGL for impeller --- .../shell/platform/embedder/embedder.h | 9 ++- .../embedder/embedder_external_texture_gl.cc | 79 ++++++++++++++++--- .../embedder/embedder_external_texture_gl.h | 8 ++ 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/shell/platform/embedder/embedder.h b/engine/src/flutter/shell/platform/embedder/embedder.h index 937ef19f3838a..dfb0896b4ed6b 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.h +++ b/engine/src/flutter/shell/platform/embedder/embedder.h @@ -401,6 +401,7 @@ typedef struct { } FlutterTransformation; typedef void (*VoidCallback)(void* /* user data */); +typedef bool (*BoolCallback)(void* /* user data */); typedef enum { /// Specifies an OpenGL texture target type. Textures are specified using @@ -508,6 +509,13 @@ typedef struct { uint32_t name; /// The texture format (example GL_RGBA8). uint32_t format; + /// The pixel data buffer. + const uint8_t* buffer; + /// The size of pixel buffer. + size_t buffer_size; + /// Callback invoked that the gpu surface texture start binding. + BoolCallback bind_callback; + /// User data to be returned on the invocation of the destruction callback. void* user_data; /// Callback invoked (on an engine managed thread) that asks the embedder to @@ -601,7 +609,6 @@ typedef struct { uint32_t format; } FlutterOpenGLSurface; -typedef bool (*BoolCallback)(void* /* user data */); typedef FlutterTransformation (*TransformationCallback)(void* /* user data */); typedef uint32_t (*UIntCallback)(void* /* user data */); typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */, diff --git a/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.cc b/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.cc index fe81731aff0d5..1a627ec864516 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.cc @@ -138,15 +138,73 @@ sk_sp EmbedderExternalTextureGL::ResolveTextureImpeller( return nullptr; } + if (texture->bind_callback != nullptr) { + return ResolveTextureImpellerSurface(aiks_context, std::move(texture)); + } else { + return ResolveTextureImpellerPixelbuffer(aiks_context, std::move(texture)); + } +} + +sk_sp EmbedderExternalTextureGL::ResolveTextureImpellerPixelbuffer( + impeller::AiksContext* aiks_context, + std::unique_ptr texture) { impeller::TextureDescriptor desc; desc.size = impeller::ISize(texture->width, texture->height); + desc.type = impeller::TextureType::kTexture2D; + desc.storage_mode = impeller::StorageMode::kDevicePrivate; + desc.format = impeller::PixelFormat::kR8G8B8A8UNormInt; + impeller::ContextGLES& context = + impeller::ContextGLES::Cast(*aiks_context->GetContext()); + std::shared_ptr image = + std::make_shared(context.GetReactor(), desc); + + image->MarkContentsInitialized(); + if (!image->SetContents(texture->buffer, texture->buffer_size)) { + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } + return nullptr; + } + if (!image) { + // In case Skia rejects the image, call the release proc so that + // embedders can perform collection of intermediates. + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } + FML_LOG(ERROR) << "Could not create external texture"; + return nullptr; + } + + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } + + return impeller::DlImageImpeller::Make(image); +} + +sk_sp EmbedderExternalTextureGL::ResolveTextureImpellerSurface( + impeller::AiksContext* aiks_context, + std::unique_ptr texture) { + impeller::TextureDescriptor desc; + desc.size = impeller::ISize(texture->width, texture->height); + desc.storage_mode = impeller::StorageMode::kDevicePrivate; + desc.format = impeller::PixelFormat::kR8G8B8A8UNormInt; + desc.type = impeller::TextureType::kTextureExternalOES; impeller::ContextGLES& context = impeller::ContextGLES::Cast(*aiks_context->GetContext()); - impeller::HandleGLES handle = context.GetReactor()->CreateHandle( - impeller::HandleType::kTexture, texture->target); std::shared_ptr image = - impeller::TextureGLES::WrapTexture(context.GetReactor(), desc, handle); + std::make_shared(context.GetReactor(), desc); + image->MarkContentsInitialized(); + image->SetCoordinateSystem( + impeller::TextureCoordinateSystem::kUploadFromHost); + if (!image->Bind()) { + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } + FML_LOG(ERROR) << "Could not bind texture"; + return nullptr; + } if (!image) { // In case Skia rejects the image, call the release proc so that @@ -157,15 +215,18 @@ sk_sp EmbedderExternalTextureGL::ResolveTextureImpeller( FML_LOG(ERROR) << "Could not create external texture"; return nullptr; } - if (texture->destruction_callback && - !context.GetReactor()->RegisterCleanupCallback( - handle, - [callback = texture->destruction_callback, - user_data = texture->user_data]() { callback(user_data); })) { - FML_LOG(ERROR) << "Could not register destruction callback"; + + if (!texture->bind_callback(texture->user_data)) { + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } return nullptr; } + if (texture->destruction_callback) { + texture->destruction_callback(texture->user_data); + } + return impeller::DlImageImpeller::Make(image); } diff --git a/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.h b/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.h index 7dbc631d56ad1..6ecb6843208d1 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.h +++ b/engine/src/flutter/shell/platform/embedder/embedder_external_texture_gl.h @@ -39,6 +39,14 @@ class EmbedderExternalTextureGL : public flutter::Texture { impeller::AiksContext* aiks_context, const SkISize& size); + sk_sp ResolveTextureImpellerPixelbuffer( + impeller::AiksContext* aiks_context, + std::unique_ptr texture); + + sk_sp ResolveTextureImpellerSurface( + impeller::AiksContext* aiks_context, + std::unique_ptr texture); + // |flutter::Texture| void Paint(PaintContext& context, const DlRect& bounds, From 827b81210c7705911ef3fdd40ddbbe427c616dfd Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 23 May 2025 17:47:47 +0900 Subject: [PATCH 05/14] [Tizen] Remove unnecessary CI --- .github/workflows/easy-cp.yml | 87 ----------------------------- .github/workflows/files-changed.yml | 41 -------------- .github/workflows/labeler.yml | 22 -------- .github/workflows/mirror.yml | 28 ---------- 4 files changed, 178 deletions(-) delete mode 100644 .github/workflows/easy-cp.yml delete mode 100644 .github/workflows/files-changed.yml delete mode 100644 .github/workflows/labeler.yml delete mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/easy-cp.yml b/.github/workflows/easy-cp.yml deleted file mode 100644 index 98e5e763aa9e1..0000000000000 --- a/.github/workflows/easy-cp.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2023 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -name: Cherry-pick Labeled PR to Release Branch - -on: - pull_request_target: - branches: master - types: [labeled] - -permissions: write-all - -jobs: - cherrypick_to_release: - name: cherrypick_to_release - runs-on: ubuntu-latest - if: | - (github.event.label.name == format('cp{0} beta', ':') || github.event.label.name == format('cp{0} stable', ':')) && - (github.event.pull_request.merged == true) - steps: - - name: Get Release Channel - run: | - echo "CHANNEL=$(echo ${{ github.event.label.name }} | cut -d ':' -f 2 | xargs)" >> $GITHUB_ENV - - name: Get Release Candidate Branch - run: | - RELEASE_BRANCH=$(curl https://raw.githubusercontent.com/flutter/flutter/$CHANNEL/bin/internal/release-candidate-branch.version) - echo "RELEASE_BRANCH=$(echo $RELEASE_BRANCH | tr -d '\n')" >> $GITHUB_ENV - - name: Get Cherry Pick PR - run: | - echo "COMMIT_SHA=$(echo ${{ github.event.pull_request.merge_commit_sha }})" >> $GITHUB_ENV - - name: Checkout Flutter Repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - with: - repository: flutteractionsbot/flutter - path: flutter - ref: master - persist-credentials: false - # Checkout all history commits on master branch, so that the cp commit is a known object - fetch-depth: 0 - # use same name when checking out branch, since the marketplace action does a hard reset. - - name: Attempt CP - id: attempt-cp - working-directory: ./flutter - run: | - git config user.name "GitHub Actions Bot" - git config user.email "<>" - git remote add upstream https://github.com/flutter/flutter.git - git fetch upstream $RELEASE_BRANCH - git fetch upstream master - git checkout -b cp-${CHANNEL}-${COMMIT_SHA} --track upstream/$RELEASE_BRANCH - git cherry-pick $COMMIT_SHA - # TODO(xilaizhang): remove this step once the template is available on release branches. - - name: Get CP Template - run: | - curl -o PULL_REQUEST_CP_TEMPLATE.md https://raw.githubusercontent.com/flutter/flutter/main/.github/PR_TEMPLATE/PULL_REQUEST_CP_TEMPLATE.md - - name: Create PR on CP success - if: ${{ steps.attempt-cp.conclusion == 'success' }} - working-directory: ./flutter - id: create-pr - run: | - git push https://${{ env.GITHUB_TOKEN }}@github.com/flutteractionsbot/flutter cp-${CHANNEL}-${COMMIT_SHA} - { - echo 'PR_URL<> "$GITHUB_ENV" - env: - GITHUB_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} - PR_TITLE: ${{ github.event.pull_request.title }} - - name: Leave Comment on CP success - if: ${{ steps.create-pr.conclusion == 'success' }} - run: | - echo $PR_URL - NEW_PR_NUMBER="${PR_URL##*/}" - SUCCESS_MSG=" @${{ github.actor }} please fill out the PR description above, afterwards the release team will review this request." - gh pr comment $NEW_PR_NUMBER -R flutter/flutter -b "${SUCCESS_MSG}" - env: - GITHUB_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} - - name: Leave Comment on CP failure - if: ${{ failure() && steps.attempt-cp.conclusion == 'failure' }} - run: | - FAILURE_MSG="Failed to create CP due to merge conflicts.
" - FAILURE_MSG+="You will need to create the PR manually. See [the cherrypick wiki](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md) for more info." - gh pr comment ${{ github.event.pull_request.number }} -R flutter/flutter -b "${FAILURE_MSG}" - env: - GITHUB_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml deleted file mode 100644 index 9fc15957e0c93..0000000000000 --- a/.github/workflows/files-changed.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -name: Generate Changed Files JSON - -on: - pull_request: - types: - - opened - - synchronize - -jobs: - generate-json: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Fetch base commit and origin/master - # Fetch what to compare the commit against - run: | - git fetch --no-tags --prune --depth=1 origin ${{ github.event.pull_request.base.sha }} - git fetch --no-tags --prune --depth=1 origin master - echo "FLUTTER_PREBUILT_ENGINE_VERSION=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_ENV" - - - name: Initialize Dart SDK - # This downloads the version of the Dart SDK for the current platform. - run: | - ./bin/dart --version - cd dev/tools && ../../bin/dart pub get - - - name: Write changed files to a JSON file - run: | - ./bin/dart run dev/tools/bin/get_files_changed.dart --since="${{ github.event.pull_request.base.sha }}" > changed_files.json - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: changed-files - path: changed_files.json diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 3cea755bccd8c..0000000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -name: "Pull Request Labeler" -on: -- pull_request_target - -# Declare default permissions as read only. -permissions: read-all - -jobs: - triage: - if: ${{ github.repository == 'flutter/flutter' }} - permissions: - pull-requests: write - runs-on: ubuntu-latest - steps: - # Source available at https://github.com/actions/labeler/blob/main/README.md - - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 - with: - sync-labels: true diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml deleted file mode 100644 index a568c78265469..0000000000000 --- a/.github/workflows/mirror.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Mirror master to main branches in the flutter repository. -on: - push: - branches: - - 'master' - -# Declare default permissions as read only. -permissions: read-all - -jobs: - mirror_job: - permissions: - pull-requests: write - runs-on: ubuntu-latest - if: ${{ github.repository == 'flutter/flutter' }} - name: Mirror master branch to main branch - steps: - - name: Mirror action step - id: mirror - uses: google/mirror-branch-action@30c52ee21f5d3bd7fb28b95501c11aae7f17eebb - with: - github-token: ${{ secrets.FLUTTERMIRRORINGBOT_TOKEN }} - source: 'master' - dest: 'main' From 132d333ff5970954b3d230f297661856a212ffb8 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 23 May 2025 17:51:34 +0900 Subject: [PATCH 06/14] [Tizen] Upgrade llvm 17 to 18 --- .github/workflows/build-docker.yml | 4 ++-- .github/workflows/build.yml | 15 ++++++++------- engine/src/flutter/ci/tizen/build_llvm.sh | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 62267c3bbf820..d15fb0f88456b 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -15,7 +15,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v5 with: - context: ci/tizen - file: ci/tizen/Dockerfile + context: engine/src/flutter/ci/tizen + file: engine/src/flutter/ci/tizen/Dockerfile push: true tags: ghcr.io/${{ github.repository_owner }}/build-engine:latest diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34d2bdd939119..61fd921e209ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,7 +119,11 @@ jobs: run: | mkdir C:\workspace\flutter cd C:\workspace\flutter - git config --global core.autocrlf true + git config --global core.autocrlf false + git config --global core.filemode false + git config --global core.fscache true + git config --global core.preloadindex true + git config --global depot-tools.allowGlobalGitConfig true git init --quiet git remote add origin https://github.com/${{ github.repository }} git fetch --depth 1 origin ${{ github.sha }} @@ -158,8 +162,7 @@ jobs: --runtime-mode=${{ matrix.mode }} ` --no-goma ` --target-dir build - # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 - C:\workspace\flutter\engine\src\flutter/third_party/ninja/ninja -C .\out\build gen_snapshot + ninja -C .\out\build gen_snapshot - uses: actions/upload-artifact@v4 with: @@ -216,8 +219,7 @@ jobs: --disable-desktop-embeddings \ --target-dir build cd engine/src - # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 - flutter/third_party/ninja/ninja -C out/build clang_arm64/gen_snapshot + ninja -C out/build clang_arm64/gen_snapshot - uses: actions/upload-artifact@v4 with: @@ -274,8 +276,7 @@ jobs: --disable-desktop-embeddings \ --target-dir build cd engine/src - # TODO(jsuya) : https://github.com/flutter/flutter/issues/163487 - flutter/third_party/ninja/ninja -C out/build clang_x64/gen_snapshot + ninja -C out/build clang_x64/gen_snapshot - uses: actions/upload-artifact@v4 with: diff --git a/engine/src/flutter/ci/tizen/build_llvm.sh b/engine/src/flutter/ci/tizen/build_llvm.sh index 507395cea8363..7d75d9c6a4252 100755 --- a/engine/src/flutter/ci/tizen/build_llvm.sh +++ b/engine/src/flutter/ci/tizen/build_llvm.sh @@ -18,7 +18,7 @@ else cd llvm-project git init git remote add origin https://github.com/llvm/llvm-project.git - git fetch --depth=1 origin llvmorg-17.0.6 + git fetch --depth=1 origin llvmorg-18.1.8 git checkout FETCH_HEAD fi @@ -29,6 +29,7 @@ cmake -G Ninja \ -DLLVM_ENABLE_PROJECTS="clang" \ -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \ -DCMAKE_C_COMPILER=clang-11 \ + -DCMAKE_CXX_FLAGS="-mssse3" \ -DCMAKE_CXX_COMPILER=clang++-11 \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="$OUTPUT_DIR" \ From 5decd3b42415f8c229ba1c8b28ebc828ebca9a3e Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 19 Jun 2025 17:04:17 +0900 Subject: [PATCH 07/14] [Tizen] Remove unnecessary CI --- .github/labeler.yml | 261 -------------------------------------------- 1 file changed, 261 deletions(-) delete mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 0978edcde0e3e..0000000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,261 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# See https://github.com/actions/labeler/blob/main/README.md for docs. -# Use git ls-files '' to see the list of matching files. - -'a: accessibility': - - changed-files: - - any-glob-to-any-file: - - '**/accessibility/*' - - '**/*accessibility*' - - '**/semantics/*' - - '**/*semantics*' - -'a: animation': - - changed-files: - - any-glob-to-any-file: - - '**/animation/*' - - '**/*animation*' - -'a: desktop': - - changed-files: - - any-glob-to-any-file: - - '**/linux/**/*' - - '**/macos/**/*' - - '**/windows/**/*' - - engine/src/flutter/shell/platform/darwin/common/**/* - -'a: internationalization': - - changed-files: - - any-glob-to-any-file: - - packages/flutter_localizations/**/* - -'a: tests': - - changed-files: - - any-glob-to-any-file: - - packages/flutter_driver/**/* - - packages/flutter_goldens/**/* - - packages/flutter_test/**/* - - packages/integration_test/**/* - -'a: text input': - - changed-files: - - all-globs-to-any-file: - - '**/*text*' - - '!**/*context*' - - '!**/*texture*' - -'d: api docs': - - changed-files: - - any-glob-to-any-file: - - examples/api/**/* - -'d: docs/': - - changed-files: - - any-glob-to-any-file: - - docs/**/* - -'d: examples': - - changed-files: - - any-glob-to-any-file: - - examples/**/* - -'e: embedder': - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/embedder - -'e: impeller': - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/impeller/**/* - -engine: - - changed-files: - - any-glob-to-any-file: - - DEPS - - engine/**/* - - docs/engine/**/* - -'f: cupertino': - - changed-files: - - any-glob-to-any-file: - - '**/cupertino/*' - - '**/*cupertino*' - - docs/libraries/cupertino/**/* - -'f: focus': - - changed-files: - - any-glob-to-any-file: - - '**/focus/*' - - '**/*focus*' - -'f: gestures': - - changed-files: - - any-glob-to-any-file: - - '**/gestures/*' - - '**/*gestures*' - -'f: material design': - - changed-files: - - any-glob-to-any-file: - - '**/material/*' - - '**/*material*' - - docs/libraries/material/**/* - -'f: routes': - - changed-files: - - any-glob-to-any-file: - - '**/navigator/*' - - '**/*navigator*' - - '**/route/*' - - '**/*route*' - -'f: scrolling': - - changed-files: - - any-glob-to-any-file: - - '**/*scroll*' - - '**/scroll/*' - - '**/*sliver*' - - '**/sliver/*' - - '**/*viewport*' - - '**/viewport/*' - -framework: - - changed-files: - - any-glob-to-any-file: - - packages/flutter/**/* - - packages/flutter_driver/**/* - - packages/flutter_goldens/**/* - - packages/flutter_localizations/**/* - - packages/flutter_test/**/* - - packages/integration_test/**/* - - examples/api/**/* - - docs/about/**/* - - docs/contributing/**/* - - docs/libraries/**/* - -'f: integration_test': - - changed-files: - - any-glob-to-any-file: - - packages/integration_test/**/* - -package: - - changed-files: - - any-glob-to-any-file: - - docs/ecosystem/**/* - -platform-android: - - changed-files: - - any-glob-to-any-file: - - docs/platform/android/**/* - - engine/src/flutter/shell/platform/android/**/* - - packages/flutter_tools/*android*' - - packages/flutter_tools/gradle/**/* - -platform-ios: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/darwin/common/**/* - - engine/src/flutter/shell/platform/darwin/ios/**/* - - packages/flutter_tools/lib/src/ios/**/* - -platform-fuchsia: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/fuchsia/**/* - -platform-linux: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/linux/**/* - -platform-macos: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/src/flutter/shell/platform/darwin/common/**/* - - engine/src/flutter/shell/platform/darwin/macos/**/* - -platform-web: - - changed-files: - - any-glob-to-any-file: - - '**/web_sdk/**/*' - - engine/src/flutter/lib/web_ui/**/* - - packages/flutter_web_plugins - -platform-windows: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/windows/**/* - -'customer: gallery': - - changed-files: - - any-glob-to-any-file: - - examples/flutter_gallery/**/* - -'c: tech-debt': - - changed-files: - - any-glob-to-any-file: - - '**/fix_data.yaml' - - '**/*.expect' - - '**/*test_fixes*' -'c: contributor-productivity': - - changed-files: - - any-glob-to-any-file: - - docs/contributing/**/* - -# Keep this synced with CODEOWNERS. -team-android: - - changed-files: - - any-glob-to-any-file: - - docs/platform/android/**/* - - engine/src/flutter/shell/platform/android/**/* - - packages/flutter_tools/**/*android* - - packages/flutter_tools/**/*gradle* - -team-ecosystem: - - changed-files: - - any-glob-to-any-file: - - docs/ecosystem/**/* - -team-engine: - - changed-files: - - any-glob-to-any-file: - - docs/engine/**/* - -team-infra: - - changed-files: - - any-glob-to-any-file: - - docs/infra/**/* - - docs/releases/**/* - -# Keep this synced with CODEOWNERS. -team-ios: - - changed-files: - - any-glob-to-any-file: - - engine/src/flutter/shell/platform/darwin/common/**/* - - engine/src/flutter/shell/platform/darwin/ios/framework/**/* - - packages/flutter_tools/**/ios/* - - packages/flutter_tools/**/macos/* - - packages/flutter_tools/**/*xcode* - - packages/flutter_tools/**/*ios* - - packages/flutter_tools/**/*macos* - -team-tool: - - changed-files: - - any-glob-to-any-file: - - docs/tool/**/* - -team-web: - - changed-files: - - any-glob-to-any-file: - - docs/platforms/web/**/* - -tool: - - changed-files: - - any-glob-to-any-file: - - packages/flutter_tools/**/* - - packages/fuchsia_remote_debug_protocol/**/* - - docs/tool/**/* From c2bedb2670f45a44b2dc1fbb5fffb5d399346fde Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Mon, 23 Jun 2025 10:54:44 +0900 Subject: [PATCH 08/14] [Tizen] Temporary fix to Microsoft STL compiler compatibility checks --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61fd921e209ed..0beee16550bbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,6 +150,10 @@ jobs: (Get-Content ".gclient") | ForEach-Object { $_ -replace "'flutter'","'.'" } | Set-Content ".gclient" # TODO(jsuya) : pipes deprecated in python 3.13. (https://dart-review.googlesource.com/c/sdk/+/307620) (Get-Content "engine/src/build/vs_toolchain.py") | ForEach-Object { $_ -replace 'import pipes','' } | Set-Content "engine/src/build/vs_toolchain.py" + + # TODO(jsuya) : Temporary fix to Microsoft STL compiler compatibility checks(https://github.com/flutter-tizen/flutter-tizen/pull/635#issuecomment-2990206946) + (Get-Content "engine/src/build/config/compiler/BUILD.gn") | ForEach-Object { $_; if ($_.Trim() -eq '"__STD_C",') { ' "_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH",' } } | Set-Content "engine/src/build/config/compiler/BUILD.gn" + gclient setdep --var=download_dart_sdk=False --var=download_android_deps=False --var=download_fuchsia_deps=False --deps-file=DEPS gclient sync -v --no-history --shallow From 6364efa6bc9368e3057779542d2efc9a53b6188a Mon Sep 17 00:00:00 2001 From: xiaowei guan <60122246+xiaowei-guan@users.noreply.github.com> Date: Fri, 29 Aug 2025 09:21:53 +0800 Subject: [PATCH 09/14] [Tizen] Enable vulkan (#11) --- engine/src/build_overrides/vulkan_headers.gni | 2 +- engine/src/flutter/impeller/tools/args.gni | 2 +- engine/src/flutter/shell/config.gni | 2 +- engine/src/flutter/tools/gn | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/src/build_overrides/vulkan_headers.gni b/engine/src/build_overrides/vulkan_headers.gni index 5efa852344924..8a4144db207b6 100644 --- a/engine/src/build_overrides/vulkan_headers.gni +++ b/engine/src/build_overrides/vulkan_headers.gni @@ -6,6 +6,6 @@ # set anything. if (is_linux) { - vulkan_use_x11 = true + vulkan_use_x11 = false vulkan_use_wayland = true } diff --git a/engine/src/flutter/impeller/tools/args.gni b/engine/src/flutter/impeller/tools/args.gni index 28d077ab49af6..d939afb4aa253 100644 --- a/engine/src/flutter/impeller/tools/args.gni +++ b/engine/src/flutter/impeller/tools/args.gni @@ -18,7 +18,7 @@ declare_args() { enable_unittests) && target_os != "fuchsia" # Whether the Vulkan backend is enabled. - impeller_enable_vulkan = (is_win || is_android || is_mac || + impeller_enable_vulkan = (is_linux || is_win || is_android || is_mac || enable_unittests) && target_os != "fuchsia" } diff --git a/engine/src/flutter/shell/config.gni b/engine/src/flutter/shell/config.gni index 9ad466439ee2e..8aa62e02417ba 100644 --- a/engine/src/flutter/shell/config.gni +++ b/engine/src/flutter/shell/config.gni @@ -7,7 +7,7 @@ declare_args() { # The logic for enabling Vulkan and Metal is in tools/gn. shell_enable_metal = false - shell_enable_vulkan = false + shell_enable_vulkan = true shell_enable_software = true } diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 82afbdf22c85e..d5dd21d9ed072 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -629,7 +629,7 @@ def to_gn_args(args): # Enable Vulkan on all platforms except for iOS. This is just # to save on mobile binary size, as there's no reason the Vulkan embedder # features can't work on these platforms. - if gn_args['target_os'] not in ['ios', 'mac', 'linux']: + if gn_args['target_os'] not in ['ios', 'mac']: gn_args['skia_use_vulkan'] = True gn_args['skia_use_vma'] = False gn_args['shell_enable_vulkan'] = True From 0cf348b89f22e105ef7902cfd4ef818ec4bd5d2b Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 12 Sep 2025 12:06:23 +0900 Subject: [PATCH 10/14] [Tizen] Add x64 release (#13) flutter-tizen/flutter-tizen#554 Added x64 artifacts for x64 emulator support (Currently, x64 Release mode is only supported on Linux hosts.) --- .github/workflows/build.yml | 41 +++++++++++++++++++++-- engine/src/flutter/ci/tizen/build_llvm.sh | 1 + engine/src/flutter/testing/testing.gni | 3 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0beee16550bbb..e828f82a2b2a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - arch: [arm, arm64, x86] + arch: [arm, arm64, x86, x64] mode: [debug, release, profile] include: - arch: arm @@ -21,6 +21,8 @@ jobs: triple: aarch64-linux-gnu - arch: x86 triple: i686-linux-gnu + - arch: x64 + triple: x86_64-linux-gnu exclude: - arch: x86 mode: release @@ -58,6 +60,7 @@ jobs: run: flutter/engine/src/flutter/ci/tizen/generate_sysroot.py --out /tizen_tools/sysroot - name: Build + if: ${{ matrix.arch != 'x64' }} run: | cd flutter # Ignore unsupported linker option. @@ -78,12 +81,37 @@ jobs: ninja -C out/build flutter_engine_library cp -f flutter/third_party/icu/flutter/icudtl.dat out/build + - name: Build(x64) + if: ${{ matrix.arch == 'x64' }} + run: | + cd flutter + + engine/src/flutter/tools/gn \ + --target-os linux \ + --linux-cpu ${{ matrix.arch }} \ + --no-goma \ + --target-triple ${{ matrix.triple }} \ + --runtime-mode ${{ matrix.mode }} \ + --enable-fontconfig \ + --disable-desktop-embeddings \ + --target-dir build + + cd engine/src + ninja -C out/build flutter_engine_library + cp -f flutter/third_party/icu/flutter/icudtl.dat out/build + - name: Build gen_snapshot - if: ${{ matrix.mode != 'debug' }} + if: ${{ matrix.mode != 'debug' && matrix.arch != 'x64'}} run: | cd flutter ninja -C engine/src/out/build clang_x64/gen_snapshot + - name: Build gen_snapshot(x64) + if: ${{ matrix.mode != 'debug' && matrix.arch == 'x64'}} + run: | + cd flutter + ninja -C engine/src/out/build gen_snapshot + - uses: actions/upload-artifact@v4 with: name: tizen-${{ matrix.arch }}-${{ matrix.mode }} @@ -100,12 +128,19 @@ jobs: if-no-files-found: error - uses: actions/upload-artifact@v4 - if: ${{ matrix.mode != 'debug' }} + if: ${{ matrix.mode != 'debug' && matrix.arch != 'x64'}} with: name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_linux-x64 path: flutter/engine/src/out/build/clang_x64/gen_snapshot if-no-files-found: error + - uses: actions/upload-artifact@v4 + if: ${{ matrix.mode != 'debug' && matrix.arch == 'x64'}} + with: + name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_linux-x64 + path: flutter/engine/src/out/build/gen_snapshot + if-no-files-found: error + windows-build: runs-on: windows-latest diff --git a/engine/src/flutter/ci/tizen/build_llvm.sh b/engine/src/flutter/ci/tizen/build_llvm.sh index 7d75d9c6a4252..de27efb73a9b6 100755 --- a/engine/src/flutter/ci/tizen/build_llvm.sh +++ b/engine/src/flutter/ci/tizen/build_llvm.sh @@ -43,4 +43,5 @@ for name in ar readelf nm strip; do ln -sf llvm-$name arm-linux-gnueabi-$name ln -sf llvm-$name aarch64-linux-gnu-$name ln -sf llvm-$name i686-linux-gnu-$name + ln -sf llvm-$name x86_64-linux-gnu-$name done diff --git a/engine/src/flutter/testing/testing.gni b/engine/src/flutter/testing/testing.gni index 5ead3d22e922c..c25746c779cec 100644 --- a/engine/src/flutter/testing/testing.gni +++ b/engine/src/flutter/testing/testing.gni @@ -15,7 +15,8 @@ declare_args() { # * host_toolchain: non-cross-compile. We can run tests on the host. # * Fuchsia: build unittests for testing on device. # * macOS: arm64 builds can run x64 binaries. - enable_unittests = current_toolchain == host_toolchain || is_fuchsia || is_mac + # Disable unit test + enable_unittests = false # Build iOS target device unit tests. # From 92f36235215b94a157c6ed260b7e0016b019261f Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 17 Sep 2025 13:02:27 +0900 Subject: [PATCH 11/14] [Tizen] Disable x64 symbol generation temporary (#14) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e828f82a2b2a3..0eb01ef09b086 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,7 +121,7 @@ jobs: if-no-files-found: error - uses: actions/upload-artifact@v4 - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'push' && matrix.arch != 'x64' }} with: name: tizen-${{ matrix.arch }}-${{ matrix.mode }}_symbols path: flutter/engine/src/out/build/so.unstripped/libflutter_engine.so From 1962c1c7e64215bd2d2255a6dd159c644e1b8271 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 18 Sep 2025 17:48:28 +0900 Subject: [PATCH 12/14] [Tizen] Update sysroot download URL (#15) https://github.com/flutter-tizen/embedder/pull/118#discussion_r2357867428 --- engine/src/flutter/ci/tizen/generate_sysroot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/ci/tizen/generate_sysroot.py b/engine/src/flutter/ci/tizen/generate_sysroot.py index c4bdc51f347cf..210f7e9ecf9e7 100755 --- a/engine/src/flutter/ci/tizen/generate_sysroot.py +++ b/engine/src/flutter/ci/tizen/generate_sysroot.py @@ -41,10 +41,10 @@ def generate_sysroot(sysroot: Path, api_version: float, arch: str, quiet=False): else: sys.exit('Unknown arch: ' + arch) - base_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Base/latest/repos/standard/packages'.format( + base_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Base/reference/repos/standard/packages'.format( api_version, api_version ) - unified_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Unified/latest/repos/standard/packages'.format( + unified_repo = 'http://download.tizen.org/snapshots/TIZEN/Tizen-{}/Tizen-{}-Unified/reference/repos/standard/packages'.format( api_version, api_version ) From 008483191238a9f3cc4ac01d0393028f279cd401 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 28 Jul 2025 14:16:15 -0700 Subject: [PATCH 13/14] [Tizen] Cherry-pick flutter commit(0b9f406589) [Flutter GPU] Fix Android/GLES crashers. (#172588) Continuation of https://github.com/flutter/flutter/pull/165630. Resolves https://github.com/flutter/flutter/issues/164278. Resolves https://github.com/bdero/flutter_scene/issues/35. Partly fixes: https://github.com/flutter/flutter/issues/160948. * Fixes OpenGLES crashers. * Threadsafe GLES pipeline creation. * Threadsafe GLES texture creation. * Fix GLES internal float texture formats. * Encode GLES passes on the raster thread. * Overwrite GLES textures on the raster thread. * Fixes vulkan memory leak (https://github.com/flutter/flutter/issues/164278). --- engine/src/flutter/impeller/core/allocator.cc | 8 ++-- engine/src/flutter/impeller/core/allocator.h | 21 ++++++++++- .../entity/contents/host_buffer_unittests.cc | 3 +- .../entity/render_target_cache_unittests.cc | 3 +- .../renderer/backend/gles/allocator_gles.cc | 5 ++- .../renderer/backend/gles/allocator_gles.h | 4 +- .../backend/gles/pipeline_library_gles.cc | 37 ++++++++++++------- .../backend/gles/pipeline_library_gles.h | 6 ++- .../renderer/backend/gles/texture_gles.cc | 19 ++++++---- .../renderer/backend/gles/texture_gles.h | 5 ++- .../renderer/backend/metal/allocator_mtl.h | 4 +- .../renderer/backend/metal/allocator_mtl.mm | 3 +- .../backend/metal/pipeline_library_mtl.h | 3 +- .../backend/metal/pipeline_library_mtl.mm | 3 +- .../renderer/backend/vulkan/allocator_vk.cc | 3 +- .../renderer/backend/vulkan/allocator_vk.h | 4 +- .../backend/vulkan/pipeline_library_vk.cc | 3 +- .../backend/vulkan/pipeline_library_vk.h | 6 ++- .../impeller/renderer/pipeline_library.h | 22 ++++++++++- .../flutter/impeller/renderer/testing/mocks.h | 2 +- engine/src/flutter/lib/gpu/command_buffer.cc | 23 +++++++----- engine/src/flutter/lib/gpu/context.cc | 18 +++++---- engine/src/flutter/lib/gpu/context.h | 4 +- engine/src/flutter/lib/gpu/device_buffer.cc | 4 +- .../src/flutter/lib/gpu/lib/src/texture.dart | 11 ++++-- engine/src/flutter/lib/gpu/render_pass.cc | 7 ++-- engine/src/flutter/lib/gpu/shader.cc | 4 +- engine/src/flutter/lib/gpu/texture.cc | 28 ++++++++++++-- engine/src/flutter/lib/gpu/texture.h | 8 ++-- .../painting/image_decoder_no_gl_unittests.h | 4 +- 30 files changed, 190 insertions(+), 85 deletions(-) diff --git a/engine/src/flutter/impeller/core/allocator.cc b/engine/src/flutter/impeller/core/allocator.cc index 19314c5bfcd59..7e0f472d15ea8 100644 --- a/engine/src/flutter/impeller/core/allocator.cc +++ b/engine/src/flutter/impeller/core/allocator.cc @@ -46,8 +46,8 @@ std::shared_ptr Allocator::CreateBuffer( return OnCreateBuffer(desc); } -std::shared_ptr Allocator::CreateTexture( - const TextureDescriptor& desc) { +std::shared_ptr Allocator::CreateTexture(const TextureDescriptor& desc, + bool threadsafe) { const auto max_size = GetMaxTextureSizeSupported(); if (desc.size.width > max_size.width || desc.size.height > max_size.height) { VALIDATION_LOG << "Requested texture size " << desc.size @@ -60,10 +60,10 @@ std::shared_ptr Allocator::CreateTexture( << " exceeds maximum supported for size " << desc.size; TextureDescriptor corrected_desc = desc; corrected_desc.mip_count = desc.size.MipCount(); - return OnCreateTexture(corrected_desc); + return OnCreateTexture(corrected_desc, threadsafe); } - return OnCreateTexture(desc); + return OnCreateTexture(desc, threadsafe); } uint16_t Allocator::MinimumBytesPerRow(PixelFormat format) const { diff --git a/engine/src/flutter/impeller/core/allocator.h b/engine/src/flutter/impeller/core/allocator.h index 50da86fe10bf1..9a3ce694a3a9a 100644 --- a/engine/src/flutter/impeller/core/allocator.h +++ b/engine/src/flutter/impeller/core/allocator.h @@ -30,7 +30,23 @@ class Allocator { std::shared_ptr CreateBuffer( const DeviceBufferDescriptor& desc); - std::shared_ptr CreateTexture(const TextureDescriptor& desc); + //------------------------------------------------------------------------------ + /// @brief Creates a new texture. + /// + /// @param[in] desc The descriptor of the texture to create. + /// @param[in] threadsafe Whether mutations to this texture should be + /// protected with a threadsafe barrier. + /// + /// This parameter only affects the OpenGLES rendering + /// backend. + /// + /// If any interaction with this texture (including + /// creation) will be done on a thread other than + /// where the OpenGLES context resides, then + /// `threadsafe`, must be set to `true`. + /// + std::shared_ptr CreateTexture(const TextureDescriptor& desc, + bool threadsafe = false); //------------------------------------------------------------------------------ /// @brief Minimum value for `row_bytes` on a Texture. The row @@ -62,7 +78,8 @@ class Allocator { const DeviceBufferDescriptor& desc) = 0; virtual std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) = 0; + const TextureDescriptor& desc, + bool threadsafe = false) = 0; private: Allocator(const Allocator&) = delete; diff --git a/engine/src/flutter/impeller/entity/contents/host_buffer_unittests.cc b/engine/src/flutter/impeller/entity/contents/host_buffer_unittests.cc index 7ba47b780f8bc..573417276d895 100644 --- a/engine/src/flutter/impeller/entity/contents/host_buffer_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/host_buffer_unittests.cc @@ -206,7 +206,8 @@ class FailingAllocator : public Allocator { return delegate_->CreateBuffer(desc); } - std::shared_ptr OnCreateTexture(const TextureDescriptor& desc) { + std::shared_ptr OnCreateTexture(const TextureDescriptor& desc, + bool threadsafe) { return delegate_->CreateTexture(desc); } diff --git a/engine/src/flutter/impeller/entity/render_target_cache_unittests.cc b/engine/src/flutter/impeller/entity/render_target_cache_unittests.cc index 4fe3ffb0c9c4d..498c11e588479 100644 --- a/engine/src/flutter/impeller/entity/render_target_cache_unittests.cc +++ b/engine/src/flutter/impeller/entity/render_target_cache_unittests.cc @@ -39,7 +39,8 @@ class TestAllocator : public Allocator { }; virtual std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) override { + const TextureDescriptor& desc, + bool threadsafe) override { if (should_fail) { return nullptr; } diff --git a/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.cc index 820ec22d69163..16e7ccd91d366 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.cc @@ -39,8 +39,9 @@ std::shared_ptr AllocatorGLES::OnCreateBuffer( // |Allocator| std::shared_ptr AllocatorGLES::OnCreateTexture( - const TextureDescriptor& desc) { - return std::make_shared(reactor_, desc); + const TextureDescriptor& desc, + bool threadsafe) { + return std::make_shared(reactor_, desc, threadsafe); } // |Allocator| diff --git a/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.h b/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.h index 14728414f467e..89bc377bd9d39 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.h +++ b/engine/src/flutter/impeller/renderer/backend/gles/allocator_gles.h @@ -31,8 +31,8 @@ class AllocatorGLES final : public Allocator { const DeviceBufferDescriptor& desc) override; // |Allocator| - std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) override; + std::shared_ptr OnCreateTexture(const TextureDescriptor& desc, + bool threadsafe) override; // |Allocator| ISize GetMaxTextureSizeSupported() const override; diff --git a/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.cc index 215d5b6d719e8..765345cac3824 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.cc @@ -185,7 +185,8 @@ std::shared_ptr PipelineLibraryGLES::CreatePipeline( const std::weak_ptr& weak_library, const PipelineDescriptor& desc, const std::shared_ptr& vert_function, - const std::shared_ptr& frag_function) { + const std::shared_ptr& frag_function, + bool threadsafe) { auto strong_library = weak_library.lock(); if (!strong_library) { @@ -209,14 +210,22 @@ std::shared_ptr PipelineLibraryGLES::CreatePipeline( const auto has_cached_program = !!cached_program; - auto pipeline = std::shared_ptr(new PipelineGLES( - reactor, // - weak_library, // - desc, // - has_cached_program - ? std::move(cached_program) - : std::make_shared(UniqueHandleGLES::MakeUntracked( - reactor, HandleType::kProgram)))); + std::shared_ptr program_handle = nullptr; + if (has_cached_program) { + program_handle = std::move(cached_program); + } else { + program_handle = threadsafe ? std::make_shared( + reactor, HandleType::kProgram) + : std::make_shared( + UniqueHandleGLES::MakeUntracked( + reactor, HandleType::kProgram)); + } + + auto pipeline = std::shared_ptr( + new PipelineGLES(reactor, // + weak_library, // + desc, // + std::move(program_handle))); auto program = reactor->GetGLHandle(pipeline->GetProgramHandle()); @@ -258,7 +267,8 @@ std::shared_ptr PipelineLibraryGLES::CreatePipeline( // |PipelineLibrary| PipelineFuture PipelineLibraryGLES::GetPipeline( PipelineDescriptor descriptor, - bool async) { + bool async, + bool threadsafe) { if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) { return found->second; } @@ -290,10 +300,11 @@ PipelineFuture PipelineLibraryGLES::GetPipeline( weak_this = weak_from_this(), // descriptor, // vert_function, // - frag_function // + frag_function, // + threadsafe // ](const ReactorGLES& reactor) { - promise->set_value( - CreatePipeline(weak_this, descriptor, vert_function, frag_function)); + promise->set_value(CreatePipeline(weak_this, descriptor, vert_function, + frag_function, threadsafe)); }); FML_CHECK(result); diff --git a/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.h b/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.h index 3b9f29f7d2274..25c51c8113d38 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.h +++ b/engine/src/flutter/impeller/renderer/backend/gles/pipeline_library_gles.h @@ -99,7 +99,8 @@ class PipelineLibraryGLES final // |PipelineLibrary| PipelineFuture GetPipeline(PipelineDescriptor descriptor, - bool async) override; + bool async, + bool threadsafe) override; // |PipelineLibrary| PipelineFuture GetPipeline( @@ -119,7 +120,8 @@ class PipelineLibraryGLES final const std::weak_ptr& weak_library, const PipelineDescriptor& desc, const std::shared_ptr& vert_shader, - const std::shared_ptr& frag_shader); + const std::shared_ptr& frag_shader, + bool threadsafe); std::shared_ptr GetProgramForKey(const ProgramKey& key); diff --git a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc index 402fb220daa96..2f4008bfbdf88 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.cc @@ -88,12 +88,12 @@ struct TexImage2DData { type = GL_UNSIGNED_BYTE; break; case PixelFormat::kR32G32B32A32Float: - internal_format = GL_RGBA; + internal_format = GL_RGBA32F; external_format = GL_RGBA; type = GL_FLOAT; break; case PixelFormat::kR16G16B16A16Float: - internal_format = GL_RGBA; + internal_format = GL_RGBA16F; external_format = GL_RGBA; type = GL_HALF_FLOAT; break; @@ -149,7 +149,7 @@ std::shared_ptr TextureGLES::WrapFBO( TextureDescriptor desc, GLuint fbo) { auto texture = std::shared_ptr( - new TextureGLES(std::move(reactor), desc, fbo, std::nullopt)); + new TextureGLES(std::move(reactor), desc, false, fbo, std::nullopt)); if (!texture->IsValid()) { return nullptr; } @@ -168,8 +168,8 @@ std::shared_ptr TextureGLES::WrapTexture( VALIDATION_LOG << "Cannot wrap a non-texture handle."; return nullptr; } - auto texture = std::shared_ptr( - new TextureGLES(std::move(reactor), desc, std::nullopt, external_handle)); + auto texture = std::shared_ptr(new TextureGLES( + std::move(reactor), desc, false, std::nullopt, external_handle)); if (!texture->IsValid()) { return nullptr; } @@ -183,15 +183,18 @@ std::shared_ptr TextureGLES::CreatePlaceholder( } TextureGLES::TextureGLES(std::shared_ptr reactor, - TextureDescriptor desc) + TextureDescriptor desc, + bool threadsafe) : TextureGLES(std::move(reactor), // desc, // + threadsafe, // std::nullopt, // std::nullopt // ) {} TextureGLES::TextureGLES(std::shared_ptr reactor, TextureDescriptor desc, + bool threadsafe, std::optional fbo, std::optional external_handle) : Texture(desc), @@ -201,7 +204,9 @@ TextureGLES::TextureGLES(std::shared_ptr reactor, reactor_->GetProcTable().GetCapabilities())), handle_(external_handle.has_value() ? external_handle.value() - : reactor_->CreateUntrackedHandle(ToHandleType(type_))), + : (threadsafe ? reactor_->CreateHandle(ToHandleType(type_)) + : reactor_->CreateUntrackedHandle( + ToHandleType(type_)))), is_wrapped_(fbo.has_value() || external_handle.has_value()), wrapped_fbo_(fbo) { // Ensure the texture descriptor itself is valid. diff --git a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h index 84deb194403ec..95893e8428a80 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h +++ b/engine/src/flutter/impeller/renderer/backend/gles/texture_gles.h @@ -75,7 +75,9 @@ class TextureGLES final : public Texture, std::shared_ptr reactor, TextureDescriptor desc); - TextureGLES(std::shared_ptr reactor, TextureDescriptor desc); + TextureGLES(std::shared_ptr reactor, + TextureDescriptor desc, + bool threadsafe = false); // |Texture| ~TextureGLES() override; @@ -164,6 +166,7 @@ class TextureGLES final : public Texture, TextureGLES(std::shared_ptr reactor, TextureDescriptor desc, + bool threadsafe, std::optional fbo, std::optional external_handle); diff --git a/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.h b/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.h index 4764c00b41900..91a47484a9516 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.h +++ b/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.h @@ -73,8 +73,8 @@ class AllocatorMTL final : public Allocator { const DeviceBufferDescriptor& desc) override; // |Allocator| - std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) override; + std::shared_ptr OnCreateTexture(const TextureDescriptor& desc, + bool threadsafe) override; // |Allocator| uint16_t MinimumBytesPerRow(PixelFormat format) const override; diff --git a/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.mm b/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.mm index 42de0b17ccc53..0b4f846da208d 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/engine/src/flutter/impeller/renderer/backend/metal/allocator_mtl.mm @@ -159,7 +159,8 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode, } std::shared_ptr AllocatorMTL::OnCreateTexture( - const TextureDescriptor& desc) { + const TextureDescriptor& desc, + bool threadsafe) { if (!IsValid()) { return nullptr; } diff --git a/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.h b/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.h index 8d6a6bdcddc5f..197cf8d43c856 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.h +++ b/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.h @@ -34,7 +34,8 @@ class PipelineLibraryMTL final : public PipelineLibrary { // |PipelineLibrary| PipelineFuture GetPipeline(PipelineDescriptor descriptor, - bool async) override; + bool async, + bool threadsafe) override; // |PipelineLibrary| PipelineFuture GetPipeline( diff --git a/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.mm b/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.mm index 1e69aeb0a2357..270fbe5653d43 100644 --- a/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.mm +++ b/engine/src/flutter/impeller/renderer/backend/metal/pipeline_library_mtl.mm @@ -113,7 +113,8 @@ static void GetMTLRenderPipelineDescriptor(const PipelineDescriptor& desc, // |PipelineLibrary| PipelineFuture PipelineLibraryMTL::GetPipeline( PipelineDescriptor descriptor, - bool async) { + bool async, + bool threadsafe) { if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) { return found->second; } diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.cc index 9bd546340a841..52e7c4950511c 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.cc @@ -468,7 +468,8 @@ class AllocatedTextureSourceVK final : public TextureSourceVK { // |Allocator| std::shared_ptr AllocatorVK::OnCreateTexture( - const TextureDescriptor& desc) { + const TextureDescriptor& desc, + bool threadsafe) { if (!IsValid()) { return nullptr; } diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.h b/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.h index 53e2772e740a6..6a2a35cbb7a75 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.h +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/allocator_vk.h @@ -68,8 +68,8 @@ class AllocatorVK final : public Allocator { const DeviceBufferDescriptor& desc) override; // |Allocator| - std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) override; + std::shared_ptr OnCreateTexture(const TextureDescriptor& desc, + bool threadsafe) override; // |Allocator| ISize GetMaxTextureSizeSupported() const override; diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc index 109b406467566..02c4e6087a4c8 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.cc @@ -152,7 +152,8 @@ std::unique_ptr PipelineLibraryVK::CreateComputePipeline( // |PipelineLibrary| PipelineFuture PipelineLibraryVK::GetPipeline( PipelineDescriptor descriptor, - bool async) { + bool async, + bool threadsafe) { Lock lock(pipelines_mutex_); if (auto found = pipelines_.find(descriptor); found != pipelines_.end()) { return found->second; diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.h b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.h index 2c2eac667b9e1..407b871dd0827 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.h +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/pipeline_library_vk.h @@ -59,8 +59,10 @@ class PipelineLibraryVK final bool IsValid() const override; // |PipelineLibrary| - PipelineFuture GetPipeline(PipelineDescriptor descriptor, - bool async) override; + PipelineFuture GetPipeline( + PipelineDescriptor descriptor, + bool async, + bool threadsafe = false) override; // |PipelineLibrary| PipelineFuture GetPipeline( diff --git a/engine/src/flutter/impeller/renderer/pipeline_library.h b/engine/src/flutter/impeller/renderer/pipeline_library.h index 4c5a8617d0bcd..472f226ba180c 100644 --- a/engine/src/flutter/impeller/renderer/pipeline_library.h +++ b/engine/src/flutter/impeller/renderer/pipeline_library.h @@ -41,9 +41,29 @@ class PipelineLibrary : public std::enable_shared_from_this { virtual bool IsValid() const = 0; + //------------------------------------------------------------------------------ + /// @brief Creates a pipeline. + /// + /// @param[in] descriptor The descriptor of the texture to create. + /// @param[in] async Whether to allow pipeline creation to be deferred. + /// If `false`, pipeline creation will block on the + /// current thread. + /// + /// @param[in] threadsafe Whether mutations to this texture should be + /// protected with a threadsafe barrier. + /// + /// This parameter only affects the OpenGLES rendering + /// backend. + /// + /// If any interaction with this texture (including + /// creation) will be done on a thread other than + /// where the OpenGLES context resides, then + /// `threadsafe`, must be set to `true`. + /// virtual PipelineFuture GetPipeline( PipelineDescriptor descriptor, - bool async = true) = 0; + bool async = true, + bool threadsafe = false) = 0; virtual PipelineFuture GetPipeline( ComputePipelineDescriptor descriptor, diff --git a/engine/src/flutter/impeller/renderer/testing/mocks.h b/engine/src/flutter/impeller/renderer/testing/mocks.h index 0ce1717b9a525..82d9f8a8ad1aa 100644 --- a/engine/src/flutter/impeller/renderer/testing/mocks.h +++ b/engine/src/flutter/impeller/renderer/testing/mocks.h @@ -53,7 +53,7 @@ class MockAllocator : public Allocator { (override)); MOCK_METHOD(std::shared_ptr, OnCreateTexture, - (const TextureDescriptor& desc), + (const TextureDescriptor& desc, bool threadsafe), (override)); }; diff --git a/engine/src/flutter/lib/gpu/command_buffer.cc b/engine/src/flutter/lib/gpu/command_buffer.cc index 76ca1ed487815..2fc212f33ba25 100644 --- a/engine/src/flutter/lib/gpu/command_buffer.cc +++ b/engine/src/flutter/lib/gpu/command_buffer.cc @@ -39,19 +39,20 @@ bool CommandBuffer::Submit() { bool CommandBuffer::Submit( const impeller::CommandBuffer::CompletionCallback& completion_callback) { - for (auto& encodable : encodables_) { - encodable->EncodeCommands(); - } - // For the GLES backend, command queue submission just flushes the reactor, // which needs to happen on the raster thread. if (context_->GetBackendType() == impeller::Context::BackendType::kOpenGLES) { auto dart_state = flutter::UIDartState::Current(); auto& task_runners = dart_state->GetTaskRunners(); - task_runners.GetRasterTaskRunner()->PostTask(fml::MakeCopyable( - [context = context_, command_buffer = command_buffer_, - completion_callback = completion_callback]() mutable { + task_runners.GetRasterTaskRunner()->PostTask( + fml::MakeCopyable([context = context_, command_buffer = command_buffer_, + completion_callback = completion_callback, + encodables = encodables_]() mutable { + for (auto& encodable : encodables) { + encodable->EncodeCommands(); + } + context->GetCommandQueue() ->Submit({command_buffer}, completion_callback) .ok(); @@ -59,6 +60,10 @@ bool CommandBuffer::Submit( return true; } + for (auto& encodable : encodables_) { + encodable->EncodeCommands(); + } + return context_->GetCommandQueue() ->Submit({command_buffer_}, completion_callback) .ok(); @@ -75,8 +80,8 @@ bool InternalFlutterGpu_CommandBuffer_Initialize( Dart_Handle wrapper, flutter::gpu::Context* contextWrapper) { auto res = fml::MakeRefCounted( - contextWrapper->GetContext(), - contextWrapper->GetContext()->CreateCommandBuffer()); + contextWrapper->GetContextShared(), + contextWrapper->GetContext().CreateCommandBuffer()); res->AssociateWithDartWrapper(wrapper); return true; diff --git a/engine/src/flutter/lib/gpu/context.cc b/engine/src/flutter/lib/gpu/context.cc index 1b8606dfa2d1d..36a715608a629 100644 --- a/engine/src/flutter/lib/gpu/context.cc +++ b/engine/src/flutter/lib/gpu/context.cc @@ -74,7 +74,11 @@ Context::Context(std::shared_ptr context) Context::~Context() = default; -std::shared_ptr Context::GetContext() { +impeller::Context& Context::GetContext() { + return *context_; +} + +std::shared_ptr& Context::GetContextShared() { return context_; } @@ -101,29 +105,27 @@ Dart_Handle InternalFlutterGpu_Context_InitializeDefault(Dart_Handle wrapper) { extern int InternalFlutterGpu_Context_GetDefaultColorFormat( flutter::gpu::Context* wrapper) { return static_cast(flutter::gpu::FromImpellerPixelFormat( - wrapper->GetContext()->GetCapabilities()->GetDefaultColorFormat())); + wrapper->GetContext().GetCapabilities()->GetDefaultColorFormat())); } extern int InternalFlutterGpu_Context_GetDefaultStencilFormat( flutter::gpu::Context* wrapper) { return static_cast(flutter::gpu::FromImpellerPixelFormat( - wrapper->GetContext()->GetCapabilities()->GetDefaultStencilFormat())); + wrapper->GetContext().GetCapabilities()->GetDefaultStencilFormat())); } extern int InternalFlutterGpu_Context_GetDefaultDepthStencilFormat( flutter::gpu::Context* wrapper) { return static_cast(flutter::gpu::FromImpellerPixelFormat( - wrapper->GetContext() - ->GetCapabilities() - ->GetDefaultDepthStencilFormat())); + wrapper->GetContext().GetCapabilities()->GetDefaultDepthStencilFormat())); } extern int InternalFlutterGpu_Context_GetMinimumUniformByteAlignment( flutter::gpu::Context* wrapper) { - return wrapper->GetContext()->GetCapabilities()->GetMinimumUniformAlignment(); + return wrapper->GetContext().GetCapabilities()->GetMinimumUniformAlignment(); } extern bool InternalFlutterGpu_Context_GetSupportsOffscreenMSAA( flutter::gpu::Context* wrapper) { - return flutter::gpu::SupportsNormalOffscreenMSAA(*wrapper->GetContext()); + return flutter::gpu::SupportsNormalOffscreenMSAA(wrapper->GetContext()); } diff --git a/engine/src/flutter/lib/gpu/context.h b/engine/src/flutter/lib/gpu/context.h index 4dbabcb5e432d..3c915827cc98a 100644 --- a/engine/src/flutter/lib/gpu/context.h +++ b/engine/src/flutter/lib/gpu/context.h @@ -30,7 +30,9 @@ class Context : public RefCountedDartWrappable { explicit Context(std::shared_ptr context); ~Context() override; - std::shared_ptr GetContext(); + impeller::Context& GetContext(); + + std::shared_ptr& GetContextShared(); private: /// An Impeller context that takes precedent over the IO state context when diff --git a/engine/src/flutter/lib/gpu/device_buffer.cc b/engine/src/flutter/lib/gpu/device_buffer.cc index b5232c2856692..1304d9b269274 100644 --- a/engine/src/flutter/lib/gpu/device_buffer.cc +++ b/engine/src/flutter/lib/gpu/device_buffer.cc @@ -56,7 +56,7 @@ bool InternalFlutterGpu_DeviceBuffer_Initialize( desc.storage_mode = flutter::gpu::ToImpellerStorageMode(storage_mode); desc.size = size_in_bytes; auto device_buffer = - gpu_context->GetContext()->GetResourceAllocator()->CreateBuffer(desc); + gpu_context->GetContext().GetResourceAllocator()->CreateBuffer(desc); if (!device_buffer) { FML_LOG(ERROR) << "Failed to create device buffer."; return false; @@ -82,7 +82,7 @@ bool InternalFlutterGpu_DeviceBuffer_InitializeWithHostData( auto mapping = fml::NonOwnedMapping(reinterpret_cast(data.data()), data.length_in_bytes()); device_buffer = - gpu_context->GetContext()->GetResourceAllocator()->CreateBufferWithCopy( + gpu_context->GetContext().GetResourceAllocator()->CreateBufferWithCopy( mapping); } if (!device_buffer) { diff --git a/engine/src/flutter/lib/gpu/lib/src/texture.dart b/engine/src/flutter/lib/gpu/lib/src/texture.dart index 4c266e37c88f2..bc88c92d09c2d 100644 --- a/engine/src/flutter/lib/gpu/lib/src/texture.dart +++ b/engine/src/flutter/lib/gpu/lib/src/texture.dart @@ -24,7 +24,8 @@ base class Texture extends NativeFieldWrapperClass1 { this.enableRenderTargetUsage, this.enableShaderReadUsage, this.enableShaderWriteUsage, - ) : _coordinateSystem = coordinateSystem { + ) : _gpuContext = gpuContext, + _coordinateSystem = coordinateSystem { if (sampleCount != 1 && sampleCount != 4) { throw Exception("Only a sample count of 1 or 4 is currently supported"); } @@ -42,6 +43,8 @@ base class Texture extends NativeFieldWrapperClass1 { ); } + GpuContext _gpuContext; + final StorageMode storageMode; final PixelFormat format; final int width; @@ -99,7 +102,7 @@ base class Texture extends NativeFieldWrapperClass1 { 'The length of sourceBytes (bytes: ${sourceBytes.lengthInBytes}) must exactly match the size of the base mip level (bytes: ${baseMipSize})', ); } - bool success = _overwrite(sourceBytes); + bool success = _overwrite(_gpuContext, sourceBytes); if (!success) { throw Exception("Texture overwrite failed"); } @@ -153,10 +156,10 @@ base class Texture extends NativeFieldWrapperClass1 { ) external int _bytesPerTexel(); - @Native, Handle)>( + @Native, Pointer, Handle)>( symbol: 'InternalFlutterGpu_Texture_Overwrite', ) - external bool _overwrite(ByteData bytes); + external bool _overwrite(GpuContext gpuContext, ByteData bytes); @Native)>( symbol: 'InternalFlutterGpu_Texture_AsImage', diff --git a/engine/src/flutter/lib/gpu/render_pass.cc b/engine/src/flutter/lib/gpu/render_pass.cc index 71b8659bd25de..03112143531b0 100644 --- a/engine/src/flutter/lib/gpu/render_pass.cc +++ b/engine/src/flutter/lib/gpu/render_pass.cc @@ -166,8 +166,9 @@ RenderPass::GetOrCreatePipeline() { dart_state->GetTaskRunners().GetRasterTaskRunner(), fml::MakeCopyable([promise = std::move(pipeline_promise), context = GetContext(), pipeline_desc]() mutable { - promise.set_value( - context->GetPipelineLibrary()->GetPipeline(pipeline_desc).Get()); + promise.set_value(context->GetPipelineLibrary() + ->GetPipeline(pipeline_desc, true, true) + .Get()); })); pipeline = pipeline_future.get(); } else { @@ -269,7 +270,7 @@ Dart_Handle InternalFlutterGpu_RenderPass_SetColorAttachment( // If the backend doesn't support normal MSAA, gracefully fallback to // rendering without MSAA. - if (!flutter::gpu::SupportsNormalOffscreenMSAA(*context->GetContext())) { + if (!flutter::gpu::SupportsNormalOffscreenMSAA(context->GetContext())) { desc.texture = desc.resolve_texture; desc.resolve_texture = nullptr; desc.store_action = impeller::StoreAction::kStore; diff --git a/engine/src/flutter/lib/gpu/shader.cc b/engine/src/flutter/lib/gpu/shader.cc index 26378f5e95c24..d0b45da23bf4a 100644 --- a/engine/src/flutter/lib/gpu/shader.cc +++ b/engine/src/flutter/lib/gpu/shader.cc @@ -62,7 +62,7 @@ std::shared_ptr Shader::GetFunctionFromLibrary( } bool Shader::IsRegistered(Context& context) { - auto& lib = *context.GetContext()->GetShaderLibrary(); + auto& lib = *context.GetContext().GetShaderLibrary(); return GetFunctionFromLibrary(lib) != nullptr; } @@ -71,7 +71,7 @@ bool Shader::RegisterSync(Context& context) { return true; // Already registered. } - auto& lib = *context.GetContext()->GetShaderLibrary(); + auto& lib = *context.GetContext().GetShaderLibrary(); std::promise promise; auto future = promise.get_future(); diff --git a/engine/src/flutter/lib/gpu/texture.cc b/engine/src/flutter/lib/gpu/texture.cc index 740e3dc51ae44..421aa55f20510 100644 --- a/engine/src/flutter/lib/gpu/texture.cc +++ b/engine/src/flutter/lib/gpu/texture.cc @@ -6,6 +6,7 @@ #include "flutter/lib/gpu/formats.h" #include "flutter/lib/ui/painting/image.h" +#include "fml/make_copyable.h" #include "fml/mapping.h" #include "impeller/core/allocator.h" #include "impeller/core/formats.h" @@ -32,15 +33,33 @@ void Texture::SetCoordinateSystem( texture_->SetCoordinateSystem(coordinate_system); } -bool Texture::Overwrite(const tonic::DartByteData& source_bytes) { +bool Texture::Overwrite(Context& gpu_context, + const tonic::DartByteData& source_bytes) { const uint8_t* data = static_cast(source_bytes.data()); auto copy = std::vector(data, data + source_bytes.length_in_bytes()); // Texture::SetContents is a bit funky right now. It takes a shared_ptr of a // mapping and we're forced to copy here. auto mapping = std::make_shared(copy); + + // For the GLES backend, command queue submission just flushes the reactor, + // which needs to happen on the raster thread. + if (gpu_context.GetContext().GetBackendType() == + impeller::Context::BackendType::kOpenGLES) { + auto dart_state = flutter::UIDartState::Current(); + auto& task_runners = dart_state->GetTaskRunners(); + + task_runners.GetRasterTaskRunner()->PostTask( + fml::MakeCopyable([texture = texture_, mapping = mapping]() mutable { + if (!texture->SetContents(mapping)) { + FML_LOG(ERROR) << "Failed to set texture contents."; + } + })); + } + if (!texture_->SetContents(mapping)) { return false; } + gpu_context.GetContext().DisposeThreadLocalCachedResources(); return true; } @@ -109,7 +128,8 @@ bool InternalFlutterGpu_Texture_Initialize(Dart_Handle wrapper, return false; } auto texture = - gpu_context->GetContext()->GetResourceAllocator()->CreateTexture(desc); + gpu_context->GetContext().GetResourceAllocator()->CreateTexture(desc, + true); if (!texture) { FML_LOG(ERROR) << "Failed to create texture."; return false; @@ -132,8 +152,10 @@ void InternalFlutterGpu_Texture_SetCoordinateSystem( } bool InternalFlutterGpu_Texture_Overwrite(flutter::gpu::Texture* texture, + flutter::gpu::Context* gpu_context, Dart_Handle source_byte_data) { - return texture->Overwrite(tonic::DartByteData(source_byte_data)); + return texture->Overwrite(*gpu_context, + tonic::DartByteData(source_byte_data)); } extern int InternalFlutterGpu_Texture_BytesPerTexel( diff --git a/engine/src/flutter/lib/gpu/texture.h b/engine/src/flutter/lib/gpu/texture.h index a08619b0b6834..04ddb575c3072 100644 --- a/engine/src/flutter/lib/gpu/texture.h +++ b/engine/src/flutter/lib/gpu/texture.h @@ -27,7 +27,7 @@ class Texture : public RefCountedDartWrappable { void SetCoordinateSystem(impeller::TextureCoordinateSystem coordinate_system); - bool Overwrite(const tonic::DartByteData& source_bytes); + bool Overwrite(Context& gpu_context, const tonic::DartByteData& source_bytes); size_t GetBytesPerTexel(); @@ -68,8 +68,10 @@ extern void InternalFlutterGpu_Texture_SetCoordinateSystem( int coordinate_system); FLUTTER_GPU_EXPORT -extern bool InternalFlutterGpu_Texture_Overwrite(flutter::gpu::Texture* wrapper, - Dart_Handle source_byte_data); +extern bool InternalFlutterGpu_Texture_Overwrite( + flutter::gpu::Texture* wrapper, + flutter::gpu::Context* gpu_context, + Dart_Handle source_byte_data); FLUTTER_GPU_EXPORT extern int InternalFlutterGpu_Texture_BytesPerTexel( diff --git a/engine/src/flutter/lib/ui/painting/image_decoder_no_gl_unittests.h b/engine/src/flutter/lib/ui/painting/image_decoder_no_gl_unittests.h index 6338873260702..4290b9808edd7 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder_no_gl_unittests.h +++ b/engine/src/flutter/lib/ui/painting/image_decoder_no_gl_unittests.h @@ -81,8 +81,8 @@ class TestImpellerAllocator : public impeller::Allocator { return std::make_shared(desc); } - std::shared_ptr OnCreateTexture( - const TextureDescriptor& desc) override { + std::shared_ptr OnCreateTexture(const TextureDescriptor& desc, + bool threadsafe) override { return std::make_shared(desc); } }; From d76513bf2867e7be4e0f3ec23c0af9a13bcde040 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 19 Sep 2025 18:15:14 +0900 Subject: [PATCH 14/14] [ci] Fix window version to 2022 flutter engine's window build uses Window SDKs 10.0.22621.0. window-2025 runner in gitHub actions no longer supports the 10.0.22621.0 SDK. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0eb01ef09b086..cb97449ae2e30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -142,7 +142,7 @@ jobs: if-no-files-found: error windows-build: - runs-on: windows-latest + runs-on: windows-2022 strategy: matrix: