spirv-compiler

A wrapper for shaderc written in Rust with features like include support built in.

Usage

This library uses shaderc as its backend for shader compilation. The included wrapping Compiler adds functionality for caching compilation of shaders in memory and in files. Include support is built-in as well.

Setup compiler

``` Rust use spirvcompiler::*; let mut compiler = CompilerBuilder::new() // Add include dirs .withincludedir("my-include-dir") // Add macros .withmacro("MYMACRO", Some("1")) // Set source language .withsource_language(SourceLanguage::GLSL) // Build compiler .build() // If shaderc fails to initialize, this returns None .unwrap();

// Compile from file let result: Result, CompileError> = compiler .compilefromfile( "test-spirv/test-macro.vert", ShaderKind::Vertex, false // Set to true if shaders should be cached to filesystem );

// Compile from string let result: Result, CompileError> = compiler .compilefromstring( "#version 450...", ShaderKind::Vertex, false // Set to true if shaders should be cached to filesystem ); ```