Skip to content

Commit

Permalink
Use the impellerc GLES output flag when compiling shaders for Android…
Browse files Browse the repository at this point in the history
… (#120647)
  • Loading branch information
jason-simmons authored Feb 15, 2023
1 parent 99dcaa2 commit 8d15083
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}

0 comments on commit 8d15083

Please sign in to comment.