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
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
14 changes: 11 additions & 3 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
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
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
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
3 changes: 2 additions & 1 deletion crates/bevy_gizmos_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn extract_gizmo_data(
// The immediate mode API does not have a main world entity to refer to,
// but we do need MainEntity on this render entity for the systems to find it.
MainEntity::from(Entity::PLACEHOLDER),
TemporaryRenderEntity,
TemporaryRenderEntity::default(),
));
}
}
Expand Down Expand Up @@ -621,6 +621,7 @@ fn line_joint_gizmo_vertex_buffer_layouts() -> Vec<VertexBufferLayout> {
/// can be added and therefore three potential entities.
#[derive(Clone, Reflect, Resource, ExtractResource)]
#[reflect(Clone, Resource)]
#[extract_app(RenderApp)]
pub struct LineGizmoEntities {
/// An entity that regular line phase items are associated with.
pub line_gizmo_renderer: MainEntity,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos_render/src/retained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(crate) fn extract_linegizmos(
handle: gizmo.handle.clone(),
},
MainEntity::from(entity),
TemporaryRenderEntity,
TemporaryRenderEntity::default(),
));
}
*previous_len = values.len();
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_pbr/src/atmosphere/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ use bevy_render::{
renderer::{RenderContext, RenderDevice, ViewQuery},
texture::{CachedTexture, GpuImage},
view::{ViewUniform, ViewUniformOffset, ViewUniforms},
RenderApp,
};
use bevy_utils::default;
use tracing::warn;

// Render world representation of an environment map light for the atmosphere
#[derive(Component, ExtractComponent, Clone, FromTemplate)]
#[extract_app(RenderApp)]
pub struct AtmosphereEnvironmentMap {
pub environment_map: Handle<Image>,
pub size: UVec2,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/atmosphere/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl From<AtmosphereSettings> for GpuAtmosphereSettings {
}
}

impl SyncComponent for AtmosphereSettings {
impl SyncComponent<RenderApp> for AtmosphereSettings {
type Target = GpuAtmosphereSettings;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/cluster/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ pub(crate) fn prepare_clusters_for_gpu_clustering(
.retain(|view_main_entity, _| all_view_main_entities.contains(view_main_entity));
}

impl ExtractResource<GpuClusteringPlugin> for GlobalClusterSettings {
impl ExtractResource<RenderApp, GpuClusteringPlugin> for GlobalClusterSettings {
type Source = GlobalClusterSettings;

fn extract_resource(source: &Self::Source) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/contact_shadows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ impl From<ContactShadows> for ContactShadowsUniform {
}
}

impl SyncComponent for ContactShadows {
impl SyncComponent<RenderApp> for ContactShadows {
type Target = (Self, ViewContactShadowsUniformOffset);
}

impl ExtractComponent for ContactShadows {
impl ExtractComponent<RenderApp> for ContactShadows {
type QueryData = &'static ContactShadows;
type QueryFilter = ();
type Out = Self;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/decal/clustered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Plugin for ClusteredDecalPlugin {
}
}

impl SyncComponent<ClusteredDecalPlugin> for ClusteredDecal {
impl SyncComponent<RenderApp, ClusteredDecalPlugin> for ClusteredDecal {
type Target = Self;
}

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_pbr/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub const DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID: u8 = 1;
///
/// Will be automatically added to entities with the [`DeferredPrepass`] component that don't already have a [`PbrDeferredLightingDepthId`].
#[derive(Component, Clone, Copy, ExtractComponent, ShaderType)]
#[extract_app(RenderApp)]
pub struct PbrDeferredLightingDepthId {
depth_id: u32,

Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_pbr/src/fog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_color::{Color, ColorToComponents, LinearRgba};
use bevy_ecs::prelude::*;
use bevy_math::{ops, Vec3};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::extract_component::ExtractComponent;
use bevy_render::{extract_component::ExtractComponent, RenderApp};

use crate::ViewFogUniformOffset;

Expand Down Expand Up @@ -52,6 +52,7 @@ use crate::ViewFogUniformOffset;
#[extract_component_filter(With<Camera>)]
#[extract_component_sync_target((Self, ViewFogUniformOffset))]
#[reflect(Component, Default, Debug, Clone)]
#[extract_app(RenderApp)]
pub struct DistanceFog {
/// The color of the fog effect.
///
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ pub fn area_light_luts_placeholder() -> Image {
}
}

impl SyncComponent<PbrPlugin> for DirectionalLight {
impl SyncComponent<RenderApp, PbrPlugin> for DirectionalLight {
type Target = (
Self,
ExtractedDirectionalLight,
Expand All @@ -516,7 +516,7 @@ impl SyncComponent<PbrPlugin> for DirectionalLight {
DirectionalLightViewEntities,
);
}
impl SyncComponent<PbrPlugin> for PointLight {
impl SyncComponent<RenderApp, PbrPlugin> for PointLight {
type Target = (
Self,
ExtractedPointLight,
Expand All @@ -525,7 +525,7 @@ impl SyncComponent<PbrPlugin> for PointLight {
PointAndSpotLightViewEntities,
);
}
impl SyncComponent<PbrPlugin> for SpotLight {
impl SyncComponent<RenderApp, PbrPlugin> for SpotLight {
type Target = (
Self,
ExtractedPointLight,
Expand All @@ -534,12 +534,12 @@ impl SyncComponent<PbrPlugin> for SpotLight {
PointAndSpotLightViewEntities,
);
}
impl SyncComponent<PbrPlugin> for RectLight {
impl SyncComponent<RenderApp, PbrPlugin> for RectLight {
type Target = (Self, ExtractedRectLight);
}
impl SyncComponent<PbrPlugin> for AmbientLight {
impl SyncComponent<RenderApp, PbrPlugin> for AmbientLight {
type Target = Self;
}
impl SyncComponent<PbrPlugin> for ShadowFilteringMethod {
impl SyncComponent<RenderApp, PbrPlugin> for ShadowFilteringMethod {
type Target = Self;
}
3 changes: 2 additions & 1 deletion crates/bevy_pbr/src/light_probe/environment_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ use bevy_render::{
},
renderer::{RenderAdapter, RenderDevice},
texture::{FallbackImage, GpuImage},
RenderApp,
};

use core::{num::NonZero, ops::Deref};
Expand Down Expand Up @@ -139,7 +140,7 @@ pub struct EnvironmentMapViewLightProbeInfo {
pub(crate) rotation: Quat,
}

impl ExtractInstance for EnvironmentMapIds {
impl ExtractInstance<RenderApp> for EnvironmentMapIds {
type QueryData = Read<EnvironmentMapLight>;

type QueryFilter = ();
Expand Down
Loading
Loading