Skip to content

Commit 7965140

Browse files
committed
Fix buffer size in wgpu triangle pipeline
1 parent 25135cd commit 7965140

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/graphics/backend_wgpu/triangle.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ impl Pipeline {
111111
});
112112

113113
let vertices = device.create_buffer(&wgpu::BufferDescriptor {
114-
size: Self::INITIAL_BUFFER_SIZE,
114+
size: mem::size_of::<Vertex>() as u32
115+
* Self::INITIAL_BUFFER_SIZE as u32,
115116
usage: wgpu::BufferUsageFlags::VERTEX,
116117
});
117118

118119
let indices = device.create_buffer(&wgpu::BufferDescriptor {
119-
size: Self::INITIAL_BUFFER_SIZE,
120+
size: Self::INITIAL_BUFFER_SIZE * 2,
120121
usage: wgpu::BufferUsageFlags::INDEX,
121122
});
122123

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

165166
self.vertices = device.create_buffer(&wgpu::BufferDescriptor {
166-
size: new_size,
167+
size: mem::size_of::<Vertex>() as u32 * new_size,
167168
usage: wgpu::BufferUsageFlags::VERTEX,
168169
});
169170

170171
self.indices = device.create_buffer(&wgpu::BufferDescriptor {
171-
size: new_size,
172+
size: new_size * 2,
172173
usage: wgpu::BufferUsageFlags::INDEX,
173174
});
174175

0 commit comments

Comments
 (0)