mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
[wgpu] make vertex buffer slots optional
This commit is contained in:
1 parent
35fd939877
commit
67b4f3c7e5
28 files changed
+143
-126
No files matched your search
@@ -127,16 +127,16 @@ impl crate::framework::Example for Example {
|
||||
entry_point: Some("main_vs"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[
|
||||
wgpu::VertexBufferLayout {
|
||||
Some(wgpu::VertexBufferLayout {
|
||||
array_stride: 4 * 4,
|
||||
step_mode: wgpu::VertexStepMode::Instance,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2],
|
||||
},
|
||||
wgpu::VertexBufferLayout {
|
||||
}),
|
||||
Some(wgpu::VertexBufferLayout {
|
||||
array_stride: 2 * 4,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![2 => Float32x2],
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
|
||||
@@ -218,7 +218,7 @@ impl crate::framework::Example for Example {
|
||||
|
||||
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||
|
||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||
let vertex_buffers = [Some(wgpu::VertexBufferLayout {
|
||||
array_stride: vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &[
|
||||
@@ -233,7 +233,7 @@ impl crate::framework::Example for Example {
|
||||
shader_location: 1,
|
||||
},
|
||||
],
|
||||
}];
|
||||
})];
|
||||
|
||||
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: None,
|
||||
|
||||
@@ -55,11 +55,11 @@ impl Example {
|
||||
module: shader,
|
||||
entry_point: Some("vs_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
buffers: &[Some(wgpu::VertexBufferLayout {
|
||||
array_stride: size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x4],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: shader,
|
||||
|
||||
@@ -196,11 +196,11 @@ impl crate::framework::Example for Example {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[VertexBufferLayout {
|
||||
buffers: &[Some(VertexBufferLayout {
|
||||
array_stride: mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: Default::default(),
|
||||
attributes: &vertex_attr_array![0 => Float32x3, 1 => Float32x3],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
|
||||
@@ -438,11 +438,11 @@ impl crate::framework::Example for Example {
|
||||
});
|
||||
|
||||
let vertex_attr = wgpu::vertex_attr_array![0 => Sint8x4, 1 => Sint8x4];
|
||||
let vb_desc = wgpu::VertexBufferLayout {
|
||||
let vertex_buffers = [Some(wgpu::VertexBufferLayout {
|
||||
array_stride: vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &vertex_attr,
|
||||
};
|
||||
})];
|
||||
|
||||
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||
|
||||
@@ -494,7 +494,7 @@ impl crate::framework::Example for Example {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_bake"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: std::slice::from_ref(&vb_desc),
|
||||
buffers: &vertex_buffers,
|
||||
},
|
||||
fragment: None,
|
||||
primitive: wgpu::PrimitiveState {
|
||||
@@ -628,7 +628,7 @@ impl crate::framework::Example for Example {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[vb_desc],
|
||||
buffers: &vertex_buffers,
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
|
||||
@@ -228,11 +228,11 @@ impl crate::framework::Example for Example {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_entity"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
buffers: &[Some(wgpu::VertexBufferLayout {
|
||||
array_stride: size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
|
||||
@@ -104,7 +104,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
|
||||
|
||||
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||
|
||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||
let vertex_buffers = [Some(wgpu::VertexBufferLayout {
|
||||
array_stride: vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &[
|
||||
@@ -119,7 +119,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
|
||||
shader_location: 1,
|
||||
},
|
||||
],
|
||||
}];
|
||||
})];
|
||||
|
||||
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: None,
|
||||
|
||||
@@ -53,7 +53,7 @@ impl crate::framework::Example for Example {
|
||||
|
||||
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||
|
||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||
let vertex_buffers = [Some(wgpu::VertexBufferLayout {
|
||||
array_stride: vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &[wgpu::VertexAttribute {
|
||||
@@ -61,7 +61,7 @@ impl crate::framework::Example for Example {
|
||||
offset: 0,
|
||||
shader_location: 0,
|
||||
}],
|
||||
}];
|
||||
})];
|
||||
|
||||
let mask_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: None,
|
||||
|
||||
@@ -340,11 +340,11 @@ impl crate::framework::Example for Example {
|
||||
module: &base_shader_module,
|
||||
entry_point: Some("vert_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
buffers: &[Some(wgpu::VertexBufferLayout {
|
||||
array_stride: vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Sint32],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: fragment_shader_module,
|
||||
|
||||
@@ -512,11 +512,11 @@ impl crate::framework::Example for Example {
|
||||
// ensured by tagging on either a `#[repr(C)]` onto a
|
||||
// struct, or a `#[repr(transparent)]` if it only contains
|
||||
// one item, which is itself `repr(C)`.
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
buffers: &[Some(wgpu::VertexBufferLayout {
|
||||
array_stride: water_vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Sint16x2, 1 => Sint8x4],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
// Fragment shader and output targets
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
@@ -579,11 +579,11 @@ impl crate::framework::Example for Example {
|
||||
module: &terrain_module,
|
||||
entry_point: Some("vs_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[wgpu::VertexBufferLayout {
|
||||
buffers: &[Some(wgpu::VertexBufferLayout {
|
||||
array_stride: terrain_vertex_size as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3, 2 => Unorm8x4],
|
||||
}],
|
||||
})],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &terrain_module,
|
||||
|
||||
Reference in new issue
Block a user