e3ae968f5f
GLSL allows an array of `lowp float` to be compared against `highp float` seamlessly because the types are considered to be the same. SkSL, however, treats these as different types, so we need to coerce the types to allow this comparison to work. In other words, these comparisons can cause an array to be implicitly casted. The expression `myHalf2Array == float[2](a, b)` should be allowed when narrowing conversions are enabled. To allow this to work, we need a dedicated IR node representing this type coercion. We now allow implicit coercion of array types when the array's component types would be implicitly coercible, and have a new IR node representing that implicit conversion. This CL fixes array comparisons, but array assignment needs additional fixes. It currently results in: "type mismatch: '=' cannot operate on (types)". Bug: skia:12248 Change-Id: I99062486c081f748f65be4b36a3a52e95b559812 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436571 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
uniform half4 colorGreen, colorRed;
|
|
|
|
bool test_scalar() {
|
|
mediump float mp = 0.5;
|
|
highp float hp = mp;
|
|
highp int ihp = 2;
|
|
mediump int imp = ihp;
|
|
|
|
return mp == hp && ihp == imp;
|
|
}
|
|
|
|
bool test_vector() {
|
|
mediump vec2 mp2 = vec2(2);
|
|
highp vec2 hp2 = mp2;
|
|
mediump vec3 mp3 = vec3(3);
|
|
highp vec3 hp3 = mp3;
|
|
mediump vec4 mp4 = vec4(4);
|
|
highp vec4 hp4 = mp4;
|
|
|
|
highp ivec2 ihp2 = ivec2(2);
|
|
mediump ivec2 imp2 = ihp2;
|
|
highp ivec3 ihp3 = ivec3(3);
|
|
mediump ivec3 imp3 = ihp3;
|
|
highp ivec4 ihp4 = ivec4(4);
|
|
mediump ivec4 imp4 = ihp4;
|
|
|
|
return mp2 == hp2 && hp3 == mp3 && mp4 == hp4 &&
|
|
imp2 == ihp2 && ihp3 == imp3 && imp4 == ihp4;
|
|
}
|
|
|
|
bool test_matrix() {
|
|
mediump mat2 mp2 = mat2(2);
|
|
highp mat2 hp2 = mp2;
|
|
mediump mat3 mp3 = mat3(3);
|
|
highp mat3 hp3 = mp3;
|
|
mediump mat4 mp4 = mat4(4);
|
|
highp mat4 hp4 = mp4;
|
|
|
|
return mp2 == hp2 && hp3 == mp3 && mp4 == hp4;
|
|
}
|
|
|
|
bool test_array() {
|
|
mediump float mf[1]; mf[0] = 1;
|
|
highp float hf[1]; hf[0] = 1;
|
|
mediump vec2 mv[2]; mv[0] = vec2(0, 1); mv[1] = vec2(2, 3);
|
|
highp vec2 hv[2]; hv[0] = vec2(0, 1); hv[1] = vec2(2, 3);
|
|
|
|
return mf[0] == hf[0] && hv[0] == mv[0] && mv[1] == hv[1];
|
|
}
|
|
|
|
vec4 main(vec2 coords) {
|
|
highp vec4 zero = vec4(0);
|
|
mediump vec4 one = vec4(1);
|
|
lowp vec4 green = colorGreen;
|
|
green = green * one + zero;
|
|
|
|
highp vec4 red = colorRed;
|
|
red = (red + zero) * one;
|
|
|
|
return (test_scalar() && test_vector() && test_matrix() && test_array()) ? green : red;
|
|
}
|