Skip to content

Commit

Permalink
Use spirv_utils instead of generating the SPIR-V definitions
Browse files Browse the repository at this point in the history
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 committed Sep 17, 2016
1 parent 0bc7f26 commit fa6ee92
Show file tree
Hide file tree
Showing 8 changed files with 699 additions and 526 deletions.
13 changes: 2 additions & 11 deletions Cargo.toml
@@ -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" }
28 changes: 13 additions & 15 deletions README.md
Expand Up @@ -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)));
Expand All @@ -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 changes: 0 additions & 134 deletions build.rs

This file was deleted.

111 changes: 0 additions & 111 deletions src/bytecode.rs

This file was deleted.

0 comments on commit fa6ee92

Please sign in to comment.