Implement node graph gpu execution via vulkano and rust gpu (#870)

* Add Executor abstraction

* Resolve inputs for proto nodes by adding compose nodes

* Add infrastructure for compiling gpu code

* Integrate nodegraph gpu execution into graph-crafter

* Extract graphene core path from env vars

* Make Color struct usable for gpu code
This commit is contained in:
TrueDoctor
2022-12-05 12:56:36 +01:00
committed by Keavon Chambers
parent 33d5db76c0
commit 57a1f653e1
26 changed files with 2140 additions and 620 deletions
+13 -15
View File
@@ -6,6 +6,11 @@ pub mod node_registry;
pub mod document;
pub mod proto;
pub mod executor;
#[cfg(feature = "gpu")]
pub mod gpu;
#[cfg(test)]
mod tests {
@@ -15,7 +20,6 @@ mod tests {
use graphene_core::{structural::*, RefNode};
use borrow_stack::BorrowStack;
use borrow_stack::FixedSizeStack;
use dyn_any::{downcast, IntoDynAny};
use graphene_std::any::{Any, DowncastNode, DynAnyNode, TypeErasedNode};
use graphene_std::ops::AddNode;
@@ -56,9 +60,7 @@ mod tests {
#[test]
fn execute_add() {
use crate::document::*;
use crate::node_registry::push_node;
use crate::proto::*;
use graphene_core::Node;
fn add_network() -> NodeNetwork {
NodeNetwork {
@@ -95,7 +97,7 @@ mod tests {
}
}
let mut network = NodeNetwork {
let network = NodeNetwork {
inputs: vec![0],
output: 0,
nodes: [(
@@ -117,18 +119,14 @@ mod tests {
.collect(),
};
let stack = FixedSizeStack::new(256);
println!("flattening");
network.flatten(0);
//println!("flat_network: {:#?}", network);
let mut proto_network = network.into_proto_network();
proto_network.reorder_ids();
//println!("reordered_ides: {:#?}", proto_network);
for (_id, node) in proto_network.nodes {
push_node(node, &stack);
}
use crate::executor::{Compiler, DynamicExecutor, Executor};
let result = unsafe { stack.get().last().unwrap().eval(32_u32.into_dyn()) };
let compiler = Compiler {};
let protograph = compiler.compile(network, false);
let exec = DynamicExecutor::new(protograph);
let result = exec.execute(32_u32.into_dyn()).unwrap();
let val = *dyn_any::downcast::<u32>(result).unwrap();
assert_eq!(val, 33_u32);
}