You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Impeller] Update impellerc to create fat shader blobs. #123741
When targeting Android, the shader blobs must contain SPIRV as well OpenGL ES shaders along with the necessary metadata. impellerc must be able to generate fat shader blobs similar to the lipo tool for dylibs. We never had this issue with iOS/macOS because there is only the Metal backend.
Do we need to combine the compiled shaders into one file? Seems like we could just ship with both files and load the appropriate shaders depending on what backend is chosen (vulkan or opengl es).
The increase in size of the compressed Flutter engine binary (that contains the prepackaged shaders) for all of Impeller is ~100K with one rendering backend. Having two backends in a binary (like Android) won't necessarily be 2x the size due to shared components but that is a reasonable (very) conservative estimate.
Uncompressed (because that is easier to analyze), the shaders are 90 KB and backend 28 KB. So we expect to duplicate just these. But the shaders compress really well in the APK/IPA.
OTOH, just Skia GPU and SKSL (the runtime shader compiler) are 553 and 192.32 KB respectively. So just the online shader compiler is larger than the Impeller prepackaged shaders. Impellers shader compiler is significantly larger but all that is in ImpellerC and run at build time only. Impeller can't generate and compile shaders at runtime so there is less code to package.
During the transition we expect to have both Impeller and Skia in the binary since we want folks to be able to opt out in case of unexpected issues. But we are working towards a Skia-GPU (and its deps) less engine. Early experiments show a binary size decrease of at least 7%.
Either way, Impeller will be significantly smaller than the current backend once we complete the transition and remove the legacy backend.
References to screenshots in the analysis I linked earlier:
Strawman design: When compiling for Android, we invoke impellerc twice - once for each backend type, GLES/VUlkan. Then a third time with each of the previous input files to merge them together into a combined format.
Might be easier than refactoring impellerc to create two different compilers.
Thats a good idea. I was thinking of something like blobcat but refactored to also create fat shader blobs instead of single backend shader libraries. But we don't ship blobcat as an artifact and we need that for runtime stages.
The argument parsing in impellerc is pretty rudimentary. But perhaps it can take multiple commands, impellerc compiler <all existing args> and then an impellerc lipo <options>.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
chinmaygarde commentedon Mar 30, 2023
cc @jonahwilliams
gaaclarke commentedon Apr 4, 2023
Do we need to combine the compiled shaders into one file? Seems like we could just ship with both files and load the appropriate shaders depending on what backend is chosen (vulkan or opengl es).
chinmaygarde commentedon May 16, 2023
On Android, we will end up using both Vulkan and OpenGL ES. So I do think this is necessary.
ldasilva-net commentedon May 18, 2023
How can this affect the app size compared to using Skia?
chinmaygarde commentedon May 18, 2023
The increase in size of the compressed Flutter engine binary (that contains the prepackaged shaders) for all of Impeller is ~100K with one rendering backend. Having two backends in a binary (like Android) won't necessarily be 2x the size due to shared components but that is a reasonable (very) conservative estimate.
Uncompressed (because that is easier to analyze), the shaders are 90 KB and backend 28 KB. So we expect to duplicate just these. But the shaders compress really well in the APK/IPA.
OTOH, just Skia GPU and SKSL (the runtime shader compiler) are 553 and 192.32 KB respectively. So just the online shader compiler is larger than the Impeller prepackaged shaders. Impellers shader compiler is significantly larger but all that is in ImpellerC and run at build time only. Impeller can't generate and compile shaders at runtime so there is less code to package.
During the transition we expect to have both Impeller and Skia in the binary since we want folks to be able to opt out in case of unexpected issues. But we are working towards a Skia-GPU (and its deps) less engine. Early experiments show a binary size decrease of at least 7%.
Either way, Impeller will be significantly smaller than the current backend once we complete the transition and remove the legacy backend.
References to screenshots in the analysis I linked earlier:



jonahwilliams commentedon Sep 25, 2023
Strawman design: When compiling for Android, we invoke impellerc twice - once for each backend type, GLES/VUlkan. Then a third time with each of the previous input files to merge them together into a combined format.
Might be easier than refactoring impellerc to create two different compilers.
chinmaygarde commentedon Sep 25, 2023
Thats a good idea. I was thinking of something like blobcat but refactored to also create fat shader blobs instead of single backend shader libraries. But we don't ship blobcat as an artifact and we need that for runtime stages.
The argument parsing in impellerc is pretty rudimentary. But perhaps it can take multiple commands,
impellerc compiler <all existing args>and then animpellerc lipo <options>.[Impeller] Add support for multi-rendering-backend fat shader archives.
[Impeller] Add support for multi-rendering-backend fat shader archive…
github-actions commentedon Jan 25, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[Impeller] Vulkan runtime effects/fragment program API (flutter-team-…
[Impeller] Vulkan runtime effects/fragment program API (flutter-team-…