Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.ktx2 filter=lfs diff=lfs merge=lfs -text
vendor/basis_universal/**/* filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
original_assets/**/* filter=lfs diff=lfs merge=lfs -text
crates/basisu_sys/src/snapshots/* filter=lfs diff=lfs merge=lfs -text
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ jobs:
run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going

- name: Build
run: cargo build --verbose
run: cargo build -r

- name: Test
run: cargo test -r

build-wasm:
name: Build wasm
Expand Down Expand Up @@ -105,7 +108,8 @@ jobs:
run: cargo binstall cargo-ndk

- name: Build
run: export ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/${{env.ANDROID_NDK_VERSION}} &&
run:
export ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/${{env.ANDROID_NDK_VERSION}} &&
export ANDROID_NDK_ROOT=${ANDROID_NDK_HOME} &&
cargo ndk-env -t arm64-v8a &&
cargo ndk -t arm64-v8a build --features bevy/android-game-activity
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

- name: Install Emscripten
uses: mymindstorm/setup-emsdk@v14
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exclude: |
.*thirdparty/.*|
.*\.svg|
vendor/basis_universal/.*|
crates/basisu_sys/src/snapshots/.*|
)$
repos:
- repo: https://github.com/codespell-project/codespell
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

## Unreleased

-

## v0.4.3

- Update basis universal to v2.1.0
- `bevy_basisu_loader_sys` crate APIs are simplified and safe.
- `bevy_basisu_loader_sys` crate gets snapshot tests.

## v0.4.2

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_basisu_loader"
version = "0.4.2"
version = "0.4.3"
edition = "2024"
repository.workspace = true
license.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ This plugin adds a loader for Basis Universal KTX2 textures with support for all

Note: This doesn't include BasisU encoder. To encode textures to `.ktx2`, use the command line tool in [Basis Universal](https://github.com/BinomialLLC/basis_universal/?tab=readme-ov-file#compressing-and-unpacking-ktx2basis-files) repo.

Web demo: https://beicause.github.io/bevy_basisu_loader/

## Usage

1. Add the Cargo dependency:
Expand Down Expand Up @@ -47,6 +45,10 @@ pub fn main() {
⚠️Note: The compressed texture dimensions must be a multiplier of block size. See https://github.com/gfx-rs/wgpu/issues/7677 for more context. Also because basisu can transcode to textures with different block size on different platforms,
the texture dimensions should satisfy all possible block sizes. For example, XUASTC 6x6 can transcode to ASTC 6x6 and BC7, so its dimensions should be a multiplier of 12.

## Test status of this repository

This repository contains snapshot tests for decoding BasisU textures in CI. Also a web demo is deployed: https://beicause.github.io/bevy_basisu_loader

## Run on web

TLDR: Just build your bevy application to `wasm32-unknown-unknown` normally.
Expand All @@ -56,8 +58,6 @@ The prebuilt wasm in `crates/basisu_sys/wasm` is automatically embedded in binar
cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -msimd128 -flto=full -sEVAL_CTORS" --wasm-opt-flags="-Os --enable-simd --enable-bulk-memory-opt --enable-nontrapping-float-to-int"
```

## Implementation details

To run on web, this repo uses a solution:

The `crates/basisu_sys/` contains a high level wrapper of the basis universal C++ library.
Expand Down
3 changes: 0 additions & 3 deletions assets/wikipedia_xuastc_ldr_6x6_mips.basisu.ktx2

This file was deleted.

3 changes: 3 additions & 0 deletions assets/wikipedia_xuastc_ldr_8x8_mips.basisu.ktx2
Git LFS file not shown
5 changes: 4 additions & 1 deletion crates/basisu_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_basisu_loader_sys"
version = "0.4.2"
version = "0.4.3"
edition = "2024"
repository.workspace = true
license.workspace = true
Expand Down Expand Up @@ -30,3 +30,6 @@ bindgen = "0.72"
name = "build-wasm-cli"
path = "src/bin/build_wasm_cli.rs"
required-features = ["build-wasm-cli"]

[dev-dependencies]
insta = "1.47.1"
8 changes: 0 additions & 8 deletions crates/basisu_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ fn compile_basisu_static() {
build.cpp_link_stdlib("c++_static");
}
build.cpp(true).std("c++17").flag("-xc++");
if build.get_compiler().is_like_gnu()
&& ["2", "3"].contains(&std::env::var("OPT_LEVEL").unwrap().as_str())
{
// gcc optimizations make basis universal don't work properly and cause artifacts
// when transcoding astc/uastc -> bcn. Limit it to -Os.
// Tested with gcc 15.2.1 on Linux.
build.opt_level_str("s");
}
for f in FLAGS {
build.flag_if_supported(f);
}
Expand Down
Loading
Loading