Add dummy binding for compute shader example (#328)

* Add dummy binding for compute shader example

* Linter fixes
This commit is contained in:
Frank Murphy 2021-01-04 11:00:34 -05:00 committed by GitHub
parent b9592e50c5
commit 8acde75c13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
use super::{shader_module, Options};
use core::num::NonZeroU64;
fn create_device_queue() -> (wgpu::Device, wgpu::Queue) {
async fn create_device_queue_async() -> (wgpu::Device, wgpu::Queue) {
@ -40,7 +41,20 @@ pub fn start(options: &Options) {
let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[],
entries: &[
// XXX - some graphics cards do not support empty bind layout groups, so
// create a dummy entry.
wgpu::BindGroupLayoutEntry {
binding: 0,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
ty: wgpu::BindingType::StorageBuffer {
dynamic: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
readonly: false,
},
},
],
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -58,10 +72,20 @@ pub fn start(options: &Options) {
},
});
let buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: 1,
usage: wgpu::BufferUsage::STORAGE,
mapped_at_creation: false,
});
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None,
layout: &bind_group_layout,
entries: &[],
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(buf.slice(..)),
}],
});
let mut encoder =