Skip to content

Commit

Permalink
Fix crash, if no triangles are being rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 8, 2024
1 parent 32ec732 commit 216fedc
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions experiments/2024-10-30/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,20 @@ impl Renderer {
occlusion_query_set: None,
});

render_pass.set_index_buffer(
index_buffer.slice(..),
wgpu::IndexFormat::Uint32,
);
render_pass.set_vertex_buffer(0, vertex_buffer.slice(..));
render_pass.set_pipeline(&self.pipeline);
render_pass.set_bind_group(0, &self.bind_group, &[]);
render_pass.draw_indexed(
0..mesh_triangles.len() as u32 * 3,
0,
0..1,
);
if !indices.is_empty() || !vertices.is_empty() {
render_pass.set_index_buffer(
index_buffer.slice(..),
wgpu::IndexFormat::Uint32,
);
render_pass.set_vertex_buffer(0, vertex_buffer.slice(..));
render_pass.set_pipeline(&self.pipeline);
render_pass.set_bind_group(0, &self.bind_group, &[]);
render_pass.draw_indexed(
0..mesh_triangles.len() as u32 * 3,
0,
0..1,
);
}
}

self.queue.submit(Some(encoder.finish()));
Expand Down

0 comments on commit 216fedc

Please sign in to comment.