From d2f791cfb3e5f196de8bb07130fc232136b4439c Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 3 Oct 2024 19:32:34 +0200 Subject: [PATCH] Make Upload Texture node resolution-aware (#2018) * Make UploadTextureNode resolution aware * Add TextureFrame implementations for MonitorNode * Add TextureFrame implementation to TransformNode --- .../document/node_graph/document_node_definitions.rs | 3 ++- node-graph/gcore/src/transform.rs | 4 ++++ node-graph/interpreted-executor/src/node_registry.rs | 2 ++ node-graph/wgpu-executor/src/lib.rs | 7 ++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index 4fc10e0e..49a0b9a6 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -1777,11 +1777,12 @@ fn static_nodes() -> Vec { }, DocumentNode { inputs: vec![NodeInput::network(concrete!(ImageFrame), 0), NodeInput::node(NodeId(0), 0)], + manual_composition: Some(generic!(T)), implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::UploadTextureNode")), ..Default::default() }, DocumentNode { - manual_composition: Some(concrete!(Footprint)), + manual_composition: Some(generic!(T)), inputs: vec![NodeInput::node(NodeId(1), 0)], implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::ImpureMemoNode")), ..Default::default() diff --git a/node-graph/gcore/src/transform.rs b/node-graph/gcore/src/transform.rs index 11fc220e..d72c0897 100644 --- a/node-graph/gcore/src/transform.rs +++ b/node-graph/gcore/src/transform.rs @@ -1,3 +1,4 @@ +use crate::application_io::TextureFrame; use crate::raster::bbox::AxisAlignedBbox; use crate::raster::{ImageFrame, Pixel}; use crate::vector::VectorData; @@ -216,6 +217,7 @@ async fn transform + 'n + ApplyTransform + Clone + Send + Syn (), (), (), + (), Footprint, )] mut input: I, @@ -223,9 +225,11 @@ async fn transform + 'n + ApplyTransform + Clone + Send + Syn () -> VectorData, () -> GraphicGroup, () -> ImageFrame, + () -> TextureFrame, Footprint -> VectorData, Footprint -> GraphicGroup, Footprint -> ImageFrame, + Footprint -> TextureFrame, )] transform_target: impl Node, translate: DVec2, diff --git a/node-graph/interpreted-executor/src/node_registry.rs b/node-graph/interpreted-executor/src/node_registry.rs index 929cbdbc..cc232af0 100644 --- a/node-graph/interpreted-executor/src/node_registry.rs +++ b/node-graph/interpreted-executor/src/node_registry.rs @@ -175,6 +175,8 @@ fn node_registry() -> HashMap, input: Footprint, fn_params: [Footprint => ImageFrame]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), params: [ImageFrame]), + async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => TextureFrame]), + async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), params: [TextureFrame]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => VectorData]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: (), fn_params: [() => VectorData]), async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Footprint, fn_params: [Footprint => graphene_core::GraphicGroup]), diff --git a/node-graph/wgpu-executor/src/lib.rs b/node-graph/wgpu-executor/src/lib.rs index bef0535b..6764bbf3 100644 --- a/node-graph/wgpu-executor/src/lib.rs +++ b/node-graph/wgpu-executor/src/lib.rs @@ -911,8 +911,13 @@ async fn render_texture<'a: 'n>(_: (), footprint: Footprint, image: impl Node(_: (), input: ImageFrame, executor: &'a WgpuExecutor) -> TextureFrame { +async fn upload_texture<'a: 'n, F: Copy + Send + Sync + 'n>( + #[implementations((), Footprint)] footprint: F, + #[implementations(() -> ImageFrame, Footprint -> ImageFrame)] input: impl Node>, + executor: &'a WgpuExecutor, +) -> TextureFrame { // let new_data: Vec = input.image.data.into_iter().map(|c| c.into()).collect(); + let input = input.eval(footprint).await; let new_data = input.image.data.into_iter().map(SRGBA8::from).collect(); let new_image = Image { width: input.image.width,