Files
Graphite/node-graph/compilation-client/src/lib.rs
Dennis Kobert 212f08c6c8 Restore functionality of GPU infrastructure (#1797)
* Update gpu nodes to compile again

Restructure `gpu-executor` and `wgpu-executor`

And libssl to nix shell

Fix graphene-cli and add half percision color format

Fix texture scaling

Remove vulkan executor

Fix compile errors

Improve execution request deduplication

* Fix warnings

* Fix graph compile issues

* Code review

* Remove test file

* Fix lint

* Wip make node futures send

* Make futures Send on non wasm targets

* Fix warnings

* Fix nested use of block_on

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2024-07-15 13:14:48 +00:00

27 lines
947 B
Rust

use gpu_compiler_bin_wrapper::CompileRequest;
use graph_craft::{proto::ProtoNetwork, Type};
use wgpu_executor::ShaderIO;
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,
})
}
// 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,
}