[flutter_tool] Build shaders as .iplr and use FragmentProgram.fromAsset for ink_sparkle (#108071)

This commit is contained in:
Zachary Anderson
2022-07-21 20:50:08 -07:00
committed by GitHub
parent cc62a5b961
commit dd20919ad6
4 changed files with 30 additions and 19 deletions

View File

@@ -443,14 +443,17 @@ flutter:
FakeCommand(
command: <String>[
impellerc,
'--flutter-spirv',
'--spirv=$outputPath',
'--sksl',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputPath.spirv',
'--input=/$shaderPath',
'--input-type=frag',
'--include=/$assetsPath',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
fileSystem.file('$outputPath.spirv').createSync(recursive: true);
},
),
]),

View File

@@ -13,7 +13,8 @@ import '../../../src/fake_process_manager.dart';
const String fragDir = '/shaders';
const String fragPath = '/shaders/my_shader.frag';
const String notFragPath = '/shaders/not_a_frag.file';
const String outputPath = '/output/shaders/my_shader.spv';
const String outputSpirvPath = '/output/shaders/my_shader.frag.spirv';
const String outputPath = '/output/shaders/my_shader.frag';
void main() {
late BufferLogger logger;
@@ -37,14 +38,17 @@ void main() {
FakeCommand(
command: <String>[
impellerc,
'--flutter-spirv',
'--spirv=$outputPath',
'--sksl',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$fragPath',
'--input-type=frag',
'--include=$fragDir',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
fileSystem.file(outputSpirvPath).createSync(recursive: true);
},
),
]);
@@ -63,6 +67,7 @@ void main() {
true,
);
expect(fileSystem.file(outputPath).existsSync(), true);
expect(fileSystem.file(outputSpirvPath).existsSync(), false);
});
testWithoutContext('compileShader invokes impellerc for non-.frag files', () async {
@@ -70,14 +75,17 @@ void main() {
FakeCommand(
command: <String>[
impellerc,
'--flutter-spirv',
'--spirv=$outputPath',
'--sksl',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
'--input-type=frag',
'--include=$fragDir',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
fileSystem.file(outputSpirvPath).createSync(recursive: true);
},
),
]);
@@ -96,6 +104,7 @@ void main() {
true,
);
expect(fileSystem.file(outputPath).existsSync(), true);
expect(fileSystem.file(outputSpirvPath).existsSync(), false);
});
testWithoutContext('compileShader throws an exception when impellerc fails', () async {
@@ -103,8 +112,10 @@ void main() {
FakeCommand(
command: <String>[
impellerc,
'--flutter-spirv',
'--spirv=$outputPath',
'--sksl',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputSpirvPath',
'--input=$notFragPath',
'--input-type=frag',
'--include=$fragDir',