mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-24 16:13:44 +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,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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue