mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-30 18:53:25 +00:00
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
//TODO: consider converting this to snapshots?
|
|
|
|
#[cfg(feature = "glsl-in")]
|
|
fn check_glsl(name: &str) {
|
|
let path = std::path::PathBuf::from("tests/cases").join(name);
|
|
let input = std::fs::read_to_string(path).unwrap();
|
|
let stage = if name.ends_with(".vert") {
|
|
naga::ShaderStage::Vertex
|
|
} else if name.ends_with(".frag") {
|
|
naga::ShaderStage::Fragment
|
|
} else if name.ends_with(".comp") {
|
|
naga::ShaderStage::Compute
|
|
} else {
|
|
panic!("Unknown extension in {:?}", name)
|
|
};
|
|
|
|
match naga::front::glsl::parse_str(&input, "main", stage, Default::default()) {
|
|
Ok(m) => match naga::proc::Validator::new().validate(&m) {
|
|
Ok(()) => (),
|
|
Err(e) => panic!("Unable to validate {}: {:?}", name, e),
|
|
},
|
|
Err(e) => panic!("Unable to parse {}: {:?}", name, e),
|
|
};
|
|
}
|
|
|
|
#[cfg(feature = "glsl-in")]
|
|
#[test]
|
|
fn parse_glsl() {
|
|
//check_glsl("glsl_constant_expression.vert"); //TODO
|
|
//check_glsl("glsl_if_preprocessor.vert");
|
|
check_glsl("glsl_preprocessor_abuse.vert");
|
|
check_glsl("glsl_vertex_test_shader.vert");
|
|
}
|