mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[naga wgsl] all swizzle components must be either color or dimension (#6187)
This commit is contained in:
parent
04618b36a8
commit
585f4a1036
@ -907,7 +907,13 @@ impl Components {
|
||||
*comp = Self::letter_component(ch).ok_or(Error::BadAccessor(name_span))?;
|
||||
}
|
||||
|
||||
Ok(Components::Swizzle { size, pattern })
|
||||
if name.chars().all(|c| matches!(c, 'x' | 'y' | 'z' | 'w'))
|
||||
|| name.chars().all(|c| matches!(c, 'r' | 'g' | 'b' | 'a'))
|
||||
{
|
||||
Ok(Components::Swizzle { size, pattern })
|
||||
} else {
|
||||
Err(Error::BadAccessor(name_span))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2371,3 +2371,21 @@ fn local_const_from_global_var() {
|
||||
"###,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_one_swizzle_type() {
|
||||
check(
|
||||
"
|
||||
const ok1 = vec2(0.0, 0.0).xy;
|
||||
const ok2 = vec2(0.0, 0.0).rg;
|
||||
const err = vec2(0.0, 0.0).xg;
|
||||
",
|
||||
r###"error: invalid field accessor `xg`
|
||||
┌─ wgsl:4:36
|
||||
│
|
||||
4 │ const err = vec2(0.0, 0.0).xg;
|
||||
│ ^^ invalid accessor
|
||||
|
||||
"###,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user