mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
* 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
35 lines
554 B
Rust
35 lines
554 B
Rust
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)))
|
|
}
|
|
}
|