Fix buffer mapping examples

This commit is contained in:
Lachlan Sneff committed 2020-06-11 12:07:47 -04:00
1 parent b1f3fbaab0
commit d9ecab0cdc
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!")