Refactor ShaderTarget to not explicitly mention impeller or Skia (#141460)
Refactors `ShaderTarget` to make it opaque as to whether it's using Impeller or SkSL and instead has it focus on the target platform it's generating for.
ImpellerC includes SkSL right now whether you ask for it or not.
The tester target also might need SkSL or Vulkan depending on whether `--enable-impeller` is passed.
diff --git a/packages/flutter_tools/lib/src/build_system/targets/android.dart b/packages/flutter_tools/lib/src/build_system/targets/android.dart
index 8254234..d1b7dc6 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/android.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/android.dart
@@ -15,7 +15,6 @@
import 'assets.dart';
import 'common.dart';
import 'icon_tree_shaker.dart';
-import 'shader_compiler.dart';
/// Prepares the asset bundle in the format expected by flutter.gradle.
///
@@ -68,7 +67,6 @@
outputDirectory,
targetPlatform: TargetPlatform.android,
buildMode: buildMode,
- shaderTarget: ShaderTarget.impellerAndroid,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(
diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart
index a8a96e7..8b5d827 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart
@@ -32,7 +32,6 @@
Map<String, DevFSContent> additionalContent = const <String, DevFSContent>{},
required TargetPlatform targetPlatform,
BuildMode? buildMode,
- required ShaderTarget shaderTarget,
List<File> additionalInputs = const <File>[],
String? flavor,
}) async {
@@ -140,8 +139,7 @@
doCopy = !await shaderCompiler.compileShader(
input: content.file as File,
outputPath: file.path,
- target: shaderTarget,
- json: targetPlatform == TargetPlatform.web_javascript,
+ targetPlatform: targetPlatform,
);
case AssetKind.model:
doCopy = !await sceneImporter.importScene(
@@ -328,7 +326,6 @@
environment,
output,
targetPlatform: TargetPlatform.android,
- shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(
diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart
index fda26a4..46f35b7 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/common.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart
@@ -79,7 +79,6 @@
environment.outputDir,
targetPlatform: TargetPlatform.android,
buildMode: buildMode,
- shaderTarget: ShaderTarget.sksl,
flavor: flavor,
);
environment.depFileService.writeToFile(
diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart
index 0b8ddfb..f05a91e 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart
@@ -503,9 +503,6 @@
environment,
assetDirectory,
targetPlatform: TargetPlatform.ios,
- // Always specify an impeller shader target so that we support runtime toggling and
- // the --enable-impeller debug flag.
- shaderTarget: ShaderTarget.impelleriOS,
additionalInputs: <File>[
flutterProject.ios.infoPlist,
flutterProject.ios.appFrameworkInfoPlist,
diff --git a/packages/flutter_tools/lib/src/build_system/targets/linux.dart b/packages/flutter_tools/lib/src/build_system/targets/linux.dart
index 0c7e1d8..bc446c5 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/linux.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/linux.dart
@@ -15,7 +15,6 @@
import 'common.dart';
import 'desktop.dart';
import 'icon_tree_shaker.dart';
-import 'shader_compiler.dart';
/// The only files/subdirectories we care out.
const List<String> _kLinuxArtifacts = <String>[
@@ -141,7 +140,6 @@
additionalContent: <String, DevFSContent>{
'version.json': DevFSStringContent(versionInfo),
},
- shaderTarget: ShaderTarget.sksl,
);
environment.depFileService.writeToFile(
depfile,
diff --git a/packages/flutter_tools/lib/src/build_system/targets/macos.dart b/packages/flutter_tools/lib/src/build_system/targets/macos.dart
index 0881169..7f69f52 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/macos.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/macos.dart
@@ -18,7 +18,6 @@
import 'assets.dart';
import 'common.dart';
import 'icon_tree_shaker.dart';
-import 'shader_compiler.dart';
/// Copy the macOS framework to the correct copy dir by invoking 'rsync'.
///
@@ -439,7 +438,6 @@
environment,
assetDirectory,
targetPlatform: TargetPlatform.darwin,
- shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(
diff --git a/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart b/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
index c03ef89..4c9d48f 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
@@ -17,21 +17,8 @@
import '../../build_info.dart';
import '../../convert.dart';
import '../../devfs.dart';
-import '../../device.dart';
import '../build_system.dart';
-/// The output shader format that should be used by the [ShaderCompiler].
-enum ShaderTarget {
- impellerAndroid(<String>['--runtime-stage-gles', '--runtime-stage-vulkan']),
- impelleriOS(<String>['--runtime-stage-metal']),
- impellerSwiftShader(<String>['--runtime-stage-vulkan']),
- sksl(<String>['--sksl']);
-
- const ShaderTarget(this.stages);
-
- final List<String> stages;
-}
-
/// A wrapper around [ShaderCompiler] to support hot reload of shader sources.
class DevelopmentShaderCompiler {
DevelopmentShaderCompiler({
@@ -47,42 +34,16 @@
final Pool _compilationPool = Pool(4);
final math.Random _random;
- late ShaderTarget _shaderTarget;
+ late TargetPlatform _targetPlatform;
bool _debugConfigured = false;
- bool _jsonMode = false;
/// Configure the output format of the shader compiler for a particular
/// flutter device.
- void configureCompiler(TargetPlatform? platform, { required ImpellerStatus impellerStatus }) {
- switch (platform) {
- case TargetPlatform.ios:
- _shaderTarget = ShaderTarget.impelleriOS;
- case TargetPlatform.android_arm64:
- case TargetPlatform.android_x64:
- case TargetPlatform.android_x86:
- case TargetPlatform.android_arm:
- case TargetPlatform.android:
- _shaderTarget = impellerStatus == ImpellerStatus.enabled
- ? ShaderTarget.impellerAndroid
- : ShaderTarget.sksl;
- case TargetPlatform.darwin:
- case TargetPlatform.linux_x64:
- case TargetPlatform.linux_arm64:
- case TargetPlatform.windows_x64:
- case TargetPlatform.windows_arm64:
- case TargetPlatform.fuchsia_arm64:
- case TargetPlatform.fuchsia_x64:
- case TargetPlatform.tester:
- _shaderTarget = impellerStatus == ImpellerStatus.enabled
- ? ShaderTarget.impellerSwiftShader
- : ShaderTarget.sksl;
- case TargetPlatform.web_javascript:
- assert(impellerStatus != ImpellerStatus.enabled);
- _shaderTarget = ShaderTarget.sksl;
- _jsonMode = true;
- case null:
- return;
+ void configureCompiler(TargetPlatform? platform) {
+ if (platform == null) {
+ return;
}
+ _targetPlatform = platform;
_debugConfigured = true;
}
@@ -107,9 +68,8 @@
final bool success = await _shaderCompiler.compileShader(
input: inputFile,
outputPath: output.path,
- target: _shaderTarget,
+ targetPlatform: _targetPlatform,
fatal: false,
- json: _jsonMode,
);
if (!success) {
return null;
@@ -144,6 +104,34 @@
final FileSystem _fs;
final Artifacts _artifacts;
+ List<String> _shaderTargetsFromTargetPlatform(TargetPlatform targetPlatform) {
+ switch (targetPlatform) {
+ case TargetPlatform.android_x64:
+ case TargetPlatform.android_x86:
+ case TargetPlatform.android_arm:
+ case TargetPlatform.android_arm64:
+ case TargetPlatform.android:
+ case TargetPlatform.linux_x64:
+ case TargetPlatform.linux_arm64:
+ case TargetPlatform.windows_x64:
+ case TargetPlatform.windows_arm64:
+ return <String>['--sksl', '--runtime-stage-gles', '--runtime-stage-vulkan'];
+
+ case TargetPlatform.ios:
+ case TargetPlatform.darwin:
+ return <String>['--sksl', '--runtime-stage-metal'];
+
+ case TargetPlatform.fuchsia_arm64:
+ case TargetPlatform.fuchsia_x64:
+ case TargetPlatform.tester:
+ return <String>['--sksl', '--runtime-stage-vulkan'];
+
+ case TargetPlatform.web_javascript:
+ return <String>['--sksl'];
+
+ }
+ }
+
/// The [Source] inputs that targets using this should depend on.
///
/// See [Target.inputs].
@@ -163,9 +151,8 @@
Future<bool> compileShader({
required File input,
required String outputPath,
- required ShaderTarget target,
+ required TargetPlatform targetPlatform,
bool fatal = true,
- required bool json,
}) async {
final File impellerc = _fs.file(
_artifacts.getHostArtifact(HostArtifact.impellerc),
@@ -180,9 +167,9 @@
final String shaderLibPath = _fs.path.join(impellerc.parent.absolute.path, 'shader_lib');
final List<String> cmd = <String>[
impellerc.path,
- ...target.stages,
+ ..._shaderTargetsFromTargetPlatform(targetPlatform),
'--iplr',
- if (json)
+ if (targetPlatform == TargetPlatform.web_javascript)
'--json',
'--sl=$outputPath',
'--spirv=$outputPath.spirv',
diff --git a/packages/flutter_tools/lib/src/build_system/targets/web.dart b/packages/flutter_tools/lib/src/build_system/targets/web.dart
index 0c650b9..28413c4 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/web.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/web.dart
@@ -28,7 +28,6 @@
import '../exceptions.dart';
import 'assets.dart';
import 'localizations.dart';
-import 'shader_compiler.dart';
/// Whether the application has web plugins.
const String kHasWebPlugins = 'HasWebPlugins';
@@ -395,7 +394,6 @@
environment,
environment.outputDir.childDirectory('assets'),
targetPlatform: TargetPlatform.web_javascript,
- shaderTarget: ShaderTarget.sksl,
);
final DepfileService depfileService = environment.depFileService;
depfileService.writeToFile(
diff --git a/packages/flutter_tools/lib/src/build_system/targets/windows.dart b/packages/flutter_tools/lib/src/build_system/targets/windows.dart
index 983eb5c..ada0afe 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/windows.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/windows.dart
@@ -12,7 +12,6 @@
import 'common.dart';
import 'desktop.dart';
import 'icon_tree_shaker.dart';
-import 'shader_compiler.dart';
/// The only files/subdirectories we care about.
const List<String> _kWindowsArtifacts = <String>[
@@ -143,7 +142,6 @@
environment,
outputDirectory,
targetPlatform: targetPlatform,
- shaderTarget: ShaderTarget.sksl,
);
environment.depFileService.writeToFile(
depfile,
diff --git a/packages/flutter_tools/lib/src/bundle_builder.dart b/packages/flutter_tools/lib/src/bundle_builder.dart
index b2fb4ce..f8d204d 100644
--- a/packages/flutter_tools/lib/src/bundle_builder.dart
+++ b/packages/flutter_tools/lib/src/bundle_builder.dart
@@ -169,11 +169,6 @@
artifacts: globals.artifacts!,
);
- ShaderTarget shaderTarget = ShaderTarget.sksl;
- if (targetPlatform == TargetPlatform.tester && impellerStatus == ImpellerStatus.enabled) {
- shaderTarget = ShaderTarget.impellerSwiftShader;
- }
-
// Limit number of open files to avoid running out of file descriptors.
final Pool pool = Pool(64);
await Future.wait<void>(
@@ -200,8 +195,7 @@
doCopy = !await shaderCompiler.compileShader(
input: input,
outputPath: file.path,
- target: shaderTarget,
- json: targetPlatform == TargetPlatform.web_javascript,
+ targetPlatform: targetPlatform,
);
case AssetKind.model:
doCopy = !await sceneImporter.importScene(
diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart
index 12d8aaf..5f7cc6a 100644
--- a/packages/flutter_tools/lib/src/run_hot.dart
+++ b/packages/flutter_tools/lib/src/run_hot.dart
@@ -268,10 +268,7 @@
await device!.initLogReader();
device
.developmentShaderCompiler
- .configureCompiler(
- device.targetPlatform,
- impellerStatus: debuggingOptions.enableImpeller,
- );
+ .configureCompiler(device.targetPlatform);
}
try {
final List<Uri?> baseUris = await _initDevFS();
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
index 3ea8959..1a9f02e 100644
--- a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
@@ -672,6 +672,8 @@
command: <String>[
impellerc,
'--sksl',
+ '--runtime-stage-gles',
+ '--runtime-stage-vulkan',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputPath.spirv',
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
index 21c8b0f..a69aeed 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
@@ -535,6 +535,7 @@
processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
+ '--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
index ccffea1..33bf54e 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
@@ -287,6 +287,7 @@
processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
+ '--sksl',
'--runtime-stage-metal',
'--iplr',
'--sl=/App.framework/flutter_assets/shader.glsl',
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart
index bf238eb..a1b6cec 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart
@@ -11,7 +11,6 @@
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/devfs.dart';
-import 'package:flutter_tools/src/device.dart';
import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart';
@@ -40,13 +39,14 @@
fileSystem.file(notFragPath).createSync(recursive: true);
});
- testWithoutContext('compileShader invokes impellerc for .frag files and sksl target', () async {
+ testWithoutContext('compileShader invokes impellerc for .frag files and web target', () async {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: <String>[
impellerc,
'--sksl',
'--iplr',
+ '--json',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$fragPath',
@@ -71,8 +71,7 @@
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
- target: ShaderTarget.sksl,
- json: false,
+ targetPlatform: TargetPlatform.web_javascript,
),
true,
);
@@ -85,6 +84,7 @@
FakeCommand(
command: <String>[
impellerc,
+ '--sksl',
'--runtime-stage-metal',
'--iplr',
'--sl=$outputPath',
@@ -110,8 +110,7 @@
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
- target: ShaderTarget.impelleriOS,
- json: false,
+ targetPlatform: TargetPlatform.ios,
),
true,
);
@@ -123,6 +122,7 @@
FakeCommand(
command: <String>[
impellerc,
+ '--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
@@ -149,8 +149,7 @@
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
- target: ShaderTarget.impellerAndroid,
- json: false,
+ targetPlatform: TargetPlatform.android,
),
true,
);
@@ -164,6 +163,7 @@
impellerc,
'--sksl',
'--iplr',
+ '--json',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
@@ -188,8 +188,7 @@
await shaderCompiler.compileShader(
input: fileSystem.file(notFragPath),
outputPath: outputPath,
- target: ShaderTarget.sksl,
- json: false,
+ targetPlatform: TargetPlatform.web_javascript,
),
true,
);
@@ -204,6 +203,7 @@
impellerc,
'--sksl',
'--iplr',
+ '--json',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
@@ -227,8 +227,7 @@
await shaderCompiler.compileShader(
input: fileSystem.file(notFragPath),
outputPath: outputPath,
- target: ShaderTarget.sksl,
- json: false,
+ targetPlatform: TargetPlatform.web_javascript,
);
fail('unreachable');
} on ShaderCompilerException catch (e) {
@@ -245,100 +244,6 @@
command: <String>[
impellerc,
'--sksl',
- '--iplr',
- '--sl=/.tmp_rand0/0.8255140718871702.temp',
- '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
- '--input=$fragPath',
- '--input-type=frag',
- '--include=$fragDir',
- '--include=$shaderLibDir',
- ],
- onRun: (_) {
- fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
- fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
- ..createSync()
- ..writeAsBytesSync(<int>[1, 2, 3, 4]);
- }
- ),
- ]);
- fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
- final ShaderCompiler shaderCompiler = ShaderCompiler(
- processManager: processManager,
- logger: logger,
- fileSystem: fileSystem,
- artifacts: artifacts,
- );
- final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
- shaderCompiler: shaderCompiler,
- fileSystem: fileSystem,
- random: math.Random(0),
- );
-
- developmentShaderCompiler.configureCompiler(
- TargetPlatform.android,
- impellerStatus: ImpellerStatus.disabled,
- );
-
- final DevFSContent? content = await developmentShaderCompiler
- .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
-
- expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
- expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv'), isNot(exists));
- expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp'), isNot(exists));
- });
-
- testWithoutContext('DevelopmentShaderCompiler can compile for Flutter Tester with Impeller and Vulkan', () async {
- final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
- FakeCommand(
- command: <String>[
- impellerc,
- '--runtime-stage-vulkan',
- '--iplr',
- '--sl=/.tmp_rand0/0.8255140718871702.temp',
- '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
- '--input=$fragPath',
- '--input-type=frag',
- '--include=$fragDir',
- '--include=$shaderLibDir',
- ],
- onRun: (_) {
- fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
- fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
- ..createSync()
- ..writeAsBytesSync(<int>[1, 2, 3, 4]);
- }
- ),
- ]);
- fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
- final ShaderCompiler shaderCompiler = ShaderCompiler(
- processManager: processManager,
- logger: logger,
- fileSystem: fileSystem,
- artifacts: artifacts,
- );
- final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
- shaderCompiler: shaderCompiler,
- fileSystem: fileSystem,
- random: math.Random(0),
- );
-
- developmentShaderCompiler.configureCompiler(
- TargetPlatform.tester,
- impellerStatus: ImpellerStatus.enabled,
- );
-
- final DevFSContent? content = await developmentShaderCompiler
- .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
-
- expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
- expect(processManager.hasRemainingExpectations, false);
- });
-
- testWithoutContext('DevelopmentShaderCompiler can compile for android with impeller', () async {
- final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
- FakeCommand(
- command: <String>[
- impellerc,
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
@@ -370,10 +275,191 @@
random: math.Random(0),
);
- developmentShaderCompiler.configureCompiler(
- TargetPlatform.android,
- impellerStatus: ImpellerStatus.enabled,
+ developmentShaderCompiler.configureCompiler(TargetPlatform.android);
+
+ final DevFSContent? content = await developmentShaderCompiler
+ .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
+
+ expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
+ expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv'), isNot(exists));
+ expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp'), isNot(exists));
+ });
+
+ testWithoutContext('DevelopmentShaderCompiler can compile for Flutter Tester with Impeller and Vulkan', () async {
+ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
+ FakeCommand(
+ command: <String>[
+ impellerc,
+ '--sksl',
+ '--runtime-stage-vulkan',
+ '--iplr',
+ '--sl=/.tmp_rand0/0.8255140718871702.temp',
+ '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
+ '--input=$fragPath',
+ '--input-type=frag',
+ '--include=$fragDir',
+ '--include=$shaderLibDir',
+ ],
+ onRun: (_) {
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
+ ..createSync()
+ ..writeAsBytesSync(<int>[1, 2, 3, 4]);
+ }
+ ),
+ ]);
+ fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
+ final ShaderCompiler shaderCompiler = ShaderCompiler(
+ processManager: processManager,
+ logger: logger,
+ fileSystem: fileSystem,
+ artifacts: artifacts,
);
+ final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
+ shaderCompiler: shaderCompiler,
+ fileSystem: fileSystem,
+ random: math.Random(0),
+ );
+
+ developmentShaderCompiler.configureCompiler(TargetPlatform.tester);
+
+ final DevFSContent? content = await developmentShaderCompiler
+ .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
+
+ expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
+ expect(processManager.hasRemainingExpectations, false);
+ });
+
+ testWithoutContext('DevelopmentShaderCompiler can compile for android with impeller', () async {
+ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
+ FakeCommand(
+ command: <String>[
+ impellerc,
+ '--sksl',
+ '--runtime-stage-gles',
+ '--runtime-stage-vulkan',
+ '--iplr',
+ '--sl=/.tmp_rand0/0.8255140718871702.temp',
+ '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
+ '--input=$fragPath',
+ '--input-type=frag',
+ '--include=$fragDir',
+ '--include=$shaderLibDir',
+ ],
+ onRun: (_) {
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
+ ..createSync()
+ ..writeAsBytesSync(<int>[1, 2, 3, 4]);
+ }
+ ),
+ ]);
+ fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
+ final ShaderCompiler shaderCompiler = ShaderCompiler(
+ processManager: processManager,
+ logger: logger,
+ fileSystem: fileSystem,
+ artifacts: artifacts,
+ );
+ final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
+ shaderCompiler: shaderCompiler,
+ fileSystem: fileSystem,
+ random: math.Random(0),
+ );
+
+ developmentShaderCompiler.configureCompiler(TargetPlatform.android);
+
+ final DevFSContent? content = await developmentShaderCompiler
+ .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
+
+ expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
+ expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv'), isNot(exists));
+ expect(fileSystem.file('/.tmp_rand0/0.8255140718871702.temp'), isNot(exists));
+ });
+
+ testWithoutContext('DevelopmentShaderCompiler can compile for Flutter Tester with Impeller and Vulkan', () async {
+ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
+ FakeCommand(
+ command: <String>[
+ impellerc,
+ '--sksl',
+ '--runtime-stage-vulkan',
+ '--iplr',
+ '--sl=/.tmp_rand0/0.8255140718871702.temp',
+ '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
+ '--input=$fragPath',
+ '--input-type=frag',
+ '--include=$fragDir',
+ '--include=$shaderLibDir',
+ ],
+ onRun: (List<String> args) {
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
+ ..createSync()
+ ..writeAsBytesSync(<int>[1, 2, 3, 4]);
+ }
+ ),
+ ]);
+ fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
+ final ShaderCompiler shaderCompiler = ShaderCompiler(
+ processManager: processManager,
+ logger: logger,
+ fileSystem: fileSystem,
+ artifacts: artifacts,
+ );
+ final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
+ shaderCompiler: shaderCompiler,
+ fileSystem: fileSystem,
+ random: math.Random(0),
+ );
+
+ developmentShaderCompiler.configureCompiler(TargetPlatform.tester);
+
+ final DevFSContent? content = await developmentShaderCompiler
+ .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
+
+ expect(await content!.contentsAsBytes(), <int>[1, 2, 3, 4]);
+ expect(processManager.hasRemainingExpectations, false);
+ });
+
+ testWithoutContext('DevelopmentShaderCompiler can compile for android with impeller', () async {
+ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
+ FakeCommand(
+ command: <String>[
+ impellerc,
+ '--sksl',
+ '--runtime-stage-gles',
+ '--runtime-stage-vulkan',
+ '--iplr',
+ '--sl=/.tmp_rand0/0.8255140718871702.temp',
+ '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
+ '--input=$fragPath',
+ '--input-type=frag',
+ '--include=$fragDir',
+ '--include=$shaderLibDir',
+ ],
+ onRun: (List<String> args) {
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp.spirv').createSync();
+ fileSystem.file('/.tmp_rand0/0.8255140718871702.temp')
+ ..createSync()
+ ..writeAsBytesSync(<int>[1, 2, 3, 4]);
+ }
+ ),
+ ]);
+ fileSystem.file(fragPath).writeAsBytesSync(<int>[1, 2, 3, 4]);
+ final ShaderCompiler shaderCompiler = ShaderCompiler(
+ processManager: processManager,
+ logger: logger,
+ fileSystem: fileSystem,
+ artifacts: artifacts,
+ );
+ final DevelopmentShaderCompiler developmentShaderCompiler = DevelopmentShaderCompiler(
+ shaderCompiler: shaderCompiler,
+ fileSystem: fileSystem,
+ random: math.Random(0),
+ );
+
+ developmentShaderCompiler.configureCompiler(TargetPlatform.android);
final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
@@ -419,10 +505,7 @@
random: math.Random(0),
);
- developmentShaderCompiler.configureCompiler(
- TargetPlatform.web_javascript,
- impellerStatus: ImpellerStatus.disabled,
- );
+ developmentShaderCompiler.configureCompiler(TargetPlatform.web_javascript);
final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart
index 7ebb61a..7b81905 100644
--- a/packages/flutter_tools/test/general.shard/cold_test.dart
+++ b/packages/flutter_tools/test/general.shard/cold_test.dart
@@ -279,10 +279,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart
index 475a208..63473bd 100644
--- a/packages/flutter_tools/test/general.shard/devfs_test.dart
+++ b/packages/flutter_tools/test/general.shard/devfs_test.dart
@@ -20,7 +20,6 @@
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
-import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:package_config/package_config.dart';
import 'package:test/fake.dart';
@@ -831,10 +830,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) async {
diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart
index 327c686..df9becf 100644
--- a/packages/flutter_tools/test/general.shard/hot_test.dart
+++ b/packages/flutter_tools/test/general.shard/hot_test.dart
@@ -967,10 +967,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart
index 497fd3b..5e6834c 100644
--- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart
@@ -2957,10 +2957,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
index 592d75b..00c0bbb 100644
--- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
@@ -1756,10 +1756,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart
index 87ab451..cdc19c2 100644
--- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart
+++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart
@@ -1475,10 +1475,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
index 7a9ce04..5034959 100644
--- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
@@ -16,7 +16,6 @@
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/devfs.dart';
-import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/html_utils.dart';
import 'package:flutter_tools/src/isolated/devfs_web.dart';
@@ -1309,10 +1308,7 @@
const FakeShaderCompiler();
@override
- void configureCompiler(
- TargetPlatform? platform, {
- required ImpellerStatus impellerStatus,
- }) { }
+ void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {
diff --git a/packages/flutter_tools/test/integration.shard/shader_compiler_test.dart b/packages/flutter_tools/test/integration.shard/shader_compiler_test.dart
index 53a3bb3..b0da068 100644
--- a/packages/flutter_tools/test/integration.shard/shader_compiler_test.dart
+++ b/packages/flutter_tools/test/integration.shard/shader_compiler_test.dart
@@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
+import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
@@ -32,8 +33,7 @@
await shaderCompiler.compileShader(
input: file,
outputPath: tmpDir.childFile('test_shader.frag.out').path,
- target: ShaderTarget.sksl,
- json: false,
+ targetPlatform: TargetPlatform.tester,
);
}
@@ -62,8 +62,7 @@
final bool compileResult = await shaderCompiler.compileShader(
input: globals.fs.file(inkSparklePath),
outputPath: inkSparkleOutputPath,
- target: ShaderTarget.sksl,
- json: false,
+ targetPlatform: TargetPlatform.tester,
);
final File resultFile = globals.fs.file(inkSparkleOutputPath);