Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=257378 rdar://109886275 Reviewed by Mike Wyrzykowski. Swizzle characters need to be checked for bounds, e.g. we can't access vec2.z, but the original patch was incorrectly checking the offset of the swizzle against the size of the resulting vector, not the vector we are loading from. * Source/WebGPU/WGSL/TypeCheck.cpp: (WGSL::TypeChecker::vectorFieldAccess): * Source/WebGPU/WGSL/tests/invalid/vector.wgsl: * Source/WebGPU/WGSL/tests/valid/swizzle.wgsl: Added. Canonical link: https://commits.webkit.org/264650@main
- Loading branch information
1 parent
c7c487a
commit cfcd3f2
Showing
3 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// RUN: %wgslc | ||
|
||
fn testi32(x: i32) | ||
{ | ||
_ = x; | ||
} | ||
|
||
fn testVec2(x: vec2<i32>) | ||
{ | ||
_ = x; | ||
} | ||
|
||
fn testVec3(x: vec3<i32>) | ||
{ | ||
_ = x; | ||
} | ||
|
||
fn testVec4(x: vec4<i32>) | ||
{ | ||
_ = x; | ||
} | ||
|
||
fn testSwizzleVec2() | ||
{ | ||
let v = vec2(0i); | ||
_ = v.x; | ||
_ = v.xx; | ||
_ = v.xxx; | ||
_ = v.xxxx; | ||
|
||
_ = v.y; | ||
_ = v.yy; | ||
_ = v.yyy; | ||
_ = v.yyyy; | ||
|
||
_ = v.xy; | ||
|
||
_ = v.r; | ||
_ = v.rr; | ||
_ = v.rrr; | ||
_ = v.rrrr; | ||
|
||
_ = v.g; | ||
_ = v.gg; | ||
_ = v.ggg; | ||
_ = v.gggg; | ||
|
||
_ = v.rg; | ||
} | ||
|
||
fn testSwizzleVec3() { | ||
let v = vec3(0); | ||
_ = v.x; | ||
_ = v.xx; | ||
_ = v.xxx; | ||
_ = v.xxxx; | ||
|
||
_ = v.y; | ||
_ = v.yy; | ||
_ = v.yyy; | ||
_ = v.yyyy; | ||
|
||
_ = v.z; | ||
_ = v.zz; | ||
_ = v.zzz; | ||
_ = v.zzzz; | ||
|
||
_ = v.xyz; | ||
|
||
_ = v.r; | ||
_ = v.rr; | ||
_ = v.rrr; | ||
_ = v.rrrr; | ||
|
||
_ = v.g; | ||
_ = v.gg; | ||
_ = v.ggg; | ||
_ = v.gggg; | ||
|
||
_ = v.b; | ||
_ = v.bb; | ||
_ = v.bbb; | ||
_ = v.bbbb; | ||
|
||
_ = v.rgb; | ||
} | ||
|
||
fn testSwizzleVec4() { | ||
let v = vec4(0); | ||
_ = v.x; | ||
_ = v.xx; | ||
_ = v.xxx; | ||
_ = v.xxxx; | ||
|
||
_ = v.y; | ||
_ = v.yy; | ||
_ = v.yyy; | ||
_ = v.yyyy; | ||
|
||
_ = v.z; | ||
_ = v.zz; | ||
_ = v.zzz; | ||
_ = v.zzzz; | ||
|
||
_ = v.w; | ||
_ = v.ww; | ||
_ = v.www; | ||
_ = v.wwww; | ||
|
||
_ = v.xyzw; | ||
|
||
_ = v.r; | ||
_ = v.rr; | ||
_ = v.rrr; | ||
_ = v.rrrr; | ||
|
||
_ = v.g; | ||
_ = v.gg; | ||
_ = v.ggg; | ||
_ = v.gggg; | ||
|
||
_ = v.b; | ||
_ = v.bb; | ||
_ = v.bbb; | ||
_ = v.bbbb; | ||
|
||
_ = v.a; | ||
_ = v.aa; | ||
_ = v.aaa; | ||
_ = v.aaaa; | ||
|
||
_ = v.rgba; | ||
} |