mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-02 12:32:17 +00:00
Clean up imports and warnings in Rust code
This commit is contained in:
parent
b030a1860b
commit
bf1a3e3daf
15 changed files with 204 additions and 191 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
|
||||||
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
|
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
|
||||||
use crate::messages::{input_mapper::utility_types::misc::ActionKeys, portfolio::document::node_graph::FrontendGraphDataType};
|
use crate::messages::portfolio::document::node_graph::FrontendGraphDataType;
|
||||||
|
|
||||||
|
use graphite_proc_macros::WidgetBuilder;
|
||||||
|
|
||||||
use derivative::*;
|
use derivative::*;
|
||||||
use graphite_proc_macros::WidgetBuilder;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Default, Derivative, Serialize, Deserialize, WidgetBuilder)]
|
#[derive(Clone, Default, Derivative, Serialize, Deserialize, WidgetBuilder)]
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
|
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
|
||||||
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
|
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
|
||||||
|
|
||||||
use document_legacy::{color::Color, layers::layer_info::LayerDataTypeDiscriminant, LayerId};
|
use document_legacy::color::Color;
|
||||||
|
use document_legacy::layers::layer_info::LayerDataTypeDiscriminant;
|
||||||
|
use document_legacy::LayerId;
|
||||||
use graphite_proc_macros::WidgetBuilder;
|
use graphite_proc_macros::WidgetBuilder;
|
||||||
|
|
||||||
use derivative::*;
|
use derivative::*;
|
||||||
|
|
|
@ -62,23 +62,23 @@ fn start_widgets(document_node: &DocumentNode, node_id: NodeId, index: usize, na
|
||||||
widgets
|
widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_widget(document_node: &DocumentNode, node_id: NodeId, index: usize, name: &str, blank_assist: bool) -> Vec<WidgetHolder> {
|
// fn text_widget(document_node: &DocumentNode, node_id: NodeId, index: usize, name: &str, blank_assist: bool) -> Vec<WidgetHolder> {
|
||||||
let mut widgets = start_widgets(document_node, node_id, index, name, FrontendGraphDataType::Text, blank_assist);
|
// let mut widgets = start_widgets(document_node, node_id, index, name, FrontendGraphDataType::Text, blank_assist);
|
||||||
|
|
||||||
if let NodeInput::Value {
|
// if let NodeInput::Value {
|
||||||
tagged_value: TaggedValue::String(x),
|
// tagged_value: TaggedValue::String(x),
|
||||||
exposed: false,
|
// exposed: false,
|
||||||
} = &document_node.inputs[index]
|
// } = &document_node.inputs[index]
|
||||||
{
|
// {
|
||||||
widgets.extend_from_slice(&[
|
// widgets.extend_from_slice(&[
|
||||||
WidgetHolder::unrelated_separator(),
|
// WidgetHolder::unrelated_separator(),
|
||||||
TextInput::new(x.clone())
|
// TextInput::new(x.clone())
|
||||||
.on_update(update_value(|x: &TextInput| TaggedValue::String(x.value.clone()), node_id, index))
|
// .on_update(update_value(|x: &TextInput| TaggedValue::String(x.value.clone()), node_id, index))
|
||||||
.widget_holder(),
|
// .widget_holder(),
|
||||||
])
|
// ])
|
||||||
}
|
// }
|
||||||
widgets
|
// widgets
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn text_area_widget(document_node: &DocumentNode, node_id: NodeId, index: usize, name: &str, blank_assist: bool) -> Vec<WidgetHolder> {
|
fn text_area_widget(document_node: &DocumentNode, node_id: NodeId, index: usize, name: &str, blank_assist: bool) -> Vec<WidgetHolder> {
|
||||||
let mut widgets = start_widgets(document_node, node_id, index, name, FrontendGraphDataType::Text, blank_assist);
|
let mut widgets = start_widgets(document_node, node_id, index, name, FrontendGraphDataType::Text, blank_assist);
|
||||||
|
|
|
@ -139,6 +139,7 @@ impl Fsm for NodeGraphToolFsmState {
|
||||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||||
|
|
||||||
use graph_craft::{document::*, generic, proto::*};
|
use graph_craft::{document::*, generic, proto::*};
|
||||||
|
|
||||||
let network = NodeNetwork {
|
let network = NodeNetwork {
|
||||||
inputs: vec![0],
|
inputs: vec![0],
|
||||||
output: 1,
|
output: 1,
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
#![cfg_attr(all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows")]
|
#![cfg_attr(all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use std::sync::Arc;
|
use graphite_editor::application::Editor;
|
||||||
|
use graphite_editor::messages::frontend::utility_types::FrontendImageData;
|
||||||
|
use graphite_editor::messages::prelude::*;
|
||||||
|
|
||||||
use axum::body::StreamBody;
|
use axum::body::StreamBody;
|
||||||
use axum::extract::Path;
|
use axum::extract::Path;
|
||||||
use axum::http;
|
use axum::http;
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::{routing::get, Router};
|
use axum::routing::get;
|
||||||
|
use axum::Router;
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use fern::colors::{Color, ColoredLevelConfig};
|
||||||
use graphite_editor::application::Editor;
|
|
||||||
use graphite_editor::messages::frontend::utility_types::FrontendImageData;
|
|
||||||
use graphite_editor::messages::prelude::*;
|
|
||||||
use http::{Response, StatusCode};
|
use http::{Response, StatusCode};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{consts::MIN_SEPERATION_VALUE, ComputeType};
|
use crate::consts::MIN_SEPERATION_VALUE;
|
||||||
|
use crate::ComputeType;
|
||||||
|
|
||||||
use glam::DVec2;
|
use glam::DVec2;
|
||||||
|
|
||||||
|
|
|
@ -544,8 +544,8 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn window_node() {
|
fn window_node() {
|
||||||
let radius = ValueNode::new(1u32);
|
let radius = ValueNode::new(1u32);
|
||||||
static data: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 25];
|
static DATA: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 25];
|
||||||
let image = ValueNode::<_>::new(ImageSlice { width: 5, height: 5, data });
|
let image = ValueNode::<_>::new(ImageSlice { width: 5, height: 5, data: DATA });
|
||||||
let window = WindowNode::new(radius, image);
|
let window = WindowNode::new(radius, image);
|
||||||
//let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
//let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
||||||
let vec = window.eval(0);
|
let vec = window.eval(0);
|
||||||
|
@ -560,8 +560,8 @@ mod test {
|
||||||
fn blur_node() {
|
fn blur_node() {
|
||||||
let radius = ValueNode::new(1u32);
|
let radius = ValueNode::new(1u32);
|
||||||
let sigma = ValueNode::new(3f64);
|
let sigma = ValueNode::new(3f64);
|
||||||
static data: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 20];
|
static DATA: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 20];
|
||||||
let image = ValueNode::<_>::new(ImageSlice { width: 10, height: 2, data });
|
let image = ValueNode::<_>::new(ImageSlice { width: 10, height: 2, data: DATA });
|
||||||
let window = WindowNode::new(radius, image);
|
let window = WindowNode::new(radius, image);
|
||||||
let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
||||||
let pos_to_dist = MapSndNode::new(DistanceNode);
|
let pos_to_dist = MapSndNode::new(DistanceNode);
|
||||||
|
@ -579,6 +579,6 @@ mod test {
|
||||||
assert_eq!(vec.len(), 10);
|
assert_eq!(vec.len(), 10);
|
||||||
let vec = ComposeNode::new(blur, collect);
|
let vec = ComposeNode::new(blur, collect);
|
||||||
let vec: TypeNode<_, (), Vec<Color>> = TypeNode::new(vec);
|
let vec: TypeNode<_, (), Vec<Color>> = TypeNode::new(vec);
|
||||||
let image = vec.eval(());
|
let _image = vec.eval(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ use std::error::Error;
|
||||||
|
|
||||||
use dyn_any::DynAny;
|
use dyn_any::DynAny;
|
||||||
|
|
||||||
use crate::{document::NodeNetwork, proto::ProtoNetwork};
|
use crate::document::NodeNetwork;
|
||||||
|
use crate::proto::ProtoNetwork;
|
||||||
|
|
||||||
pub struct Compiler {}
|
pub struct Compiler {}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,8 @@ where
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
use graphene_core::{ops::dynamic::Dynamic, AsRefNode};
|
use graphene_core::ops::dynamic::Dynamic;
|
||||||
|
use graphene_core::AsRefNode;
|
||||||
pub struct BoxedComposition<'a, Second> {
|
pub struct BoxedComposition<'a, Second> {
|
||||||
pub first: Box<dyn Node<(), Output = Dynamic<'a>>>,
|
pub first: Box<dyn Node<(), Output = Dynamic<'a>>>,
|
||||||
pub second: Second,
|
pub second: Second,
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
use graph_craft::document::*;
|
||||||
|
use graph_craft::proto::*;
|
||||||
|
use graphene_core::raster::Image;
|
||||||
|
use graphene_core::value::ValueNode;
|
||||||
|
use graphene_core::Node;
|
||||||
|
|
||||||
use bytemuck::Pod;
|
use bytemuck::Pod;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use dyn_any::StaticTypeSized;
|
use dyn_any::StaticTypeSized;
|
||||||
use graph_craft::document::*;
|
|
||||||
use graph_craft::proto::*;
|
|
||||||
use graphene_core::{raster::Image, value::ValueNode, Node};
|
|
||||||
|
|
||||||
pub struct MapGpuNode<NN: Node<()>, I: IntoIterator<Item = S>, S: StaticTypeSized + Sync + Send + Pod, O: StaticTypeSized + Sync + Send + Pod>(pub NN, PhantomData<(S, I, O)>);
|
pub struct MapGpuNode<NN: Node<()>, I: IntoIterator<Item = S>, S: StaticTypeSized + Sync + Send + Pod, O: StaticTypeSized + Sync + Send + Pod>(pub NN, PhantomData<(S, I, O)>);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use dyn_any::{DynAny, StaticType};
|
use dyn_any::{DynAny, StaticType};
|
||||||
use graphene_core::ops::FlatMapResultNode;
|
use graphene_core::generic::FnNode;
|
||||||
|
use graphene_core::ops::{FlatMapResultNode, MapResultNode};
|
||||||
use graphene_core::raster::{Color, Image};
|
use graphene_core::raster::{Color, Image};
|
||||||
use graphene_core::structural::{ComposeNode, ConsNode};
|
use graphene_core::structural::{ComposeNode, ConsNode, Then};
|
||||||
use graphene_core::{generic::FnNode, ops::MapResultNode, structural::Then, value::ValueNode, Node};
|
use graphene_core::value::ValueNode;
|
||||||
|
use graphene_core::Node;
|
||||||
use image::Pixel;
|
use image::Pixel;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use std::error::Error;
|
use crate::node_registry::push_node;
|
||||||
|
|
||||||
use borrow_stack::{BorrowStack, FixedSizeStack};
|
use borrow_stack::{BorrowStack, FixedSizeStack};
|
||||||
|
use graph_craft::executor::Executor;
|
||||||
|
use graph_craft::proto::ProtoNetwork;
|
||||||
use graphene_core::Node;
|
use graphene_core::Node;
|
||||||
use graphene_std::any::{Any, TypeErasedNode};
|
use graphene_std::any::{Any, TypeErasedNode};
|
||||||
|
|
||||||
use crate::node_registry::push_node;
|
use std::error::Error;
|
||||||
use graph_craft::{executor::Executor, proto::ProtoNetwork};
|
|
||||||
|
|
||||||
pub struct DynamicExecutor {
|
pub struct DynamicExecutor {
|
||||||
stack: FixedSizeStack<TypeErasedNode<'static>>,
|
stack: FixedSizeStack<TypeErasedNode<'static>>,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use glam::DVec2;
|
||||||
use graphene_core::generic::FnNode;
|
use graphene_core::generic::FnNode;
|
||||||
use graphene_core::ops::{AddNode, CloneNode, IdNode, TypeNode};
|
use graphene_core::ops::{AddNode, CloneNode, IdNode, TypeNode};
|
||||||
use graphene_core::raster::color::Color;
|
use graphene_core::raster::color::Color;
|
||||||
use graphene_core::raster::{Image, MapFnIterator};
|
use graphene_core::raster::Image;
|
||||||
use graphene_core::structural::{ComposeNode, ConsNode, Then};
|
use graphene_core::structural::{ComposeNode, ConsNode, Then};
|
||||||
use graphene_core::value::ValueNode;
|
use graphene_core::value::ValueNode;
|
||||||
use graphene_core::vector::subpath::Subpath;
|
use graphene_core::vector::subpath::Subpath;
|
||||||
|
@ -483,7 +483,7 @@ static NODE_REGISTRY: &[(NodeIdentifier, NodeConstructor)] = &[
|
||||||
(NodeIdentifier::new("graphene_std::memo::CacheNode", &[concrete!("Image")]), |proto_node, stack| {
|
(NodeIdentifier::new("graphene_std::memo::CacheNode", &[concrete!("Image")]), |proto_node, stack| {
|
||||||
let node_id = proto_node.input.unwrap_node() as usize;
|
let node_id = proto_node.input.unwrap_node() as usize;
|
||||||
use graphene_core::raster::*;
|
use graphene_core::raster::*;
|
||||||
if let ConstructionArgs::Nodes(image_args) = proto_node.construction_args {
|
if let ConstructionArgs::Nodes(_image_args) = proto_node.construction_args {
|
||||||
stack.push_fn(move |nodes| {
|
stack.push_fn(move |nodes| {
|
||||||
let image = nodes.get(node_id).unwrap();
|
let image = nodes.get(node_id).unwrap();
|
||||||
let node: DynAnyNode<_, Image, Image, &Image> = DynAnyNode::new(CacheNode::new());
|
let node: DynAnyNode<_, Image, Image, &Image> = DynAnyNode::new(CacheNode::new());
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use super::context::Context;
|
use super::context::Context;
|
||||||
|
|
||||||
|
use graph_craft::executor::{Any, Executor};
|
||||||
|
|
||||||
|
use graphene_core::gpu::PushConstants;
|
||||||
|
|
||||||
use bytemuck::Pod;
|
use bytemuck::Pod;
|
||||||
use dyn_any::StaticTypeSized;
|
use dyn_any::StaticTypeSized;
|
||||||
use graph_craft::executor::{Any, Executor};
|
use vulkano::buffer::{self, BufferUsage, CpuAccessibleBuffer};
|
||||||
use vulkano::{
|
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
|
||||||
buffer::{self, BufferUsage, CpuAccessibleBuffer},
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
|
||||||
command_buffer::{allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage},
|
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||||
descriptor_set::{allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet},
|
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||||
device::Device,
|
use vulkano::device::Device;
|
||||||
memory::allocator::StandardMemoryAllocator,
|
use vulkano::memory::allocator::StandardMemoryAllocator;
|
||||||
pipeline::{ComputePipeline, Pipeline, PipelineBindPoint},
|
use vulkano::pipeline::{ComputePipeline, Pipeline, PipelineBindPoint};
|
||||||
sync::GpuFuture,
|
use vulkano::sync::GpuFuture;
|
||||||
};
|
|
||||||
|
|
||||||
use graph_craft::proto::*;
|
|
||||||
use graphene_core::gpu::PushConstants;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GpuExecutor<I: StaticTypeSized, O> {
|
pub struct GpuExecutor<I: StaticTypeSized, O> {
|
||||||
|
@ -111,73 +110,72 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
|
||||||
buffer::CpuAccessibleBuffer::from_iter(alloc, buffer_usage, false, data.into_iter())
|
buffer::CpuAccessibleBuffer::from_iter(alloc, buffer_usage, false, data.into_iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
// TODO: Fix this test
|
||||||
mod test {
|
// #[cfg(test)]
|
||||||
use super::*;
|
// mod test {
|
||||||
use graph_craft::concrete;
|
// use graph_craft::proto::{ConstructionArgs, NodeIdentifier, ProtoNetwork, ProtoNode, ProtoNodeInput, Type};
|
||||||
use graph_craft::generic;
|
// use graph_craft::{concrete, generic};
|
||||||
|
|
||||||
fn inc_network() -> ProtoNetwork {
|
// fn inc_network() -> ProtoNetwork {
|
||||||
let mut construction_network = ProtoNetwork {
|
// let mut construction_network = ProtoNetwork {
|
||||||
inputs: vec![10],
|
// inputs: vec![10],
|
||||||
output: 1,
|
// output: 1,
|
||||||
nodes: [
|
// nodes: [
|
||||||
(
|
// (
|
||||||
1,
|
// 1,
|
||||||
ProtoNode {
|
// ProtoNode {
|
||||||
identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
|
// identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
|
||||||
input: ProtoNodeInput::Node(11),
|
// input: ProtoNodeInput::Node(11),
|
||||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
// construction_args: ConstructionArgs::Nodes(vec![]),
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
(
|
// (
|
||||||
10,
|
// 10,
|
||||||
ProtoNode {
|
// ProtoNode {
|
||||||
identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
|
// identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
|
||||||
input: ProtoNodeInput::Network,
|
// input: ProtoNodeInput::Network,
|
||||||
construction_args: ConstructionArgs::Nodes(vec![14]),
|
// construction_args: ConstructionArgs::Nodes(vec![14]),
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
(
|
// (
|
||||||
11,
|
// 11,
|
||||||
ProtoNode {
|
// ProtoNode {
|
||||||
identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
|
// identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
|
||||||
input: ProtoNodeInput::Node(10),
|
// input: ProtoNodeInput::Node(10),
|
||||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
// construction_args: ConstructionArgs::Nodes(vec![]),
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
(
|
// (
|
||||||
14,
|
// 14,
|
||||||
ProtoNode {
|
// ProtoNode {
|
||||||
identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
|
// identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
|
||||||
input: ProtoNodeInput::None,
|
// input: ProtoNodeInput::None,
|
||||||
construction_args: ConstructionArgs::Value(Box::new(3_u32)),
|
// construction_args: ConstructionArgs::Value(Box::new(3_u32)),
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
]
|
// ]
|
||||||
.into_iter()
|
// .into_iter()
|
||||||
.collect(),
|
// .collect(),
|
||||||
};
|
// };
|
||||||
construction_network.resolve_inputs();
|
// construction_network.resolve_inputs();
|
||||||
construction_network.reorder_ids();
|
// construction_network.reorder_ids();
|
||||||
construction_network
|
// construction_network
|
||||||
}
|
// }
|
||||||
|
|
||||||
// TODO: Fix this test
|
// #[test]
|
||||||
/*#[test]
|
// fn add_on_gpu() {
|
||||||
fn add_on_gpu() {
|
// use crate::executor::Executor;
|
||||||
use crate::executor::Executor;
|
// let m = compiler::Metadata::new("project".to_owned(), vec!["test@example.com".to_owned()]);
|
||||||
let m = compiler::Metadata::new("project".to_owned(), vec!["test@example.com".to_owned()]);
|
// let network = inc_network();
|
||||||
let network = inc_network();
|
// let temp_dir = tempfile::tempdir().expect("failed to create tempdir");
|
||||||
let temp_dir = tempfile::tempdir().expect("failed to create tempdir");
|
|
||||||
|
|
||||||
let executor: GpuExecutor<u32, u32> = GpuExecutor::new(Context::new(), network, m, temp_dir.path()).unwrap();
|
// let executor: GpuExecutor<u32, u32> = GpuExecutor::new(Context::new(), network, m, temp_dir.path()).unwrap();
|
||||||
|
|
||||||
let data: Vec<_> = (0..1024).map(|x| x as u32).collect();
|
// let data: Vec<_> = (0..1024).map(|x| x as u32).collect();
|
||||||
let result = executor.execute(Box::new(data)).unwrap();
|
// let result = executor.execute(Box::new(data)).unwrap();
|
||||||
let result = dyn_any::downcast::<Vec<u32>>(result).unwrap();
|
// let result = dyn_any::downcast::<Vec<u32>>(result).unwrap();
|
||||||
for (i, r) in result.iter().enumerate() {
|
// for (i, r) in result.iter().enumerate() {
|
||||||
assert_eq!(*r, i as u32 + 3);
|
// assert_eq!(*r, i as u32 + 3);
|
||||||
}
|
// }
|
||||||
}*/
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -170,74 +170,74 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
// TODO: Fix this test
|
||||||
mod test {
|
// #[cfg(test)]
|
||||||
use super::*;
|
// mod test {
|
||||||
use graph_craft::concrete;
|
// use super::*;
|
||||||
use graph_craft::generic;
|
// use graph_craft::concrete;
|
||||||
use graph_craft::proto::*;
|
// use graph_craft::generic;
|
||||||
|
// use graph_craft::proto::*;
|
||||||
|
|
||||||
fn inc_network() -> ProtoNetwork {
|
// #[test]
|
||||||
let mut construction_network = ProtoNetwork {
|
// fn add_on_gpu() {
|
||||||
inputs: vec![10],
|
// use crate::executor::Executor;
|
||||||
output: 1,
|
// let m = compiler::Metadata::new("project".to_owned(), vec!["test@example.com".to_owned()]);
|
||||||
nodes: [
|
// let network = inc_network();
|
||||||
(
|
// let temp_dir = tempfile::tempdir().expect("failed to create tempdir");
|
||||||
1,
|
|
||||||
ProtoNode {
|
|
||||||
identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
|
|
||||||
input: ProtoNodeInput::Node(11),
|
|
||||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
10,
|
|
||||||
ProtoNode {
|
|
||||||
identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
|
|
||||||
input: ProtoNodeInput::Network,
|
|
||||||
construction_args: ConstructionArgs::Nodes(vec![14]),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
11,
|
|
||||||
ProtoNode {
|
|
||||||
identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
|
|
||||||
input: ProtoNodeInput::Node(10),
|
|
||||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
14,
|
|
||||||
ProtoNode {
|
|
||||||
identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
|
|
||||||
input: ProtoNodeInput::None,
|
|
||||||
construction_args: ConstructionArgs::Value(Box::new(3_u32)),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.collect(),
|
|
||||||
};
|
|
||||||
construction_network.resolve_inputs();
|
|
||||||
construction_network.reorder_ids();
|
|
||||||
construction_network
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Fix this test
|
// let executor: GpuExecutor<u32, u32> = GpuExecutor::new(Context::new(), network, m, temp_dir.path()).unwrap();
|
||||||
/*#[test]
|
|
||||||
fn add_on_gpu() {
|
|
||||||
use crate::executor::Executor;
|
|
||||||
let m = compiler::Metadata::new("project".to_owned(), vec!["test@example.com".to_owned()]);
|
|
||||||
let network = inc_network();
|
|
||||||
let temp_dir = tempfile::tempdir().expect("failed to create tempdir");
|
|
||||||
|
|
||||||
let executor: GpuExecutor<u32, u32> = GpuExecutor::new(Context::new(), network, m, temp_dir.path()).unwrap();
|
// let data: Vec<_> = (0..1024).map(|x| x as u32).collect();
|
||||||
|
// let result = executor.execute(Box::new(data)).unwrap();
|
||||||
|
// let result = dyn_any::downcast::<Vec<u32>>(result).unwrap();
|
||||||
|
// for (i, r) in result.iter().enumerate() {
|
||||||
|
// assert_eq!(*r, i as u32 + 3);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
let data: Vec<_> = (0..1024).map(|x| x as u32).collect();
|
// fn inc_network() -> ProtoNetwork {
|
||||||
let result = executor.execute(Box::new(data)).unwrap();
|
// let mut construction_network = ProtoNetwork {
|
||||||
let result = dyn_any::downcast::<Vec<u32>>(result).unwrap();
|
// inputs: vec![10],
|
||||||
for (i, r) in result.iter().enumerate() {
|
// output: 1,
|
||||||
assert_eq!(*r, i as u32 + 3);
|
// nodes: [
|
||||||
}
|
// (
|
||||||
}*/
|
// 1,
|
||||||
}
|
// ProtoNode {
|
||||||
|
// identifier: NodeIdentifier::new("graphene_core::ops::IdNode", &[generic!("u32")]),
|
||||||
|
// input: ProtoNodeInput::Node(11),
|
||||||
|
// construction_args: ConstructionArgs::Nodes(vec![]),
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// (
|
||||||
|
// 10,
|
||||||
|
// ProtoNode {
|
||||||
|
// identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
|
||||||
|
// input: ProtoNodeInput::Network,
|
||||||
|
// construction_args: ConstructionArgs::Nodes(vec![14]),
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// (
|
||||||
|
// 11,
|
||||||
|
// ProtoNode {
|
||||||
|
// identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[generic!("u32"), generic!("u32")]),
|
||||||
|
// input: ProtoNodeInput::Node(10),
|
||||||
|
// construction_args: ConstructionArgs::Nodes(vec![]),
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// (
|
||||||
|
// 14,
|
||||||
|
// ProtoNode {
|
||||||
|
// identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
|
||||||
|
// input: ProtoNodeInput::None,
|
||||||
|
// construction_args: ConstructionArgs::Value(Box::new(3_u32)),
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ]
|
||||||
|
// .into_iter()
|
||||||
|
// .collect(),
|
||||||
|
// };
|
||||||
|
// construction_network.resolve_inputs();
|
||||||
|
// construction_network.reorder_ids();
|
||||||
|
// construction_network
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue