diff options
author | 2020-02-26 12:52:30 +0100 | |
---|---|---|
committer | 2020-02-26 12:55:04 +0100 | |
commit | c58d94f3fda40f215254008ec105aeab56085b0e (patch) | |
tree | e169e0cfd35b23973dcb53da3ef9b81267d82b07 /wgpu/src/texture | |
parent | 59d45a5440aaa46c7dc8f3dc70c8518167c10418 (diff) | |
download | iced-c58d94f3fda40f215254008ec105aeab56085b0e.tar.gz iced-c58d94f3fda40f215254008ec105aeab56085b0e.tar.bz2 iced-c58d94f3fda40f215254008ec105aeab56085b0e.zip |
Avoid creating a vertex buffer every frame
Diffstat (limited to 'wgpu/src/texture')
-rw-r--r-- | wgpu/src/texture/atlas.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/wgpu/src/texture/atlas.rs b/wgpu/src/texture/atlas.rs index b950e59b..bf528dc9 100644 --- a/wgpu/src/texture/atlas.rs +++ b/wgpu/src/texture/atlas.rs @@ -67,24 +67,22 @@ impl Atlas { where C: Copy + 'static, { - let memory = { + let entry = { let current_size = self.layers.len(); - let memory = self.allocate(width, height)?; + let entry = self.allocate(width, height)?; // We grow the internal texture after allocating if necessary let new_layers = self.layers.len() - current_size; self.grow(new_layers, device, encoder); - memory + entry }; - dbg!(&memory); - let buffer = device .create_buffer_mapped(data.len(), wgpu::BufferUsage::COPY_SRC) .fill_from_slice(data); - match &memory { + match &entry { Entry::Contiguous(allocation) => { self.upload_texture(&buffer, 0, &allocation, encoder); } @@ -105,7 +103,7 @@ impl Atlas { } } - Some(memory) + Some(entry) } fn allocate(&mut self, width: u32, height: u32) -> Option<Entry> { |