Skip to content

Commit

Permalink
remove unused view and upload buffer, remove use of unsafe, just use …
Browse files Browse the repository at this point in the history
…resize (was also using reserve wrong anyways)
  • Loading branch information
profan committed Jun 16, 2021
1 parent aef85eb commit 90d135e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/pipeline/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::num::NonZeroU32;

pub struct Cache {
texture: wgpu::Texture,
pub(super) view: wgpu::TextureView,
padded_cache: Vec<u8>
}

Expand All @@ -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
}
}

Expand All @@ -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();

Expand Down

0 comments on commit 90d135e

Please sign in to comment.