Skip to content

Commit 30f4278

Browse files
committed
use entries in a few places
1 parent 3d28f60 commit 30f4278

File tree

3 files changed

+39
-107
lines changed

3 files changed

+39
-107
lines changed

crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,20 @@ impl FromWorld for BloomDownsamplingPipeline {
4141
fn from_world(world: &mut World) -> Self {
4242
let render_device = world.resource::<RenderDevice>();
4343

44-
// Input texture binding
45-
let texture = BindGroupLayoutEntry {
46-
binding: 0,
47-
ty: BindingType::Texture {
48-
sample_type: TextureSampleType::Float { filterable: true },
49-
view_dimension: TextureViewDimension::D2,
50-
multisampled: false,
51-
},
52-
visibility: ShaderStages::FRAGMENT,
53-
count: None,
54-
};
55-
56-
// Sampler binding
57-
let sampler = BindGroupLayoutEntry {
58-
binding: 1,
59-
ty: BindingType::Sampler(SamplerBindingType::Filtering),
60-
visibility: ShaderStages::FRAGMENT,
61-
count: None,
62-
};
63-
64-
// Downsampling settings binding
65-
let settings = BindGroupLayoutEntry {
66-
binding: 2,
67-
ty: BindingType::Buffer {
68-
ty: BufferBindingType::Uniform,
69-
has_dynamic_offset: true,
70-
min_binding_size: Some(BloomUniforms::min_size()),
71-
},
72-
visibility: ShaderStages::FRAGMENT,
73-
count: None,
74-
};
75-
7644
// Bind group layout
7745
let bind_group_layout = render_device.create_bind_group_layout(
78-
Some("bloom_downsampling_bind_group_layout_with_settings"),
79-
&[texture, sampler, settings],
46+
"bloom_downsampling_bind_group_layout_with_settings",
47+
&BindGroupLayoutEntries::sequential(
48+
ShaderStages::FRAGMENT,
49+
(
50+
// Input texture binding
51+
texture_2d(TextureSampleType::Float { filterable: true }),
52+
// Sampler binding
53+
sampler(SamplerBindingType::Filtering),
54+
// Downsampling settings binding
55+
uniform_buffer(true, Some(BloomUniforms::min_size())),
56+
),
57+
),
8058
);
8159

8260
// Sampler

crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,17 @@ impl FromWorld for BloomUpsamplingPipeline {
3333

3434
let bind_group_layout = render_device.create_bind_group_layout(
3535
"bloom_upsampling_bind_group_layout",
36-
&[
37-
// Input texture
38-
BindGroupLayoutEntry {
39-
binding: 0,
40-
ty: BindingType::Texture {
41-
sample_type: TextureSampleType::Float { filterable: true },
42-
view_dimension: TextureViewDimension::D2,
43-
multisampled: false,
44-
},
45-
visibility: ShaderStages::FRAGMENT,
46-
count: None,
47-
},
48-
// Sampler
49-
BindGroupLayoutEntry {
50-
binding: 1,
51-
ty: BindingType::Sampler(SamplerBindingType::Filtering),
52-
visibility: ShaderStages::FRAGMENT,
53-
count: None,
54-
},
55-
// BloomUniforms
56-
BindGroupLayoutEntry {
57-
binding: 2,
58-
ty: BindingType::Buffer {
59-
ty: BufferBindingType::Uniform,
60-
has_dynamic_offset: true,
61-
min_binding_size: Some(BloomUniforms::min_size()),
62-
},
63-
visibility: ShaderStages::FRAGMENT,
64-
count: None,
65-
},
66-
],
36+
&BindGroupLayoutEntries::sequential(
37+
ShaderStages::FRAGMENT,
38+
(
39+
// Input texture
40+
texture_2d(TextureSampleType::Float { filterable: true }),
41+
// Sampler
42+
sampler(SamplerBindingType::Filtering),
43+
// BloomUniforms
44+
uniform_buffer(true, Some(BloomUniforms::min_size())),
45+
),
46+
),
6747
);
6848

6949
BloomUpsamplingPipeline { bind_group_layout }

examples/shader/post_processing.rs

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ use bevy::{
1919
render_graph::{
2020
NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner,
2121
},
22-
render_resource::{
23-
BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry,
24-
BindingType, CachedRenderPipelineId, ColorTargetState, ColorWrites, FragmentState,
25-
MultisampleState, Operations, PipelineCache, PrimitiveState, RenderPassColorAttachment,
26-
RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType,
27-
SamplerDescriptor, ShaderStages, ShaderType, TextureFormat, TextureSampleType,
28-
TextureViewDimension,
29-
},
22+
render_resource::*,
3023
renderer::{RenderContext, RenderDevice},
3124
texture::BevyDefault,
3225
view::ViewTarget,
@@ -226,40 +219,21 @@ impl FromWorld for PostProcessPipeline {
226219
let render_device = world.resource::<RenderDevice>();
227220

228221
// We need to define the bind group layout used for our pipeline
229-
let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
230-
label: Some("post_process_bind_group_layout"),
231-
entries: &[
232-
// The screen texture
233-
BindGroupLayoutEntry {
234-
binding: 0,
235-
visibility: ShaderStages::FRAGMENT,
236-
ty: BindingType::Texture {
237-
sample_type: TextureSampleType::Float { filterable: true },
238-
view_dimension: TextureViewDimension::D2,
239-
multisampled: false,
240-
},
241-
count: None,
242-
},
243-
// The sampler that will be used to sample the screen texture
244-
BindGroupLayoutEntry {
245-
binding: 1,
246-
visibility: ShaderStages::FRAGMENT,
247-
ty: BindingType::Sampler(SamplerBindingType::Filtering),
248-
count: None,
249-
},
250-
// The settings uniform that will control the effect
251-
BindGroupLayoutEntry {
252-
binding: 2,
253-
visibility: ShaderStages::FRAGMENT,
254-
ty: BindingType::Buffer {
255-
ty: bevy::render::render_resource::BufferBindingType::Uniform,
256-
has_dynamic_offset: false,
257-
min_binding_size: Some(PostProcessSettings::min_size()),
258-
},
259-
count: None,
260-
},
261-
],
262-
});
222+
let layout = render_device.create_bind_group_layout(
223+
"post_process_bind_group_layout",
224+
&BindGroupLayoutEntries::sequential(
225+
// The layout entries will only be visible in the fragment stage
226+
ShaderStages::FRAGMENT,
227+
(
228+
// The screen texture
229+
texture_2d(TextureSampleType::Float { filterable: true }),
230+
// The sampler that will be used to sample the screen texture
231+
sampler(SamplerBindingType::Filtering),
232+
// The settings uniform that will control the effect
233+
uniform_buffer(false, Some(PostProcessSettings::min_size())),
234+
),
235+
),
236+
);
263237

264238
// We can create the sampler here since it won't change at runtime and doesn't depend on the view
265239
let sampler = render_device.create_sampler(&SamplerDescriptor::default());

0 commit comments

Comments
 (0)