Skip to content

Commit 1b1af05

Browse files
Merge branch 'main' into preconvert-to-srgb
2 parents a8ace76 + 0747b66 commit 1b1af05

File tree

151 files changed

+5283
-3821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+5283
-3821
lines changed

benches/benches/bevy_ecs/events/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy_ecs::prelude::*;
22

3-
#[derive(Event, BufferedEvent)]
3+
#[derive(BufferedEvent)]
44
struct BenchEvent<const SIZE: usize>([u8; SIZE]);
55

66
pub struct Benchmark<const SIZE: usize>(Events<BenchEvent<SIZE>>);

benches/benches/bevy_ecs/events/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy_ecs::prelude::*;
22

3-
#[derive(Event, BufferedEvent)]
3+
#[derive(BufferedEvent)]
44
struct BenchEvent<const SIZE: usize>([u8; SIZE]);
55

66
impl<const SIZE: usize> Default for BenchEvent<SIZE> {

crates/bevy_a11y/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ use accesskit::Node;
2626
use bevy_app::Plugin;
2727
use bevy_derive::{Deref, DerefMut};
2828
use bevy_ecs::{
29-
component::Component,
30-
event::{BufferedEvent, Event},
31-
resource::Resource,
32-
schedule::SystemSet,
29+
component::Component, event::BufferedEvent, resource::Resource, schedule::SystemSet,
3330
};
3431

3532
#[cfg(feature = "bevy_reflect")]
@@ -45,7 +42,7 @@ use serde::{Deserialize, Serialize};
4542
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
4643

4744
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
48-
#[derive(Event, BufferedEvent, Deref, DerefMut)]
45+
#[derive(BufferedEvent, Deref, DerefMut)]
4946
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
5047
pub struct ActionRequest(pub accesskit::ActionRequest);
5148

crates/bevy_app/src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ impl App {
355355
/// # use bevy_app::prelude::*;
356356
/// # use bevy_ecs::prelude::*;
357357
/// #
358-
/// # #[derive(Event, BufferedEvent)]
358+
/// # #[derive(BufferedEvent)]
359359
/// # struct MyEvent;
360360
/// # let mut app = App::new();
361361
/// #
@@ -1417,7 +1417,7 @@ fn run_once(mut app: App) -> AppExit {
14171417
/// This type is roughly meant to map to a standard definition of a process exit code (0 means success, not 0 means error). Due to portability concerns
14181418
/// (see [`ExitCode`](https://doc.rust-lang.org/std/process/struct.ExitCode.html) and [`process::exit`](https://doc.rust-lang.org/std/process/fn.exit.html#))
14191419
/// we only allow error codes between 1 and [255](u8::MAX).
1420-
#[derive(Event, BufferedEvent, Debug, Clone, Default, PartialEq, Eq)]
1420+
#[derive(BufferedEvent, Debug, Clone, Default, PartialEq, Eq)]
14211421
pub enum AppExit {
14221422
/// [`App`] exited without any problems.
14231423
#[default]
@@ -1485,7 +1485,7 @@ mod tests {
14851485
change_detection::{DetectChanges, ResMut},
14861486
component::Component,
14871487
entity::Entity,
1488-
event::{BufferedEvent, Event, EventWriter, Events},
1488+
event::{BufferedEvent, EventWriter, Events},
14891489
lifecycle::RemovedComponents,
14901490
query::With,
14911491
resource::Resource,
@@ -1851,7 +1851,7 @@ mod tests {
18511851
}
18521852
#[test]
18531853
fn events_should_be_updated_once_per_update() {
1854-
#[derive(Event, BufferedEvent, Clone)]
1854+
#[derive(BufferedEvent, Clone)]
18551855
struct TestEvent;
18561856

18571857
let mut app = App::new();

crates/bevy_asset/src/event.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::{Asset, AssetId, AssetLoadError, AssetPath, UntypedAssetId};
2-
use bevy_ecs::event::{BufferedEvent, Event};
2+
use bevy_ecs::event::BufferedEvent;
33
use bevy_reflect::Reflect;
44
use core::fmt::Debug;
55

66
/// A [`BufferedEvent`] emitted when a specific [`Asset`] fails to load.
77
///
88
/// For an untyped equivalent, see [`UntypedAssetLoadFailedEvent`].
9-
#[derive(Event, BufferedEvent, Clone, Debug)]
9+
#[derive(BufferedEvent, Clone, Debug)]
1010
pub struct AssetLoadFailedEvent<A: Asset> {
1111
/// The stable identifier of the asset that failed to load.
1212
pub id: AssetId<A>,
@@ -24,7 +24,7 @@ impl<A: Asset> AssetLoadFailedEvent<A> {
2424
}
2525

2626
/// An untyped version of [`AssetLoadFailedEvent`].
27-
#[derive(Event, BufferedEvent, Clone, Debug)]
27+
#[derive(BufferedEvent, Clone, Debug)]
2828
pub struct UntypedAssetLoadFailedEvent {
2929
/// The stable identifier of the asset that failed to load.
3030
pub id: UntypedAssetId,
@@ -46,7 +46,7 @@ impl<A: Asset> From<&AssetLoadFailedEvent<A>> for UntypedAssetLoadFailedEvent {
4646

4747
/// [`BufferedEvent`]s that occur for a specific loaded [`Asset`], such as "value changed" events and "dependency" events.
4848
#[expect(missing_docs, reason = "Documenting the id fields is unhelpful.")]
49-
#[derive(Event, BufferedEvent, Reflect)]
49+
#[derive(BufferedEvent, Reflect)]
5050
pub enum AssetEvent<A: Asset> {
5151
/// Emitted whenever an [`Asset`] is added.
5252
Added { id: AssetId<A> },

crates/bevy_asset/src/loader_builders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl NestedLoader<'_, '_, StaticTyped, Deferred> {
314314
} else {
315315
self.load_context
316316
.asset_server
317-
.get_or_create_path_handle(path, None)
317+
.get_or_create_path_handle(path, self.meta_transform)
318318
};
319319
self.load_context.dependencies.insert(handle.id().untyped());
320320
handle

crates/bevy_camera/src/camera.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,30 @@ impl Camera {
567567
/// To get the world space coordinates with Normalized Device Coordinates, you should use
568568
/// [`ndc_to_world`](Self::ndc_to_world).
569569
///
570+
/// # Example
571+
/// ```no_run
572+
/// # use bevy_window::Window;
573+
/// # use bevy_ecs::prelude::{Single, IntoScheduleConfigs};
574+
/// # use bevy_transform::prelude::{GlobalTransform, TransformSystems};
575+
/// # use bevy_camera::Camera;
576+
/// # use bevy_app::{App, PostUpdate};
577+
/// #
578+
/// fn system(camera_query: Single<(&Camera, &GlobalTransform)>, window: Single<&Window>) {
579+
/// let (camera, camera_transform) = *camera_query;
580+
///
581+
/// if let Some(cursor_position) = window.cursor_position()
582+
/// // Calculate a ray pointing from the camera into the world based on the cursor's position.
583+
/// && let Ok(ray) = camera.viewport_to_world(camera_transform, cursor_position)
584+
/// {
585+
/// println!("{ray:?}");
586+
/// }
587+
/// }
588+
///
589+
/// # let mut app = App::new();
590+
/// // Run the system after transform propagation so the camera's global transform is up-to-date.
591+
/// app.add_systems(PostUpdate, system.after(TransformSystems::Propagate));
592+
/// ```
593+
///
570594
/// # Panics
571595
///
572596
/// Will panic if the camera's projection matrix is invalid (has a determinant of 0) and
@@ -605,6 +629,30 @@ impl Camera {
605629
/// To get the world space coordinates with Normalized Device Coordinates, you should use
606630
/// [`ndc_to_world`](Self::ndc_to_world).
607631
///
632+
/// # Example
633+
/// ```no_run
634+
/// # use bevy_window::Window;
635+
/// # use bevy_ecs::prelude::*;
636+
/// # use bevy_transform::prelude::{GlobalTransform, TransformSystems};
637+
/// # use bevy_camera::Camera;
638+
/// # use bevy_app::{App, PostUpdate};
639+
/// #
640+
/// fn system(camera_query: Single<(&Camera, &GlobalTransform)>, window: Single<&Window>) {
641+
/// let (camera, camera_transform) = *camera_query;
642+
///
643+
/// if let Some(cursor_position) = window.cursor_position()
644+
/// // Calculate a world position based on the cursor's position.
645+
/// && let Ok(world_pos) = camera.viewport_to_world_2d(camera_transform, cursor_position)
646+
/// {
647+
/// println!("World position: {world_pos:.2}");
648+
/// }
649+
/// }
650+
///
651+
/// # let mut app = App::new();
652+
/// // Run the system after transform propagation so the camera's global transform is up-to-date.
653+
/// app.add_systems(PostUpdate, system.after(TransformSystems::Propagate));
654+
/// ```
655+
///
608656
/// # Panics
609657
///
610658
/// Will panic if the camera's projection matrix is invalid (has a determinant of 0) and

crates/bevy_core_pipeline/src/blit/mod.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Plugin for BlitPlugin {
3636

3737
#[derive(Resource)]
3838
pub struct BlitPipeline {
39-
pub texture_bind_group: BindGroupLayout,
39+
pub layout: BindGroupLayout,
4040
pub sampler: Sampler,
4141
pub fullscreen_shader: FullscreenShader,
4242
pub fragment_shader: Handle<Shader>,
@@ -46,7 +46,7 @@ impl FromWorld for BlitPipeline {
4646
fn from_world(render_world: &mut World) -> Self {
4747
let render_device = render_world.resource::<RenderDevice>();
4848

49-
let texture_bind_group = render_device.create_bind_group_layout(
49+
let layout = render_device.create_bind_group_layout(
5050
"blit_bind_group_layout",
5151
&BindGroupLayoutEntries::sequential(
5252
ShaderStages::FRAGMENT,
@@ -60,14 +60,28 @@ impl FromWorld for BlitPipeline {
6060
let sampler = render_device.create_sampler(&SamplerDescriptor::default());
6161

6262
BlitPipeline {
63-
texture_bind_group,
63+
layout,
6464
sampler,
6565
fullscreen_shader: render_world.resource::<FullscreenShader>().clone(),
6666
fragment_shader: load_embedded_asset!(render_world, "blit.wgsl"),
6767
}
6868
}
6969
}
7070

71+
impl BlitPipeline {
72+
pub fn create_bind_group(
73+
&self,
74+
render_device: &RenderDevice,
75+
src_texture: &TextureView,
76+
) -> BindGroup {
77+
render_device.create_bind_group(
78+
None,
79+
&self.layout,
80+
&BindGroupEntries::sequential((src_texture, &self.sampler)),
81+
)
82+
}
83+
}
84+
7185
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
7286
pub struct BlitPipelineKey {
7387
pub texture_format: TextureFormat,
@@ -81,7 +95,7 @@ impl SpecializedRenderPipeline for BlitPipeline {
8195
fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor {
8296
RenderPipelineDescriptor {
8397
label: Some("blit pipeline".into()),
84-
layout: vec![self.texture_bind_group.clone()],
98+
layout: vec![self.layout.clone()],
8599
vertex: self.fullscreen_shader.to_vertex_state(),
86100
fragment: Some(FragmentState {
87101
shader: self.fragment_shader.clone(),

crates/bevy_core_pipeline/src/msaa_writeback.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@ impl ViewNode for MsaaWritebackNode {
9898
occlusion_query_set: None,
9999
};
100100

101-
let bind_group = render_context.render_device().create_bind_group(
102-
None,
103-
&blit_pipeline.texture_bind_group,
104-
&BindGroupEntries::sequential((post_process.source, &blit_pipeline.sampler)),
105-
);
101+
let bind_group =
102+
blit_pipeline.create_bind_group(render_context.render_device(), post_process.source);
106103

107104
let mut render_pass = render_context
108105
.command_encoder()

crates/bevy_core_pipeline/src/upscaling/node.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use bevy_ecs::{prelude::*, query::QueryItem};
33
use bevy_render::{
44
camera::{CameraOutputMode, ClearColor, ClearColorConfig, ExtractedCamera},
55
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
6-
render_resource::{
7-
BindGroup, BindGroupEntries, PipelineCache, RenderPassDescriptor, TextureViewId,
8-
},
6+
render_resource::{BindGroup, PipelineCache, RenderPassDescriptor, TextureViewId},
97
renderer::RenderContext,
108
view::ViewTarget,
119
};
@@ -30,9 +28,9 @@ impl ViewNode for UpscalingNode {
3028
(target, upscaling_target, camera): QueryItem<Self::ViewQuery>,
3129
world: &World,
3230
) -> Result<(), NodeRunError> {
33-
let pipeline_cache = world.get_resource::<PipelineCache>().unwrap();
34-
let blit_pipeline = world.get_resource::<BlitPipeline>().unwrap();
35-
let clear_color_global = world.get_resource::<ClearColor>().unwrap();
31+
let pipeline_cache = world.resource::<PipelineCache>();
32+
let blit_pipeline = world.resource::<BlitPipeline>();
33+
let clear_color_global = world.resource::<ClearColor>();
3634

3735
let clear_color = if let Some(camera) = camera {
3836
match camera.output_mode {
@@ -48,19 +46,18 @@ impl ViewNode for UpscalingNode {
4846
ClearColorConfig::None => None,
4947
};
5048
let converted_clear_color = clear_color.map(Into::into);
51-
let upscaled_texture = target.main_texture_view();
49+
// texture to be upscaled to the output texture
50+
let main_texture_view = target.main_texture_view();
5251

5352
let mut cached_bind_group = self.cached_texture_bind_group.lock().unwrap();
5453
let bind_group = match &mut *cached_bind_group {
55-
Some((id, bind_group)) if upscaled_texture.id() == *id => bind_group,
54+
Some((id, bind_group)) if main_texture_view.id() == *id => bind_group,
5655
cached_bind_group => {
57-
let bind_group = render_context.render_device().create_bind_group(
58-
None,
59-
&blit_pipeline.texture_bind_group,
60-
&BindGroupEntries::sequential((upscaled_texture, &blit_pipeline.sampler)),
61-
);
56+
let bind_group = blit_pipeline
57+
.create_bind_group(render_context.render_device(), main_texture_view);
6258

63-
let (_, bind_group) = cached_bind_group.insert((upscaled_texture.id(), bind_group));
59+
let (_, bind_group) =
60+
cached_bind_group.insert((main_texture_view.id(), bind_group));
6461
bind_group
6562
}
6663
};

0 commit comments

Comments
 (0)