Skip to content

Commit 26dc71f

Browse files
committed
updated remaining post-processing nodes to make use of the new builder API
1 parent bb7b5d4 commit 26dc71f

File tree

6 files changed

+50
-93
lines changed

6 files changed

+50
-93
lines changed

crates/bevy_core_pipeline/src/bloom/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl Node for BloomNode {
246246
.add_color_attachment(view)
247247
.begin()
248248
.set_camera_viewport(camera)
249-
.set_render_pipeline(downsampling_prefilter_pipeline)
249+
.set_pipeline(downsampling_prefilter_pipeline)
250250
.set_bind_group(
251251
0,
252252
&bind_groups.prefilter_bind_group,
@@ -264,7 +264,7 @@ impl Node for BloomNode {
264264
.add_color_attachment(view)
265265
.begin()
266266
.set_camera_viewport(camera)
267-
.set_render_pipeline(downsampling_pipeline)
267+
.set_pipeline(downsampling_pipeline)
268268
.set_bind_group(
269269
0,
270270
&bind_groups.downsampling_bind_groups[mip as usize - 1],
@@ -282,7 +282,7 @@ impl Node for BloomNode {
282282
.add_color_attachment(view)
283283
.begin()
284284
.set_camera_viewport(camera)
285-
.set_render_pipeline(upsampling_pipeline)
285+
.set_pipeline(upsampling_pipeline)
286286
.set_bind_group(
287287
0,
288288
&bind_groups.upsampling_bind_groups[mip as usize - 1],
@@ -299,7 +299,7 @@ impl Node for BloomNode {
299299
.set_color_ops(LoadOp::Load, true)
300300
.begin()
301301
.set_camera_viewport(camera)
302-
.set_render_pipeline(upsampling_final_pipeline)
302+
.set_pipeline(upsampling_final_pipeline)
303303
.set_bind_group(
304304
0,
305305
&bind_groups.upsampling_final_bind_group,

crates/bevy_core_pipeline/src/fxaa/node.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
use std::sync::Mutex;
2-
31
use crate::fxaa::{CameraFxaaPipeline, Fxaa, FxaaPipeline};
4-
use bevy_ecs::prelude::*;
5-
use bevy_ecs::query::QueryState;
2+
use bevy_ecs::{prelude::*, query::QueryState};
63
use bevy_render::{
74
render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType},
85
render_resource::{
9-
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, FilterMode, Operations,
10-
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor,
11-
TextureViewId,
6+
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, FilterMode, PipelineCache,
7+
SamplerDescriptor, TextureViewId,
128
},
139
renderer::RenderContext,
1410
view::{ExtractedView, ViewTarget},
1511
};
1612
use bevy_utils::default;
13+
use std::sync::Mutex;
1714

1815
pub struct FxaaNode {
1916
query: QueryState<
@@ -109,23 +106,14 @@ impl Node for FxaaNode {
109106
}
110107
};
111108

112-
let pass_descriptor = RenderPassDescriptor {
113-
label: Some("fxaa_pass"),
114-
color_attachments: &[Some(RenderPassColorAttachment {
115-
view: destination,
116-
resolve_target: None,
117-
ops: Operations::default(),
118-
})],
119-
depth_stencil_attachment: None,
120-
};
121-
122-
let mut render_pass = render_context
123-
.command_encoder()
124-
.begin_render_pass(&pass_descriptor);
125-
126-
render_pass.set_pipeline(pipeline);
127-
render_pass.set_bind_group(0, bind_group, &[]);
128-
render_pass.draw(0..3, 0..1);
109+
render_context
110+
.render_pass(view_entity)
111+
.set_label("fxaa_pass")
112+
.add_color_attachment(destination)
113+
.begin()
114+
.set_pipeline(pipeline)
115+
.set_bind_group(0, bind_group, &[])
116+
.draw(0..3, 0..1);
129117

130118
Ok(())
131119
}

crates/bevy_core_pipeline/src/tonemapping/node.rs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
use std::sync::Mutex;
2-
31
use crate::tonemapping::{TonemappingPipeline, ViewTonemappingPipeline};
4-
use bevy_ecs::prelude::*;
5-
use bevy_ecs::query::QueryState;
2+
use bevy_ecs::{prelude::*, query::QueryState};
63
use bevy_render::{
74
render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType},
85
render_resource::{
9-
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, LoadOp, Operations,
10-
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor,
11-
TextureViewId,
6+
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, LoadOp, PipelineCache,
7+
SamplerDescriptor, TextureViewId,
128
},
139
renderer::RenderContext,
1410
view::{ExtractedView, ViewTarget},
1511
};
12+
use std::sync::Mutex;
1613

1714
pub struct TonemappingNode {
1815
query: QueryState<(&'static ViewTarget, &'static ViewTonemappingPipeline), With<ExtractedView>>,
@@ -98,26 +95,15 @@ impl Node for TonemappingNode {
9895
}
9996
};
10097

101-
let pass_descriptor = RenderPassDescriptor {
102-
label: Some("tonemapping_pass"),
103-
color_attachments: &[Some(RenderPassColorAttachment {
104-
view: destination,
105-
resolve_target: None,
106-
ops: Operations {
107-
load: LoadOp::Clear(Default::default()), // TODO shouldn't need to be cleared
108-
store: true,
109-
},
110-
})],
111-
depth_stencil_attachment: None,
112-
};
113-
114-
let mut render_pass = render_context
115-
.command_encoder()
116-
.begin_render_pass(&pass_descriptor);
117-
118-
render_pass.set_pipeline(pipeline);
119-
render_pass.set_bind_group(0, bind_group, &[]);
120-
render_pass.draw(0..3, 0..1);
98+
render_context
99+
.render_pass(view_entity)
100+
.set_label("tonemapping_pass")
101+
.add_color_attachment(destination)
102+
.set_color_ops(LoadOp::Clear(Default::default()), true)
103+
.begin()
104+
.set_pipeline(pipeline)
105+
.set_bind_group(0, bind_group, &[])
106+
.draw(0..3, 0..1);
121107

122108
Ok(())
123109
}

crates/bevy_core_pipeline/src/upscaling/node.rs

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
use std::sync::Mutex;
2-
3-
use bevy_ecs::prelude::*;
4-
use bevy_ecs::query::QueryState;
1+
use super::{UpscalingPipeline, ViewUpscalingPipeline};
2+
use bevy_ecs::{prelude::*, query::QueryState};
53
use bevy_render::{
64
render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType},
75
render_resource::{
8-
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, LoadOp, Operations,
9-
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor,
10-
TextureViewId,
6+
BindGroup, BindGroupDescriptor, BindGroupEntry, BindingResource, LoadOp, PipelineCache,
7+
SamplerDescriptor, TextureViewId,
118
},
129
renderer::RenderContext,
1310
view::{ExtractedView, ViewTarget},
1411
};
15-
16-
use super::{UpscalingPipeline, ViewUpscalingPipeline};
12+
use std::sync::Mutex;
1713

1814
pub struct UpscalingNode {
1915
query: QueryState<(&'static ViewTarget, &'static ViewUpscalingPipeline), With<ExtractedView>>,
@@ -51,9 +47,8 @@ impl Node for UpscalingNode {
5147
let pipeline_cache = world.get_resource::<PipelineCache>().unwrap();
5248
let upscaling_pipeline = world.get_resource::<UpscalingPipeline>().unwrap();
5349

54-
let (target, upscaling_target) = match self.query.get_manual(world, view_entity) {
55-
Ok(query) => query,
56-
Err(_) => return Ok(()),
50+
let Ok((target, upscaling_target)) = self.query.get_manual(world, view_entity) else {
51+
return Ok(());
5752
};
5853

5954
let upscaled_texture = target.main_texture();
@@ -89,31 +84,19 @@ impl Node for UpscalingNode {
8984
}
9085
};
9186

92-
let pipeline = match pipeline_cache.get_render_pipeline(upscaling_target.0) {
93-
Some(pipeline) => pipeline,
94-
None => return Ok(()),
95-
};
96-
97-
let pass_descriptor = RenderPassDescriptor {
98-
label: Some("upscaling_pass"),
99-
color_attachments: &[Some(RenderPassColorAttachment {
100-
view: target.out_texture(),
101-
resolve_target: None,
102-
ops: Operations {
103-
load: LoadOp::Clear(Default::default()),
104-
store: true,
105-
},
106-
})],
107-
depth_stencil_attachment: None,
87+
let Some(pipeline) = pipeline_cache.get_render_pipeline(upscaling_target.0) else {
88+
return Ok(());
10889
};
10990

110-
let mut render_pass = render_context
111-
.command_encoder()
112-
.begin_render_pass(&pass_descriptor);
113-
114-
render_pass.set_pipeline(pipeline);
115-
render_pass.set_bind_group(0, bind_group, &[]);
116-
render_pass.draw(0..3, 0..1);
91+
render_context
92+
.render_pass(view_entity)
93+
.set_label("upscaling_pass")
94+
.add_color_attachment(target.out_texture())
95+
.set_color_ops(LoadOp::Clear(Default::default()), true)
96+
.begin()
97+
.set_pipeline(pipeline)
98+
.set_bind_group(0, bind_group, &[])
99+
.draw(0..3, 0..1);
117100

118101
Ok(())
119102
}

crates/bevy_render/src/render_phase/draw_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ impl<'a> TrackedRenderPass<'a> {
131131

132132
/// Sets the active [`RenderPipeline`].
133133
///
134-
/// Subsequent draw calls will exhibit the behavior defined by the `pipeline`.
135-
pub fn set_render_pipeline(&mut self, pipeline: &'a RenderPipeline) -> &mut Self {
134+
/// Subsequent draw calls will exhibit the behavior defined by this `pipeline`.
135+
pub fn set_pipeline(&mut self, pipeline: &'a RenderPipeline) -> &mut Self {
136136
trace!("set pipeline: {:?}", pipeline);
137137
if self.state.is_pipeline_set(pipeline.id()) {
138138
return self;

crates/bevy_render/src/render_phase/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<P: CachedRenderPipelinePhaseItem> RenderCommand<P> for SetItemPipeline {
177177
.into_inner()
178178
.get_render_pipeline(item.cached_pipeline())
179179
{
180-
pass.set_render_pipeline(pipeline);
180+
pass.set_pipeline(pipeline);
181181
RenderCommandResult::Success
182182
} else {
183183
RenderCommandResult::Failure

0 commit comments

Comments
 (0)