mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Restructure GPU compilation execution pipeline (#903)
* Restructure gpu compilation execution pipeline * Add compilation server/client infrastructure * Add wgpu executor
This commit is contained in:
committed by
Keavon Chambers
parent
be32f7949f
commit
79ad3e7908
18
node-graph/compilation-server/Cargo.toml
Normal file
18
node-graph/compilation-server/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "compilation-server"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
axum = "0.6.1"
|
||||
serde_json = "1.0"
|
||||
graph-craft = { version = "0.1.0", path = "../graph-craft", features = ["serde"] }
|
||||
gpu-compiler-bin-wrapper = { version = "0.1.0", path = "../gpu-compiler/gpu-compiler-bin-wrapper" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tempfile = "3.3.0"
|
||||
anyhow = "1.0.68"
|
||||
futures = "0.3"
|
||||
39
node-graph/compilation-server/src/main.rs
Normal file
39
node-graph/compilation-server/src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpu_compiler_bin_wrapper::CompileRequest;
|
||||
|
||||
use axum::{
|
||||
extract::{Json, State},
|
||||
http::StatusCode,
|
||||
routing::{get, post},
|
||||
Router,
|
||||
};
|
||||
|
||||
struct AppState {
|
||||
compile_dir: tempfile::TempDir,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let shared_state = Arc::new(AppState {
|
||||
compile_dir: tempfile::tempdir().expect("failed to create tempdir"),
|
||||
});
|
||||
|
||||
// build our application with a single route
|
||||
let app = Router::new()
|
||||
.route("/", get(|| async { "Hello from compilation server!" }))
|
||||
.route("/compile", get(|| async { "Supported targets: spirv" }))
|
||||
.route("/compile/spriv", post(post_compile_spriv))
|
||||
.with_state(shared_state);
|
||||
|
||||
// run it with hyper on localhost:3000
|
||||
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
|
||||
}
|
||||
|
||||
async fn post_compile_spriv(State(state): State<Arc<AppState>>, Json(compile_request): Json<CompileRequest>) -> Result<Vec<u8>, StatusCode> {
|
||||
let path = std::env::var("CARGO_MANIFEST_DIR").unwrap() + "/../gpu-compiler/Cargo.toml";
|
||||
compile_request.compile(state.compile_dir.path().to_str().expect("non utf8 tempdir path"), &path).map_err(|e| {
|
||||
eprintln!("compilation failed: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user