Improve texture caching by allowing weak refs and more formats (#4447)

* Destroy GPU textures when the last reference drops

* Request pooled textures synchronously

* Pool cached textures by format

* Add the owned GPU buffer type

* Route the remaining GPU allocations through the executor

* Add weak texture parking to the texture cache

* Raise the texture cache budget to 1GB for native and 512MB for wasm
This commit is contained in:
Timon
2026-08-27 15:19:00 +00:00
committed by GitHub
parent 8c48d5acce
commit 96cc520c4b
13 changed files with 213 additions and 169 deletions

View File

@@ -0,0 +1,34 @@
use std::ops::Deref;
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct Buffer(Arc<BufferInner>);
#[derive(Debug)]
struct BufferInner(wgpu::Buffer);
impl Drop for BufferInner {
fn drop(&mut self) {
self.0.destroy();
}
}
impl Deref for Buffer {
type Target = wgpu::Buffer;
fn deref(&self) -> &Self::Target {
&self.0.0
}
}
impl AsRef<wgpu::Buffer> for Buffer {
fn as_ref(&self) -> &wgpu::Buffer {
&self.0.0
}
}
impl From<wgpu::Buffer> for Buffer {
fn from(buffer: wgpu::Buffer) -> Self {
Self(Arc::new(BufferInner(buffer)))
}
}