Skip to content

Commit

Permalink
Fix texture delete in Device::deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakor Gyula committed Jan 16, 2020
1 parent 95722c5 commit 68cd26f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions webrender/src/device/gfx/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2656,12 +2656,7 @@ impl<B: hal::Backend> Device<B> {
}
}

fn free_texture(&mut self, mut texture: Texture) {
if texture.still_in_flight(self.frame_id, self.frame_count) {
self.retained_textures.push(texture);
return;
}

fn free_texture_unconditionaly(&mut self, mut texture: Texture) {
if texture.supports_depth() {
self.release_depth_target(texture.get_dimensions());
}
Expand Down Expand Up @@ -2698,16 +2693,24 @@ impl<B: hal::Backend> Device<B> {
texture.id = 0;
}

fn free_texture(&mut self, texture: Texture) {
if texture.still_in_flight(self.frame_id, self.frame_count) {
self.retained_textures.push(texture);
return;
}
self.free_texture_unconditionaly(texture);
}

fn delete_retained_textures(&mut self) {
let textures: SmallVec<[Texture; 16]> = self.retained_textures.drain(..).collect();
for texture in textures {
self.free_texture(texture);
}
}

pub fn delete_texture(&mut self, texture: Texture) {
//debug_assert!(self.inside_frame);
if texture.size.width + texture.size.height == 0 {
pub fn delete_texture(&mut self, mut texture: Texture) {
if texture.size_in_bytes() == 0 {
texture.id = 0;
return;
}

Expand Down Expand Up @@ -3685,10 +3688,10 @@ impl<B: hal::Backend> Device<B> {
pub fn deinit(mut self) {
self.device.wait_idle().unwrap();
for texture in self.retained_textures.drain(..).collect::<Vec<_>>() {
self.free_texture(texture);
self.free_texture_unconditionaly(texture);
}
for texture in self.readback_textures.drain(..).collect::<Vec<_>>() {
self.free_texture(texture);
self.free_texture_unconditionaly(texture);
}
unsafe {
if self.save_cache && self.cache_path.is_some() {
Expand Down

0 comments on commit 68cd26f

Please sign in to comment.