Skip to content
Permalink
Browse files

Use spirv_utils instead of generating the SPIR-V definitions

Add a wrapper around the graph with automated type inference
Added support for most of the common data types
  • Loading branch information...
Léo-Paul COUTURIER
Léo-Paul COUTURIER committed Sep 17, 2016
1 parent 0bc7f26 commit fa6ee9223d10e37c2e85b4f9c9739013b0f0c11b
Showing with 699 additions and 526 deletions.
  1. +2 −11 Cargo.toml
  2. +13 −15 README.md
  3. +0 −134 build.rs
  4. +0 −111 src/bytecode.rs
  5. +96 −0 src/glsl.rs
  6. +336 −4 src/graph.rs
  7. +252 −214 src/lib.rs
  8. +0 −37 src/spirv.rs
@@ -1,22 +1,13 @@
[package]
name = "rasen"
version = "0.1.0"
version = "0.2.0"
authors = ["l3ops <root@leops.me>"]
build = "build.rs"
description = "Generate SPIR-V bytecode from an operation graph"
repository = "https://github.com/leops/rasen"
readme = "README.md"
keywords = ["SPIRV", "Vulkan", "GLSL"]
license = "MIT"

[features]
default = ["aster/with-syntex"]

[dependencies]
petgraph = "0.2.8"

[build-dependencies]
aster = "0.26.1"
syntex_syntax = "0.43.0"
json = "0.10.2"
hyper = "0.9.10"
spirv-utils = { git = "https://github.com/leops/spirv-utils.git", rev = "ef68f9c" }
@@ -3,17 +3,15 @@ rasen
Generate SPIR-V bytecode from an operation graph (heavy WIP)

```rust
extern crate petgraph;
extern crate rasen;
use petgraph::Graph;
use rasen::*;
fn main() {
let mut graph = Graph::<Node, ()>::new();
let mut graph = Graph::new();
// A vec3 input at location 0
let normal = graph.add_node(Node::Input(0, TypeName::Vec3));
let normal = graph.add_node(Node::Input(0, TypeName::Vec(3)));
// Some ambient light constants
let min_light = graph.add_node(Node::Constant(TypedValue::Float(0.1)));
@@ -30,28 +28,28 @@ fn main() {
let multiply = graph.add_node(Node::Multiply);
// And a vec4 output at location 0
let color = graph.add_node(Node::Output(0, TypeName::Vec4));
let color = graph.add_node(Node::Output(0, TypeName::Vec(4)));
// Normalize the normal
graph.add_edge(normal, normalize, ());
graph.add_edge(normal, normalize);
// Compute the dot product of the surface normal and the light direction
graph.add_edge(normalize, dot, ());
graph.add_edge(light_dir, dot, ());
graph.add_edge(normalize, dot);
graph.add_edge(light_dir, dot);
// Restrict the result into the ambient light range
graph.add_edge(dot, clamp, ());
graph.add_edge(min_light, clamp, ());
graph.add_edge(max_light, clamp, ());
graph.add_edge(dot, clamp);
graph.add_edge(min_light, clamp);
graph.add_edge(max_light, clamp);
// Multiply the light intensity by the surface color
graph.add_edge(clamp, multiply, ());
graph.add_edge(mat_color, multiply, ());
graph.add_edge(clamp, multiply);
graph.add_edge(mat_color, multiply);
// Write the result to the output
graph.add_edge(multiply, color, ());
graph.add_edge(multiply, color);
let bytecode = build_program(&graph);
let bytecode = build_program(&graph, ShaderType::Fragment);
// bytecode is now a Vec<u8> you can pass to Vulkan to create the shader module
}
```
134 build.rs

This file was deleted.

This file was deleted.

0 comments on commit fa6ee92

Please sign in to comment.
You can’t perform that action at this time.