Skip to content

Improve CompressedImageSaver #14671

@JMS55

Description

@JMS55

It's time to get serious about texture speed :). Streaming mips can come later, first we need a better system that actually compresses textures (on disk).


Old plan (ignore everything under this)

The current CompressedImageSaver outputs basisu files, which tend to be quite large, as they're designed for random-access decompression on the GPU, not for linear-reads like loading from disk. We should supercompress the textures by compressing the basisu with zstd. By storing that in a ktx2, we can reuse the existing ImageLoader (ktx2 zstd-supercompressed textures are an existing standard), no need for a custom loader.

We may also want to skip basisu, and just store BC7/ASTC/etc in supercompressed KTX2 files directly, to avoid the overhead, and let us support more formats. See the optional bullet points below. If so, a lot of the bullets below are invalid.

TODO

  • Rename to CompressedTextureSaver, as it's only meant to be used for 3D textures
  • Enable set_rdo_uastc()
  • After converting to basisu, encode to a zstd-supercompressed ktx2
  • Add docs
    • Explain disk compression vs GPU compressed texture formats
    • Describe the pipeline: PNG/JPEG -> basisu -> zstd -> ktx2 -> BC7/ASTC
    • Note that it generates mipmaps
    • Explain why you want to do this: smaller size on disk, faster rendering
  • Add an example (might also want to rework the asset_decompression example to work on something other than an image, or just replace it outright)
  • Add support for the GLTF extension KHR_texture_basisu(?)
    • Not sure if this is needed? Bevy can already support ktx2 files that store both basisu, and suprecompressed basisu + zstd data
  • (Optional) Add support for saving to either BC7 and/or ASTC supercompressed ktx2 files directly (not sure how expensive the runtime transcoding from basisu is, might not matter)
  • (Optional) Add support for BC6 textures and ASTC HDR for HDR content
  • (Optional) Use BC5 for normal maps

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-FeatureA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile times

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions