Fix offsets of buffer uploads in triangle pipeline

This commit is contained in:
Héctor Ramón Jiménez 2020-02-28 19:38:17 +01:00
parent bab7dbcaef
commit 96f75eae4d

View File

@ -248,7 +248,7 @@ impl Pipeline {
&vertex_buffer, &vertex_buffer,
0, 0,
&self.vertex_buffer.raw, &self.vertex_buffer.raw,
last_vertex as u64, (std::mem::size_of::<Vertex2D>() * last_vertex) as u64,
(std::mem::size_of::<Vertex2D>() * mesh.vertices.len()) as u64, (std::mem::size_of::<Vertex2D>() * mesh.vertices.len()) as u64,
); );
@ -256,7 +256,7 @@ impl Pipeline {
&index_buffer, &index_buffer,
0, 0,
&self.index_buffer.raw, &self.index_buffer.raw,
last_index as u64, (std::mem::size_of::<u32>() * last_index) as u64,
(std::mem::size_of::<u32>() * mesh.indices.len()) as u64, (std::mem::size_of::<u32>() * mesh.indices.len()) as u64,
); );
@ -313,27 +313,30 @@ impl Pipeline {
depth_stencil_attachment: None, 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 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( render_pass.set_bind_group(
0, 0,
&self.constants, &self.constants,
&[(std::mem::size_of::<Uniforms>() * i) as u64], &[(std::mem::size_of::<Uniforms>() * i) as u64],
); );
render_pass render_pass
.set_index_buffer(&self.index_buffer.raw, index_offset); .set_index_buffer(&self.index_buffer.raw, index_offset);
render_pass.set_vertex_buffers( render_pass.set_vertex_buffers(
0, 0,
&[(&self.vertex_buffer.raw, vertex_offset)], &[(&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); render_pass.draw_indexed(0..indices as u32, 0, 0..1);
} }