From 90d135ebaec1ae6148516252ee4786ae9578bda2 Mon Sep 17 00:00:00 2001 From: profan Date: Wed, 16 Jun 2021 17:56:57 +0100 Subject: [PATCH] remove unused view and upload buffer, remove use of unsafe, just use resize (was also using reserve wrong anyways) --- src/pipeline/cache.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/pipeline/cache.rs b/src/pipeline/cache.rs index fbaebba..7becd60 100644 --- a/src/pipeline/cache.rs +++ b/src/pipeline/cache.rs @@ -2,7 +2,6 @@ use std::num::NonZeroU32; pub struct Cache { texture: wgpu::Texture, - pub(super) view: wgpu::TextureView, padded_cache: Vec } @@ -25,19 +24,12 @@ impl Cache { sample_count: 1, }); - let view = texture.create_view(&wgpu::TextureViewDescriptor::default()); - - let upload_buffer = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("wgpu_glyph::Cache upload buffer"), - size: Self::INITIAL_UPLOAD_BUFFER_SIZE, - usage: wgpu::BufferUsage::COPY_DST | wgpu::BufferUsage::COPY_SRC, - mapped_at_creation: false, - }); + let mut padded_cache = Vec::new(); + padded_cache.reserve(Self::INITIAL_UPLOAD_BUFFER_SIZE as usize); Cache { texture, - view, - padded_cache: Vec::new() + padded_cache } } @@ -62,11 +54,7 @@ impl Cache { let padded_width = width + padded_width_padding; let padded_data_size = (padded_width * height) as u64; - self.padded_cache.reserve(padded_data_size as usize); - - unsafe { - self.padded_cache.set_len(padded_data_size as usize); - } + self.padded_cache.resize(padded_data_size as usize, 0); let padded_data = self.padded_cache.as_mut_slice();