Update README.md
1 file changed
tree: b44f3ea6ada7816f74e4f2fb00726a35883bce57
  1. bin/
  2. detex/
  3. transcoder/
  4. basisu.sln
  5. basisu.vcxproj
  6. basisu.vcxproj.filters
  7. basisu_backend.cpp
  8. basisu_backend.h
  9. basisu_basis_file.cpp
  10. basisu_basis_file.h
  11. basisu_comp.cpp
  12. basisu_comp.h
  13. basisu_enc.cpp
  14. basisu_enc.h
  15. basisu_etc.cpp
  16. basisu_etc.h
  17. basisu_frontend.cpp
  18. basisu_frontend.h
  19. basisu_global_selector_palette_helpers.cpp
  20. basisu_global_selector_palette_helpers.h
  21. basisu_gpu_texture.cpp
  22. basisu_gpu_texture.h
  23. basisu_pvrtc1_4.cpp
  24. basisu_pvrtc1_4.h
  25. basisu_resample_filters.cpp
  26. basisu_resampler.cpp
  27. basisu_resampler.h
  28. basisu_resampler_filters.h
  29. basisu_ssim.cpp
  30. basisu_ssim.h
  31. basisu_tool.cpp
  32. build_clang.sh
  33. CMakeLists.txt
  34. LICENSE
  35. lodepng.cpp
  36. lodepng.h
  37. README.md
README.md

basis_universal

Basis Universal GPU Texture Compression Codec

So far, we've compiled this using MSVS 2019, and under Ubuntu using cmake with either clang 3.8 or gcc 5.4.

The command line tool is named “basisu”. Run basisu without any parameters for help.

To compress an sRGB image to .basis:

basisu -srgb x.png

Note that basisu defaults to linear colorspace metrics, not sRGB. If the input is a photograph, or a diffuse/albedo/specular/etc. texture, you want to use sRGB for much better rate distortion performance.

To unpack a .basis file to .png/.ktx files:

basisu x.basis

The mipmapped .KTX files will be in a variety of GPU formats (PVRTC1 4bpp, ETC1-2, BC1-5, BC7), and to my knowledge there is no single .KTX viewer tool that supports every GPU texture format. BC1-5 and BC7 files are viewable using AMD‘s Compressonator, ETC1/2 using Mali’s Texture Compression Tool, and PVRTC1 using Imagination Tech's PVRTexTool. Links:

https://duckduckgo.com/?q=mali+texture+compression+tool&atb=v146-1&ia=web https://gpuopen.com/gaming-product/compressonator/ https://www.imgtec.com/developers/powervr-sdk-tools/pvrtextool/

To use .basis files in an application, you only need the files in the “transcoder” directory. The entire transcoder lives in a single .cpp file: transcoder/basisu_transcoder.cpp. If compiling with gcc/clang, be sure strict aliasing is disabled when compiling this file, as I have not tested either the encoder or transcoder with strict aliasing enabled: -fno-strict-aliasing (The Linux kernel is also compiled with this option.)

To use the transcoder, #include “transcoder/basisu_transcoder.h” and “transcoder/basisu_global_selector_palette.h”. Call basist::basisu_transcoder_init() a single time (probably at startup). Also, probably at startup, you need to create a single instance of the basist::etc1_global_selector_codebook class, like this:

basist::etc1_global_selector_codebook sel_codebook(basist::g_global_selector_cb_size, basist::g_global_selector_cb);

Now you can use the transcoder, which is implemented in the “basisu_transcoder” class in transcoder/basisu_transcoder.h. The key methods are start_decoding(), get_total_images(), get_image_info(), get_image_level_info(), and transcode_image_level().

I will be simplifying the transcoder so the caller doesn‘t need to deal with etc1_global_selector_codebook’s next.

transcode_image_level() and transcode_slice() are thread safe, i.e. you can decompressor multiple images/slices from multiple threads. start_decoding() is not thread safe.