Crate shaderc [−] [src]
Rust binding for the shaderc library.
The shaderc library provides an API for compiling GLSL/HLSL source code to SPIRV modules. It has been shipping in the Android NDK since version r12b.
The shaderc_combined
library (libshaderc_combined.a
on Unix like
systems) is required for proper linking. You can compile it by checking out
the shaderc project and follow the instructions there. Then place
libshaderc_combined.a
at a path that is scanned by the linker (e.g., the
deps
directory within the target
directory).
Examples
Compile a shader into SPIR-V binary module and assembly text:
use shaderc; let source = "#version 310 es\n void EP() {}"; let mut compiler = shaderc::Compiler::new().unwrap(); let mut options = shaderc::CompileOptions::new().unwrap(); options.add_macro_definition("EP", Some("main")); let binary_result = compiler.compile_into_spirv( source, shaderc::ShaderKind::Vertex, "shader.glsl", "main", Some(&options)).unwrap(); assert_eq!(Some(&0x07230203), binary_result.as_binary().first()); let text_result = compiler.compile_into_spirv_assembly( source, shaderc::ShaderKind::Vertex, "shader.glsl", "main", Some(&options)).unwrap(); assert!(text_result.as_text().starts_with("; SPIR-V\n"));
Structs
CompilationArtifact |
An opaque object containing the results of compilation. |
CompileOptions |
An opaque object managing options to compilation. |
Compiler |
An opaque object managing all compiler states. |
Enums
Error |
Error. |
GlslProfile |
GLSL profile. |
Limit |
Resource limit. |
OptimizationLevel |
Optimization level. |
ShaderKind |
Shader kind. |
SourceLanguage |
Source language. |
TargetEnv |
Target environment. |
Functions
get_spirv_version |
Returns the version and revision of the SPIR-V generated by this library. |
parse_version_profile |
Parses the version and profile from the given |
Type Definitions
Result |
Compilation status. |