Skip to content
Open
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ bevy_post_process = ["bevy_internal/bevy_post_process"]
# Provides various anti aliasing solutions
bevy_anti_alias = ["bevy_internal/bevy_anti_alias"]

# Adds extract
bevy_extract = ["bevy_internal/bevy_extract"]

# Adds gamepad support
bevy_gilrs = ["gamepad", "bevy_internal/bevy_gilrs"]

Expand Down Expand Up @@ -748,6 +751,7 @@ bytemuck = "1"
bevy_animation = { path = "crates/bevy_animation", version = "0.19.0-dev", default-features = false }
bevy_asset = { path = "crates/bevy_asset", version = "0.19.0-dev", default-features = false }
bevy_ecs = { path = "crates/bevy_ecs", version = "0.19.0-dev", default-features = false }
bevy_extract = { path = "crates/bevy_extract", version = "0.19.0-dev", default-features = false }
bevy_gizmos = { path = "crates/bevy_gizmos", version = "0.19.0-dev", default-features = false }
bevy_image = { path = "crates/bevy_image", version = "0.19.0-dev", default-features = false }
bevy_reflect = { path = "crates/bevy_reflect", version = "0.19.0-dev", default-features = false }
Expand Down
10 changes: 10 additions & 0 deletions _release-content/migration-guides/extract-extract-a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Extract Extract
pull_requests: []
---

Extraction used to be specific of Main World to Render World, but will now be generic

- Use `TemporaryRenderEntity::default()` instead of `TemporaryRenderEntity`

NOTE: more to come
30 changes: 30 additions & 0 deletions _release-content/migration-guides/extract-extract-b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Extract Extract
pull_requests: []
---

Extraction used to be specific of Main World to Render World, but will now be generic

- When using traits, specify the `AppLabel`, e.g. `SyncComponent`, `ExtractComponent`

Before:

```rust,ignore
impl SyncComponent for TemporalAntiAliasing { ... }

#[derive(Component, ExtractComponent)]
#[extract_app(RenderApp)]
pub struct Foo { ... }
```

After:

```rust,ignore
impl SyncComponent<RenderApp> for TemporalAntiAliasing { ... }

#[derive(Component, ExtractComponent)]
#[extract_app(RenderApp)]
pub struct Foo { ... }
```

NOTE: more to come
12 changes: 12 additions & 0 deletions _release-content/migration-guides/extract-extract-e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Extract Extract
pull_requests: []
---

Extraction used to be specific of Main World to Render World, but will now be generic

All above has moved to new crate `bevy_extract`.

Most extraction parts are re-exported by `bevy_render` , but some migrations are needed

NOTE: more to come
1 change: 1 addition & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ seq-macro = "0.3.6"
# Bevy crates
bevy_app = { path = "../crates/bevy_app" }
bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi_threaded"] }
bevy_extract = { path = "../crates/bevy_extract" }
bevy_math = { path = "../crates/bevy_math" }
bevy_picking = { path = "../crates/bevy_picking", features = ["mesh_picking"] }
bevy_reflect = { path = "../crates/bevy_reflect", features = ["functions"] }
Expand Down
16 changes: 12 additions & 4 deletions benches/benches/bevy_render/extract_render_asset.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use bevy_app::{App, AppLabel};
use bevy_asset::{Asset, AssetApp, AssetEvent, AssetId, Assets, RenderAssetUsages};
use bevy_ecs::prelude::*;
use bevy_ecs::{prelude::*, schedule::ScheduleLabel};
use bevy_reflect::TypePath;
use bevy_render::{
extract_plugin::ExtractPlugin,
render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin},
RenderApp,
Render, RenderApp, RenderSystems,
};
use criterion::{criterion_group, BenchmarkId, Criterion, Throughput};
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -33,6 +33,8 @@ impl RenderAsset for DummyRenderAsset {
}
}

pub(crate) fn pre_extract(_main_world: &mut World, _render_world: &mut World) {}

fn extract_render_asset_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("extract_render_asset");

Expand All @@ -45,7 +47,13 @@ fn extract_render_asset_bench(c: &mut Criterion) {

app.add_plugins(bevy_asset::AssetPlugin::default());
app.init_asset::<DummyAsset>();
app.add_plugins(ExtractPlugin::default());
app.add_plugins(ExtractPlugin::<RenderApp>::new(
pre_extract,
Render::base_schedule,
Render.intern(),
RenderSystems::ExtractCommands.intern(),
RenderSystems::PostCleanup.intern(),
));
app.add_plugins(RenderAssetPlugin::<DummyRenderAsset>::default());

app.finish();
Expand Down Expand Up @@ -80,7 +88,7 @@ fn extract_render_asset_bench(c: &mut Criterion) {

// Measuring the extract call
let start = Instant::now();
bevy_render::extract_plugin::extract(main.world_mut(), render_world);
bevy_extract::extract_plugin::extract(main.world_mut(), render_world);
total += Instant::now().duration_since(start);

// Run a standard app update to allow Bevy's internal systems to flush/clear the message queues.
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_anti_alias/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bevy_image = { path = "../bevy_image", version = "0.19.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.19.0-dev" }
bevy_shader = { path = "../bevy_shader", version = "0.19.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev" }
bevy_extract = { path = "../bevy_extract", version = "0.19.0-dev" }
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.19.0-dev" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.19.0-dev" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ pub struct CasUniform {
sharpness: f32,
}

impl SyncComponent for ContrastAdaptiveSharpening {
impl SyncComponent<RenderApp> for ContrastAdaptiveSharpening {
type Target = (DenoiseCas, CasUniform);
}

impl ExtractComponent for ContrastAdaptiveSharpening {
impl ExtractComponent<RenderApp> for ContrastAdaptiveSharpening {
type QueryData = &'static Self;
type QueryFilter = With<Camera>;
type Out = (DenoiseCas, CasUniform);
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_anti_alias/src/fxaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Sensitivity {
#[reflect(Component, Default, Clone)]
#[extract_component_filter(With<Camera>)]
#[doc(alias = "FastApproximateAntiAliasing")]
#[extract_app(RenderApp)]
pub struct Fxaa {
/// Enable render passes for FXAA.
pub enabled: bool,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_anti_alias/src/smaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct SmaaPlugin;
ViewSmaaPipelines,
))]
#[doc(alias = "SubpixelMorphologicalAntiAliasing")]
#[extract_app(RenderApp)]
pub struct Smaa {
/// A predefined set of SMAA parameters: i.e. a quality level.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_anti_alias/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Default for TemporalAntiAliasing {
}
}

impl SyncComponent for TemporalAntiAliasing {
impl SyncComponent<RenderApp> for TemporalAntiAliasing {
type Target = Self;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ mod tests {
fn test_extract_sees_changes() {
use super::AppLabel;

#[derive(AppLabel, Clone, Copy, Hash, PartialEq, Eq, Debug)]
#[derive(AppLabel, Clone, Copy, Hash, PartialEq, Eq, Debug, Default)]
struct MySubApp;

#[derive(Resource)]
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_app/src/sub_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ type ExtractFn = Box<dyn FnMut(&mut World, &mut World) + Send>;
/// # Example
///
/// ```
/// # use bevy_app::{App, AppLabel, SubApp, Main};
/// # use bevy_app::{App, SubApp, Main};
/// # use bevy_derive::AppLabel;
/// # use bevy_ecs::prelude::*;
/// # use bevy_ecs::schedule::ScheduleLabel;
///
/// #[derive(Resource, Default)]
/// struct Val(pub i32);
///
/// #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, AppLabel)]
/// #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, AppLabel, Default)]
/// struct ExampleApp;
///
/// // Create an app with a certain resource.
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bevy_color = { path = "../bevy_color", version = "0.19.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.19.0-dev" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.19.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev" }
bevy_extract = { path = "../bevy_extract", version = "0.19.0-dev" }
bevy_image = { path = "../bevy_image", version = "0.19.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.19.0-dev" }
bevy_light = { path = "../bevy_light", version = "0.19.0-dev" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/fullscreen_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<T: FullscreenMaterial> Plugin for FullscreenMaterialPlugin<T> {

/// A trait to define a material that will render to the entire screen using a fullscreen triangle.
pub trait FullscreenMaterial:
Component + ExtractComponent + Clone + Copy + ShaderType + WriteInto + Default
Component + ExtractComponent<RenderApp> + Clone + Copy + ShaderType + WriteInto + Default
{
/// The shader that will run on the entire screen using a fullscreen triangle.
fn fragment_shader() -> ShaderRef;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_core_pipeline/src/oit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub mod resolve;
#[derive(Clone, Copy, ExtractComponent, Reflect, ShaderType, Component)]
#[extract_component_sync_target((Self, OrderIndependentTransparencySettingsOffset, OitResolvePipelineId))]
#[reflect(Clone, Default)]
#[extract_app(RenderApp)]
pub struct OrderIndependentTransparencySettings {
/// Controls how many fragments will be exactly sorted.
/// If the scene has more fragments than this, they will be merged approximately.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ use crate::{
#[reflect(Component, Default, Clone)]
pub struct NoBackgroundMotionVectors;

impl SyncComponent for NoBackgroundMotionVectors {
impl SyncComponent<RenderApp> for NoBackgroundMotionVectors {
type Target = Self;
}

impl ExtractComponent for NoBackgroundMotionVectors {
impl ExtractComponent<RenderApp> for NoBackgroundMotionVectors {
type QueryData = Read<NoBackgroundMotionVectors>;
type QueryFilter = ();
type Out = Self;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Plugin for SkyboxPlugin {
}
}

impl SyncComponent<SkyboxPlugin> for Skybox {
impl SyncComponent<RenderApp, SkyboxPlugin> for Skybox {
type Target = (Self, SkyboxUniforms, SkyboxPipelineId, SkyboxBindGroup);
}

Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use crate::FullscreenShader;

/// 3D LUT (look up table) textures used for tonemapping
#[derive(Resource, Clone, ExtractResource)]
#[extract_app(RenderApp)]
pub struct TonemappingLuts {
pub blender_filmic: Handle<Image>,
pub agx: Handle<Image>,
Expand Down Expand Up @@ -116,6 +117,7 @@ pub struct TonemappingPipeline {
)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component, Debug, Hash, Default, PartialEq)]
#[extract_app(RenderApp)]
pub enum Tonemapping {
/// Bypass tonemapping.
None,
Expand Down Expand Up @@ -377,6 +379,7 @@ pub fn prepare_view_tonemapping_pipelines(
)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component, Debug, Hash, Default, PartialEq)]
#[extract_app(RenderApp)]
pub enum DebandDither {
#[default]
Disabled,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_dev_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bevy_color = { path = "../bevy_color", version = "0.19.0-dev" }
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.19.0-dev" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.19.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev" }
bevy_extract = { path = "../bevy_extract", version = "0.19.0-dev" }
bevy_image = { path = "../bevy_image", version = "0.19.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.19.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.19.0-dev" }
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_dev_tools/src/render_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ pub enum RenderDebugOverlayEvent {
/// Overwrites the default [`GlobalRenderDebugOverlay`] resource.
#[derive(Component, Clone, ExtractComponent, Reflect, PartialEq)]
#[reflect(Component, Default)]
#[extract_app(RenderApp)]
pub struct RenderDebugOverlay {
/// Enables or disables drawing the overlay.
pub enabled: bool,
Expand All @@ -295,6 +296,7 @@ impl Default for RenderDebugOverlay {
/// Can be overwritten by using a [`RenderDebugOverlay`] component.
#[derive(Resource, Clone, ExtractResource, ExtractComponent, Reflect, PartialEq)]
#[reflect(Resource, Default)]
#[extract_app(RenderApp)]
pub struct GlobalRenderDebugOverlay {
/// Enables or disables drawing the overlay.
pub enabled: bool,
Expand Down
39 changes: 39 additions & 0 deletions crates/bevy_extract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "bevy_extract"
version = "0.19.0-dev"
edition = "2024"
description = "Provides extract functionality for Bevy Engine"
homepage = "https://bevy.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
default = []
trace = []

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.19.0-dev" }
bevy_camera = { path = "../bevy_camera", version = "0.19.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.19.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev" }
bevy_extract_macros = { path = "../bevy_extract/macros", version = "0.19.0-dev" }
bevy_log = { path = "../bevy_log", version = "0.19.0-dev" }
bevy_platform = { path = "../bevy_platform", version = "0.19.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.19.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.19.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.19.0-dev" }

# other
# downcast-rs = { version = "2", default-features = false }

[dev-dependencies]
# crossbeam-channel = "0.5.0"

[lints]
workspace = true

[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
all-features = true
Loading
Loading