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: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.ktx2 filter=lfs diff=lfs merge=lfs -text
*.basisu_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
77 changes: 65 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,48 @@ concurrency:
env:
CARGO_TERM_COLOR: always
EM_VERSION: 4.0.22
ANDROID_NDK_VERSION: 28.1.13356709

jobs:
build-linux-wasm:
name: Build linux,wasm
runs-on: ubuntu-latest
build-lib:
name: Build ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

- name: Install Linux dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: ./.github/actions/install-linux-deps

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Clippy
run: cargo clippy -- -D warnings

- name: Doc
run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going

- name: Build
run: cargo build --verbose

build-wasm:
name: Build wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -41,16 +70,40 @@ jobs:
- name: Install wasm-opt
run: wget https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-linux.tar.gz && tar -xvf binaryen-version_125-x86_64-linux.tar.gz && sudo cp binaryen-version_125/bin/wasm-opt /usr/local/bin/ && rm -r binaryen-version_125 && rm binaryen-version_125-x86_64-linux.tar.gz

- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --verbose

- name: Build basisu vendor wasm
run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-Os -flto=full" --wasm-opt-flags="-Os"
run: 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"

- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: crates/basisu_sys/wasm/

- name: Build wasm
run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo build --target wasm32-unknown-unknown

build-android:
name: Build android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: aarch64-linux-android

- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@v1.16.6

- name: Install Android NDK
run: |
sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager 'ndk;${{env.ANDROID_NDK_VERSION}}'

- name: Install cargo-ndk
run: cargo binstall cargo-ndk

- name: Build
run: cargo ndk -t arm64-v8a build --features bevy/android-game-activity
68 changes: 0 additions & 68 deletions .github/workflows/ci_minimal.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Linter

on:
workflow_dispatch:
push:
branches: ["master"]
pull_request:
branches: ["master"]

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
toml:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install taplo
run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
- name: Run Taplo
id: taplo
run: taplo fmt --check --diff
- name: Taplo info
if: failure()
run: |
echo 'To fix toml fmt, please run `taplo fmt`.'
echo 'To check for a diff, run `taplo fmt --check --diff`.'
echo 'You can find taplo here: https://taplo.tamasfe.dev/'
echo 'Or if you use VSCode, use the `Even Better Toml` extension.'
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml'

typos:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check for typos
uses: crate-ci/typos@ad3053d3adbcce7f2e3c60fd4ddfc239787d1eff # v1.43.2
- name: Typos info
if: failure()
run: |
echo 'To fix typos, please run `typos -w`'
echo 'To check for a diff, run `typos`'
echo 'You can find typos here: https://crates.io/crates/typos'
echo 'if you use VSCode, you can also install `Typos Spell Checker'
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
name: Release ${{ (github.event_name == 'workflow_dispatch' && inputs.dry_run && '(Dry Run)') || '' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

Expand All @@ -50,10 +49,9 @@ jobs:
targets: wasm32-unknown-unknown

- name: Build basisu vendor wasm
run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os"

run: 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"
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: |
crates/basisu_sys/wasm/basisu_vendor.js
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true

Expand All @@ -58,15 +57,14 @@ jobs:
run: cargo binstall --force wasm-bindgen-cli

- name: Build basisu vendor wasm
run: cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os"

run: 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"
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: crates/basisu_sys/wasm/

- name: Build
run: cargo b -p test_scene --target wasm32-unknown-unknown --profile web_release
run: RUSTFLAGS="-Ctarget-feature=+simd128" cargo b -p test_scene --target wasm32-unknown-unknown --profile web_release

- name: Wasm bindgen
run: wasm-bindgen --out-name wasm_example --out-dir web/target/ --target web target/wasm32-unknown-unknown/web_release/test_scene.wasm
Expand All @@ -78,7 +76,7 @@ jobs:
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v4
with:
path: web/

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ pub fn main() {

1. Load ktx2 basis universal textures. Supports `D2`, `D2Array` and `Cube` texture types. Only supports KTX2 format (zstd compression is supported). No support for `.basis` format.
```rs
let image_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu_ktx2");
let image_handle = asset_server.load("gl_skybox_etc1s_cubemap_mips_12.basisu.ktx2");
```

⚠️Note: you have to rename the file extension to `.basisu_ktx2` to load it with this `BasisuLoader`. This is a limitations of bevy because otherwise bevy will load `.ktx2` file with its `ImageLoader`.
⚠️Note: you have to rename the file extension to `.basisu.ktx2` to load it with this `BasisuLoader`. This is a limitations of bevy because otherwise bevy will load `.ktx2` file with its `ImageLoader`.

⚠️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.
Expand All @@ -59,7 +59,7 @@ TLDR: Just build your bevy application to `wasm32-unknown-unknown` normally.

The prebuilt wasm in `crates/basisu_sys/wasm` is automatically embedded in binary when building. It was prebuilt through CI with:
```sh
cargo r -p bevy_basisu_loader_sys --bin build-wasm-cli --features build-wasm-cli -- --emcc-flags="-sEVAL_CTORS -Os -flto=full" --wasm-opt-flags="-Os"
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"
```

## Bevy version compatibility
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/basisu_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const DEFINES: [(&str, &str); 5] = [
("BASISD_SUPPORT_PVRTC1", "0"),
// ("BASISD_SUPPORT_ETC2_EAC_A8", "1"),
// ("BASISD_SUPPORT_ASTC", "1"),
// ("BASISD_SUPPORT_XUASTC", "1"),
("BASISD_SUPPORT_ATC", "0"),
// ("BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY", "1"),
// ("BASISD_SUPPORT_ETC2_EAC_RG11", "1"),
// ("BASISD_SUPPORT_ASTC_HIGHER_OPAQUE_QUALITY", "1"),
("BASISD_SUPPORT_FXT1", "0"),
("BASISD_SUPPORT_PVRTC2", "0"),
// ("BASISD_SUPPORT_UASTC_HDR", "1"),
Expand Down Expand Up @@ -97,7 +98,6 @@ fn compile_basisu_static() {

fn gen_wasm_build_cmd() {
let wasm_args = [
"-msimd128",
"-sSTRICT",
"-sEXPORT_ES6",
"-sINCOMING_MODULE_JS_API=wasmBinary",
Expand Down
9 changes: 1 addition & 8 deletions crates/basisu_sys/src/bin/build_wasm_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ pub fn build_wasm_cmd() {

if let Some(flags) = user_args.wasm_opt_flags {
let mut wasm_opt_cmd = std::process::Command::new("wasm-opt");
wasm_opt_cmd.args([
"--enable-simd",
"--enable-bulk-memory-opt",
"--enable-nontrapping-float-to-int",
"wasm/basisu_vendor.wasm",
"-o",
"wasm/basisu_vendor.wasm",
]);
wasm_opt_cmd.args(["wasm/basisu_vendor.wasm", "-o", "wasm/basisu_vendor.wasm"]);

wasm_opt_cmd.args(flags.split(" ").filter(|s| !s.is_empty()));

Expand Down
Loading