@@ -8,6 +8,7 @@ use graphene_std::Context;
88use graphene_std:: ContextFeatures ;
99use graphene_std:: uuid:: NodeId ;
1010use std:: sync:: Arc ;
11+ use wgpu_executor:: WgpuExecutor ;
1112
1213pub fn wrap_network_in_scope ( mut network : NodeNetwork , editor_api : Arc < WasmEditorApi > ) -> NodeNetwork {
1314 network. generate_node_paths ( & [ ] ) ;
@@ -68,7 +69,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<WasmEdito
6869 } ;
6970
7071 // wrap the inner network in a scope
71- let nodes = vec ! [
72+ let mut nodes = vec ! [
7273 inner_network,
7374 render_node,
7475 DocumentNode {
@@ -77,11 +78,21 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<WasmEdito
7778 ..Default :: default ( )
7879 } ,
7980 ] ;
81+ let mut scope_injections = vec ! [ ( "editor-api" . to_string( ) , ( NodeId ( 2 ) , concrete!( & WasmEditorApi ) ) ) ] ;
82+
83+ if cfg ! ( feature = "gpu" ) {
84+ nodes. push ( DocumentNode {
85+ implementation : DocumentNodeImplementation :: ProtoNode ( ProtoNodeIdentifier :: from ( "graphene_core::ops::IntoNode<&WgpuExecutor>" ) ) ,
86+ inputs : vec ! [ NodeInput :: node( NodeId ( 2 ) , 0 ) ] ,
87+ ..Default :: default ( )
88+ } ) ;
89+ scope_injections. push ( ( "wgpu-executor" . to_string ( ) , ( NodeId ( 3 ) , concrete ! ( & WgpuExecutor ) ) ) ) ;
90+ }
8091
8192 NodeNetwork {
8293 exports : vec ! [ NodeInput :: node( NodeId ( 1 ) , 0 ) ] ,
8394 nodes : nodes. into_iter ( ) . enumerate ( ) . map ( |( id, node) | ( NodeId ( id as u64 ) , node) ) . collect ( ) ,
84- scope_injections : [ ( "editor-api" . to_string ( ) , ( NodeId ( 2 ) , concrete ! ( & WasmEditorApi ) ) ) ] . into_iter ( ) . collect ( ) ,
95+ scope_injections : scope_injections . into_iter ( ) . collect ( ) ,
8596 // TODO(TrueDoctor): check if it makes sense to set `generated` to `true`
8697 generated : false ,
8798 }
0 commit comments