When Impeller is enabled for flutter tester choose correct shader target. (#141391)

When compiling shaders for flutter tester, include Vulkan shaders when targeting Impeller.
This commit is contained in:
Jonah Williams
2024-01-12 09:49:54 -08:00
committed by GitHub
parent 2da87e6108
commit f2745e97d5
6 changed files with 88 additions and 23 deletions

View File

@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/bundle_builder.dart';
import 'package:flutter_tools/src/cache.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/project.dart';
import 'package:standard_message_codec/standard_message_codec.dart';
@@ -622,6 +623,7 @@ flutter:
<String, AssetKind>{},
loggerOverride: testLogger,
targetPlatform: TargetPlatform.android,
impellerStatus: ImpellerStatus.disabled,
);
expect(testLogger.warningText, contains('Expected Error Text'));
@@ -744,6 +746,7 @@ flutter:
bundle.entryKinds,
loggerOverride: testLogger,
targetPlatform: TargetPlatform.android,
impellerStatus: ImpellerStatus.disabled,
);
}, overrides: <Type, Generator>{
@@ -790,6 +793,7 @@ flutter:
bundle.entryKinds,
loggerOverride: testLogger,
targetPlatform: TargetPlatform.web_javascript,
impellerStatus: ImpellerStatus.disabled,
);
}, overrides: <Type, Generator>{
@@ -873,6 +877,7 @@ flutter:
bundle.entryKinds,
loggerOverride: testLogger,
targetPlatform: TargetPlatform.web_javascript,
impellerStatus: ImpellerStatus.disabled,
);
expect((globals.processManager as FakeProcessManager).hasRemainingExpectations, false);
}, overrides: <Type, Generator>{

View File

@@ -287,6 +287,53 @@ void main() {
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(