diff --git a/examples/hello_compute_rust/main.rs b/examples/hello_compute_rust/main.rs index ef5bdef87..27c5ad774 100644 --- a/examples/hello_compute_rust/main.rs +++ b/examples/hello_compute_rust/main.rs @@ -88,13 +88,16 @@ fn main() { } encoder.copy_buffer_to_buffer(&storage_buffer, 0, &staging_buffer, 0, size); + device.get_queue().submit(&[encoder.finish()]); + staging_buffer.map_read_async(0, size, |result: wgpu::BufferMapAsyncResult<&[u32]>| { if let wgpu::BufferMapAsyncResult::Success(data) = result { println!("Times: {:?}", data); } - staging_buffer.unmap(); + // staging_buffer.unmap(); // TODO }); + let encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { todo: 0 }); device.get_queue().submit(&[encoder.finish()]); } diff --git a/wgpu-rs/src/lib.rs b/wgpu-rs/src/lib.rs index cd456656a..32eb32b7d 100644 --- a/wgpu-rs/src/lib.rs +++ b/wgpu-rs/src/lib.rs @@ -530,7 +530,7 @@ impl Buffer { pub fn map_read_async(&self, start: u32, size: u32, callback: F) where T: 'static + Copy, - F: FnOnce(BufferMapAsyncResult<&[T]>), + F: FnOnce(BufferMapAsyncResult<&[T]>) + 'static, { let type_size = std::mem::size_of::() as u32; assert_ne!(type_size, 0); @@ -575,7 +575,7 @@ impl Buffer { pub fn map_write_async(&self, start: u32, size: u32, callback: F) where T: 'static + Copy, - F: FnOnce(BufferMapAsyncResult<&mut [T]>), + F: FnOnce(BufferMapAsyncResult<&mut [T]>) + 'static, { let type_size = std::mem::size_of::() as u32; assert_ne!(type_size, 0);