Skip to content

Commit e23146a

Browse files
authored
Avoid breaking change: set_bind_group now takes Into<Option<...>> rather than Option<...> (#6452)
1 parent a8c9356 commit e23146a

File tree

41 files changed

+76
-74
lines changed

Some content is hidden

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

41 files changed

+76
-74
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ By @teoxoy [#6134](https://github.com/gfx-rs/wgpu/pull/6134).
6969
#### `set_bind_group` now takes an `Option` for the bind group argument.
7070

7171
https://gpuweb.github.io/gpuweb/#programmable-passes-bind-groups specifies that bindGroup
72-
is nullable. This change is the start of implementing this part of the spec. Callers that
73-
specify a `Some()` value should have unchanged behavior. Handling of `None` values still
72+
is nullable. This change is the start of implementing this part of the spec.
73+
Callers that specify a `Some()` value should have unchanged behavior. Handling of `None` values still
7474
needs to be implemented by backends.
75+
For convenience, the `set_bind_group` on compute/render passes & encoders takes `impl Into<Option<&BindGroup>>`,
76+
so most code should still work the same.
7577

7678
By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
7779

benches/benches/computepass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl ComputepassState {
389389
let end_idx = start_idx + dispatch_per_pass;
390390
for dispatch_idx in start_idx..end_idx {
391391
compute_pass.set_pipeline(&self.pipeline);
392-
compute_pass.set_bind_group(0, Some(&self.bind_groups[dispatch_idx]), &[]);
392+
compute_pass.set_bind_group(0, &self.bind_groups[dispatch_idx], &[]);
393393
compute_pass.dispatch_workgroups(1, 1, 1);
394394
}
395395

benches/benches/renderpass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl RenderpassState {
367367
let end_idx = start_idx + draws_per_pass;
368368
for draw_idx in start_idx..end_idx {
369369
render_pass.set_pipeline(&self.pipeline);
370-
render_pass.set_bind_group(0, Some(&self.bind_groups[draw_idx]), &[]);
370+
render_pass.set_bind_group(0, &self.bind_groups[draw_idx], &[]);
371371
for i in 0..VERTEX_BUFFERS_PER_DRAW {
372372
render_pass.set_vertex_buffer(
373373
i as u32,

examples/src/boids/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl crate::framework::Example for Example {
292292
timestamp_writes: None,
293293
});
294294
cpass.set_pipeline(&self.compute_pipeline);
295-
cpass.set_bind_group(0, Some(&self.particle_bind_groups[self.frame_num % 2]), &[]);
295+
cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]);
296296
cpass.dispatch_workgroups(self.work_group_count, 1, 1);
297297
}
298298
command_encoder.pop_debug_group();

examples/src/bunnymark/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ impl Example {
128128
occlusion_query_set: None,
129129
});
130130
rpass.set_pipeline(&self.pipeline);
131-
rpass.set_bind_group(0, Some(&self.global_group), &[]);
131+
rpass.set_bind_group(0, &self.global_group, &[]);
132132
for i in 0..self.bunnies.len() {
133133
let offset =
134134
(i as wgpu::DynamicOffset) * (uniform_alignment as wgpu::DynamicOffset);
135-
rpass.set_bind_group(1, Some(&self.local_group), &[offset]);
135+
rpass.set_bind_group(1, &self.local_group, &[offset]);
136136
rpass.draw(0..4, 0..1);
137137
}
138138
}

examples/src/conservative_raster/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl crate::framework::Example for Example {
296296
});
297297

298298
rpass.set_pipeline(&self.pipeline_upscale);
299-
rpass.set_bind_group(0, Some(&self.bind_group_upscale), &[]);
299+
rpass.set_bind_group(0, &self.bind_group_upscale, &[]);
300300
rpass.draw(0..3, 0..1);
301301

302302
if let Some(pipeline_lines) = &self.pipeline_lines {

examples/src/cube/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl crate::framework::Example for Example {
358358
});
359359
rpass.push_debug_group("Prepare data for draw.");
360360
rpass.set_pipeline(&self.pipeline);
361-
rpass.set_bind_group(0, Some(&self.bind_group), &[]);
361+
rpass.set_bind_group(0, &self.bind_group, &[]);
362362
rpass.set_index_buffer(self.index_buf.slice(..), wgpu::IndexFormat::Uint16);
363363
rpass.set_vertex_buffer(0, self.vertex_buf.slice(..));
364364
rpass.pop_debug_group();

examples/src/hello_compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async fn execute_gpu_inner(
132132
timestamp_writes: None,
133133
});
134134
cpass.set_pipeline(&compute_pipeline);
135-
cpass.set_bind_group(0, Some(&bind_group), &[]);
135+
cpass.set_bind_group(0, &bind_group, &[]);
136136
cpass.insert_debug_marker("compute collatz iterations");
137137
cpass.dispatch_workgroups(numbers.len() as u32, 1, 1); // Number of cells to run, the (x,y,z) size of item being processed
138138
}

examples/src/hello_synchronization/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async fn execute(
125125
timestamp_writes: None,
126126
});
127127
compute_pass.set_pipeline(&patient_pipeline);
128-
compute_pass.set_bind_group(0, Some(&bind_group), &[]);
128+
compute_pass.set_bind_group(0, &bind_group, &[]);
129129
compute_pass.dispatch_workgroups(local_patient_workgroup_results.len() as u32, 1, 1);
130130
}
131131
queue.submit(Some(command_encoder.finish()));
@@ -147,7 +147,7 @@ async fn execute(
147147
timestamp_writes: None,
148148
});
149149
compute_pass.set_pipeline(&hasty_pipeline);
150-
compute_pass.set_bind_group(0, Some(&bind_group), &[]);
150+
compute_pass.set_bind_group(0, &bind_group, &[]);
151151
compute_pass.dispatch_workgroups(local_patient_workgroup_results.len() as u32, 1, 1);
152152
}
153153
queue.submit(Some(command_encoder.finish()));

examples/src/hello_workgroups/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async fn run() {
124124
timestamp_writes: None,
125125
});
126126
compute_pass.set_pipeline(&pipeline);
127-
compute_pass.set_bind_group(0, Some(&bind_group), &[]);
127+
compute_pass.set_bind_group(0, &bind_group, &[]);
128128
/* Note that since each workgroup will cover both arrays, we only need to
129129
cover the length of one array. */
130130
compute_pass.dispatch_workgroups(local_a.len() as u32, 1, 1);

0 commit comments

Comments
 (0)