Skip to content

Commit 8d15083

Browse files
Use the impellerc GLES output flag when compiling shaders for Android (#120647)
1 parent 99dcaa2 commit 8d15083

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

packages/flutter_tools/lib/src/build_system/targets/android.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class AndroidAssetBundle extends Target {
6767
outputDirectory,
6868
targetPlatform: TargetPlatform.android,
6969
buildMode: buildMode,
70-
shaderTarget: ShaderTarget.sksl,
70+
shaderTarget: ShaderTarget.impellerAndroid,
7171
);
7272
final DepfileService depfileService = DepfileService(
7373
fileSystem: environment.fileSystem,

packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,59 @@ void main() {
501501

502502
expect(depfile.outputs[2].path, '/out/abi1/app.so-4.part.so');
503503
});
504+
505+
testUsingContext('DebugAndroidApplication with impeller and shader compilation', () async {
506+
// Create impellerc to work around fallback detection logic.
507+
fileSystem.file(artifacts.getHostArtifact(HostArtifact.impellerc)).createSync(recursive: true);
508+
509+
final Environment environment = Environment.test(
510+
fileSystem.currentDirectory,
511+
outputDir: fileSystem.directory('out')..createSync(),
512+
defines: <String, String>{
513+
kBuildMode: 'debug',
514+
},
515+
processManager: processManager,
516+
artifacts: artifacts,
517+
fileSystem: fileSystem,
518+
logger: logger,
519+
);
520+
environment.buildDir.createSync(recursive: true);
521+
522+
// create pre-requisites.
523+
environment.buildDir.childFile('app.dill')
524+
.writeAsStringSync('abcd');
525+
fileSystem
526+
.file(artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug))
527+
.createSync(recursive: true);
528+
fileSystem
529+
.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
530+
.createSync(recursive: true);
531+
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
532+
fileSystem.file('.packages').writeAsStringSync('\n');
533+
fileSystem.file('shader.glsl').writeAsStringSync('test');
534+
535+
processManager.addCommands(<FakeCommand>[
536+
const FakeCommand(command: <String>[
537+
'HostArtifact.impellerc',
538+
'--runtime-stage-gles',
539+
'--iplr',
540+
'--sl=out/flutter_assets/shader.glsl',
541+
'--spirv=out/flutter_assets/shader.glsl.spirv',
542+
'--input=/shader.glsl',
543+
'--input-type=frag',
544+
'--include=/',
545+
'--include=/./shader_lib',
546+
]),
547+
]);
548+
549+
await const DebugAndroidApplication().build(environment);
550+
expect(processManager, hasNoRemainingExpectations);
551+
552+
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true);
553+
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true);
554+
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true);
555+
}, overrides: <Type, Generator>{
556+
FileSystem: () => fileSystem,
557+
ProcessManager: () => processManager,
558+
});
504559
}

0 commit comments

Comments
 (0)