eb68973c2f
The GLSL spec allows matrix constructors containing vectors that would split between multiple columns of the matrix. However, in practice, this does not actually work well on a lot of GPUs! - "cast not allowed", "internal error": Tegra 3 Quadro P400 GTX 660 GTX 960 - Compiles, but generates wrong result: RadeonR9M470X RadeonHD7770 Since this isn't a pattern we expect to see in user code, we now report it as an error at compile time. mat2(vec4) is treated as an exceptional case and still allowed. Change-Id: Id6925984a2d1ec948aec4defcc790a197a96cf86 Bug: skia:12443 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449518 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
72 lines
3.9 KiB
GLSL
72 lines
3.9 KiB
GLSL
|
|
out vec4 sk_FragColor;
|
|
uniform vec4 colorGreen;
|
|
uniform vec4 colorRed;
|
|
uniform mat2 testMatrix2x2;
|
|
bool test_half_b() {
|
|
bool ok = true;
|
|
mat2x3 m23 = mat2x3(2.0);
|
|
ok = ok && m23 == mat2x3(2.0, 0.0, 0.0, 0.0, 2.0, 0.0);
|
|
mat2x4 m24 = mat2x4(3.0);
|
|
ok = ok && m24 == mat2x4(3.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0);
|
|
mat3x2 m32 = mat3x2(4.0);
|
|
ok = ok && m32 == mat3x2(4.0, 0.0, 0.0, 4.0, 0.0, 0.0);
|
|
mat3x4 m34 = mat3x4(5.0);
|
|
ok = ok && m34 == mat3x4(5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0);
|
|
mat4x2 m42 = (mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * 6.0);
|
|
ok = ok && m42 == mat4x2(6.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0);
|
|
mat4x3 m43 = mat4x3(7.0);
|
|
ok = ok && m43 == mat4x3(7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0);
|
|
mat2 m22 = m32 * m23;
|
|
ok = ok && m22 == mat2(8.0);
|
|
mat3 m33 = m43 * m34;
|
|
ok = ok && m33 == mat3(35.0);
|
|
m23 += 1.0;
|
|
ok = ok && m23 == mat2x3(3.0, 1.0, 1.0, 1.0, 3.0, 1.0);
|
|
m32 -= 2.0;
|
|
ok = ok && m32 == mat3x2(2.0, -2.0, -2.0, 2.0, -2.0, -2.0);
|
|
m24 /= 4.0;
|
|
ok = ok && m24 == mat2x4(0.75, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0);
|
|
vec4 h4 = vec4(testMatrix2x2);
|
|
ok = ok && mat2x3(h4.xyz, h4.w, h4.xy) == mat2x3(1.0, 2.0, 3.0, 4.0, 1.0, 2.0);
|
|
ok = ok && mat2x4(h4.xyz, h4.w, h4.x, h4.yzw) == mat2x4(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
ok = ok && mat3x2(h4.xy, h4.zw, h4.x, h4.y) == mat3x2(1.0, 2.0, 3.0, 4.0, 1.0, 2.0);
|
|
ok = ok && mat3x4(h4.xy, h4.zw, h4, h4.x, h4.yz, h4.w) == mat3x4(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
ok = ok && mat4x2(h4.xy, h4.z, h4.w, h4.xy, h4.z, h4.w) == mat4x2(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
ok = ok && mat4x3(h4.x, h4.yz, h4.wx, h4.y, h4.zwx, h4.yzw) == mat4x3(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
return ok;
|
|
}
|
|
vec4 main() {
|
|
bool _0_ok = true;
|
|
mat2x3 _1_m23 = mat2x3(2.0);
|
|
_0_ok = _0_ok && _1_m23 == mat2x3(2.0, 0.0, 0.0, 0.0, 2.0, 0.0);
|
|
mat2x4 _2_m24 = mat2x4(3.0);
|
|
_0_ok = _0_ok && _2_m24 == mat2x4(3.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0);
|
|
mat3x2 _3_m32 = mat3x2(4.0);
|
|
_0_ok = _0_ok && _3_m32 == mat3x2(4.0, 0.0, 0.0, 4.0, 0.0, 0.0);
|
|
mat3x4 _4_m34 = mat3x4(5.0);
|
|
_0_ok = _0_ok && _4_m34 == mat3x4(5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0);
|
|
mat4x2 _5_m42 = (mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * 6.0);
|
|
_0_ok = _0_ok && _5_m42 == mat4x2(6.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0);
|
|
mat4x3 _6_m43 = mat4x3(7.0);
|
|
_0_ok = _0_ok && _6_m43 == mat4x3(7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0, 7.0, 0.0, 0.0, 0.0);
|
|
mat2 _7_m22 = _3_m32 * _1_m23;
|
|
_0_ok = _0_ok && _7_m22 == mat2(8.0);
|
|
mat3 _8_m33 = _6_m43 * _4_m34;
|
|
_0_ok = _0_ok && _8_m33 == mat3(35.0);
|
|
_1_m23 += 1.0;
|
|
_0_ok = _0_ok && _1_m23 == mat2x3(3.0, 1.0, 1.0, 1.0, 3.0, 1.0);
|
|
_3_m32 -= 2.0;
|
|
_0_ok = _0_ok && _3_m32 == mat3x2(2.0, -2.0, -2.0, 2.0, -2.0, -2.0);
|
|
_2_m24 /= 4.0;
|
|
_0_ok = _0_ok && _2_m24 == mat2x4(0.75, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0);
|
|
vec4 _10_f4 = vec4(testMatrix2x2);
|
|
_0_ok = _0_ok && mat2x3(_10_f4.xyz, _10_f4.w, _10_f4.xy) == mat2x3(1.0, 2.0, 3.0, 4.0, 1.0, 2.0);
|
|
_0_ok = _0_ok && mat2x4(_10_f4.xyz, _10_f4.w, _10_f4.x, _10_f4.yzw) == mat2x4(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
_0_ok = _0_ok && mat3x2(_10_f4.xy, _10_f4.zw, _10_f4.x, _10_f4.y) == mat3x2(1.0, 2.0, 3.0, 4.0, 1.0, 2.0);
|
|
_0_ok = _0_ok && mat3x4(_10_f4.xy, _10_f4.zw, _10_f4, _10_f4.x, _10_f4.yz, _10_f4.w) == mat3x4(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
_0_ok = _0_ok && mat4x2(_10_f4.xy, _10_f4.z, _10_f4.w, _10_f4.xy, _10_f4.z, _10_f4.w) == mat4x2(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
_0_ok = _0_ok && mat4x3(_10_f4.x, _10_f4.yz, _10_f4.wx, _10_f4.y, _10_f4.zwx, _10_f4.yzw) == mat4x3(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0);
|
|
return _0_ok && test_half_b() ? colorGreen : colorRed;
|
|
}
|