Expand description
§Rust binding and wrappers for the Basis Universal pure C API.
Rust binding and wrappers for the basisu pure C API, through FFI on native and wasm-bindgen on web. See also https://github.com/BinomialLLC/basis_universal/wiki#encoder-and-transcoding-c-api-documentation.
This crate also contains optional high level API that is easier to use with wgpu-types. Enabling the extra cargo feature to use the high level BasisuEncoder and BasisuTranscoder.
Note that BC1, PVRTC1, ATC, FXT1, PVRTC2 are not compiled to reduce binary size, as they are not transcode targets by default.
This supports wasm32-unknown-unknown by embedding prebuilt basisu wasm binary and wasm-bindgen. You need to call instantiate_embedded_basisu_wasm function before calling other functions if running on the web.
By default, the prebuilt basisu wasm is from Github artifact in CI. It is built with:
cargo r -p basisu_c_sys --bin gen_make_wasm --features __gen_make_wasm -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS"
mkdir build && cd build
emcmake cmake ..
emmake make -j$(nproc)Feature flags:
encoder: Enable basisu encoder, which will significantly increase the binary size. By default only transcoder is enabled.serde: Enableserdeon some structs.extra: Enable extra high level encoder and transcoder API that is easier to use withwgpu-types.
Modules§
- common
- encoder
encoder - extra
extra - transcoder
Enums§
- Basis
Texture Format - A enum that wraps
common::BTF_*. - Transcode
Target Format - A enum that wraps
common::TF_*.
Functions§
- copy_
basisu_ ⚠memory_ to_ host - Use this to copy memory between host and basisu. This is required on web where memory isn’t shared.
- copy_
host_ ⚠memory_ to_ basisu - Use this to copy memory between host and basisu. This is required on web where memory isn’t shared.
- instantiate_
embedded_ basisu_ wasm - Instantiate the embedded basisu wasm, required on web before calling other functions. This is no-op on native platforms.