Unverified Commit c417c462 authored by Dan Field's avatar Dan Field Committed by GitHub

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.
parent ceab0e00
...@@ -15,7 +15,6 @@ import '../exceptions.dart'; ...@@ -15,7 +15,6 @@ import '../exceptions.dart';
import 'assets.dart'; import 'assets.dart';
import 'common.dart'; import 'common.dart';
import 'icon_tree_shaker.dart'; import 'icon_tree_shaker.dart';
import 'shader_compiler.dart';
/// Prepares the asset bundle in the format expected by flutter.gradle. /// Prepares the asset bundle in the format expected by flutter.gradle.
/// ///
...@@ -68,7 +67,6 @@ abstract class AndroidAssetBundle extends Target { ...@@ -68,7 +67,6 @@ abstract class AndroidAssetBundle extends Target {
outputDirectory, outputDirectory,
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
buildMode: buildMode, buildMode: buildMode,
shaderTarget: ShaderTarget.impellerAndroid,
flavor: environment.defines[kFlavor], flavor: environment.defines[kFlavor],
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
......
...@@ -32,7 +32,6 @@ Future<Depfile> copyAssets( ...@@ -32,7 +32,6 @@ Future<Depfile> copyAssets(
Map<String, DevFSContent> additionalContent = const <String, DevFSContent>{}, Map<String, DevFSContent> additionalContent = const <String, DevFSContent>{},
required TargetPlatform targetPlatform, required TargetPlatform targetPlatform,
BuildMode? buildMode, BuildMode? buildMode,
required ShaderTarget shaderTarget,
List<File> additionalInputs = const <File>[], List<File> additionalInputs = const <File>[],
String? flavor, String? flavor,
}) async { }) async {
...@@ -140,8 +139,7 @@ Future<Depfile> copyAssets( ...@@ -140,8 +139,7 @@ Future<Depfile> copyAssets(
doCopy = !await shaderCompiler.compileShader( doCopy = !await shaderCompiler.compileShader(
input: content.file as File, input: content.file as File,
outputPath: file.path, outputPath: file.path,
target: shaderTarget, targetPlatform: targetPlatform,
json: targetPlatform == TargetPlatform.web_javascript,
); );
case AssetKind.model: case AssetKind.model:
doCopy = !await sceneImporter.importScene( doCopy = !await sceneImporter.importScene(
...@@ -328,7 +326,6 @@ class CopyAssets extends Target { ...@@ -328,7 +326,6 @@ class CopyAssets extends Target {
environment, environment,
output, output,
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor], flavor: environment.defines[kFlavor],
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
......
...@@ -79,7 +79,6 @@ class CopyFlutterBundle extends Target { ...@@ -79,7 +79,6 @@ class CopyFlutterBundle extends Target {
environment.outputDir, environment.outputDir,
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
buildMode: buildMode, buildMode: buildMode,
shaderTarget: ShaderTarget.sksl,
flavor: flavor, flavor: flavor,
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
......
...@@ -503,9 +503,6 @@ abstract class IosAssetBundle extends Target { ...@@ -503,9 +503,6 @@ abstract class IosAssetBundle extends Target {
environment, environment,
assetDirectory, assetDirectory,
targetPlatform: TargetPlatform.ios, 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>[ additionalInputs: <File>[
flutterProject.ios.infoPlist, flutterProject.ios.infoPlist,
flutterProject.ios.appFrameworkInfoPlist, flutterProject.ios.appFrameworkInfoPlist,
......
...@@ -15,7 +15,6 @@ import 'assets.dart'; ...@@ -15,7 +15,6 @@ import 'assets.dart';
import 'common.dart'; import 'common.dart';
import 'desktop.dart'; import 'desktop.dart';
import 'icon_tree_shaker.dart'; import 'icon_tree_shaker.dart';
import 'shader_compiler.dart';
/// The only files/subdirectories we care out. /// The only files/subdirectories we care out.
const List<String> _kLinuxArtifacts = <String>[ const List<String> _kLinuxArtifacts = <String>[
...@@ -141,7 +140,6 @@ abstract class BundleLinuxAssets extends Target { ...@@ -141,7 +140,6 @@ abstract class BundleLinuxAssets extends Target {
additionalContent: <String, DevFSContent>{ additionalContent: <String, DevFSContent>{
'version.json': DevFSStringContent(versionInfo), 'version.json': DevFSStringContent(versionInfo),
}, },
shaderTarget: ShaderTarget.sksl,
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
depfile, depfile,
......
...@@ -18,7 +18,6 @@ import '../exceptions.dart'; ...@@ -18,7 +18,6 @@ import '../exceptions.dart';
import 'assets.dart'; import 'assets.dart';
import 'common.dart'; import 'common.dart';
import 'icon_tree_shaker.dart'; import 'icon_tree_shaker.dart';
import 'shader_compiler.dart';
/// Copy the macOS framework to the correct copy dir by invoking 'rsync'. /// Copy the macOS framework to the correct copy dir by invoking 'rsync'.
/// ///
...@@ -439,7 +438,6 @@ abstract class MacOSBundleFlutterAssets extends Target { ...@@ -439,7 +438,6 @@ abstract class MacOSBundleFlutterAssets extends Target {
environment, environment,
assetDirectory, assetDirectory,
targetPlatform: TargetPlatform.darwin, targetPlatform: TargetPlatform.darwin,
shaderTarget: ShaderTarget.sksl,
flavor: environment.defines[kFlavor], flavor: environment.defines[kFlavor],
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
......
...@@ -17,21 +17,8 @@ import '../../base/logger.dart'; ...@@ -17,21 +17,8 @@ import '../../base/logger.dart';
import '../../build_info.dart'; import '../../build_info.dart';
import '../../convert.dart'; import '../../convert.dart';
import '../../devfs.dart'; import '../../devfs.dart';
import '../../device.dart';
import '../build_system.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. /// A wrapper around [ShaderCompiler] to support hot reload of shader sources.
class DevelopmentShaderCompiler { class DevelopmentShaderCompiler {
DevelopmentShaderCompiler({ DevelopmentShaderCompiler({
...@@ -47,42 +34,16 @@ class DevelopmentShaderCompiler { ...@@ -47,42 +34,16 @@ class DevelopmentShaderCompiler {
final Pool _compilationPool = Pool(4); final Pool _compilationPool = Pool(4);
final math.Random _random; final math.Random _random;
late ShaderTarget _shaderTarget; late TargetPlatform _targetPlatform;
bool _debugConfigured = false; bool _debugConfigured = false;
bool _jsonMode = false;
/// Configure the output format of the shader compiler for a particular /// Configure the output format of the shader compiler for a particular
/// flutter device. /// flutter device.
void configureCompiler(TargetPlatform? platform, { required ImpellerStatus impellerStatus }) { void configureCompiler(TargetPlatform? platform) {
switch (platform) { if (platform == null) {
case TargetPlatform.ios: return;
_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;
} }
_targetPlatform = platform;
_debugConfigured = true; _debugConfigured = true;
} }
...@@ -107,9 +68,8 @@ class DevelopmentShaderCompiler { ...@@ -107,9 +68,8 @@ class DevelopmentShaderCompiler {
final bool success = await _shaderCompiler.compileShader( final bool success = await _shaderCompiler.compileShader(
input: inputFile, input: inputFile,
outputPath: output.path, outputPath: output.path,
target: _shaderTarget, targetPlatform: _targetPlatform,
fatal: false, fatal: false,
json: _jsonMode,
); );
if (!success) { if (!success) {
return null; return null;
...@@ -144,6 +104,34 @@ class ShaderCompiler { ...@@ -144,6 +104,34 @@ class ShaderCompiler {
final FileSystem _fs; final FileSystem _fs;
final Artifacts _artifacts; 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. /// The [Source] inputs that targets using this should depend on.
/// ///
/// See [Target.inputs]. /// See [Target.inputs].
...@@ -163,9 +151,8 @@ class ShaderCompiler { ...@@ -163,9 +151,8 @@ class ShaderCompiler {
Future<bool> compileShader({ Future<bool> compileShader({
required File input, required File input,
required String outputPath, required String outputPath,
required ShaderTarget target, required TargetPlatform targetPlatform,
bool fatal = true, bool fatal = true,
required bool json,
}) async { }) async {
final File impellerc = _fs.file( final File impellerc = _fs.file(
_artifacts.getHostArtifact(HostArtifact.impellerc), _artifacts.getHostArtifact(HostArtifact.impellerc),
...@@ -180,9 +167,9 @@ class ShaderCompiler { ...@@ -180,9 +167,9 @@ class ShaderCompiler {
final String shaderLibPath = _fs.path.join(impellerc.parent.absolute.path, 'shader_lib'); final String shaderLibPath = _fs.path.join(impellerc.parent.absolute.path, 'shader_lib');
final List<String> cmd = <String>[ final List<String> cmd = <String>[
impellerc.path, impellerc.path,
...target.stages, ..._shaderTargetsFromTargetPlatform(targetPlatform),
'--iplr', '--iplr',
if (json) if (targetPlatform == TargetPlatform.web_javascript)
'--json', '--json',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputPath.spirv', '--spirv=$outputPath.spirv',
......
...@@ -28,7 +28,6 @@ import '../depfile.dart'; ...@@ -28,7 +28,6 @@ import '../depfile.dart';
import '../exceptions.dart'; import '../exceptions.dart';
import 'assets.dart'; import 'assets.dart';
import 'localizations.dart'; import 'localizations.dart';
import 'shader_compiler.dart';
/// Whether the application has web plugins. /// Whether the application has web plugins.
const String kHasWebPlugins = 'HasWebPlugins'; const String kHasWebPlugins = 'HasWebPlugins';
...@@ -395,7 +394,6 @@ class WebReleaseBundle extends Target { ...@@ -395,7 +394,6 @@ class WebReleaseBundle extends Target {
environment, environment,
environment.outputDir.childDirectory('assets'), environment.outputDir.childDirectory('assets'),
targetPlatform: TargetPlatform.web_javascript, targetPlatform: TargetPlatform.web_javascript,
shaderTarget: ShaderTarget.sksl,
); );
final DepfileService depfileService = environment.depFileService; final DepfileService depfileService = environment.depFileService;
depfileService.writeToFile( depfileService.writeToFile(
......
...@@ -12,7 +12,6 @@ import 'assets.dart'; ...@@ -12,7 +12,6 @@ import 'assets.dart';
import 'common.dart'; import 'common.dart';
import 'desktop.dart'; import 'desktop.dart';
import 'icon_tree_shaker.dart'; import 'icon_tree_shaker.dart';
import 'shader_compiler.dart';
/// The only files/subdirectories we care about. /// The only files/subdirectories we care about.
const List<String> _kWindowsArtifacts = <String>[ const List<String> _kWindowsArtifacts = <String>[
...@@ -143,7 +142,6 @@ abstract class BundleWindowsAssets extends Target { ...@@ -143,7 +142,6 @@ abstract class BundleWindowsAssets extends Target {
environment, environment,
outputDirectory, outputDirectory,
targetPlatform: targetPlatform, targetPlatform: targetPlatform,
shaderTarget: ShaderTarget.sksl,
); );
environment.depFileService.writeToFile( environment.depFileService.writeToFile(
depfile, depfile,
......
...@@ -169,11 +169,6 @@ Future<void> writeBundle( ...@@ -169,11 +169,6 @@ Future<void> writeBundle(
artifacts: globals.artifacts!, 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. // Limit number of open files to avoid running out of file descriptors.
final Pool pool = Pool(64); final Pool pool = Pool(64);
await Future.wait<void>( await Future.wait<void>(
...@@ -200,8 +195,7 @@ Future<void> writeBundle( ...@@ -200,8 +195,7 @@ Future<void> writeBundle(
doCopy = !await shaderCompiler.compileShader( doCopy = !await shaderCompiler.compileShader(
input: input, input: input,
outputPath: file.path, outputPath: file.path,
target: shaderTarget, targetPlatform: targetPlatform,
json: targetPlatform == TargetPlatform.web_javascript,
); );
case AssetKind.model: case AssetKind.model:
doCopy = !await sceneImporter.importScene( doCopy = !await sceneImporter.importScene(
......
...@@ -268,10 +268,7 @@ class HotRunner extends ResidentRunner { ...@@ -268,10 +268,7 @@ class HotRunner extends ResidentRunner {
await device!.initLogReader(); await device!.initLogReader();
device device
.developmentShaderCompiler .developmentShaderCompiler
.configureCompiler( .configureCompiler(device.targetPlatform);
device.targetPlatform,
impellerStatus: debuggingOptions.enableImpeller,
);
} }
try { try {
final List<Uri?> baseUris = await _initDevFS(); final List<Uri?> baseUris = await _initDevFS();
......
...@@ -672,6 +672,8 @@ flutter: ...@@ -672,6 +672,8 @@ flutter:
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl', '--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr', '--iplr',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputPath.spirv', '--spirv=$outputPath.spirv',
......
...@@ -535,6 +535,7 @@ void main() { ...@@ -535,6 +535,7 @@ void main() {
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[ const FakeCommand(command: <String>[
'HostArtifact.impellerc', 'HostArtifact.impellerc',
'--sksl',
'--runtime-stage-gles', '--runtime-stage-gles',
'--runtime-stage-vulkan', '--runtime-stage-vulkan',
'--iplr', '--iplr',
......
...@@ -287,6 +287,7 @@ void main() { ...@@ -287,6 +287,7 @@ void main() {
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[ const FakeCommand(command: <String>[
'HostArtifact.impellerc', 'HostArtifact.impellerc',
'--sksl',
'--runtime-stage-metal', '--runtime-stage-metal',
'--iplr', '--iplr',
'--sl=/App.framework/flutter_assets/shader.glsl', '--sl=/App.framework/flutter_assets/shader.glsl',
......
...@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -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_info.dart';
import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart'; import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import '../../../src/common.dart'; import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart'; import '../../../src/fake_process_manager.dart';
...@@ -40,13 +39,14 @@ void main() { ...@@ -40,13 +39,14 @@ void main() {
fileSystem.file(notFragPath).createSync(recursive: true); 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>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl', '--sksl',
'--iplr', '--iplr',
'--json',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputSpirvPath', '--spirv=$outputSpirvPath',
'--input=$fragPath', '--input=$fragPath',
...@@ -71,8 +71,7 @@ void main() { ...@@ -71,8 +71,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: fileSystem.file(fragPath), input: fileSystem.file(fragPath),
outputPath: outputPath, outputPath: outputPath,
target: ShaderTarget.sksl, targetPlatform: TargetPlatform.web_javascript,
json: false,
), ),
true, true,
); );
...@@ -85,6 +84,7 @@ void main() { ...@@ -85,6 +84,7 @@ void main() {
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl',
'--runtime-stage-metal', '--runtime-stage-metal',
'--iplr', '--iplr',
'--sl=$outputPath', '--sl=$outputPath',
...@@ -110,8 +110,7 @@ void main() { ...@@ -110,8 +110,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: fileSystem.file(fragPath), input: fileSystem.file(fragPath),
outputPath: outputPath, outputPath: outputPath,
target: ShaderTarget.impelleriOS, targetPlatform: TargetPlatform.ios,
json: false,
), ),
true, true,
); );
...@@ -123,6 +122,7 @@ void main() { ...@@ -123,6 +122,7 @@ void main() {
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl',
'--runtime-stage-gles', '--runtime-stage-gles',
'--runtime-stage-vulkan', '--runtime-stage-vulkan',
'--iplr', '--iplr',
...@@ -149,8 +149,7 @@ void main() { ...@@ -149,8 +149,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: fileSystem.file(fragPath), input: fileSystem.file(fragPath),
outputPath: outputPath, outputPath: outputPath,
target: ShaderTarget.impellerAndroid, targetPlatform: TargetPlatform.android,
json: false,
), ),
true, true,
); );
...@@ -164,6 +163,7 @@ void main() { ...@@ -164,6 +163,7 @@ void main() {
impellerc, impellerc,
'--sksl', '--sksl',
'--iplr', '--iplr',
'--json',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputSpirvPath', '--spirv=$outputSpirvPath',
'--input=$notFragPath', '--input=$notFragPath',
...@@ -188,8 +188,7 @@ void main() { ...@@ -188,8 +188,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: fileSystem.file(notFragPath), input: fileSystem.file(notFragPath),
outputPath: outputPath, outputPath: outputPath,
target: ShaderTarget.sksl, targetPlatform: TargetPlatform.web_javascript,
json: false,
), ),
true, true,
); );
...@@ -204,6 +203,7 @@ void main() { ...@@ -204,6 +203,7 @@ void main() {
impellerc, impellerc,
'--sksl', '--sksl',
'--iplr', '--iplr',
'--json',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputSpirvPath', '--spirv=$outputSpirvPath',
'--input=$notFragPath', '--input=$notFragPath',
...@@ -227,8 +227,7 @@ void main() { ...@@ -227,8 +227,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: fileSystem.file(notFragPath), input: fileSystem.file(notFragPath),
outputPath: outputPath, outputPath: outputPath,
target: ShaderTarget.sksl, targetPlatform: TargetPlatform.web_javascript,
json: false,
); );
fail('unreachable'); fail('unreachable');
} on ShaderCompilerException catch (e) { } on ShaderCompilerException catch (e) {
...@@ -245,6 +244,8 @@ void main() { ...@@ -245,6 +244,8 @@ void main() {
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl', '--sksl',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr', '--iplr',
'--sl=/.tmp_rand0/0.8255140718871702.temp', '--sl=/.tmp_rand0/0.8255140718871702.temp',
'--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv', '--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
...@@ -274,10 +275,7 @@ void main() { ...@@ -274,10 +275,7 @@ void main() {
random: math.Random(0), random: math.Random(0),
); );
developmentShaderCompiler.configureCompiler( developmentShaderCompiler.configureCompiler(TargetPlatform.android);
TargetPlatform.android,
impellerStatus: ImpellerStatus.disabled,
);
final DevFSContent? content = await developmentShaderCompiler final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath))); .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
...@@ -292,6 +290,7 @@ void main() { ...@@ -292,6 +290,7 @@ void main() {
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl',
'--runtime-stage-vulkan', '--runtime-stage-vulkan',
'--iplr', '--iplr',
'--sl=/.tmp_rand0/0.8255140718871702.temp', '--sl=/.tmp_rand0/0.8255140718871702.temp',
...@@ -322,10 +321,7 @@ void main() { ...@@ -322,10 +321,7 @@ void main() {
random: math.Random(0), random: math.Random(0),
); );
developmentShaderCompiler.configureCompiler( developmentShaderCompiler.configureCompiler(TargetPlatform.tester);
TargetPlatform.tester,
impellerStatus: ImpellerStatus.enabled,
);
final DevFSContent? content = await developmentShaderCompiler final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath))); .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
...@@ -339,6 +335,7 @@ void main() { ...@@ -339,6 +335,7 @@ void main() {
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--sksl',
'--runtime-stage-gles', '--runtime-stage-gles',
'--runtime-stage-vulkan', '--runtime-stage-vulkan',
'--iplr', '--iplr',
...@@ -370,10 +367,99 @@ void main() { ...@@ -370,10 +367,99 @@ void main() {
random: math.Random(0), random: math.Random(0),
); );
developmentShaderCompiler.configureCompiler( developmentShaderCompiler.configureCompiler(TargetPlatform.android);
TargetPlatform.android,
impellerStatus: ImpellerStatus.enabled, 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 final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath))); .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
...@@ -419,10 +505,7 @@ void main() { ...@@ -419,10 +505,7 @@ void main() {
random: math.Random(0), random: math.Random(0),
); );
developmentShaderCompiler.configureCompiler( developmentShaderCompiler.configureCompiler(TargetPlatform.web_javascript);
TargetPlatform.web_javascript,
impellerStatus: ImpellerStatus.disabled,
);
final DevFSContent? content = await developmentShaderCompiler final DevFSContent? content = await developmentShaderCompiler
.recompileShader(DevFSFileContent(fileSystem.file(fragPath))); .recompileShader(DevFSFileContent(fileSystem.file(fragPath)));
......
...@@ -279,10 +279,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -279,10 +279,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -20,7 +20,6 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -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/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
...@@ -831,10 +830,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -831,10 +830,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) async { Future<DevFSContent> recompileShader(DevFSContent inputShader) async {
......
...@@ -967,10 +967,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -967,10 +967,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -2957,10 +2957,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -2957,10 +2957,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -1756,10 +1756,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -1756,10 +1756,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -1475,10 +1475,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -1475,10 +1475,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -16,7 +16,6 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart'; ...@@ -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/compile.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/devfs.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/globals.dart' as globals;
import 'package:flutter_tools/src/html_utils.dart'; import 'package:flutter_tools/src/html_utils.dart';
import 'package:flutter_tools/src/isolated/devfs_web.dart'; import 'package:flutter_tools/src/isolated/devfs_web.dart';
...@@ -1309,10 +1308,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler { ...@@ -1309,10 +1308,7 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
const FakeShaderCompiler(); const FakeShaderCompiler();
@override @override
void configureCompiler( void configureCompiler(TargetPlatform? platform) { }
TargetPlatform? platform, {
required ImpellerStatus impellerStatus,
}) { }
@override @override
Future<DevFSContent> recompileShader(DevFSContent inputShader) { Future<DevFSContent> recompileShader(DevFSContent inputShader) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.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/build_system/targets/shader_compiler.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
...@@ -32,8 +33,7 @@ void main() { ...@@ -32,8 +33,7 @@ void main() {
await shaderCompiler.compileShader( await shaderCompiler.compileShader(
input: file, input: file,
outputPath: tmpDir.childFile('test_shader.frag.out').path, outputPath: tmpDir.childFile('test_shader.frag.out').path,
target: ShaderTarget.sksl, targetPlatform: TargetPlatform.tester,
json: false,
); );
} }
...@@ -62,8 +62,7 @@ void main() { ...@@ -62,8 +62,7 @@ void main() {
final bool compileResult = await shaderCompiler.compileShader( final bool compileResult = await shaderCompiler.compileShader(
input: globals.fs.file(inkSparklePath), input: globals.fs.file(inkSparklePath),
outputPath: inkSparkleOutputPath, outputPath: inkSparkleOutputPath,
target: ShaderTarget.sksl, targetPlatform: TargetPlatform.tester,
json: false,
); );
final File resultFile = globals.fs.file(inkSparkleOutputPath); final File resultFile = globals.fs.file(inkSparkleOutputPath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment