[Tool][Impeller] Make impellerc produce Vulkan and GLES shaders for Android. (#140976)

This should wait for some upstream work, just don't want to lose it locally for now. I'll switch this from draft and update the description when it's ready.
This commit is contained in:
Dan Field 2024-01-11 09:49:59 -08:00 committed by GitHub
parent f5fb61b953
commit 9f2e681e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -22,13 +22,13 @@ import '../build_system.dart';
/// The output shader format that should be used by the [ShaderCompiler]. /// The output shader format that should be used by the [ShaderCompiler].
enum ShaderTarget { enum ShaderTarget {
impellerAndroid('--runtime-stage-gles'), impellerAndroid(<String>['--runtime-stage-gles', '--runtime-stage-vulkan']),
impelleriOS('--runtime-stage-metal'), impelleriOS(<String>['--runtime-stage-metal']),
sksl('--sksl'); sksl(<String>['--sksl']);
const ShaderTarget(this.target); const ShaderTarget(this.stages);
final String target; 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.
@ -177,7 +177,7 @@ 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.target, ...target.stages,
'--iplr', '--iplr',
if (json) if (json)
'--json', '--json',

View File

@ -536,6 +536,7 @@ void main() {
const FakeCommand(command: <String>[ const FakeCommand(command: <String>[
'HostArtifact.impellerc', 'HostArtifact.impellerc',
'--runtime-stage-gles', '--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr', '--iplr',
'--sl=out/flutter_assets/shader.glsl', '--sl=out/flutter_assets/shader.glsl',
'--spirv=out/flutter_assets/shader.glsl.spirv', '--spirv=out/flutter_assets/shader.glsl.spirv',

View File

@ -118,12 +118,13 @@ void main() {
expect(fileSystem.file(outputPath).existsSync(), true); expect(fileSystem.file(outputPath).existsSync(), true);
}); });
testWithoutContext('compileShader invokes impellerc for .frag files and opengl es', () async { testWithoutContext('compileShader invokes impellerc for .frag files and Android', () async {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand( FakeCommand(
command: <String>[ command: <String>[
impellerc, impellerc,
'--runtime-stage-gles', '--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr', '--iplr',
'--sl=$outputPath', '--sl=$outputPath',
'--spirv=$outputPath.spirv', '--spirv=$outputPath.spirv',
@ -292,6 +293,7 @@ void main() {
command: <String>[ command: <String>[
impellerc, impellerc,
'--runtime-stage-gles', '--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',