Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Textures stored in memory twice when format unsupported

Discussion in 'General Graphics' started by lpiljek, Jan 31, 2020.

  1. lpiljek

    lpiljek

    Joined:
    Nov 11, 2015
    Posts:
    12
    The question is regarding the texture compression formats (i.g. ETC2 or ASTC) and what happens when you try to load the texture on a device that has no native support for that format.

    The documentation says:
    "When you use a Texture compression format that is not supported on the target platform, the Textures are decompressed to RGBA 32 and stored in memory alongside the compressed Textures. When this happens, time is lost decompressing Textures, and memory is lost because you are storing them twice."
    Source: https://docs.unity3d.com/Manual/class-TextureImporterOverride.html

    What I don't understand is WHY Unity keeps the original unsupported texture in the memory after it already decompressed it. And more importantly, is there a way to change this and only keep the decompressed version in memory (since it's the only thing that is actually useful on that device)?
    Or did I misunderstand the documentation?
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,128
    If I had to guess it likely does this so it can remove the decompressed texture from memory when it is not in use and then decompress it again when it's needed. If it removed the compressed texture from memory only to require it again it would have to pull it out of flash storage which will be far slower.
     
  3. lpiljek

    lpiljek

    Joined:
    Nov 11, 2015
    Posts:
    12
    OK, but that would imply that Unity never really deallocates textures no matter if the format is supported or not because it's always slower to load it from storage. It would also mean that Unity constantly decompresses those textures in memory instead of just doing it once when first loading the texture.
    I'm not sure that is true. And even if it was I would appreciate a way to decide what needs to be kept in memory and what doesn't.