Skip to content

[Impeller] Update impellerc to create fat shader blobs. #123741

Description

@chinmaygarde

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.

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    P1High-priority issues at the top of the work list
    e: impellerImpeller rendering backend issues and features requests
    on Mar 30, 2023
  2. moved this to 🤔 Needs Triage in Impelleron Mar 30, 2023
  3. chinmaygarde commented on Mar 30, 2023

    @chinmaygarde
    ContributorAuthor
  4. moved this from 🤔 Needs Triage to 🖖 Vulkan in Impelleron Mar 30, 2023
  5. gaaclarke commented on Apr 4, 2023

    @gaaclarke
    Member

    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).

  6. chinmaygarde commented on May 16, 2023

    @chinmaygarde
    ContributorAuthor

    On Android, we will end up using both Vulkan and OpenGL ES. So I do think this is necessary.

  7. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on May 16, 2023
  8. ldasilva-net commented on May 18, 2023

    @ldasilva-net

    How can this affect the app size compared to using Skia?

  9. chinmaygarde commented on May 18, 2023

    @chinmaygarde
    ContributorAuthor

    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:
    Screenshot 2023-05-18 at 10 13 43 AM
    Screenshot 2023-05-18 at 10 14 44 AM
    Screenshot 2023-05-18 at 10 17 55 AM

  10. jonahwilliams commented on Sep 25, 2023

    @jonahwilliams
    Contributor

    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.

  11. chinmaygarde commented on Sep 25, 2023

    @chinmaygarde
    ContributorAuthor

    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>.

  12. self-assigned this
    on Jan 9, 2024
  13. moved this from 🖖 Vulkan to ✅ Done in Impelleron Jan 11, 2024
  14. github-actions commented on Jan 25, 2024

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions