Use the impellerc GLES output flag when compiling shaders for Android (#120647)

This commit is contained in:
Jason Simmons 2023-02-15 11:01:00 -08:00 committed by GitHub
parent 99dcaa2d9c
commit 8d150833b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 1 deletions

View File

@ -67,7 +67,7 @@ abstract class AndroidAssetBundle extends Target {
outputDirectory,
targetPlatform: TargetPlatform.android,
buildMode: buildMode,
shaderTarget: ShaderTarget.sksl,
shaderTarget: ShaderTarget.impellerAndroid,
);
final DepfileService depfileService = DepfileService(
fileSystem: environment.fileSystem,

View File

@ -501,4 +501,59 @@ void main() {
expect(depfile.outputs[2].path, '/out/abi1/app.so-4.part.so');
});
testUsingContext('DebugAndroidApplication with impeller and shader compilation', () async {
// Create impellerc to work around fallback detection logic.
fileSystem.file(artifacts.getHostArtifact(HostArtifact.impellerc)).createSync(recursive: true);
final Environment environment = Environment.test(
fileSystem.currentDirectory,
outputDir: fileSystem.directory('out')..createSync(),
defines: <String, String>{
kBuildMode: 'debug',
},
processManager: processManager,
artifacts: artifacts,
fileSystem: fileSystem,
logger: logger,
);
environment.buildDir.createSync(recursive: true);
// create pre-requisites.
environment.buildDir.childFile('app.dill')
.writeAsStringSync('abcd');
fileSystem
.file(artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug))
.createSync(recursive: true);
fileSystem
.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
.createSync(recursive: true);
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
fileSystem.file('.packages').writeAsStringSync('\n');
fileSystem.file('shader.glsl').writeAsStringSync('test');
processManager.addCommands(<FakeCommand>[
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
'--runtime-stage-gles',
'--iplr',
'--sl=out/flutter_assets/shader.glsl',
'--spirv=out/flutter_assets/shader.glsl.spirv',
'--input=/shader.glsl',
'--input-type=frag',
'--include=/',
'--include=/./shader_lib',
]),
]);
await const DebugAndroidApplication().build(environment);
expect(processManager, hasNoRemainingExpectations);
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true);
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true);
expect(fileSystem.file(fileSystem.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
});
}