Skip to content

Commit 180d8de

Browse files
committed
Examples fixes
1 parent 1f0b279 commit 180d8de

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

examples/3d/manual_material.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use bevy::{
2121
render_phase::DrawFunctions,
2222
render_resource::{
2323
binding_types::{sampler, texture_2d},
24-
AsBindGroup, BindGroupLayout, BindGroupLayoutEntries, BindingResources,
24+
AsBindGroup, BindGroupLayoutDescriptor, BindGroupLayoutEntries, BindingResources,
2525
OwnedBindingResource, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages,
2626
TextureSampleType, TextureViewDimension, UnpreparedBindGroup,
2727
},
@@ -77,7 +77,7 @@ fn init_image_material_resources(
7777
render_device: Res<RenderDevice>,
7878
mut bind_group_allocators: ResMut<MaterialBindGroupAllocators>,
7979
) {
80-
let bind_group_layout = render_device.create_bind_group_layout(
80+
let bind_group_layout = BindGroupLayoutDescriptor::new(
8181
"image_material_layout",
8282
&BindGroupLayoutEntries::sequential(
8383
ShaderStages::FRAGMENT,
@@ -98,7 +98,7 @@ fn init_image_material_resources(
9898
}
9999

100100
#[derive(Resource)]
101-
struct ImageMaterialBindGroupLayout(BindGroupLayout);
101+
struct ImageMaterialBindGroupLayout(BindGroupLayoutDescriptor);
102102

103103
#[derive(Resource)]
104104
struct ImageMaterialBindGroupSampler(Sampler);

examples/shader/compute_shader_game_of_life.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ fn prepare_bind_group(
136136
game_of_life_images: Res<GameOfLifeImages>,
137137
game_of_life_uniforms: Res<GameOfLifeUniforms>,
138138
render_device: Res<RenderDevice>,
139+
pipeline_cache: Res<PipelineCache>,
139140
queue: Res<RenderQueue>,
140141
) {
141142
let view_a = gpu_images.get(&game_of_life_images.texture_a).unwrap();
@@ -148,7 +149,7 @@ fn prepare_bind_group(
148149

149150
let bind_group_0 = render_device.create_bind_group(
150151
None,
151-
&pipeline.texture_bind_group_layout,
152+
&pipeline_cache.get_bind_group_layout(&pipeline.texture_bind_group_layout),
152153
&BindGroupEntries::sequential((
153154
&view_a.texture_view,
154155
&view_b.texture_view,
@@ -157,7 +158,7 @@ fn prepare_bind_group(
157158
);
158159
let bind_group_1 = render_device.create_bind_group(
159160
None,
160-
&pipeline.texture_bind_group_layout,
161+
&pipeline_cache.get_bind_group_layout(&pipeline.texture_bind_group_layout),
161162
&BindGroupEntries::sequential((
162163
&view_b.texture_view,
163164
&view_a.texture_view,
@@ -169,18 +170,17 @@ fn prepare_bind_group(
169170

170171
#[derive(Resource)]
171172
struct GameOfLifePipeline {
172-
texture_bind_group_layout: BindGroupLayout,
173+
texture_bind_group_layout: BindGroupLayoutDescriptor,
173174
init_pipeline: CachedComputePipelineId,
174175
update_pipeline: CachedComputePipelineId,
175176
}
176177

177178
fn init_game_of_life_pipeline(
178179
mut commands: Commands,
179-
render_device: Res<RenderDevice>,
180180
asset_server: Res<AssetServer>,
181181
pipeline_cache: Res<PipelineCache>,
182182
) {
183-
let texture_bind_group_layout = render_device.create_bind_group_layout(
183+
let texture_bind_group_layout = BindGroupLayoutDescriptor::new(
184184
"GameOfLifeImages",
185185
&BindGroupLayoutEntries::sequential(
186186
ShaderStages::COMPUTE,

examples/shader/gpu_readback.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ fn prepare_bind_group(
153153
mut commands: Commands,
154154
pipeline: Res<ComputePipeline>,
155155
render_device: Res<RenderDevice>,
156+
pipeline_cache: Res<PipelineCache>,
156157
buffer: Res<ReadbackBuffer>,
157158
image: Res<ReadbackImage>,
158159
buffers: Res<RenderAssets<GpuShaderStorageBuffer>>,
@@ -162,7 +163,7 @@ fn prepare_bind_group(
162163
let image = images.get(&image.0).unwrap();
163164
let bind_group = render_device.create_bind_group(
164165
None,
165-
&pipeline.layout,
166+
&pipeline_cache.get_bind_group_layout(pipeline.layout),
166167
&BindGroupEntries::sequential((
167168
buffer.buffer.as_entire_buffer_binding(),
168169
image.texture_view.into_binding(),
@@ -173,7 +174,7 @@ fn prepare_bind_group(
173174

174175
#[derive(Resource)]
175176
struct ComputePipeline {
176-
layout: BindGroupLayout,
177+
layout: BindGroupLayoutDescriptor,
177178
pipeline: CachedComputePipelineId,
178179
}
179180

@@ -183,8 +184,8 @@ fn init_compute_pipeline(
183184
asset_server: Res<AssetServer>,
184185
pipeline_cache: Res<PipelineCache>,
185186
) {
186-
let layout = render_device.create_bind_group_layout(
187-
None,
187+
let layout = BindGroupLayoutDescriptor::new(
188+
"",
188189
&BindGroupLayoutEntries::sequential(
189190
ShaderStages::COMPUTE,
190191
(

examples/shader_advanced/custom_post_processing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl ViewNode for PostProcessNode {
178178
// is to make sure you get it during the node execution.
179179
let bind_group = render_context.render_device().create_bind_group(
180180
"post_process_bind_group",
181-
&post_process_pipeline.layout,
181+
&pipeline_cache.get_bind_group_layout(&post_process_pipeline.layout),
182182
// It's important for this to match the BindGroupLayout defined in the PostProcessPipeline
183183
&BindGroupEntries::sequential((
184184
// Make sure to use the source view
@@ -222,7 +222,7 @@ impl ViewNode for PostProcessNode {
222222
// This contains global data used by the render pipeline. This will be created once on startup.
223223
#[derive(Resource)]
224224
struct PostProcessPipeline {
225-
layout: BindGroupLayout,
225+
layout: BindGroupLayoutDescriptor,
226226
sampler: Sampler,
227227
pipeline_id: CachedRenderPipelineId,
228228
}
@@ -235,7 +235,7 @@ fn init_post_process_pipeline(
235235
pipeline_cache: Res<PipelineCache>,
236236
) {
237237
// We need to define the bind group layout used for our pipeline
238-
let layout = render_device.create_bind_group_layout(
238+
let layout = BindGroupLayoutDescriptor::new(
239239
"post_process_bind_group_layout",
240240
&BindGroupLayoutEntries::sequential(
241241
// The layout entries will only be visible in the fragment stage

examples/shader_advanced/texture_binding_array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ impl AsBindGroup for BindlessMaterial {
102102

103103
fn as_bind_group(
104104
&self,
105-
layout: &BindGroupLayout,
105+
layout: &BindGroupLayoutDescriptor,
106106
render_device: &RenderDevice,
107+
pipeline_cache: &PipelineCache,
107108
(image_assets, fallback_image): &mut SystemParamItem<'_, '_, Self::Param>,
108109
) -> Result<PreparedBindGroup, AsBindGroupError> {
109110
// retrieve the render resources from handles
@@ -129,7 +130,7 @@ impl AsBindGroup for BindlessMaterial {
129130

130131
let bind_group = render_device.create_bind_group(
131132
"bindless_material_bind_group",
132-
layout,
133+
&pipeline_cache.get_bind_group_layout(layout),
133134
&BindGroupEntries::sequential((&textures[..], &fallback_image.sampler)),
134135
);
135136

0 commit comments

Comments
 (0)