Add bind group caching

This commit is contained in:
Keavon Chambers
2020-05-11 00:38:01 -07:00
parent 59cb448872
commit 9a60ba54fe
3 changed files with 84 additions and 69 deletions

View File

@@ -1,20 +1,20 @@
pub struct DrawCommand {
pub pipeline_name: String,
pub bind_group: wgpu::BindGroup,
pub bind_group_name: String,
pub vertex_buffer: wgpu::Buffer,
pub index_buffer: wgpu::Buffer,
pub index_count: u32,
}
impl DrawCommand {
pub fn new(device: &wgpu::Device, pipeline_name: &str, vertices: &[[f32; 2]], indices: &[u16], bind_group: wgpu::BindGroup) -> Self {
pub fn new(device: &wgpu::Device, pipeline_name: &str, bind_group_name: &str, vertices: &[[f32; 2]], indices: &[u16]) -> Self {
let vertex_buffer = device.create_buffer_with_data(bytemuck::cast_slice(vertices), wgpu::BufferUsage::VERTEX);
let index_buffer = device.create_buffer_with_data(bytemuck::cast_slice(indices), wgpu::BufferUsage::INDEX);
let index_count = indices.len() as u32;
Self {
pipeline_name: String::from(pipeline_name),
bind_group,
bind_group_name: String::from(bind_group_name),
vertex_buffer,
index_buffer,
index_count,