Handle empty variable names in namer (#1484)

* Handle empty variable names in namer

* Add glsl-in test with empty global name
This commit is contained in:
Igor Shaposhnik
2021-10-27 00:46:27 +03:00
committed by GitHub
parent 63dbd38edc
commit 00bbbed90a
3 changed files with 35 additions and 1 deletions

View File

@@ -117,7 +117,13 @@ impl Namer {
pub fn call_or(&mut self, label: &Option<String>, fallback: &str) -> String {
self.call(match *label {
Some(ref name) => name,
Some(ref name) => {
if name.trim().is_empty() {
fallback
} else {
name
}
}
None => fallback,
})
}

View File

@@ -0,0 +1,7 @@
layout(set = 1, binding = 1) uniform TextureData {
vec4 material;
};
void main() {
vec2 coords = vec2(material.xy);
}

View File

@@ -0,0 +1,21 @@
[[block]]
struct TextureData {
material: vec4<f32>;
};
[[group(1), binding(1)]]
var<uniform> global: TextureData;
fn main1() {
var coords: vec2<f32>;
let e2: vec4<f32> = global.material;
coords = vec2<f32>(e2.xy);
return;
}
[[stage(fragment)]]
fn main() {
main1();
return;
}