Skip to content

Commit

Permalink
Fix buffer size in wgpu triangle pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 2, 2019
1 parent 25135cd commit 7965140
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/graphics/backend_wgpu/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ impl Pipeline {
});

let vertices = device.create_buffer(&wgpu::BufferDescriptor {
size: Self::INITIAL_BUFFER_SIZE,
size: mem::size_of::<Vertex>() as u32
* Self::INITIAL_BUFFER_SIZE as u32,
usage: wgpu::BufferUsageFlags::VERTEX,
});

let indices = device.create_buffer(&wgpu::BufferDescriptor {
size: Self::INITIAL_BUFFER_SIZE,
size: Self::INITIAL_BUFFER_SIZE * 2,
usage: wgpu::BufferUsageFlags::INDEX,
});

Expand Down Expand Up @@ -163,12 +164,12 @@ impl Pipeline {
let new_size = vertices.len().max(indices.len()) as u32;

self.vertices = device.create_buffer(&wgpu::BufferDescriptor {
size: new_size,
size: mem::size_of::<Vertex>() as u32 * new_size,
usage: wgpu::BufferUsageFlags::VERTEX,
});

self.indices = device.create_buffer(&wgpu::BufferDescriptor {
size: new_size,
size: new_size * 2,
usage: wgpu::BufferUsageFlags::INDEX,
});

Expand Down

0 comments on commit 7965140

Please sign in to comment.