mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58:04 +08:00
Restructure GPU execution to model GPU pipelines in the node graph (#1088)
* Start implementing GpuExecutor for wgpu * Implement read_output_buffer function * Implement extraction node in the compiler * Generate type annotations during shader compilation * Start adding node wrapprs for graph execution api * Wrap more of the api in nodes * Restructure Pipeline to accept arbitrary shader inputs * Adapt nodes to new trait definitions * Start implementing gpu-compiler trait * Adapt shader generation * Hardstuck on pointer casts * Pass nodes as references in gpu code to avoid zsts * Update gcore to compile on the gpu * Fix color doc tests * Impl Node for node refs
This commit is contained in:
committed by
Keavon Chambers
parent
161bbc62b4
commit
bdc1ef926a
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
authors = [{% for author in authors %}"{{author}}", {% endfor %}]
|
||||
name = "{{name}}-node"
|
||||
version = "0.1.0"
|
||||
authors = [{%for author in authors%}"{{author}}", {%endfor%}]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
@@ -13,5 +13,7 @@ crate-type = ["dylib", "lib"]
|
||||
libm = { git = "https://github.com/rust-lang/libm", tag = "0.2.5" }
|
||||
|
||||
[dependencies]
|
||||
spirv-std = { version = "0.5" , features= ["glam"]}
|
||||
graphene-core = {path = "{{gcore_path}}", default-features = false, features = ["gpu"]}
|
||||
spirv-std = { version = "0.7" }
|
||||
graphene-core = { path = "{{gcore_path}}", default-features = false, features = [
|
||||
"gpu",
|
||||
] }
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2022-12-18"
|
||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview", "clippy", "cargofmt", "rustc"]
|
||||
channel = "nightly-2023-03-04"
|
||||
components = [
|
||||
"rust-src",
|
||||
"rustc-dev",
|
||||
"llvm-tools-preview",
|
||||
"clippy",
|
||||
"rustfmt",
|
||||
"rustc",
|
||||
]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![no_std]
|
||||
#![feature(unchecked_math)]
|
||||
#![deny(warnings)]
|
||||
|
||||
#[cfg(target_arch = "spirv")]
|
||||
extern crate spirv_std;
|
||||
@@ -14,25 +13,23 @@ pub mod gpu {
|
||||
#[allow(unused)]
|
||||
#[spirv(compute(threads({{compute_threads}})))]
|
||||
pub fn eval (
|
||||
#[spirv(global_invocation_id)] global_id: UVec3,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] a: &[{{input_type}}],
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] y: &mut [{{output_type}}],
|
||||
//#[spirv(push_constant)] push_consts: &graphene_core::gpu::PushConstants,
|
||||
{% for input in inputs %}
|
||||
{{input}}
|
||||
{% endfor %}
|
||||
) {
|
||||
let gid = global_id.x as usize;
|
||||
// Only process up to n, which is the length of the buffers.
|
||||
//if global_id.x < push_consts.n {
|
||||
y[gid] = node_graph(a[gid]);
|
||||
//}
|
||||
}
|
||||
|
||||
fn node_graph(input: {{input_type}}) -> {{output_type}} {
|
||||
use graphene_core::Node;
|
||||
|
||||
{% for input in input_nodes %}
|
||||
let i{{loop.index0}} = graphene_core::value::CopiedNode::new(i{{loop.index0}});
|
||||
let _{{input.id}} = {{input.fqn}}::new({% for arg in input.args %}{{arg}}, {% endfor %});
|
||||
let {{input.id}} = graphene_core::structural::ComposeNode::new(i{{loop.index0}}, _{{input.id}});
|
||||
{% endfor %}
|
||||
|
||||
{% for node in nodes %}
|
||||
let {{node.id}} = {{node.fqn}}::new({% for arg in node.args %}{{arg}}, {% endfor %});
|
||||
{% endfor %}
|
||||
{{last_node}}.eval(input)
|
||||
}
|
||||
let output = {{last_node}}.eval(());
|
||||
// TODO: Write output to buffer
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user