Skip to content

Commit

Permalink
[Tool][Impeller] Make impellerc produce Vulkan and GLES shaders for A…
Browse files Browse the repository at this point in the history
…ndroid. (#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.
  • Loading branch information
dnfield committed Jan 11, 2024
1 parent f5fb61b commit 9f2e681
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import '../build_system.dart';

/// The output shader format that should be used by the [ShaderCompiler].
enum ShaderTarget {
impellerAndroid('--runtime-stage-gles'),
impelleriOS('--runtime-stage-metal'),
sksl('--sksl');
impellerAndroid(<String>['--runtime-stage-gles', '--runtime-stage-vulkan']),
impelleriOS(<String>['--runtime-stage-metal']),
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.
Expand Down Expand Up @@ -177,7 +177,7 @@ class ShaderCompiler {
final String shaderLibPath = _fs.path.join(impellerc.parent.absolute.path, 'shader_lib');
final List<String> cmd = <String>[
impellerc.path,
target.target,
...target.stages,
'--iplr',
if (json)
'--json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ void main() {
const FakeCommand(command: <String>[
'HostArtifact.impellerc',
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
'--sl=out/flutter_assets/shader.glsl',
'--spirv=out/flutter_assets/shader.glsl.spirv',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ void main() {
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>[
FakeCommand(
command: <String>[
impellerc,
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
'--sl=$outputPath',
'--spirv=$outputPath.spirv',
Expand Down Expand Up @@ -292,6 +293,7 @@ void main() {
command: <String>[
impellerc,
'--runtime-stage-gles',
'--runtime-stage-vulkan',
'--iplr',
'--sl=/.tmp_rand0/0.8255140718871702.temp',
'--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',
Expand Down

0 comments on commit 9f2e681

Please sign in to comment.