Skip to content

Commit e9a8d4f

Browse files
committed
WIP shaders: wrap Texture in Arc within Raster<GPU>
1 parent 0a052b8 commit e9a8d4f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

node-graph/gcore/src/raster_types.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@ pub use gpu::GPU;
134134
mod gpu {
135135
use super::*;
136136
use crate::raster_types::__private::Sealed;
137+
use std::sync::Arc;
137138

138139
#[derive(Clone, Debug, PartialEq, Hash)]
139140
pub struct GPU {
140-
pub texture: wgpu::Texture,
141+
pub texture: Arc<InnerTexture>,
141142
}
142143

143144
impl Sealed for Raster<GPU> {}
@@ -150,17 +151,30 @@ mod gpu {
150151

151152
impl Raster<GPU> {
152153
pub fn new_gpu(texture: wgpu::Texture) -> Self {
153-
Self::new(GPU { texture })
154+
Self::new(GPU {
155+
texture: Arc::new(InnerTexture(texture)),
156+
})
154157
}
155158

156159
pub fn data(&self) -> &wgpu::Texture {
157160
&self.texture
158161
}
159162
}
160163

161-
impl Drop for GPU {
164+
#[derive(Debug, PartialEq, Hash)]
165+
pub struct InnerTexture(wgpu::Texture);
166+
167+
impl Deref for InnerTexture {
168+
type Target = wgpu::Texture;
169+
170+
fn deref(&self) -> &Self::Target {
171+
&self.0
172+
}
173+
}
174+
175+
impl Drop for InnerTexture {
162176
fn drop(&mut self) {
163-
self.texture.destroy();
177+
self.0.destroy();
164178
}
165179
}
166180
}

node-graph/wgpu-executor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl WgpuExecutor {
140140
let mut renderer = self.vello_renderer.lock().await;
141141
for (image, texture) in context.resource_overrides.iter() {
142142
let texture_view = wgpu::TexelCopyTextureInfoBase {
143-
texture: texture.texture.clone(),
143+
texture: wgpu::Texture::clone(&texture.texture),
144144
mip_level: 0,
145145
origin: Origin3d::ZERO,
146146
aspect: TextureAspect::All,

node-graph/wgpu-executor/src/shader_runtime/per_pixel_adjust_runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl PerPixelAdjustGraphicsPipeline {
230230
rp.draw(0..3, 0..1);
231231

232232
TableRow {
233-
element: Raster::new(GPU { texture: tex_out }),
233+
element: Raster::new_gpu(tex_out),
234234
transform: *instance.transform,
235235
alpha_blending: *instance.alpha_blending,
236236
source_node_id: *instance.source_node_id,

0 commit comments

Comments
 (0)