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.
This commit is contained in:
Dan Field 2024-01-31 13:30:02 -08:00 committed by GitHub
parent ceab0e005f
commit c417c4623c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 250 additions and 226 deletions

View file

@ -15,7 +15,6 @@ import '../exceptions.dart';
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 @@ abstract class AndroidAssetBundle extends Target {
outputDirectory,
targetPlatform: TargetPlatform.android,
buildMode: buildMode,
shaderTarget: ShaderTarget.impellerAndroid,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(

View file

@ -32,7 +32,6 @@ Future<Depfile> copyAssets(
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 @@ Future<Depfile> copyAssets(
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 @@ class CopyAssets extends Target {
environment,
output,
targetPlatform: TargetPlatform.android,
shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(

View file

@ -79,7 +79,6 @@ class CopyFlutterBundle extends Target {
environment.outputDir,
targetPlatform: TargetPlatform.android,
buildMode: buildMode,
shaderTarget: ShaderTarget.sksl,
flavor: flavor,
);
environment.depFileService.writeToFile(

View file

@ -503,9 +503,6 @@ abstract class IosAssetBundle extends Target {
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,

View file

@ -15,7 +15,6 @@ import 'assets.dart';
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 @@ abstract class BundleLinuxAssets extends Target {
additionalContent: <String, DevFSContent>{
'version.json': DevFSStringContent(versionInfo),
},
shaderTarget: ShaderTarget.sksl,
);
environment.depFileService.writeToFile(
depfile,

View file

@ -18,7 +18,6 @@ import '../exceptions.dart';
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 @@ abstract class MacOSBundleFlutterAssets extends Target {
environment,
assetDirectory,
targetPlatform: TargetPlatform.darwin,
shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor],
);
environment.depFileService.writeToFile(

View file

@ -17,21 +17,8 @@ import '../../base/logger.dart';
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 @@ class DevelopmentShaderCompiler {
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 @@ class DevelopmentShaderCompiler {
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 @@ class ShaderCompiler {
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 @@ class ShaderCompiler {
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 @@ class ShaderCompiler {
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',

View file

@ -28,7 +28,6 @@ import '../depfile.dart';
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 @@ class WebReleaseBundle extends Target {
environment,
environment.outputDir.childDirectory('assets'),
targetPlatform: TargetPlatform.web_javascript,
shaderTarget: ShaderTarget.sksl,
);
final DepfileService depfileService = environment.depFileService;
depfileService.writeToFile(

View file

@ -12,7 +12,6 @@ import 'assets.dart';
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 @@ abstract class BundleWindowsAssets extends Target {
environment,
outputDirectory,
targetPlatform: targetPlatform,
shaderTarget: ShaderTarget.sksl,
);
environment.depFileService.writeToFile(
depfile,

View file

@ -169,11 +169,6 @@ Future<void> writeBundle(
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 @@ Future<void> writeBundle(
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(

View file

@ -268,10 +268,7 @@ class HotRunner extends ResidentRunner {
await device!.initLogReader();
device
.developmentShaderCompiler
.configureCompiler(
device.targetPlatform,
impellerStatus: debuggingOptions.enableImpeller,
);
.configureCompiler(device.targetPlatform);
}
try {
final List<Uri?> baseUris = await _initDevFS();

View file

@ -672,6 +672,8 @@ flutter:
command: <String>[
impellerc,
'--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputPath.spirv',

View file

@ -535,6 +535,7 @@ void main() {
processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
'--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',

View file

@ -287,6 +287,7 @@ void main() {
processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
'--sksl',
'--runtime-stage-metal',
'--iplr',
'--sl=/App.framework/flutter_assets/shader.glsl',

View file

@ -11,7 +11,6 @@ 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/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart';
@ -40,13 +39,14 @@ void main() {
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 @@ void main() {
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
target: ShaderTarget.sksl,
json: false,
targetPlatform: TargetPlatform.web_javascript,
),
true,
);
@ -85,6 +84,7 @@ void main() {
FakeCommand(
command: <String>[
impellerc,
'--sksl',
'--runtime-stage-metal',
'--iplr',
'--sl=$outputPath',
@ -110,8 +110,7 @@ void main() {
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
target: ShaderTarget.impelleriOS,
json: false,
targetPlatform: TargetPlatform.ios,
),
true,
);
@ -123,6 +122,7 @@ void main() {
FakeCommand(
command: <String>[
impellerc,
'--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
@ -149,8 +149,7 @@ void main() {
await shaderCompiler.compileShader(
input: fileSystem.file(fragPath),
outputPath: outputPath,
target: ShaderTarget.impellerAndroid,
json: false,
targetPlatform: TargetPlatform.android,
),
true,
);
@ -164,6 +163,7 @@ void main() {
impellerc,
'--sksl',
'--iplr',
'--json',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
@ -188,8 +188,7 @@ void main() {
await shaderCompiler.compileShader(
input: fileSystem.file(notFragPath),
outputPath: outputPath,
target: ShaderTarget.sksl,
json: false,
targetPlatform: TargetPlatform.web_javascript,
),
true,
);
@ -204,6 +203,7 @@ void main() {
impellerc,
'--sksl',
'--iplr',
'--json',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
@ -227,8 +227,7 @@ void main() {
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 @@ void main() {
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 @@ void main() {
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 @@ void main() {
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)));

View file

@ -279,10 +279,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -20,7 +20,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/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 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) async {

View file

@ -967,10 +967,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -2957,10 +2957,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -1756,10 +1756,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -1475,10 +1475,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -16,7 +16,6 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
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 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler();
@override
void configureCompiler(
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
void configureCompiler(TargetPlatform? platform) { }
@override
Future<DevFSContent> recompileShader(DevFSContent inputShader) {

View file

@ -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 @@ void main() {
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 @@ void main() {
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);