Fix lifetime of cached textures (#4333)

* Fix in-use textures being destroyed

* Remove ImageTexture refs

* Review
This commit is contained in:
Timon
2026-07-14 13:23:31 +02:00
committed by Keavon Chambers
parent ba0a97aefe
commit 7e29fe9a31
18 changed files with 100 additions and 79 deletions

View File

@@ -1,4 +1,5 @@
use glam::UVec2;
use raster_types::Texture;
use std::collections::VecDeque;
use std::sync::Arc;
@@ -16,7 +17,7 @@ impl TextureCache {
}
}
pub fn request_texture(&mut self, device: &wgpu::Device, size: UVec2) -> Arc<wgpu::Texture> {
pub fn request_texture(&mut self, device: &wgpu::Device, size: UVec2) -> Texture {
let size = size.max(UVec2::ONE);
if let Some(pos) = self
@@ -27,7 +28,7 @@ impl TextureCache {
let entry = self.textures.remove(pos).unwrap();
let texture = entry.clone();
self.textures.push_back(entry);
return texture;
return texture.into();
}
let incoming_bytes = size.x as u64 * size.y as u64 * 4;
@@ -50,7 +51,7 @@ impl TextureCache {
self.textures.push_back(texture.clone());
texture
texture.into()
}
fn total_free_bytes(&self) -> u64 {