From e0383a0b96d16e7cb974dddee7fd3d029d806f6e Mon Sep 17 00:00:00 2001 From: atlv Date: Mon, 14 Jul 2025 16:53:26 -0400 Subject: [PATCH] Add zstd release note (#20053) # Objective - Add a release note for the new zstd backend. - Doing so, I realized it was really cumbersome to enable this feature because we default-enable ruzstd AND make it take precedence if both are enabled. We can improve ux a bit by making the optional feature take precedence when both are enabled. This still doesnt remove the unneeded dependency, but oh well. Note: it would be nice to have a way to make zstd_c not do anything when building wasm, but im not sure theres a way to do that, as it seems like it would need negative features. --------- Co-authored-by: Jan Hohenheim --- crates/bevy_image/src/ktx2.rs | 4 +-- .../release-notes/faster-zstd-option.md | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 release-content/release-notes/faster-zstd-option.md diff --git a/crates/bevy_image/src/ktx2.rs b/crates/bevy_image/src/ktx2.rs index 61304c2145..be9f8ecc55 100644 --- a/crates/bevy_image/src/ktx2.rs +++ b/crates/bevy_image/src/ktx2.rs @@ -58,7 +58,7 @@ pub fn ktx2_buffer_to_image( })?; levels.push(decompressed); } - #[cfg(feature = "zstd_rust")] + #[cfg(all(feature = "zstd_rust", not(feature = "zstd_c")))] SupercompressionScheme::Zstandard => { let mut cursor = std::io::Cursor::new(level.data); let mut decoder = ruzstd::decoding::StreamingDecoder::new(&mut cursor) @@ -71,7 +71,7 @@ pub fn ktx2_buffer_to_image( })?; levels.push(decompressed); } - #[cfg(all(feature = "zstd_c", not(feature = "zstd_rust")))] + #[cfg(feature = "zstd_c")] SupercompressionScheme::Zstandard => { levels.push(zstd::decode_all(level.data).map_err(|err| { TextureError::SuperDecompressionError(format!( diff --git a/release-content/release-notes/faster-zstd-option.md b/release-content/release-notes/faster-zstd-option.md new file mode 100644 index 0000000000..01c4bc98c3 --- /dev/null +++ b/release-content/release-notes/faster-zstd-option.md @@ -0,0 +1,27 @@ +--- +title: Faster Zstd decompression option +authors: ["@atlv24", "@brianreavis"] +pull_requests: [19793] +--- + +There is now an option to use the [zstd](https://crates.io/crates/zstd) c-bindings instead of [ruzstd](https://crates.io/crates/ruzstd). +This is less safe and portable, but can be around 44% faster. + +The two features that control which one is used are `zstd_rust` and `zstd_c`. +`zstd_rust` is enabled by default, but `zstd_c` takes precedence if both are enabled. + +To enable it, add the feature to the `bevy` entry of your Cargo.toml: + +```toml +bevy = { version = "0.17.0", features = ["zstd_c"] } +``` + +Note: this will still include a dependency on `ruzstd`, because mutually exclusive features are not supported by Cargo. +To remove this dependency, disable default-features, and manually enable any default features you need: + +```toml +bevy = { version = "0.17.0", default-features = false, features = [ + "zstd_c", + "bevy_render", # etc.. +] } +```