diff --git a/node-graph/interpreted-executor/src/util.rs b/node-graph/interpreted-executor/src/util.rs index e436d769c2..13d2b19c83 100644 --- a/node-graph/interpreted-executor/src/util.rs +++ b/node-graph/interpreted-executor/src/util.rs @@ -73,7 +73,7 @@ pub fn wrap_network_in_scope(network: NodeNetwork, editor_api: Arc(_: impl Ctx, #[scope("editor-api")] editor_api: } #[node_macro::node(category(""))] -pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> Resource { +pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope(editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi) -> Resource { let application_io = editor_api.application_io.as_ref().expect("ApplicationIo must be available when using resources"); application_io.load_resource(hash).await.unwrap_or_else(|| { panic!("Resource {hash} not found"); @@ -275,11 +275,11 @@ pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[editor_api::IDE } #[node_macro::node(category(""), inject_scope)] -pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor { +pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor { editor_api.application_io.as_ref().unwrap().gpu_executor().expect("GPU executor not available") } #[node_macro::node(category(""), inject_scope)] -pub async fn try_wgpu_executor<'a: 'n>(_: impl Ctx, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> Option<&'a ::wgpu_executor::WgpuExecutor> { +pub async fn try_wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi) -> Option<&'a ::wgpu_executor::WgpuExecutor> { editor_api.application_io.as_ref().unwrap().gpu_executor() } diff --git a/node-graph/nodes/gstd/src/render_background.rs b/node-graph/nodes/gstd/src/render_background.rs index a1c8a0df49..2037883e41 100644 --- a/node-graph/nodes/gstd/src/render_background.rs +++ b/node-graph/nodes/gstd/src/render_background.rs @@ -14,7 +14,7 @@ use wgpu_executor::{AsyncWgpuPipeline, WgpuExecutor, WgpuPipelineCache}; #[node_macro::node(category(""))] async fn render_background<'a: 'n>( ctx: impl Ctx + ExtractFootprint + ExtractVarArgs, - #[scope(background_compositor_pipeline::IDENTIFIER)] pipeline: WgpuPipelineCache, + #[scope(composit_background_pipeline::IDENTIFIER)] pipeline: WgpuPipelineCache, data: RenderOutput, ) -> RenderOutput { let footprint = ctx.footprint(); @@ -36,7 +36,7 @@ async fn render_background<'a: 'n>( RenderOutputType::Texture(foreground_texture) => { let doc_to_screen = (glam::DAffine2::from_scale(glam::DVec2::splat(render_params.scale)) * render_params.footprint.transform).as_affine2(); let blended = pipeline - .run::(&BackgroundCompositorArgs { + .run::(&CompositBackgroundArgs { foreground: foreground_texture.as_ref(), backgrounds: &metadata.backgrounds, document_to_screen: doc_to_screen, @@ -118,16 +118,18 @@ async fn render_background<'a: 'n>( } #[node_macro::node(category(""), inject_scope)] -async fn background_compositor_pipeline<'a: 'n>( +async fn composit_background_pipeline<'a: 'n>( _ctx: impl Ctx, - #[scope(crate::platform_application_io::wgpu_executor::IDENTIFIER)] executor: &'a WgpuExecutor, + #[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Option<&'a WgpuExecutor>, #[data] pipeline: WgpuPipelineCache, ) -> WgpuPipelineCache { - executor.pipeline_init::(pipeline); + if let Some(executor) = executor { + executor.pipeline_init::(pipeline); + } pipeline.clone() } -pub struct BackgroundCompositor { +pub struct CompositBackground { checker_rect_pipeline: wgpu::RenderPipeline, checker_viewport_pipeline: wgpu::RenderPipeline, fullscreen_pipeline: wgpu::RenderPipeline, @@ -136,15 +138,15 @@ pub struct BackgroundCompositor { sampler: wgpu::Sampler, } -pub struct BackgroundCompositorArgs<'a> { +pub struct CompositBackgroundArgs<'a> { foreground: &'a wgpu::Texture, backgrounds: &'a [rendering::Background], document_to_screen: Affine2, zoom: f32, } -impl AsyncWgpuPipeline for BackgroundCompositor { - type Args<'a> = BackgroundCompositorArgs<'a>; +impl AsyncWgpuPipeline for CompositBackground { + type Args<'a> = CompositBackgroundArgs<'a>; type Out = Arc; fn create(executor: &WgpuExecutor) -> Self { @@ -327,7 +329,7 @@ impl AsyncWgpuPipeline for BackgroundCompositor { } async fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> Self::Out { - let &BackgroundCompositorArgs { + let &CompositBackgroundArgs { foreground, backgrounds, document_to_screen, @@ -437,7 +439,7 @@ impl AsyncWgpuPipeline for BackgroundCompositor { } } -impl BackgroundCompositor { +impl CompositBackground { fn create_checker_bind_group(&self, device: &wgpu::Device, uniforms: CompositeUniforms) -> wgpu::BindGroup { let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("background_checker_uniforms"), diff --git a/node-graph/nodes/gstd/src/render_pixel_preview.rs b/node-graph/nodes/gstd/src/render_pixel_preview.rs index 331ddc29ca..2cc2964151 100644 --- a/node-graph/nodes/gstd/src/render_pixel_preview.rs +++ b/node-graph/nodes/gstd/src/render_pixel_preview.rs @@ -58,7 +58,7 @@ pub async fn render_pixel_preview<'a: 'n>( let transform = DAffine2::from_translation(-upstream_min) * footprint.transform.inverse() * DAffine2::from_scale(logical_resolution); let resampled = pipeline - .run::(&ResamplerArgs { + .run::(&PixelPreviewArgs { source: source_texture.as_ref(), transform: &transform, size: physical_resolution, @@ -77,10 +77,12 @@ pub async fn render_pixel_preview<'a: 'n>( #[node_macro::node(category(""), inject_scope)] async fn pixel_preview_pipeline<'a: 'n>( _ctx: impl Ctx, - #[scope(crate::platform_application_io::wgpu_executor::IDENTIFIER)] executor: &'a WgpuExecutor, + #[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Option<&'a WgpuExecutor>, #[data] pipeline: WgpuPipelineCache, ) -> WgpuPipelineCache { - executor.pipeline_init::(pipeline); + if let Some(executor) = executor { + executor.pipeline_init::(pipeline); + } pipeline.clone() } @@ -89,14 +91,14 @@ pub struct PixelPreview { bind_group_layout: wgpu::BindGroupLayout, } -pub struct ResamplerArgs<'a> { +pub struct PixelPreviewArgs<'a> { source: &'a wgpu::Texture, transform: &'a DAffine2, size: UVec2, } impl AsyncWgpuPipeline for PixelPreview { - type Args<'a> = ResamplerArgs<'a>; + type Args<'a> = PixelPreviewArgs<'a>; type Out = Arc; fn create(executor: &WgpuExecutor) -> Self { @@ -169,7 +171,7 @@ impl AsyncWgpuPipeline for PixelPreview { async fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> Self::Out { let context = &executor.context(); - let &ResamplerArgs { source, transform, size } = args; + let &PixelPreviewArgs { source, transform, size } = args; let output = executor.request_texture(size).await;