From fb72d43392c0976b576442a2c8e88b0c68e24735 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 19 Aug 2025 15:46:53 +0200 Subject: [PATCH] shader-rt: replace gpu node's args and ret types with `Raster` --- .../src/shader_nodes/per_pixel_adjust.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs b/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs index 36cbff50b..b263a2c15 100644 --- a/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs +++ b/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs @@ -1,6 +1,7 @@ use crate::parsing::{Input, NodeFnAttributes, ParsedField, ParsedFieldType, ParsedNodeFn, RegularParsedField}; use crate::shader_nodes::{CodegenShaderEntryPoint, ShaderNodeType}; use convert_case::{Case, Casing}; +use proc_macro_crate::FoundCrate; use proc_macro2::{Ident, Span, TokenStream}; use quote::{ToTokens, format_ident, quote}; use std::borrow::Cow; @@ -105,14 +106,24 @@ impl CodegenShaderEntryPoint for PerPixelAdjust { let struct_name = format_ident!("{}", fn_name.to_string().to_case(Case::Pascal)); let mod_name = fn_name.clone(); + let gcore = match &parsed.crate_name { + FoundCrate::Itself => format_ident!("crate"), + FoundCrate::Name(name) => format_ident!("{name}"), + }; + let raster_gpu = syn::parse2::(quote!(#gcore::table::Table<#gcore::raster_types::Raster<#gcore::raster_types::GPU>>))?; + let fields = parsed .fields .iter() .map(|f| match &f.ty { - ParsedFieldType::Regular(reg) => Ok(ParsedField { - ty: ParsedFieldType::Regular(RegularParsedField { gpu_image: false, ..reg.clone() }), + ParsedFieldType::Regular(reg @ RegularParsedField { gpu_image: true, .. }) => Ok(ParsedField { + ty: ParsedFieldType::Regular(RegularParsedField { + ty: raster_gpu.clone(), + ..reg.clone() + }), ..f.clone() }), + ParsedFieldType::Regular(RegularParsedField { gpu_image: false, .. }) => Ok(f.clone()), ParsedFieldType::Node { .. } => Err(syn::Error::new_spanned(&f.pat_ident, "PerPixelAdjust shader nodes cannot accept other nodes as generics")), }) .collect::>()?; @@ -146,7 +157,7 @@ impl CodegenShaderEntryPoint for PerPixelAdjust { }), implementations: Default::default(), }, - output_type: parsed.output_type.clone(), + output_type: raster_gpu, is_async: true, fields, body,