-
Notifications
You must be signed in to change notification settings - Fork 63
Description
I had time to kill so I spent an afternoon investigating how to hook up KtxImporter with Zstandard supercompression and the latest Basis Universal formats. Mainly writing this down so I don't forget again, but also happy to get some input.
Zstandard
This was rather trivial to add to KtxImporter, but might be unneeded (more below).
zstdhas a script to generate single file libraries. The decoder is a ~600kB .c file without dependencies that can be bundled. The readme mentions a compiled WASM binary size of 26kB for the decoder, but I haven't verified that.- decoding is dead simple, not more than 3 function calls, and it's handled transparently
Updating basisu
Updating basis_universal to 1.15 for BasisImporter worked fairly quickly, too, with two caveats:
- converter tests don't pass because image delta is over the limit, I assume this is the result of some new quality setting somewhere
- keeping compatability with old versions (mainly the prehistoric 1.11 on vcpkg) is a little trickier because some functions and options changed names, but can be worked around with some SFINAE dances (there might be a version define to
#ifon, haven't checked)
Forwarding Basis-compressed KTX2 to BasisImporter
This one gave me a bit of a headache. I naively assumed BasisImporter could handle the raw data inside KTX2 level data, but currently it only decodes .basis containers. There are ways to use the lowlevel transcoders, but for BasisLZ (Basis ETC1 + LZ supercompression) this is completely insane because you need to validate and decompress the global LZ data and somehow pass that through to BasisImporter.
The far easier solution here is to detect Basis data in KTXImporter early and then directly send the entire file data to BasisImporter. Basisu 1.15 can decode KTX2 and handles all the BasisLZ supercompression stuff for us. BasisImporter then only needs a few minor changes to use ktx2_transcoder next to the existing basisu_transcoder (which only supports .basis containers).
Another effect would be that basisu handles all Zstandard decoding, so that might not have to be handled in KtxImporter, unless it's commonly used outside of Basis-compressed KTX files. Needs some investigation.
Metadata
Metadata
Assignees
Labels
Projects
Status