glsl-in: Add test for conditional builtin inject

This commit is contained in:
João Capucho
2022-02-19 10:04:11 +00:00
committed by Dzmitry Malyshau
parent 9f62feee87
commit 1ccfc8991e
3 changed files with 49 additions and 0 deletions

9
tests/in/variations.glsl Normal file
View File

@@ -0,0 +1,9 @@
#version 460 core
layout(set = 0, binding = 0) uniform textureCube texCube;
layout(set = 0, binding = 1) uniform sampler samp;
void main() {
ivec2 sizeCube = textureSize(samplerCube(texCube, samp), 0);
float a = ceil(1.0);
}

View File

@@ -0,0 +1,21 @@
#version 310 es
precision highp float;
precision highp int;
uniform highp samplerCube _group_0_binding_0_fs;
void main_1() {
ivec2 sizeCube = ivec2(0);
float a = 0.0;
sizeCube = textureSize(_group_0_binding_0_fs, 0).xy;
a = ceil(1.0);
return;
}
void main() {
main_1();
return;
}

View File

@@ -556,6 +556,25 @@ fn convert_spv_all() {
convert_spv("degrees", false, Targets::empty());
}
#[cfg(feature = "glsl-in")]
#[test]
fn convert_glsl_variations_check() {
let root = env!("CARGO_MANIFEST_DIR");
let file = fs::read_to_string(format!("{}/{}/variations.glsl", root, BASE_DIR_IN))
.expect("Couldn't find glsl file");
let mut parser = naga::front::glsl::Parser::default();
let module = parser
.parse(
&naga::front::glsl::Options {
stage: naga::ShaderStage::Fragment,
defines: Default::default(),
},
&file,
)
.unwrap();
check_targets(&module, "variations-glsl", Targets::GLSL);
}
#[cfg(feature = "glsl-in")]
#[allow(unused_variables)]
#[test]