Bindings for Binomial LLC's basis-universal Supercompressed GPU Texture Codec

Overview

basis-universal-rs

Bindings for Binomial LLC's basis-universal Supercompressed GPU Texture Codec

basis-universal functionality can be grouped into two categories:

  • Encoding: Compresses and encode textures (optionally combining multiple images and mipmap layers in a single file/binary blob)
  • Transcoding: Unpacks the texture into GPU-friendly compression formats. The final format can be chosen based on what the available GPU hardware can support.

Encoding can be done ahead of time using a command line tool in the upstream repository.

The encoded data can either be stored as a file or a binary blob. This data can include multiple images, and each image can store multiple levels. This is commonly used for storing cube textures and textures with precomputed mipmaps. This library also supports generating mipmaps for you.

Please refer to https://github.com/BinomialLLC/basis_universal for more details.

Status

These bindings should be production-ready. The API should remain fairly stable (assuming no major upstream changes in the wrapped basis-universal library)

Performance

The C++ code that is wrapped by these bindings is built at the same optimization level used for building the basis-universal-sys crate. Most users of these bindings will benefit from building this crate with optimizations enabled, even during development. To do that, place this in your Cargo.toml file.

[profile.dev.package."basis-universal-sys"]
opt-level = 3

Enable optimizations for ALL upstream crates works too:

[profile.dev.package."*"]
opt-level = 3

License

The bindings are licensed under either of

at your option.

Upstream Dependencies

Some dependencies may be licensed under other terms. These licenses include "ISC", "CC0-1.0", "BSD-2-Clause", "BSD-3-Clause", and "Zlib". This is validated on a best-effort basis in every CI run using cargo-deny.

Binomial LLC's basis-universal Supercompressed GPU Texture Codec is licensed under Apache License 2.0:

Copyright (C) 2019-2020 Binomial LLC. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See LICENSE-APACHE and LICENSE-MIT.

Comments
  • Wasm support

    Wasm support

    Hi! I mentioned I started working on wasm support here: https://github.com/aclysma/basis-universal-rs/issues/10. I've been using this on a branch of this crate for a while but I thought I'd just now have a go at merging my changes. This PR isn't super ready yet but some aspect could be merged. I've rewritten some calls like basis_transcoder_format_is_uncompressed and validate_output_buffer_size in rust so there are less bindings to the basis-universal wasm binary that I have to implement.

    opened by expenses 4
  • Add support for the low-level UASTC transcoder

    Add support for the low-level UASTC transcoder

    I have similar code for at least transcode_slice() for the low-level ETC1S transcoder but I didn't yet figure out how to get BasisLZ/ETC1S data from KTX2 and feed it into that function. This, however, for UASTC is working.

    opened by superdump 0
  • Support for `wasm32-unknown-unknown` via binding with the provided emscripten wasm file

    Support for `wasm32-unknown-unknown` via binding with the provided emscripten wasm file

    CC @superdump

    I've been working on writing bindings for the transcoder wasm that basis_universal provides so that I can parse and transcode basis files in wasm. I've got a repo for this here: https://github.com/expenses/basis-universal-rs-wasm

    It'd be fantastic if we could get support for this into this crate, so that wasm support just works. A couple of notes:

    • I had to set EXPORT_ES6=1 in the emscripten link flags:

      https://github.com/BinomialLLC/basis_universal/blob/b38c3e4a9bf85d2fe13e2a9d5495be90eb927381/webgl/transcoder/CMakeLists.txt#L51

      I don't know if I strictly needed to do this, but it made binding with wasm-bindgen via #[wasm_bindgen(js_name = default)] a lot easier.

    • The emscripten code loads the module asyncronously, which means you can't directly import the exports in wasm-bindgen because they're only created after initialisation. To work around this I had to use reflection to create the javascript classes: https://github.com/expenses/basis-universal-rs-wasm/blob/8274f56092c930bb0dfbb35b0386235a3c5a9813/src/lib.rs#L36-L38

    • By default the emscripten code attempts to load the wasm binary from a relative url. Because wasm-bindgen copies the referenced javascript module to a snippet such as pkg/snippets/basis-universal-wasm-8dd816e8505190b7/basis_universal/webgl/transcoder/build/basis_transcoder.js but does not copy anything else. this load fails.

      Luckily the code allows settings a wasmBinary key in the object that's passed in, so you can provide your own wasm file: https://github.com/expenses/basis-universal-rs-wasm/blob/master/src/lib.rs#L26-L31. I just include_bytes! the file for ease of use.

    • Because the wrapper API is quite different from the normal API, we're probably going to have to write our own wrapper to bring the APIs to parity.

    This will all take a while, but I'll try to create good bindings for the .basisu transcoder and work from there.

    opened by expenses 6
  • Consider implementing additional traits

    Consider implementing additional traits

    Could consider implementing:

    • Send, Sync
    • Debug, Clone, Copy, PartialEq, Eq, Hash
    • Serialize/Deserialize (probably gated by feature flag)
    • Anything else?
    opened by aclysma 0
  • Make CompressorImageRef safer

    Make CompressorImageRef safer

    It's possible to get a CompressorImageRef from CompressorParams, drop CompressorParams, and cause undefined behavior by using CompressorImageRef. Some API improvements would enable rust borrow checking to catch this at compile time.

    opened by aclysma 0
Owner
Philip Degarmo
Network games programmer in San Diego, CA
Philip Degarmo
Yet Another Texture Packer - a small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet

YATP (Yet Another Texture Packer) A small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet. Installation

Petar Petrov 2 Sep 11, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Basis Spline Fun(ctions) and NURBS Curves / Surfaces

bsfun Basis Spline Fun(ctions) This is a super simple Rust library for working with basis splines and NURBS (Non-Uniform Rational B-Splines) with zero

null 5 May 14, 2023
a simple rust service for Scheduling commands execution on time basis, an easy alternative to cron

Tasker A Simple crate which provides a service and a configuration API for genrating commands based tasks ,on time basis. Installation build from sour

Daniel Madmon 5 Jun 1, 2023
Abstract GPU Project - The easiest and most ergonomic GPU library

Abstract GPU Project - The easiest and most ergonomic GPU library

LyricWulf 9 Nov 30, 2022
🎨 Example-based texture synthesis written in Rust 🦀

?? texture-synthesis A light Rust API for Multiresolution Stochastic Texture Synthesis [1], a non-parametric example-based algorithm for image generat

Embark 1.7k Dec 31, 2022
Implements the free and open audio codec Opus in Rust.

opus-native Overview Implements the free and open audio codec Opus in Rust. Status This crate is under heavy development. Most functionality is not wo

Nils Hasenbanck 9 Nov 28, 2022
A rusty, dual-wielding Quake and Half-Life texture WAD parser.

Ogre   A rusty, dual-wielding Quake and Half-Life texture WAD parser ogre is a rust representation and nom parser for Quake and Half-Life WAD files. I

Josh Palmer 16 Dec 5, 2022
Pure-rust implementation of legacy H.263 video codec and associated color transforms

website | demo | nightly builds | wiki h263-rs h263-rs is a pure-Rust implementation of ITU-T Recommendation H.263 (2005/08), a video codec commonly u

Ruffle 7 Dec 18, 2022
Simple async codec for rkyv. Reuses streaming buffer for maximum speed

rkyv_codec Simple async codec for rkyv. Reuses streaming buffer for maximum speed! This crate provides a makeshift adaptor for streaming &Archived<Obj

Zyansheep 19 Jun 14, 2022
A cross-platform image (texture) viewer

img_maniac A cross-platform image (texture) viewer Features Drag and drop images: Users can easily add as many images as they want to the main window

Allen Dang 90 May 7, 2023
Designed as successor to Pretty-Good-Video for improved codec structure, API design & performance

Pretty Fast Video Minimal video codec designed as a successor to Pretty Good Video Goals are to improve: Quality API design Codec structure (Hopefully

Hazel Stagner 36 Jun 5, 2023
A parallel universal-ctags wrapper for git repository

ptags A parallel universal-ctags wrapper for git repository Description ptags is a universal-ctags wrapper to have the following features. Search git

null 107 Dec 30, 2022
Cargo subcommand to automatically create universal libraries for iOS.

cargo lipo Provides a cargo lipo subcommand which automatically creates a universal library for use with your iOS application. Maintenance Status Plea

Tim Neumann 430 Dec 29, 2022
Wikit - A universal dictionary

Wikit - A universal dictionary What is it? To be short, Wikit is a tool which can (fully, may be in future) render and create dictionary file in MDX/M

bugnofree 120 Dec 3, 2022
Wikit - A universal dictionary

Wikit - A universal dictionary

bugnofree 120 Dec 3, 2022
Universal Schema Analysis

schema_analysis Universal-ish Schema Analysis Ever wished you could figure out what was in that json file? Or maybe it was xml... Ehr, yaml? It was de

null 23 Jul 13, 2022
Universal configuration library parser

LIBUCL Table of Contents generated with DocToc Introduction Basic structure Improvements to the json notation General syntax sugar Automatic arrays cr

Vsevolod Stakhov 1.5k Jan 7, 2023
Universal changelog generator using conventional commit+ with monorepo support. Written in Rust.

chlog Universal changelog generator using conventional commit+ with monorepo support. chlog can generate the changelog from the conventional commits w

Jeff Yang 3 Nov 27, 2022
a universal meta-transliterator that can decipher arbitrary encoding schemas, built in pure Rust

transliterati a universal meta-transliterator that can decipher arbitrary encoding schemas, built in pure Rust what does it do? You give it this: Барл

Catherine Koshka 7 Dec 21, 2022