diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index fe34040e..0a118bd2 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -248,7 +248,7 @@ impl Pipeline { &vertex_buffer, 0, &self.vertex_buffer.raw, - last_vertex as u64, + (std::mem::size_of::() * last_vertex) as u64, (std::mem::size_of::() * mesh.vertices.len()) as u64, ); @@ -256,7 +256,7 @@ impl Pipeline { &index_buffer, 0, &self.index_buffer.raw, - last_index as u64, + (std::mem::size_of::() * last_index) as u64, (std::mem::size_of::() * mesh.indices.len()) as u64, ); @@ -313,27 +313,30 @@ impl Pipeline { depth_stencil_attachment: None, }); + render_pass.set_pipeline(&self.pipeline); + render_pass.set_scissor_rect( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + ); + for (i, (vertex_offset, index_offset, indices)) in - offsets.drain(..).enumerate() + offsets.into_iter().enumerate() { - render_pass.set_pipeline(&self.pipeline); render_pass.set_bind_group( 0, &self.constants, &[(std::mem::size_of::() * i) as u64], ); + render_pass .set_index_buffer(&self.index_buffer.raw, index_offset); + render_pass.set_vertex_buffers( 0, &[(&self.vertex_buffer.raw, vertex_offset)], ); - render_pass.set_scissor_rect( - bounds.x, - bounds.y, - bounds.width, - bounds.height, - ); render_pass.draw_indexed(0..indices as u32, 0, 0..1); }