From c58d94f3fda40f215254008ec105aeab56085b0e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 26 Feb 2020 12:52:30 +0100 Subject: Avoid creating a vertex buffer every frame --- wgpu/src/texture/atlas.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'wgpu/src/texture/atlas.rs') 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 { -- cgit