mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 15:28:04 +08:00
Improve texture caching by allowing weak refs and more formats (#4447)
This commit is contained in:
34
node-graph/libraries/wgpu-executor/src/buffer.rs
Normal file
34
node-graph/libraries/wgpu-executor/src/buffer.rs
Normal 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)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user