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

Master #57283

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ group("unittests") {
}

if (is_ios) {
public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
# public_deps += [ "//flutter/shell/platform/darwin/ios:ios_test_flutter" ]
}

# Compile all unittests targets if enabled.
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ vars = {
"upstream_benchmark": "https://github.com/google/benchmark.git",
"upstream_boringssl": "https://github.com/openssl/openssl.git",
"upstream_brotli": "https://github.com/google/brotli.git",
"upstream_buildroot": "https://github.com/flutter/buildroot.git",
"upstream_buildroot": "https://github.com/easion/buildroot_tvos.git",
"upstream_dart_style": "https://github.com/dart-lang/dart_style.git",
"upstream_dartdoc": "https://github.com/dart-lang/dartdoc.git",
"upstream_equatable": "https://github.com/felangel/equatable.git",
Expand Down Expand Up @@ -253,7 +253,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'cc9bcddf1524812c80ef741191d5db7469e705de',
'src': 'https://github.com/easion/buildroot_tvos.git' + '@' + 'master',

'src/flutter/third_party/depot_tools':
Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '580b4ff3f5cd0dcaa2eacda28cefe0f45320e8f7',
Expand Down
4 changes: 2 additions & 2 deletions build/secondary/flutter/third_party/ocmock/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source_set("ocmock_src") {
"-Wno-misleading-indentation",
]
if (is_ios) {
cflags += [ "-mios-simulator-version-min=$ios_testing_deployment_target" ]
cflags += [ "-mtvos-simulator-version-min=$ios_testing_deployment_target" ]
}

sources = [
Expand Down Expand Up @@ -115,7 +115,7 @@ static_library("ocmock") {
# Force the static lib to include code from dependencies
complete_static_lib = true
if (is_ios) {
cflags = [ "-mios-simulator-version-min=$ios_testing_deployment_target" ]
cflags = [ "-mtvos-simulator-version-min=$ios_testing_deployment_target" ]
}
public_deps = [ ":ocmock_src" ]
}
4 changes: 2 additions & 2 deletions fml/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
// is really mac/ios.
#include <TargetConditionals.h>
#define FML_OS_MACOSX 1
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || (defined(TARGET_OS_TV) && TARGET_OS_TV)
#define FML_OS_IOS 1
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
#if (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR) || (defined(TARGET_TV_SIMULATOR) && TARGET_TV_SIMULATOR)
#define FML_OS_IOS_SIMULATOR 1
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#elif defined(__linux__)
Expand Down
29 changes: 29 additions & 0 deletions get_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

get_depot_tools(){
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -b main
export PATH=$PATH:${PWD}/depot_tools
}

ENGINE_VERSION=$(curl -s https://raw.githubusercontent.com/flutter/flutter/stable/bin/internal/engine.version)

echo "ENGINE_VERSION=${ENGINE_VERSION}"

export DEPOT_TOOLS_UPDATE=0
export GCLIENT_PY3=1
gclient --version

cat << EOF > .gclient
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "[email protected]:easion/engine.git@master",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
},
]
EOF

gclient sync --no-history --revision ${FLUTTER_ENGINE_SHA} -R -D -j ${NUM_PROC}
73 changes: 46 additions & 27 deletions impeller/renderer/backend/metal/allocator_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
static bool DeviceSupportsDeviceTransientTargets(id<MTLDevice> device) {
// Refer to the "Memoryless render targets" feature in the table below:
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(ios 13.0, tvos 13.0, macos 10.15, *)) {
return [device supportsFamily:MTLGPUFamilyApple2];
} else {
Expand All @@ -34,21 +35,29 @@ static bool DeviceSupportsDeviceTransientTargets(id<MTLDevice> device) {
return false;
#endif
}
#else
return [device supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily1_v1];;
#endif
FML_UNREACHABLE();
}

static bool DeviceHasUnifiedMemoryArchitecture(id<MTLDevice> device) {
if (@available(ios 13.0, tvos 13.0, macOS 10.15, *)) {
return [device hasUnifiedMemory];
} else {
#if FML_OS_IOS
// iOS devices where the availability check can fail always have had UMA.
return true;
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(ios 13.0, tvos 13.0, macOS 10.15, *)) {
return [device hasUnifiedMemory];
} else {
#if FML_OS_IOS
// iOS devices where the availability check can fail always have had UMA.
return true;
#else
// Mac devices where the availability check can fail have never had UMA.
return false;
#endif
}
#else
// Mac devices where the availability check can fail have never had UMA.
return false;
return false;
#endif
}

FML_UNREACHABLE();
}

Expand All @@ -59,27 +68,36 @@ ISize DeviceMaxTextureSizeSupported(id<MTLDevice> device) {
// According to the feature set table, there are two supported max sizes :
// 16384 and 8192 for devices flutter support. The former is used on macs and
// latest ios devices. The latter is used on old ios devices.
if (@available(macOS 10.15, iOS 13, tvOS 13, *)) {
if ([device supportsFamily:MTLGPUFamilyApple3] ||
[device supportsFamily:MTLGPUFamilyMacCatalyst1] ||
[device supportsFamily:MTLGPUFamilyMac1]) {
return {16384, 16384};
}
return {8192, 8192};
} else {
#if FML_OS_IOS
if ([device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1] ||
[device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) {
return {16384, 16384};
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(macOS 10.15, iOS 13, tvOS 13, *)) {
if ([device supportsFamily:MTLGPUFamilyApple3] ||
[device supportsFamily:MTLGPUFamilyMacCatalyst1] ||
[device supportsFamily:MTLGPUFamilyMac1]) {
return {16384, 16384};
}
return {8192, 8192};
} else {
#if FML_OS_IOS
if ([device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1] ||
[device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) {
return {16384, 16384};
}
#endif
#if FML_OS_MACOSX
return {16384, 16384};
#endif
return {8192, 8192};
}
#endif
#if FML_OS_MACOSX
#else
if ([device supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily2_v1])
return {16384, 16384};
#endif
else
return {8192, 8192};
}
#endif

}

#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
static bool SupportsLossyTextureCompression(id<MTLDevice> device) {
#ifdef FML_OS_IOS_SIMULATOR
return false;
Expand All @@ -90,6 +108,7 @@ static bool SupportsLossyTextureCompression(id<MTLDevice> device) {
return false;
#endif
}
#endif

void DebugAllocatorStats::Increment(size_t size) {
size_.fetch_add(size, std::memory_order_relaxed);
Expand Down Expand Up @@ -219,14 +238,14 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode,

mtl_texture_desc.storageMode = ToMTLStorageMode(
desc.storage_mode, supports_memoryless_targets_, supports_uma_);

#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(macOS 12.5, ios 15.0, *)) {
if (desc.compression_type == CompressionType::kLossy &&
SupportsLossyTextureCompression(device_)) {
mtl_texture_desc.compressionType = MTLTextureCompressionTypeLossy;
}
}

#endif
#ifdef IMPELLER_DEBUG
if (desc.storage_mode != StorageMode::kDeviceTransient) {
debug_allocater_->Increment(desc.GetByteSizeOfAllMipLevels());
Expand Down
11 changes: 8 additions & 3 deletions impeller/renderer/backend/metal/command_buffer_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace impeller {

// NOLINTEND(readability-identifier-naming)
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
API_AVAILABLE(ios(14.0), macos(11.0))
static NSString* MTLCommandEncoderErrorStateToString(
MTLCommandEncoderErrorState state) {
Expand All @@ -31,6 +33,9 @@
}
return @"unknown";
}
#endif

// NOLINTEND(readability-identifier-naming)

static NSString* MTLCommandBufferErrorToString(MTLCommandBufferError code) {
switch (code) {
Expand Down Expand Up @@ -84,7 +89,7 @@ static bool LogMTLCommandBufferErrorIfPresent(id<MTLCommandBuffer> buffer) {
.UTF8String
<< std::endl;
}

#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(iOS 14.0, macOS 11.0, *)) {
NSArray<id<MTLCommandBufferEncoderInfo>>* infos =
buffer.error.userInfo[MTLCommandBufferEncoderInfoErrorKey];
Expand All @@ -108,14 +113,14 @@ static bool LogMTLCommandBufferErrorIfPresent(id<MTLCommandBuffer> buffer) {
}
}
}

#endif
stream << "<<<<<<<";
VALIDATION_LOG << stream.str();
return false;
}

static id<MTLCommandBuffer> CreateCommandBuffer(id<MTLCommandQueue> queue) {
#ifndef FLUTTER_RELEASE
#if !defined(FLUTTER_RELEASE) && !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(iOS 14.0, macOS 11.0, *)) {
auto desc = [[MTLCommandBufferDescriptor alloc] init];
// Degrades CPU performance slightly but is well worth the cost for typical
Expand Down
23 changes: 16 additions & 7 deletions impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ static bool DeviceSupportsFramebufferFetch(id<MTLDevice> device) {
return false;
#else // FML_OS_IOS_SIMULATOR

#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(macOS 10.15, iOS 13, tvOS 13, *)) {
return [device supportsFamily:MTLGPUFamilyApple2];
}
#endif
// According to
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf , Apple2
// corresponds to iOS GPU family 2, which supports A8 devices.
#if FML_OS_IOS
return [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v1];
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
return [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v1];
#else
return [device supportsFeatureSet:MTLFeatureSet_tvOS_GPUFamily1_v1];
#endif
#else
return false;
#endif // FML_OS_IOS
Expand All @@ -43,12 +49,15 @@ static bool DeviceSupportsFramebufferFetch(id<MTLDevice> device) {

static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
bool supports_subgroups = false;
// Refer to the "SIMD-scoped reduction operations" feature in the table
// below: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
if (@available(ios 13.0, tvos 13.0, macos 10.15, *)) {
supports_subgroups = [device supportsFamily:MTLGPUFamilyApple7] ||
[device supportsFamily:MTLGPUFamilyMac2];
}
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
// Refer to the "SIMD-scoped reduction operations" feature in the table
// below: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
if (@available(ios 13.0, tvos 13.0, macos 10.15, *)) {
supports_subgroups = [device supportsFamily:MTLGPUFamilyApple7] ||
[device supportsFamily:MTLGPUFamilyMac2];
}
#endif

return supports_subgroups;
}

Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/backend/metal/sampler_library_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
desc.sAddressMode = ToMTLSamplerAddressMode(descriptor.width_address_mode);
desc.tAddressMode = ToMTLSamplerAddressMode(descriptor.height_address_mode);
desc.rAddressMode = ToMTLSamplerAddressMode(descriptor.depth_address_mode);
#if !(defined(TARGET_OS_TV) && TARGET_OS_TV)
if (@available(iOS 14.0, macos 10.12, *)) {
desc.borderColor = MTLSamplerBorderColorTransparentBlack;
}
#endif
#ifdef IMPELLER_DEBUG
if (!descriptor.label.empty()) {
desc.label = @(descriptor.label.data());
Expand Down
50 changes: 50 additions & 0 deletions ninja_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e
RED='\033[0;31m'
NOCOLOR='\033[0m'

if [[ $(uname -m) == "arm64" ]]; then
echo "Host: arm64"
GN_SIM_ARGS="--simulator-cpu=arm64"
GN_ARGS="--mac-cpu=arm64"
OUTPUT_POSTFIX="_arm64"
else
echo "Host: x64"
GN_SIM_ARGS=""
GN_ARGS=""
OUTPUT_POSTFIX=""
fi

if [[ "$1" == "clean" ]]; then
echo "Clean build ..."
rm -irf ./out/ios_debug_sim_unopt$OUTPUT_POSTFIX
rm -rf ./out/ios_debug_unopt$OUTPUT_POSTFIX
rm -rf ./out/ios_release$OUTPUT_POSTFIX
rm -rf ./out/host_debug_unopt$OUTPUT_POSTFIX
rm -rf ./out/host_release$OUTPUT_POSTFIX
fi

if [[ "$1" == "clean" ]] || [[ ! -d ./out/ios_debug_sim_unopt$OUTPUT_POSTFIX ]]; then
./flutter/tools/gn --ios --no-goma --simulator --unoptimized $GN_SIM_ARGS
fi
ninja -C out/ios_debug_sim_unopt$OUTPUT_POSTFIX

if [[ "$1" == "clean" ]] || [[ ! -d ./out/ios_debug_unopt$OUTPUT_POSTFIX ]]; then
./flutter/tools/gn --ios --no-goma --unoptimized $GN_ARGS
fi
ninja -C out/ios_debug_unopt$OUTPUT_POSTFIX

if [[ "$1" == "clean" ]] || [[ ! -d ./out/ios_release$OUTPUT_POSTFIX ]]; then
./flutter/tools/gn --ios --no-goma --runtime-mode=release $GN_ARGS
fi
ninja -C out/ios_release$OUTPUT_POSTFIX

if [[ "$1" == "clean" ]] || [[ ! -d ./out/host_debug_unopt$OUTPUT_POSTFIX ]]; then
./flutter/tools/gn --no-goma --unoptimized --no-prebuilt-dart-sdk $GN_ARGS
fi
ninja -C out/host_debug_unopt$OUTPUT_POSTFIX

if [[ "$1" == "clean" ]] || [[ ! -d ./out/host_release$OUTPUT_POSTFIX ]]; then
./flutter/tools/gn --no-goma --no-lto --runtime-mode=release --no-prebuilt-dart-sdk $GN_ARGS
fi
ninja -C out/host_release$OUTPUT_POSTFIX
10 changes: 6 additions & 4 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,17 @@ source_set("flutter_framework_source") {
"AudioToolbox.framework",
"CoreMedia.framework",
"CoreVideo.framework",
"IOSurface.framework",
"QuartzCore.framework",
"WebKit.framework",
"MediaPlayer.framework",
"IOSurface.framework",
#"WebKit.framework",
"UIKit.framework",
"GameController.framework",
]
if (flutter_runtime_mode == "profile" || flutter_runtime_mode == "debug") {
# This is required by the profiler_metrics_ios.mm to get GPU statistics.
# Usage in release builds will cause rejection from the App Store.
frameworks += [ "IOKit.framework" ]
# frameworks += [ "IOKit.framework" ]
}

deps = [
Expand Down Expand Up @@ -205,7 +207,7 @@ shared_library("ios_test_flutter") {
cflags = [
"-fvisibility=default",
"-F$platform_frameworks_path",
"-mios-simulator-version-min=$ios_testing_deployment_target",
"-mtvos-simulator-version-min=$ios_testing_deployment_target",
]

ldflags = [
Expand Down
Loading