mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/shader: bug fix: a swizzling 'r' didn't work for vec2
Closes #2652
This commit is contained in:
parent
01bb42526a
commit
b5ca404c42
@ -1178,7 +1178,7 @@ func isValidSwizzling(swizzling string, t shaderir.Type) bool {
|
||||
|
||||
switch t.Main {
|
||||
case shaderir.Vec2, shaderir.IVec2:
|
||||
return !strings.ContainsAny(swizzling, "zwbarq")
|
||||
return !strings.ContainsAny(swizzling, "zwbapq")
|
||||
case shaderir.Vec3, shaderir.IVec3:
|
||||
return !strings.ContainsAny(swizzling, "waq")
|
||||
case shaderir.Vec4, shaderir.IVec4:
|
||||
|
@ -2752,9 +2752,31 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a vec2; var b vec3 = a.xyz; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.xyw; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b vec3 = a.xyz; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.zzz; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec4 = a.xyzw; _ = b", err: true},
|
||||
|
||||
{stmt: "var a vec2; var b float = a.r; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b float = a.g; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b float = a.b; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b float = a.a; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec2 = a.rg; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b vec3 = a.rgb; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.rga; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.rgg; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b vec3 = a.bbb; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec4 = a.rgba; _ = b", err: true},
|
||||
|
||||
{stmt: "var a vec2; var b float = a.s; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b float = a.t; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b float = a.p; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b float = a.q; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec2 = a.st; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b vec3 = a.stp; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.stq; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec3 = a.stt; _ = b", err: false},
|
||||
{stmt: "var a vec2; var b vec3 = a.ppp; _ = b", err: true},
|
||||
{stmt: "var a vec2; var b vec4 = a.stpq; _ = b", err: true},
|
||||
|
||||
{stmt: "var a vec3; var b float = a.x; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b float = a.y; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b float = a.z; _ = b", err: false},
|
||||
@ -2763,7 +2785,7 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a vec3; var b vec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b vec3 = a.xyw; _ = b", err: true},
|
||||
{stmt: "var a vec3; var b vec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b vec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b vec3 = a.zzz; _ = b", err: false},
|
||||
{stmt: "var a vec3; var b vec4 = a.xyzw; _ = b", err: true},
|
||||
|
||||
{stmt: "var a vec4; var b float = a.x; _ = b", err: false},
|
||||
@ -2774,7 +2796,7 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a vec4; var b vec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a vec4; var b vec3 = a.xyw; _ = b", err: false},
|
||||
{stmt: "var a vec4; var b vec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a vec4; var b vec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a vec4; var b vec3 = a.zzz; _ = b", err: false},
|
||||
{stmt: "var a vec4; var b vec4 = a.xyzw; _ = b", err: false},
|
||||
|
||||
{stmt: "var a ivec2; var b int = a.x; _ = b", err: false},
|
||||
@ -2785,7 +2807,7 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a ivec2; var b ivec3 = a.xyz; _ = b", err: true},
|
||||
{stmt: "var a ivec2; var b ivec3 = a.xyw; _ = b", err: true},
|
||||
{stmt: "var a ivec2; var b ivec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a ivec2; var b ivec3 = a.xyz; _ = b", err: true},
|
||||
{stmt: "var a ivec2; var b ivec3 = a.zzz; _ = b", err: true},
|
||||
{stmt: "var a ivec2; var b ivec4 = a.xyzw; _ = b", err: true},
|
||||
|
||||
{stmt: "var a ivec3; var b int = a.x; _ = b", err: false},
|
||||
@ -2796,7 +2818,7 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a ivec3; var b ivec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a ivec3; var b ivec3 = a.xyw; _ = b", err: true},
|
||||
{stmt: "var a ivec3; var b ivec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a ivec3; var b ivec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a ivec3; var b ivec3 = a.zzz; _ = b", err: false},
|
||||
{stmt: "var a ivec3; var b ivec4 = a.xyzw; _ = b", err: true},
|
||||
|
||||
{stmt: "var a ivec4; var b int = a.x; _ = b", err: false},
|
||||
@ -2807,7 +2829,7 @@ func TestSyntaxSwizzling(t *testing.T) {
|
||||
{stmt: "var a ivec4; var b ivec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a ivec4; var b ivec3 = a.xyw; _ = b", err: false},
|
||||
{stmt: "var a ivec4; var b ivec3 = a.xyy; _ = b", err: false},
|
||||
{stmt: "var a ivec4; var b ivec3 = a.xyz; _ = b", err: false},
|
||||
{stmt: "var a ivec4; var b ivec3 = a.zzz; _ = b", err: false},
|
||||
{stmt: "var a ivec4; var b ivec4 = a.xyzw; _ = b", err: false},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user