From c5bd8acce9abb3cb8d562ab22217fd182f478eb0 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 16 Jun 2026 20:30:11 +0000 Subject: [PATCH] Fix WIP --- .../interpreted-executor/src/node_registry.rs | 6 ++++-- node-graph/interpreted-executor/src/util.rs | 6 +++--- .../nodes/gstd/src/platform_application_io.rs | 14 ++++++++++++-- node-graph/nodes/gstd/src/render_cache.rs | 6 +++--- node-graph/nodes/gstd/src/render_node.rs | 3 ++- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/node-graph/interpreted-executor/src/node_registry.rs b/node-graph/interpreted-executor/src/node_registry.rs index 0b84eca441..a53d442b17 100644 --- a/node-graph/interpreted-executor/src/node_registry.rs +++ b/node-graph/interpreted-executor/src/node_registry.rs @@ -201,8 +201,9 @@ fn node_registry() -> HashMap, input: Context, fn_params: [Context => ListDyn, Context => graphene_std::ContextFeatures]), #[cfg(target_family = "wasm")] async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => CanvasHandle, Context => graphene_std::ContextFeatures]), - async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => wgpu_executor::WgpuPipelineCache, Context => graphene_std::ContextFeatures]), async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => &wgpu_executor::WgpuExecutor, Context => graphene_std::ContextFeatures]), + async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => Option<&wgpu_executor::WgpuExecutor>, Context => graphene_std::ContextFeatures]), + async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => wgpu_executor::WgpuPipelineCache, Context => graphene_std::ContextFeatures]), // ========== // MEMO NODES // ========== @@ -288,8 +289,9 @@ fn node_registry() -> HashMap, input: Context, fn_params: [Context => graphene_std::transform::ScaleType]), async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => graphene_std::vector::misc::InterpolationDistribution]), async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => RenderIntermediate]), - async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => wgpu_executor::WgpuPipelineCache]), async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => &wgpu_executor::WgpuExecutor]), + async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => Option<&wgpu_executor::WgpuExecutor>]), + async_node!(graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => wgpu_executor::WgpuPipelineCache]), ]; // ============= // CONVERT NODES diff --git a/node-graph/interpreted-executor/src/util.rs b/node-graph/interpreted-executor/src/util.rs index 277e3c5a77..e436d769c2 100644 --- a/node-graph/interpreted-executor/src/util.rs +++ b/node-graph/interpreted-executor/src/util.rs @@ -38,7 +38,7 @@ pub fn wrap_network_in_scope(network: NodeNetwork, editor_api: Arc(_: impl Ctx, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> &'a PlatformEditorApi { + editor_api +} + #[node_macro::node(category(""))] -pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> Resource { +pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[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"); @@ -270,6 +275,11 @@ pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope("editor-a } #[node_macro::node(category(""), inject_scope)] -pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor { +pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[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> { + editor_api.application_io.as_ref().unwrap().gpu_executor() +} diff --git a/node-graph/nodes/gstd/src/render_cache.rs b/node-graph/nodes/gstd/src/render_cache.rs index cdf3a310ec..30c3325d20 100644 --- a/node-graph/nodes/gstd/src/render_cache.rs +++ b/node-graph/nodes/gstd/src/render_cache.rs @@ -326,8 +326,8 @@ fn flood_fill(start: &TileCoord, tile_set: &HashSet, visited: &mut Ha #[node_macro::node(category(""))] pub async fn render_output_cache<'a: 'n>( ctx: impl Ctx + ExtractAll + CloneVarArgs + ExtractRealTime + ExtractAnimationTime + ExtractPointerPosition + Sync, - #[scope(crate::platform_application_io::wgpu_executor::IDENTIFIER)] executor: &'a WgpuExecutor, - #[scope("editor-api")] editor_api: &'a PlatformEditorApi, + #[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Option<&'a WgpuExecutor>, + #[scope(crate::platform_application_io::editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi, data: impl Node, Output = RenderOutput> + Send + Sync, #[data] tile_cache: TileCache, ) -> RenderOutput { @@ -404,8 +404,8 @@ pub async fn render_output_cache<'a: 'n>( return data.eval(context.into_context()).await; } + let executor = executor.expect("GPU executor not available"); let output_texture = executor.request_texture(physical_resolution).await; - let combined_metadata = composite_cached_regions(&all_regions, &output_texture, &device_origin_offset, &footprint.transform, &executor); RenderOutput { diff --git a/node-graph/nodes/gstd/src/render_node.rs b/node-graph/nodes/gstd/src/render_node.rs index d9181ef5cd..0c27afcc3f 100644 --- a/node-graph/nodes/gstd/src/render_node.rs +++ b/node-graph/nodes/gstd/src/render_node.rs @@ -75,7 +75,7 @@ async fn render_intermediate<'a: 'n, T: 'static + Render + WasmNotSend + Send + #[node_macro::node(category(""))] async fn render<'a: 'n>( ctx: impl Ctx + ExtractFootprint + ExtractVarArgs, - #[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: RenderIntermediate, ) -> RenderOutput { let footprint = ctx.footprint(); @@ -133,6 +133,7 @@ async fn render<'a: 'n>( } let texture = executor + .expect("GPU executor not available") .render_vello_scene(&transformed_scene, physical_resolution, context, None) .await .expect("Failed to render Vello scene");