shaderc-dyn-rs
Rust bindings for the shaderc library.
Note: This is a fork of google/shaderc-rs that loads the shaderc shared library at runtime using
libloading, instead of statically linking or building from source at compile time. A pre-builtlibshaderc_sharedshared library is required to be available at runtime. Pls ping me if the fork is outdated.
Usage
First add to your Cargo.toml:
[]
= "0.10"
Then add to your crate root:
extern crate shaderc_dyn;
Documentation
shaderc-dyn provides the Compiler interface to compile GLSL/HLSL
source code into SPIR-V binary modules or assembly code. It can also assemble
SPIR-V assembly into binary module. Default compilation behavior can be
adjusted using CompileOptions. Successful results are kept in
CompilationArtifacts.
Example
Compile a shader into SPIR-V binary module and assembly text:
use shaderc_dyn;
let source = "#version 310 es\n void EP() {}";
let mut compiler = new.unwrap;
let mut options = new.unwrap;
options.add_macro_definition;
let binary_result = compiler.compile_into_spirv.unwrap;
assert_eq!;
let text_result = compiler.compile_into_spirv_assembly.unwrap;
assert!;
Setup
This fork requires a pre-built shaderc shared library to be installed and available on the system library search path at runtime.
Required shared library
| Platform | Library name |
|---|---|
| Windows | shaderc_shared.dll |
| macOS | libshaderc_shared.dylib |
| Linux | libshaderc_shared.so |
Environment variable
Set SHADERC_LIB_PATH to the full path of the shared library to override
automatic search:
Installation
The shared library is included in the Vulkan SDK or can be installed via package managers:
- macOS (Homebrew):
brew install shaderc - Ubuntu/Debian:
sudo apt install libshaderc-dev - Arch Linux:
pacman -S shaderc - Windows: Install the Vulkan SDK and
ensure the SDK's
Bindirectory is onPATH
Contributions
This project is licensed under the Apache 2 license. Please see CONTRIBUTING before contributing.
Authors
This project is initialized and mainly developed by Lei Zhang (@antiagainst).