skia2/tests/sksl/shared/ResizeMatrixNonsquare.glsl
John Stiles 3c74a5357a Add GLSL workaround for 4x2 diagonal matrix bug.
GLSL now emits 4x2 diagonal matrices as:
	`(mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * n)`
instead of
	`mat4x2(n)`.

This works around a long-standing GLSL bug in both Mesa and glslang that
affects several drivers:
https://github.com/KhronosGroup/glslang/issues/2645

Change-Id: If529d5cd150ce720f436cb3634a2fd3423919278
Bug: skia:12003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410137
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-18 22:50:19 +00:00

21 lines
596 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
float result = 0.0;
mat3 g = mat3(mat2x3(1.0));
result += g[0].x;
mat3 h = mat3(mat3x2(1.0));
result += h[0].x;
mat4 i = mat4(mat4x3((mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * 1.0)));
result += i[0].x;
mat4 j = mat4(mat3x4(mat2x4(1.0)));
result += j[0].x;
mat2x4 k = mat2x4((mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * 1.0));
result += k[0].x;
mat4x2 l = mat4x2(mat2x4(1.0));
result += l[0].x;
return result == 6.0 ? colorGreen : colorRed;
}