mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
ICE
This commit is contained in:
parent
edb33e0c82
commit
1e52715d95
13 changed files with 174 additions and 110 deletions
|
@ -4,6 +4,7 @@ use gpu_executor::{GpuExecutor, ShaderIO, ShaderInput};
|
|||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::*;
|
||||
use graph_craft::proto::*;
|
||||
use graphene_core::quantization::{PackedPixel, QuantizationChannels};
|
||||
use graphene_core::raster::*;
|
||||
use graphene_core::*;
|
||||
use wgpu_executor::WgpuExecutor;
|
||||
|
@ -112,15 +113,27 @@ async fn create_compute_pass_descriptor(node: DocumentNode, image: &ImageFrame<C
|
|||
|
||||
log::debug!("inner_network: {:?}", inner_network);
|
||||
let network = NodeNetwork {
|
||||
inputs: vec![], //vec![0, 1],
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
inputs: vec![1, 2], //vec![0, 1],
|
||||
outputs: vec![NodeOutput::new(6, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Slice".into(),
|
||||
inputs: vec![NodeInput::Inline(InlineRust::new("i1[(_global_index.y * i0 + _global_index.x) as usize]".into(), concrete![Color]))],
|
||||
inputs: vec![NodeInput::Inline(InlineRust::new("i2[(_global_index.y * i1 + _global_index.x) as usize]".into(), concrete![Color]))],
|
||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::CopiedNode".into()),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Quantization".into(),
|
||||
inputs: vec![NodeInput::Network(concrete!(quantization::Quantization))],
|
||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::CloneNode".into()),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Width".into(),
|
||||
inputs: vec![NodeInput::Network(concrete!(u32))],
|
||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::ops::IdNode".into()),
|
||||
..Default::default()
|
||||
},
|
||||
/*DocumentNode {
|
||||
name: "Index".into(),
|
||||
//inputs: vec![NodeInput::Network(concrete!(UVec3))],
|
||||
|
@ -135,26 +148,36 @@ async fn create_compute_pass_descriptor(node: DocumentNode, image: &ImageFrame<C
|
|||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::storage::GetNode".into()),
|
||||
..Default::default()
|
||||
},*/
|
||||
DocumentNode {
|
||||
name: "Dequantize".into(),
|
||||
inputs: vec![NodeInput::node(0, 0), NodeInput::node(1, 0)],
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::quantization::DeQuantizeNode"),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "MapNode".into(),
|
||||
inputs: vec![NodeInput::node(0, 0)],
|
||||
inputs: vec![NodeInput::node(3, 0)],
|
||||
implementation: DocumentNodeImplementation::Network(inner_network),
|
||||
..Default::default()
|
||||
},
|
||||
/*
|
||||
DocumentNode {
|
||||
name: "Quantize".into(),
|
||||
inputs: vec![NodeInput::node(4, 0), NodeInput::node(1, 0)],
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::quantization::QuantizeNode"),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "SaveNode".into(),
|
||||
inputs: vec![
|
||||
//NodeInput::node(0, 0),
|
||||
NodeInput::node(5, 0),
|
||||
NodeInput::Inline(InlineRust::new(
|
||||
"o0[_global_index.x as usize] = i0[_global_index.x as usize]".into(),
|
||||
"move |x| o0[(_global_index.y * i1 + _global_index.x) as usize] = x".into(),
|
||||
Type::Fn(Box::new(concrete!(Color)), Box::new(concrete!(()))),
|
||||
)),
|
||||
],
|
||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::value::ValueNode".into()),
|
||||
implementation: DocumentNodeImplementation::Unresolved("graphene_core::generic::FnOnceNode".into()),
|
||||
..Default::default()
|
||||
},
|
||||
*/
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
|
@ -171,12 +194,13 @@ async fn create_compute_pass_descriptor(node: DocumentNode, image: &ImageFrame<C
|
|||
vec![concrete!(Color)],
|
||||
ShaderIO {
|
||||
inputs: vec![
|
||||
ShaderInput::UniformBuffer((), concrete!(quantization::QuantizationChannels)),
|
||||
ShaderInput::UniformBuffer((), concrete!(u32)),
|
||||
ShaderInput::StorageBuffer((), concrete!(Color)),
|
||||
ShaderInput::StorageBuffer((), concrete!(PackedPixel)),
|
||||
//ShaderInput::Constant(gpu_executor::GPUConstant::GlobalInvocationId),
|
||||
ShaderInput::OutputBuffer((), concrete!(Color)),
|
||||
ShaderInput::OutputBuffer((), concrete!(PackedPixel)),
|
||||
],
|
||||
output: ShaderInput::OutputBuffer((), concrete!(Color)),
|
||||
output: ShaderInput::OutputBuffer((), concrete!(PackedPixel)),
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -202,6 +226,7 @@ async fn create_compute_pass_descriptor(node: DocumentNode, image: &ImageFrame<C
|
|||
return frame;*/
|
||||
log::debug!("creating buffer");
|
||||
let width_uniform = executor.create_uniform_buffer(image.image.width).unwrap();
|
||||
let quantization_uniform = executor.create_uniform_buffer(QuantizationChannels::default()).unwrap();
|
||||
let storage_buffer = executor
|
||||
.create_storage_buffer(
|
||||
image.image.data.clone(),
|
||||
|
|
|
@ -7,8 +7,7 @@ use dyn_any::DynAny;
|
|||
pub struct AnyRefNode<'n, N: Node<'n>>(N, PhantomData<&'n ()>);
|
||||
|
||||
impl<'n, N: Node<'n, Output = &'n O>, O: DynAny<'n> + 'n> Node<'n> for AnyRefNode<'n, N> {
|
||||
type Output = &'n (dyn DynAny<'n>);
|
||||
fn eval(&'n self) -> Self::Output {
|
||||
fn eval(&'n self) -> &'n (dyn DynAny<'n>) {
|
||||
let value: &O = self.0.eval();
|
||||
value
|
||||
}
|
||||
|
@ -22,8 +21,7 @@ impl<'n, N: Node<'n, Output = &'n O>, O: 'n + ?Sized> AnyRefNode<'n, N> {
|
|||
pub struct StorageNode<'n>(&'n dyn Node<'n, Output = &'n dyn DynAny<'n>>);
|
||||
|
||||
impl<'n> Node<'n> for StorageNode<'n> {
|
||||
type Output = &'n (dyn DynAny<'n>);
|
||||
fn eval(&'n self) -> Self::Output {
|
||||
fn eval(&'n self) -> &'n (dyn DynAny<'n>) {
|
||||
self.0.eval()
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +34,6 @@ impl<'n> StorageNode<'n> {
|
|||
#[derive(Default)]
|
||||
pub struct AnyValueNode<'n, T>(T, PhantomData<&'n ()>);
|
||||
impl<'n, T: 'n + DynAny<'n>> Node<'n> for AnyValueNode<'n, T> {
|
||||
type Output = &'n dyn DynAny<'n>;
|
||||
fn eval(&'n self) -> &'n dyn DynAny<'n> {
|
||||
&self.0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue