Crates.io | glslang-sys |
lib.rs | glslang-sys |
version | |
source | src |
created_at | 2015-05-09 17:59:21.771821 |
updated_at | 2024-10-26 04:56:13.021292 |
description | Raw C bindings to glslang |
homepage | |
repository | https://github.com/SnowflakePowered/glslang-rs |
max_upload_size | |
id | 2066 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | 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` |
size | 0 |
Safe Rust bindings to glslang
[dependencies]
glslang = "0.3"
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())
}