Skip to content

Commit bf26734

Browse files
committed
gpu invert node demo
1 parent eb8605a commit bf26734

File tree

12 files changed

+1531
-26
lines changed

12 files changed

+1531
-26
lines changed

Cargo.lock

Lines changed: 384 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"frontend/wasm",
66
"frontend/src-tauri",
77
"node-graph/gcore",
8+
"node-graph/gcore-shader",
89
"node-graph/gstd",
910
"node-graph/graph-craft",
1011
"node-graph/graphene-cli",
@@ -69,7 +70,7 @@ axum = "0.8"
6970
chrono = "0.4"
7071
ron = "0.8"
7172
fastnoise-lite = "1.1"
72-
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu.git" }
73+
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "9a357691334b9cdd13c82a740ced97c5d857bf4d" }
7374
wgpu-types = "23"
7475
wgpu = "23"
7576
once_cell = "1.13" # Remove when `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>) is stabilized in Rust 1.80 and we bump our MSRV
@@ -108,6 +109,7 @@ kurbo = { version = "0.11.0", features = ["serde"] }
108109
petgraph = { version = "0.7.1", default-features = false, features = [
109110
"graphmap",
110111
] }
112+
cargo-gpu = { git = "https://github.com/rust-gpu/cargo-gpu", rev = "7f5358bf3bac7363c8017409942464365ca61fd8", features = ["wgsl-out"] }
111113

112114
[profile.dev]
113115
opt-level = 1

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use graph_craft::ProtoNodeIdentifier;
1414
use graph_craft::concrete;
1515
use graph_craft::document::value::*;
1616
use graph_craft::document::*;
17+
use graphene_core::application_io::TextureFrameTable;
1718
use graphene_core::raster::brush_cache::BrushCache;
1819
use graphene_core::raster::image::ImageFrameTable;
1920
use graphene_core::raster::{CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, NoiseType, RedGreenBlueAlpha};
@@ -1850,6 +1851,91 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
18501851
description: Cow::Borrowed("TODO"),
18511852
properties: None,
18521853
},
1854+
#[cfg(feature = "gpu")]
1855+
DocumentNodeDefinition {
1856+
identifier: "GPU Invert",
1857+
category: "Debug: GPU",
1858+
node_template: NodeTemplate {
1859+
document_node: DocumentNode {
1860+
implementation: DocumentNodeImplementation::Network(NodeNetwork {
1861+
exports: vec![NodeInput::node(NodeId(2), 0)],
1862+
nodes: [
1863+
DocumentNode {
1864+
inputs: vec![NodeInput::scope("editor-api")],
1865+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::IntoNode<&WgpuExecutor>")),
1866+
..Default::default()
1867+
},
1868+
DocumentNode {
1869+
inputs: vec![NodeInput::network(concrete!(TextureFrameTable), 0), NodeInput::node(NodeId(0), 0)],
1870+
manual_composition: Some(generic!(T)),
1871+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::gcore_shader_nodes::GpuInvertNode")),
1872+
..Default::default()
1873+
},
1874+
DocumentNode {
1875+
manual_composition: Some(generic!(T)),
1876+
inputs: vec![NodeInput::node(NodeId(1), 0)],
1877+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::ImpureMemoNode")),
1878+
..Default::default()
1879+
},
1880+
]
1881+
.into_iter()
1882+
.enumerate()
1883+
.map(|(id, node)| (NodeId(id as u64), node))
1884+
.collect(),
1885+
..Default::default()
1886+
}),
1887+
// experimentally determined to work
1888+
inputs: vec![NodeInput::value(TaggedValue::None, true)],
1889+
// inputs: vec![NodeInput::value(TaggedValue::TextureFrame(TextureFrameTable::default()), true)],
1890+
// inputs: vec![],
1891+
// inputs: vec![NodeInput::network(concrete!(TextureFrameTable), 0)],
1892+
..Default::default()
1893+
},
1894+
persistent_node_metadata: DocumentNodePersistentMetadata {
1895+
input_properties: vec![("In", "TODO").into()],
1896+
output_names: vec!["Texture".to_string()],
1897+
network_metadata: Some(NodeNetworkMetadata {
1898+
persistent_metadata: NodeNetworkPersistentMetadata {
1899+
node_metadata: [
1900+
DocumentNodeMetadata {
1901+
persistent_metadata: DocumentNodePersistentMetadata {
1902+
display_name: "Extract Executor".to_string(),
1903+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
1904+
..Default::default()
1905+
},
1906+
..Default::default()
1907+
},
1908+
DocumentNodeMetadata {
1909+
persistent_metadata: DocumentNodePersistentMetadata {
1910+
display_name: "Upload Texture".to_string(),
1911+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(7, 0)),
1912+
..Default::default()
1913+
},
1914+
..Default::default()
1915+
},
1916+
DocumentNodeMetadata {
1917+
persistent_metadata: DocumentNodePersistentMetadata {
1918+
display_name: "Cache".to_string(),
1919+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(14, 0)),
1920+
..Default::default()
1921+
},
1922+
..Default::default()
1923+
},
1924+
]
1925+
.into_iter()
1926+
.enumerate()
1927+
.map(|(id, node)| (NodeId(id as u64), node))
1928+
.collect(),
1929+
..Default::default()
1930+
},
1931+
..Default::default()
1932+
}),
1933+
..Default::default()
1934+
},
1935+
},
1936+
description: Cow::Borrowed("TODO"),
1937+
properties: None,
1938+
},
18531939
DocumentNodeDefinition {
18541940
identifier: "Extract",
18551941
category: "Debug",

node-graph/gcore-shader/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "graphene-core-shader"
3+
version = "0.1.0"
4+
edition = "2024"
5+
description = "Graphene nodes compiled to shaders"
6+
authors = ["Graphite Authors <[email protected]>"]
7+
license = "MIT OR Apache-2.0"
8+
9+
[lib]
10+
crate-type = ["rlib", "cdylib"]
11+
12+
[features]
13+
gpu = ["glam/libm"]
14+
15+
[dependencies]
16+
# Workspace dependencies
17+
spirv-std = { workspace = true }
18+
bytemuck = { workspace = true }
19+
glam = { workspace = true, features = [
20+
"scalar-math", "bytemuck"
21+
] }
22+
23+
[lints.rust]
24+
# the spirv target is not in the list of common cfgs so must be added manually
25+
unexpected_cfgs = { level = "warn", check-cfg = [
26+
'cfg(target_arch, values("spirv"))',
27+
] }

0 commit comments

Comments
 (0)