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]
2020-06-11 16:09:55 +00:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

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();
}
}

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!")