Restructure GPU compilation execution pipeline (#903)

* Restructure gpu compilation execution pipeline

* Add compilation server/client infrastructure

* Add wgpu executor
This commit is contained in:
Dennis Kobert
2022-12-31 02:52:04 +01:00
committed by Keavon Chambers
parent 5a4ef40d24
commit a492e7a4bb
43 changed files with 2744 additions and 482 deletions

View File

@@ -0,0 +1,17 @@
[package]
name = "{{name}}-node"
version = "0.1.0"
authors = [{%for author in authors%}"{{author}}", {%endfor%}]
edition = "2021"
license = "MIT OR Apache-2.0"
publish = false
[lib]
crate-type = ["dylib", "lib"]
[patch.crates-io]
libm = { git = "https://github.com/rust-lang/libm", tag = "0.2.5" }
[dependencies]
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu" , features= ["glam"]}
graphene-core = {path = "{{gcore_path}}", default-features = false, features = ["gpu"]}

View File

@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2022-10-29"
components = ["rust-src", "rustc-dev", "llvm-tools-preview", "clippy", "cargofmt", "rustc"]

View File

@@ -0,0 +1,38 @@
#![no_std]
#![feature(unchecked_math)]
#![deny(warnings)]
#[cfg(target_arch = "spirv")]
extern crate spirv_std;
#[cfg(target_arch = "spirv")]
pub mod gpu {
use super::*;
use spirv_std::spirv;
use spirv_std::glam::UVec3;
#[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,
) {
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 node in nodes %}
let {{node.id}} = {{node.fqn}}::new({% for arg in node.args %}{{arg}}, {% endfor %});
{% endfor %}
{{last_node}}.eval(input)
}
}