summaryrefslogtreecommitdiffstats
path: root/wgpu/src/texture
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-26 12:52:30 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-26 12:55:04 +0100
commitc58d94f3fda40f215254008ec105aeab56085b0e (patch)
treee169e0cfd35b23973dcb53da3ef9b81267d82b07 /wgpu/src/texture
parent59d45a5440aaa46c7dc8f3dc70c8518167c10418 (diff)
downloadiced-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.rs12
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> {