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

Commit cc2f55d

Browse files
authored
[Impeller] Cleanup shader generation and specify min macOS version. (#37952)
* [Impeller] Cleanup shader generation and specify min macOS version. We used to add workarounds for flutter/flutter#106066. However, that issue has been resolved. But the workarounds made it so that unopt local engine builds would build inconsistent shaders. Also, the mac builds would specify the iOS as well mac shader standards to the compiler. The mac target also never got a min OS version. The script has been cleaned up for readability. * Format.
1 parent ab8f921 commit cc2f55d

File tree

2 files changed

+19
-43
lines changed

2 files changed

+19
-43
lines changed

impeller/tools/build_metal_library.py

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ def main():
3838
required=True,
3939
help='The source file to compile. Can be specified multiple times.'
4040
)
41-
parser.add_argument(
42-
'--optimize',
43-
action='store_true',
44-
default=False,
45-
help='If available optimizations must be applied to the compiled Metal sources.'
46-
)
4741
parser.add_argument(
4842
'--platform',
4943
required=True,
@@ -59,73 +53,59 @@ def main():
5953
'xcrun',
6054
]
6155

56+
# Select the SDK.
57+
command += ['-sdk']
6258
if args.platform == 'mac':
6359
command += [
64-
'-sdk',
6560
'macosx',
6661
]
6762
elif args.platform == 'ios':
6863
command += [
69-
'-sdk',
7064
'iphoneos',
7165
]
7266
elif args.platform == 'ios-simulator':
7367
command += [
74-
'-sdk',
7568
'iphonesimulator',
7669
]
70+
else:
71+
raise 'Unknown target platform'
7772

7873
command += [
7974
'metal',
80-
# These warnings are from generated code and would make no sense to the GLSL
81-
# author.
75+
# These warnings are from generated code and would make no sense to the
76+
# GLSL author.
8277
'-Wno-unused-variable',
8378
# Both user and system header will be tracked.
8479
'-MMD',
80+
# Like -Os (and thus -O2), but reduces code size further.
81+
'-Oz',
82+
# Allow aggressive, lossy floating-point optimizations.
83+
'-ffast-math',
8584
'-MF',
8685
args.depfile,
8786
'-o',
8887
args.output,
8988
]
9089

90+
# Select the Metal standard and the minimum supported OS versions.
9191
# The Metal standard must match the specification in impellerc.
9292
if args.platform == 'mac':
9393
command += [
9494
'--std=macos-metal1.2',
95+
'-mmacos-version-min=10.14',
9596
]
96-
97-
if args.optimize:
97+
elif args.platform == 'ios':
9898
command += [
99-
# Like -Os (and thus -O2), but reduces code size further.
100-
'-Oz',
101-
# Allow aggressive, lossy floating-point optimizations.
102-
'-ffast-math',
103-
# limiting to ios-metal1.2 disables shader debug symbols, only
104-
# enabling these in optimize mode.
105-
# see https://github.com/flutter/flutter/issues/106066
10699
'--std=ios-metal1.2',
100+
'-mios-version-min=10.0',
107101
]
108-
if args.platform == 'ios':
109-
command += [
110-
'-mios-version-min=10.0',
111-
]
112-
elif args.platform == 'ios-simulator':
113-
command += [
114-
'-miphonesimulator-version-min=11.0',
115-
]
116-
else:
102+
elif args.platform == 'ios-simulator':
117103
command += [
118-
# Embeds both sources and driver options in the output. This aids in
119-
# debugging but should be removed from release builds.
120-
# TODO(chinmaygarde): Use -frecord-sources when CI upgrades to
121-
# Xcode 13.
122-
'-MO',
123-
# Assist the sampling profiler.
124-
'-gline-tables-only',
125-
'-g',
126-
# Optimize for debuggability.
127-
'-Og',
104+
'--std=ios-metal1.2',
105+
'-miphonesimulator-version-min=11.0',
128106
]
107+
else:
108+
raise 'Unknown target platform'
129109

130110
command += args.source
131111

impeller/tools/impeller.gni

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ template("metal_library") {
135135
rebase_path(depfile),
136136
]
137137

138-
if (!is_debug) {
139-
args += [ "--optimize" ]
140-
}
141-
142138
if (is_ios) {
143139
if (use_ios_simulator) {
144140
args += [ "--platform=ios-simulator" ]

0 commit comments

Comments
 (0)