Skip to content

Commit

Permalink
move test data into distinct files
Browse files Browse the repository at this point in the history
  • Loading branch information
ScanMountGoat committed Aug 12, 2024
1 parent cb97b21 commit fe69049
Show file tree
Hide file tree
Showing 20 changed files with 1,087 additions and 1,272 deletions.
658 changes: 13 additions & 645 deletions wgsl_to_wgpu/src/bindgroup.rs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions wgsl_to_wgpu/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,22 @@ mod tests {
]);
if let Some(value) = self.b1 {
entries.insert("b1".to_owned(), if value { 1.0 } else { 0.0 });
}
};
if let Some(value) = self.b2 {
entries.insert("b2".to_owned(), if value { 1.0 } else { 0.0 });
}
};
if let Some(value) = self.f1 {
entries.insert("f1".to_owned(), value as f64);
}
};
if let Some(value) = self.i1 {
entries.insert("i1".to_owned(), value as f64);
}
};
if let Some(value) = self.i3 {
entries.insert("i3".to_owned(), value as f64);
}
};
if let Some(value) = self.a {
entries.insert("0".to_owned(), value as f64);
}
};
if let Some(value) = self.b {
entries.insert("35".to_owned(), value as f64);
}
Expand Down
133 changes: 133 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/compute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
pub mod bind_groups {
#[derive(Debug)]
pub struct BindGroup0(wgpu::BindGroup);
#[derive(Debug)]
pub struct BindGroupLayout0<'a> {
pub src: wgpu::BufferBinding<'a>,
pub vertex_weights: wgpu::BufferBinding<'a>,
pub dst: wgpu::BufferBinding<'a>,
}
const LAYOUT_DESCRIPTOR0: wgpu::BindGroupLayoutDescriptor = wgpu::BindGroupLayoutDescriptor {
label: Some("LayoutDescriptor0"),
entries: &[
wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Storage { read_only: true },
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Storage { read_only: true },
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Storage { read_only: false },
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
},
],
};
impl BindGroup0 {
pub fn get_bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0)
}
pub fn from_bindings(device: &wgpu::Device, bindings: BindGroupLayout0) -> Self {
let bind_group_layout = device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0);
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout,
entries: &[
wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(bindings.src),
},
wgpu::BindGroupEntry {
binding: 1,
resource: wgpu::BindingResource::Buffer(bindings.vertex_weights),
},
wgpu::BindGroupEntry {
binding: 2,
resource: wgpu::BindingResource::Buffer(bindings.dst),
},
],
label: Some("BindGroup0"),
});
Self(bind_group)
}
pub fn set<'a>(&'a self, render_pass: &mut wgpu::ComputePass<'a>) {
render_pass.set_bind_group(0, &self.0, &[]);
}
}
#[derive(Debug)]
pub struct BindGroup1(wgpu::BindGroup);
#[derive(Debug)]
pub struct BindGroupLayout1<'a> {
pub transforms: wgpu::BufferBinding<'a>,
}
const LAYOUT_DESCRIPTOR1: wgpu::BindGroupLayoutDescriptor = wgpu::BindGroupLayoutDescriptor {
label: Some("LayoutDescriptor1"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
}],
};
impl BindGroup1 {
pub fn get_bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&LAYOUT_DESCRIPTOR1)
}
pub fn from_bindings(device: &wgpu::Device, bindings: BindGroupLayout1) -> Self {
let bind_group_layout = device.create_bind_group_layout(&LAYOUT_DESCRIPTOR1);
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout,
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(bindings.transforms),
}],
label: Some("BindGroup1"),
});
Self(bind_group)
}
pub fn set<'a>(&'a self, render_pass: &mut wgpu::ComputePass<'a>) {
render_pass.set_bind_group(1, &self.0, &[]);
}
}
#[derive(Debug, Copy, Clone)]
pub struct BindGroups<'a> {
pub bind_group0: &'a BindGroup0,
pub bind_group1: &'a BindGroup1,
}
impl<'a> BindGroups<'a> {
pub fn set(&self, pass: &mut wgpu::ComputePass<'a>) {
self.bind_group0.set(pass);
self.bind_group1.set(pass);
}
}
}
pub fn set_bind_groups<'a>(
pass: &mut wgpu::ComputePass<'a>,
bind_group0: &'a bind_groups::BindGroup0,
bind_group1: &'a bind_groups::BindGroup1,
) {
bind_group0.set(pass);
bind_group1.set(pass);
}
15 changes: 15 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/compute.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct VertexInput0 {};
struct VertexWeight {};
struct Vertices {};
struct VertexWeights {};
struct Transforms {};

@group(0) @binding(0) var<storage, read> src: array<vec4<f32>>;
@group(0) @binding(1) var<storage, read> vertex_weights: VertexWeights;
@group(0) @binding(2) var<storage, read_write> dst: Vertices;

@group(1) @binding(0) var<uniform> transforms: Transforms;

@compute
@workgroup_size(64)
fn main() {}
56 changes: 56 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/fragment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pub mod bind_groups {
#[derive(Debug)]
pub struct BindGroup0(wgpu::BindGroup);
#[derive(Debug)]
pub struct BindGroupLayout0<'a> {
pub transforms: wgpu::BufferBinding<'a>,
}
const LAYOUT_DESCRIPTOR0: wgpu::BindGroupLayoutDescriptor = wgpu::BindGroupLayoutDescriptor {
label: Some("LayoutDescriptor0"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
}],
};
impl BindGroup0 {
pub fn get_bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0)
}
pub fn from_bindings(device: &wgpu::Device, bindings: BindGroupLayout0) -> Self {
let bind_group_layout = device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0);
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout,
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(bindings.transforms),
}],
label: Some("BindGroup0"),
});
Self(bind_group)
}
pub fn set<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) {
render_pass.set_bind_group(0, &self.0, &[]);
}
}
#[derive(Debug, Copy, Clone)]
pub struct BindGroups<'a> {
pub bind_group0: &'a BindGroup0,
}
impl<'a> BindGroups<'a> {
pub fn set(&self, pass: &mut wgpu::RenderPass<'a>) {
self.bind_group0.set(pass);
}
}
}
pub fn set_bind_groups<'a>(
pass: &mut wgpu::RenderPass<'a>,
bind_group0: &'a bind_groups::BindGroup0,
) {
bind_group0.set(pass);
}
6 changes: 6 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/fragment.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct Transforms {};

@group(0) @binding(0) var<uniform> transforms: Transforms;

@fragment
fn fs_main() {}
56 changes: 56 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/vertex.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pub mod bind_groups {
#[derive(Debug)]
pub struct BindGroup0(wgpu::BindGroup);
#[derive(Debug)]
pub struct BindGroupLayout0<'a> {
pub transforms: wgpu::BufferBinding<'a>,
}
const LAYOUT_DESCRIPTOR0: wgpu::BindGroupLayoutDescriptor = wgpu::BindGroupLayoutDescriptor {
label: Some("LayoutDescriptor0"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::VERTEX,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
}],
};
impl BindGroup0 {
pub fn get_bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {
device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0)
}
pub fn from_bindings(device: &wgpu::Device, bindings: BindGroupLayout0) -> Self {
let bind_group_layout = device.create_bind_group_layout(&LAYOUT_DESCRIPTOR0);
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout,
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(bindings.transforms),
}],
label: Some("BindGroup0"),
});
Self(bind_group)
}
pub fn set<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) {
render_pass.set_bind_group(0, &self.0, &[]);
}
}
#[derive(Debug, Copy, Clone)]
pub struct BindGroups<'a> {
pub bind_group0: &'a BindGroup0,
}
impl<'a> BindGroups<'a> {
pub fn set(&self, pass: &mut wgpu::RenderPass<'a>) {
self.bind_group0.set(pass);
}
}
}
pub fn set_bind_groups<'a>(
pass: &mut wgpu::RenderPass<'a>,
bind_group0: &'a bind_groups::BindGroup0,
) {
bind_group0.set(pass);
}
6 changes: 6 additions & 0 deletions wgsl_to_wgpu/src/data/bindgroup/vertex.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct Transforms {};

@group(0) @binding(0) var<uniform> transforms: Transforms;

@vertex
fn vs_main() {}
Loading

0 comments on commit fe69049

Please sign in to comment.