mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Clean up imports and warnings in Rust code
This commit is contained in:
@@ -544,8 +544,8 @@ mod test {
|
||||
#[test]
|
||||
fn window_node() {
|
||||
let radius = ValueNode::new(1u32);
|
||||
static data: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 25];
|
||||
let image = ValueNode::<_>::new(ImageSlice { width: 5, height: 5, data });
|
||||
static DATA: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 25];
|
||||
let image = ValueNode::<_>::new(ImageSlice { width: 5, height: 5, data: DATA });
|
||||
let window = WindowNode::new(radius, image);
|
||||
//let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
||||
let vec = window.eval(0);
|
||||
@@ -560,8 +560,8 @@ mod test {
|
||||
fn blur_node() {
|
||||
let radius = ValueNode::new(1u32);
|
||||
let sigma = ValueNode::new(3f64);
|
||||
static data: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 20];
|
||||
let image = ValueNode::<_>::new(ImageSlice { width: 10, height: 2, data });
|
||||
static DATA: &[Color] = &[Color::from_rgbf32_unchecked(1., 0., 0.); 20];
|
||||
let image = ValueNode::<_>::new(ImageSlice { width: 10, height: 2, data: DATA });
|
||||
let window = WindowNode::new(radius, image);
|
||||
let window: TypeNode<_, u32, ImageWindowIterator<'static>> = TypeNode::new(window);
|
||||
let pos_to_dist = MapSndNode::new(DistanceNode);
|
||||
@@ -579,6 +579,6 @@ mod test {
|
||||
assert_eq!(vec.len(), 10);
|
||||
let vec = ComposeNode::new(blur, collect);
|
||||
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 crate::{document::NodeNetwork, proto::ProtoNetwork};
|
||||
use crate::document::NodeNetwork;
|
||||
use crate::proto::ProtoNetwork;
|
||||
|
||||
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 first: Box<dyn Node<(), Output = Dynamic<'a>>>,
|
||||
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 core::marker::PhantomData;
|
||||
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)>);
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use core::marker::PhantomData;
|
||||
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::structural::{ComposeNode, ConsNode};
|
||||
use graphene_core::{generic::FnNode, ops::MapResultNode, structural::Then, value::ValueNode, Node};
|
||||
use graphene_core::structural::{ComposeNode, ConsNode, Then};
|
||||
use graphene_core::value::ValueNode;
|
||||
use graphene_core::Node;
|
||||
use image::Pixel;
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use std::error::Error;
|
||||
use crate::node_registry::push_node;
|
||||
|
||||
use borrow_stack::{BorrowStack, FixedSizeStack};
|
||||
use graph_craft::executor::Executor;
|
||||
use graph_craft::proto::ProtoNetwork;
|
||||
use graphene_core::Node;
|
||||
use graphene_std::any::{Any, TypeErasedNode};
|
||||
|
||||
use crate::node_registry::push_node;
|
||||
use graph_craft::{executor::Executor, proto::ProtoNetwork};
|
||||
use std::error::Error;
|
||||
|
||||
pub struct DynamicExecutor {
|
||||
stack: FixedSizeStack<TypeErasedNode<'static>>,
|
||||
|
||||
@@ -3,7 +3,7 @@ use glam::DVec2;
|
||||
use graphene_core::generic::FnNode;
|
||||
use graphene_core::ops::{AddNode, CloneNode, IdNode, TypeNode};
|
||||
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::value::ValueNode;
|
||||
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| {
|
||||
let node_id = proto_node.input.unwrap_node() as usize;
|
||||
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| {
|
||||
let image = nodes.get(node_id).unwrap();
|
||||
let node: DynAnyNode<_, Image, Image, &Image> = DynAnyNode::new(CacheNode::new());
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
use std::path::Path;
|
||||
|
||||
use super::context::Context;
|
||||
|
||||
use graph_craft::executor::{Any, Executor};
|
||||
|
||||
use graphene_core::gpu::PushConstants;
|
||||
|
||||
use bytemuck::Pod;
|
||||
use dyn_any::StaticTypeSized;
|
||||
use graph_craft::executor::{Any, Executor};
|
||||
use vulkano::{
|
||||
buffer::{self, BufferUsage, CpuAccessibleBuffer},
|
||||
command_buffer::{allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage},
|
||||
descriptor_set::{allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet},
|
||||
device::Device,
|
||||
memory::allocator::StandardMemoryAllocator,
|
||||
pipeline::{ComputePipeline, Pipeline, PipelineBindPoint},
|
||||
sync::GpuFuture,
|
||||
};
|
||||
|
||||
use graph_craft::proto::*;
|
||||
use graphene_core::gpu::PushConstants;
|
||||
use vulkano::buffer::{self, BufferUsage, CpuAccessibleBuffer};
|
||||
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
|
||||
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||
use vulkano::device::Device;
|
||||
use vulkano::memory::allocator::StandardMemoryAllocator;
|
||||
use vulkano::pipeline::{ComputePipeline, Pipeline, PipelineBindPoint};
|
||||
use vulkano::sync::GpuFuture;
|
||||
|
||||
#[derive(Debug)]
|
||||
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())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use graph_craft::concrete;
|
||||
use graph_craft::generic;
|
||||
// TODO: Fix this test
|
||||
// #[cfg(test)]
|
||||
// mod test {
|
||||
// use graph_craft::proto::{ConstructionArgs, NodeIdentifier, ProtoNetwork, ProtoNode, ProtoNodeInput, Type};
|
||||
// use graph_craft::{concrete, generic};
|
||||
|
||||
fn inc_network() -> ProtoNetwork {
|
||||
let mut construction_network = ProtoNetwork {
|
||||
inputs: vec![10],
|
||||
output: 1,
|
||||
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
|
||||
}
|
||||
// fn inc_network() -> ProtoNetwork {
|
||||
// let mut construction_network = ProtoNetwork {
|
||||
// inputs: vec![10],
|
||||
// output: 1,
|
||||
// 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
|
||||
// }
|
||||
|
||||
// TODO: Fix this test
|
||||
/*#[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");
|
||||
// #[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 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();
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -170,74 +170,74 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use graph_craft::concrete;
|
||||
use graph_craft::generic;
|
||||
use graph_craft::proto::*;
|
||||
// TODO: Fix this test
|
||||
// #[cfg(test)]
|
||||
// mod test {
|
||||
// use super::*;
|
||||
// use graph_craft::concrete;
|
||||
// use graph_craft::generic;
|
||||
// use graph_craft::proto::*;
|
||||
|
||||
fn inc_network() -> ProtoNetwork {
|
||||
let mut construction_network = ProtoNetwork {
|
||||
inputs: vec![10],
|
||||
output: 1,
|
||||
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
|
||||
}
|
||||
// #[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");
|
||||
|
||||
// TODO: Fix this test
|
||||
/*#[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 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();
|
||||
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);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
// fn inc_network() -> ProtoNetwork {
|
||||
// let mut construction_network = ProtoNetwork {
|
||||
// inputs: vec![10],
|
||||
// output: 1,
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user