mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
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:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
7
tests/in/glsl/empty-global-name.frag
Normal file
7
tests/in/glsl/empty-global-name.frag
Normal file
@@ -0,0 +1,7 @@
|
||||
layout(set = 1, binding = 1) uniform TextureData {
|
||||
vec4 material;
|
||||
};
|
||||
|
||||
void main() {
|
||||
vec2 coords = vec2(material.xy);
|
||||
}
|
||||
21
tests/out/wgsl/empty-global-name-frag.wgsl
Normal file
21
tests/out/wgsl/empty-global-name-frag.wgsl
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user