Skip to content

Commit 8acde75

Browse files
authored
Add dummy binding for compute shader example (#328)
* Add dummy binding for compute shader example * Linter fixes
1 parent b9592e5 commit 8acde75

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

examples/runners/wgpu/src/compute.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::{shader_module, Options};
2+
use core::num::NonZeroU64;
23

34
fn create_device_queue() -> (wgpu::Device, wgpu::Queue) {
45
async fn create_device_queue_async() -> (wgpu::Device, wgpu::Queue) {
@@ -40,7 +41,20 @@ pub fn start(options: &Options) {
4041

4142
let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
4243
label: None,
43-
entries: &[],
44+
entries: &[
45+
// XXX - some graphics cards do not support empty bind layout groups, so
46+
// create a dummy entry.
47+
wgpu::BindGroupLayoutEntry {
48+
binding: 0,
49+
count: None,
50+
visibility: wgpu::ShaderStage::COMPUTE,
51+
ty: wgpu::BindingType::StorageBuffer {
52+
dynamic: false,
53+
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
54+
readonly: false,
55+
},
56+
},
57+
],
4458
});
4559

4660
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@@ -58,10 +72,20 @@ pub fn start(options: &Options) {
5872
},
5973
});
6074

75+
let buf = device.create_buffer(&wgpu::BufferDescriptor {
76+
label: None,
77+
size: 1,
78+
usage: wgpu::BufferUsage::STORAGE,
79+
mapped_at_creation: false,
80+
});
81+
6182
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
6283
label: None,
6384
layout: &bind_group_layout,
64-
entries: &[],
85+
entries: &[wgpu::BindGroupEntry {
86+
binding: 0,
87+
resource: wgpu::BindingResource::Buffer(buf.slice(..)),
88+
}],
6589
});
6690

6791
let mut encoder =

0 commit comments

Comments
 (0)