mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
* Web gpu execution MVP Ready infrastructure for wgpu experimentation Start implementing simple gpu test case Fix Extract Node not working with nested networks Convert inputs for extracted node to network inputs Fix missing cors headers Feature gate gcore to make it once again no-std compatible Add skeleton structure gpu shader Work on gpu node graph output saving Fix Get and Set nodes Fix storage nodes Fix shader construction errors -> spirv errors Add unsafe version Add once cell node Web gpu execution MVP
31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
use gpu_compiler_bin_wrapper::CompileRequest;
|
|
use gpu_executor::ShaderIO;
|
|
use graph_craft::{proto::ProtoNetwork, Type};
|
|
|
|
pub async fn compile(networks: Vec<ProtoNetwork>, inputs: Vec<Type>, outputs: Vec<Type>, io: ShaderIO) -> Result<Shader, reqwest::Error> {
|
|
let client = reqwest::Client::new();
|
|
|
|
let compile_request = CompileRequest::new(networks, inputs.clone(), outputs.clone(), io.clone());
|
|
let response = client.post("http://localhost:3000/compile/spirv").json(&compile_request).send();
|
|
let response = response.await?;
|
|
response.bytes().await.map(|b| Shader {
|
|
spirv_binary: b.chunks(4).map(|x| u32::from_le_bytes(x.try_into().unwrap())).collect(),
|
|
input_types: inputs,
|
|
output_types: outputs,
|
|
io,
|
|
})
|
|
}
|
|
|
|
pub fn compile_sync(networks: Vec<ProtoNetwork>, inputs: Vec<Type>, outputs: Vec<Type>, io: ShaderIO) -> Result<Shader, reqwest::Error> {
|
|
future_executor::block_on(compile(networks, inputs, outputs, io))
|
|
}
|
|
|
|
// TODO: should we add the entry point as a field?
|
|
/// A compiled shader with type annotations.
|
|
pub struct Shader {
|
|
pub spirv_binary: Vec<u32>,
|
|
pub input_types: Vec<Type>,
|
|
pub output_types: Vec<Type>,
|
|
pub io: ShaderIO,
|
|
}
|