Crate glsl_to_spirv_macros [] [src]

Use this crate to compile your GLSL shaders at compile time into binaries embedded in your program.

This crate requires you to also use the glsl-to-spirv-macros-impl crate. Without it these macros will not work. Unfortunately it is not yet possible to combine the two crates into one.

Example usage:

#[macro_use] extern crate glsl_to_spirv_macros;
#[macro_use] extern crate glsl_to_spirv_macros_impl;

static some_shader: &'static [u8] = glsl_vs!{r#"
    // Shader code here
"#};

fn main() {
    let another_shader = include_glsl_fs!("path/to/shader");
}

All macros in this crate return &'static [u8], and can be used in the definition of static as well as local variables. Every macro takes a string literal, e.g. "...", r#"..."# etc.

These macros generate Vulkan-compatible SPIR-V binaries using the official glslang compiler - they are not designed for use with other APIs, like OpenCL.

Macros

glsl_cs

Compiles a string containing a GLSL compute shader into SPIR-V binary data.

glsl_fs

Compiles a string containing a GLSL fragment shader into SPIR-V binary data.

glsl_gs

Compiles a string containing a GLSL geometry shader into SPIR-V binary data.

glsl_tcs

Compiles a string containing a GLSL tessellation control shader into SPIR-V binary data.

glsl_tes

Compiles a string containing a GLSL tessellation evaluation shader into SPIR-V binary data.

glsl_vs

Compiles a string containing a GLSL vertex shader into SPIR-V binary data.

include_glsl_cs

Compiles the specified file (path relative to the crate root) containing a GLSL compute shader into SPIR-V binary data.

include_glsl_fs

Compiles the specified file (path relative to the crate root) containing a GLSL fragment shader into SPIR-V binary data.

include_glsl_gs

Compiles the specified file (path relative to the crate root) containing a GLSL geometry shader into SPIR-V binary data.

include_glsl_tcs

Compiles the specified file (path relative to the crate root) containing a GLSL tessellation control shader into SPIR-V binary data.

include_glsl_tes

Compiles the specified file (path relative to the crate root) containing a GLSL tessellation evaluation shader into SPIR-V binary data.

include_glsl_vs

Compiles the specified file (path relative to the crate root) containing a GLSL vertex shader into SPIR-V binary data.