1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use gfx::{ buffer, handle, memory, Factory, Resources, }; use gfx::memory::Bind; pub fn grow_buffer<R: Resources, F: Factory<R>, T>( factory: &mut F, buffer: &handle::Buffer<R, T>, buffer_role: buffer::Role, required_size: usize, ) -> handle::Buffer<R, T> { let mut size = buffer.len(); while size < required_size { size *= 2; } factory.create_buffer(size, buffer_role, memory::Usage::Dynamic, Bind::empty()) .expect("Could not create buffer") }