use std::borrow::Cow;
pub fn create_shader_module(device: &wgpu::Device, label: &str, wgsl: &str) -> wgpu::ShaderModule {
device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some(label),
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(wgsl)),
})
}
pub fn create_pipeline_layout_single(
device: &wgpu::Device,
label: &str,
bgl: &wgpu::BindGroupLayout,
) -> wgpu::PipelineLayout {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some(label),
bind_group_layouts: &[bgl],
push_constant_ranges: &[],
})
}
pub fn create_compute_pipeline(
device: &wgpu::Device,
label: &str,
layout: &wgpu::PipelineLayout,
module: &wgpu::ShaderModule,
) -> wgpu::ComputePipeline {
device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: Some(label),
layout: Some(layout),
module,
entry_point: "main",
})
}
pub fn create_pipeline_layout_empty(device: &wgpu::Device, label: &str) -> wgpu::PipelineLayout {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some(label),
bind_group_layouts: &[],
push_constant_ranges: &[],
})
}