Skip to content

Instantly share code, notes, and snippets.

@valbaca
Created August 13, 2022 21:29
Show Gist options
  • Save valbaca/c57a2117f7dafca67d6078c34addf417 to your computer and use it in GitHub Desktop.
Save valbaca/c57a2117f7dafca67d6078c34addf417 to your computer and use it in GitHub Desktop.
diff --git a/src/main.rs b/src/main.rs
index 61a0589..9cf361e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,12 +40,8 @@ impl<'a> Buffer<'a> {
pub fn from_data<T: Copy>(device: &'a Device, _data: &[T]) -> Self {
let mut staging_buffer = Buffer::new(device);
- {
- let staging_buffer_memory = staging_buffer.memory_mut();
- staging_buffer_memory.map();
- staging_buffer_memory.unmap();
- }
-
+ staging_buffer.map_unmap();
+
let buffer = Self::new(device);
staging_buffer.copy_to_buffer(&buffer);
@@ -60,6 +56,11 @@ impl<'a> Buffer<'a> {
&mut self.memory
}
+ pub fn map_unmap(&mut self) {
+ self.memory.map();
+ self.memory.unmap();
+ }
+
fn copy_to_buffer(&self, _dst_buffer: &Buffer) {
//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment