-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split off bevy_image from bevy_render (#15650)
# Objective - bevy_render is gargantuan ## Solution - Split off bevy_image ## Testing - Ran some examples
- Loading branch information
Showing
20 changed files
with
293 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
bitflags::bitflags! { | ||
/// Defines where the asset will be used. | ||
/// | ||
/// If an asset is set to the `RENDER_WORLD` but not the `MAIN_WORLD`, the asset will be | ||
/// unloaded from the asset server once it's been extracted and prepared in the render world. | ||
/// | ||
/// Unloading the asset saves on memory, as for most cases it is no longer necessary to keep | ||
/// it in RAM once it's been uploaded to the GPU's VRAM. However, this means you can no longer | ||
/// access the asset from the CPU (via the `Assets<T>` resource) once unloaded (without re-loading it). | ||
/// | ||
/// If you never need access to the asset from the CPU past the first frame it's loaded on, | ||
/// or only need very infrequent access, then set this to `RENDER_WORLD`. Otherwise, set this to | ||
/// `RENDER_WORLD | MAIN_WORLD`. | ||
/// | ||
/// If you have an asset that doesn't actually need to end up in the render world, like an Image | ||
/// that will be decoded into another Image asset, use `MAIN_WORLD` only. | ||
/// | ||
/// ## Platform-specific | ||
/// | ||
/// On Wasm, it is not possible for now to free reserved memory. To control memory usage, load assets | ||
/// in sequence and unload one before loading the next. See this | ||
/// [discussion about memory management](https://github.com/WebAssembly/design/issues/1397) for more | ||
/// details. | ||
#[repr(transparent)] | ||
#[derive(Serialize, Deserialize, Hash, Clone, Copy, PartialEq, Eq, Debug, Reflect)] | ||
#[reflect(opaque)] | ||
#[reflect(Serialize, Deserialize, Hash, PartialEq, Debug)] | ||
pub struct RenderAssetUsages: u8 { | ||
const MAIN_WORLD = 1 << 0; | ||
const RENDER_WORLD = 1 << 1; | ||
} | ||
} | ||
|
||
impl Default for RenderAssetUsages { | ||
/// Returns the default render asset usage flags: | ||
/// `RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD` | ||
/// | ||
/// This default configuration ensures the asset persists in the main world, even after being prepared for rendering. | ||
/// | ||
/// If your asset does not change, consider using `RenderAssetUsages::RENDER_WORLD` exclusively. This will cause | ||
/// the asset to be unloaded from the main world once it has been prepared for rendering. If the asset does not need | ||
/// to reach the render world at all, use `RenderAssetUsages::MAIN_WORLD` exclusively. | ||
fn default() -> Self { | ||
RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[package] | ||
name = "bevy_image" | ||
version = "0.15.0-dev" | ||
edition = "2021" | ||
description = "Provides image types for Bevy Engine" | ||
homepage = "https://bevyengine.org" | ||
repository = "https://github.com/bevyengine/bevy" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["bevy"] | ||
|
||
[features] | ||
png = ["image/png"] | ||
exr = ["image/exr"] | ||
hdr = ["image/hdr"] | ||
tga = ["image/tga"] | ||
jpeg = ["image/jpeg"] | ||
bmp = ["image/bmp"] | ||
webp = ["image/webp"] | ||
dds = ["ddsfile"] | ||
pnm = ["image/pnm"] | ||
|
||
# For ktx2 supercompression | ||
zlib = ["flate2"] | ||
zstd = ["ruzstd"] | ||
|
||
[dependencies] | ||
bevy_asset = { path = "../bevy_asset", version = "0.15.0-dev" } | ||
bevy_color = { path = "../bevy_color", version = "0.15.0-dev", features = [ | ||
"serialize", | ||
"wgpu-types", | ||
] } | ||
bevy_math = { path = "../bevy_math", version = "0.15.0-dev" } | ||
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [ | ||
"bevy", | ||
] } | ||
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" } | ||
|
||
# rendering | ||
image = { version = "0.25.2", default-features = false } | ||
|
||
# misc | ||
bitflags = { version = "2.3", features = ["serde"] } | ||
bytemuck = { version = "1.5" } | ||
wgpu = { version = "22", default-features = false } | ||
serde = { version = "1", features = ["derive"] } | ||
thiserror = "1.0" | ||
futures-lite = "2.0.1" | ||
ddsfile = { version = "0.5.2", optional = true } | ||
ktx2 = { version = "0.3.0", optional = true } | ||
# For ktx2 supercompression | ||
flate2 = { version = "1.0.22", optional = true } | ||
ruzstd = { version = "0.7.0", optional = true } | ||
# For transcoding of UASTC/ETC1S universal formats, and for .basis file support | ||
basis-universal = { version = "0.3.0", optional = true } | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[package.metadata.docs.rs] | ||
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"] | ||
all-features = true |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
..._render/src/texture/exr_texture_loader.rs → crates/bevy_image/src/exr_texture_loader.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
..._render/src/texture/hdr_texture_loader.rs → crates/bevy_image/src/hdr_texture_loader.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...r/src/texture/image_texture_conversion.rs → ...evy_image/src/image_texture_conversion.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// FIXME(15321): solve CI failures, then replace with `#![expect()]`. | ||
#![allow(missing_docs, reason = "Not all docs are written yet, see #3492.")] | ||
#![allow(unsafe_code)] | ||
|
||
mod image; | ||
pub use self::image::*; | ||
#[cfg(feature = "basis-universal")] | ||
mod basis; | ||
#[cfg(feature = "dds")] | ||
mod dds; | ||
#[cfg(feature = "exr")] | ||
mod exr_texture_loader; | ||
#[cfg(feature = "hdr")] | ||
mod hdr_texture_loader; | ||
#[cfg(feature = "ktx2")] | ||
mod ktx2; | ||
|
||
#[cfg(feature = "ktx2")] | ||
pub use self::ktx2::*; | ||
#[cfg(feature = "dds")] | ||
pub use dds::*; | ||
#[cfg(feature = "exr")] | ||
pub use exr_texture_loader::*; | ||
#[cfg(feature = "hdr")] | ||
pub use hdr_texture_loader::*; | ||
|
||
pub(crate) mod image_texture_conversion; | ||
pub use image_texture_conversion::IntoDynamicImageError; |
Oops, something went wrong.