glslang

Crates.ioglslang
lib.rsglslang
version
sourcesrc
created_at2022-09-24 19:07:35.233085
updated_at2024-10-15 22:27:49.037913
descriptionRust bindings to glslang
homepage
repositoryhttps://github.com/SnowflakePowered/glslang-rs
max_upload_size
id673189
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Ronny Chan (chyyran)

documentation

README

glslang-rs

Safe Rust bindings to glslang

Latest Version Docs License

Usage

[dependencies]
glslang = "0.3"

Example

Compiling a shader

    use rspirv::binary::Disassemble;
    use glslang::*;

    #[test]
    pub fn test_compile() {
        // Acquire the compiler instance
        let compiler = Compiler::acquire().unwrap();
        let source = ShaderSource::try_from(String::from(
r#"
#version 450

layout(location = 0) out vec4 color;
layout(binding = 1) uniform sampler2D tex;

void main() {
    color = texture(tex, vec2(0.0));
}
"#,
        ))
        .expect("source");

        let limits = ResourceLimits::default();
        let input = ShaderInput::new(
            &source,
            &limits,
            ShaderStage::Fragment,
            &CompilerOptions::default(),
            None,
        );
        let shader = Shader::new(&compiler, input).expect("shader init");

        let mut program = Program::new(&compiler);

        program.add_shader(shader);
        program.link().expect("link error");

        let code = program.compile(ShaderStage::Fragment).expect("shader");
       
        // Use rspirv to disassemble
        let mut loader = rspirv::dr::Loader::new();
        rspirv::binary::parse_words(&code, &mut loader).unwrap();
        let module = loader.module();

        println!("{}", module.disassemble())
    }
Commit count: 50

cargo fmt