366: Fix buffer mapping examples r=cwfitzgerald a=lachlansneff

Fixes #364 

Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
This commit is contained in:
bors[bot]andLachlan Sneff authored and GitHub committed 2020-06-11 16:09:55 +00:00
commit 9842d2065f
2 files changed
+9

No files matched your search

+4
View File
@@ -153,6 +153,10 @@ async fn run() {
}
png_writer.finish().unwrap();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(padded_buffer);
output_buffer.unmap();
}
}
+5
View File
@@ -123,7 +123,12 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
.chunks_exact(4)
.map(|b| u32::from_ne_bytes(b.try_into().unwrap()))
.collect();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(data);
staging_buffer.unmap();
result
} else {
panic!("failed to run compute on gpu!")