• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*#pragma settings SkVMDebugTrace*/
2
3uniform half4 colorGreen, colorRed;
4
5bool test_scalar() {
6    mediump float mp  = 0.5;
7    highp   float hp  = mp;
8    highp   int   ihp = 2;
9    mediump int   imp = ihp;
10
11    return mp == hp && ihp == imp;
12}
13
14bool test_vector() {
15    mediump vec2 mp2 = vec2(2);
16    highp   vec2 hp2 = mp2;
17    mediump vec3 mp3 = vec3(3);
18    highp   vec3 hp3 = mp3;
19    mediump vec4 mp4 = vec4(4);
20    highp   vec4 hp4 = mp4;
21
22    highp   ivec2 ihp2 = ivec2(2);
23    mediump ivec2 imp2 = ihp2;
24    highp   ivec3 ihp3 = ivec3(3);
25    mediump ivec3 imp3 = ihp3;
26    highp   ivec4 ihp4 = ivec4(4);
27    mediump ivec4 imp4 = ihp4;
28
29    return mp2 == hp2   && hp3 == mp3   && mp4 == hp4 &&
30           imp2 == ihp2 && ihp3 == imp3 && imp4 == ihp4;
31}
32
33bool test_matrix() {
34    mediump mat2 mp2 = mat2(2);
35    highp   mat2 hp2 = mp2;
36    mediump mat3 mp3 = mat3(3);
37    highp   mat3 hp3 = mp3;
38    mediump mat4 mp4 = mat4(4);
39    highp   mat4 hp4 = mp4;
40
41    return mp2 == hp2 && hp3 == mp3 && mp4 == hp4;
42}
43
44bool test_array() {
45    mediump float  mf[1]; mf[0] = 1;
46    highp   float  hf[1]; hf[0] = 1;
47    mediump vec2   mv[2]; mv[0] = vec2(0, 1); mv[1] = vec2(2, 3);
48    highp   vec2   hv[2]; hv[0] = vec2(0, 1); hv[1] = vec2(2, 3);
49
50    return mf[0] == hf[0] && hv[0] == mv[0] && mv[1] == hv[1];
51}
52
53bool highp_param  (highp   float value) { return value == 1; }
54bool mediump_param(mediump float value) { return value == 2; }
55bool lowp_param   (lowp    float value) { return value == 3; }
56
57vec4 main(vec2 coords) {
58    highp   vec4 zero = vec4(0);
59    mediump vec4 one = vec4(1);
60    lowp    vec4 green = colorGreen;
61    green = green * one + zero;
62
63    highp vec4 red = colorRed;
64    red = (red + zero) * one;
65
66    return (test_scalar() && test_vector() && test_matrix() && test_array() &&
67            highp_param(1) && mediump_param(2) && lowp_param(3)) ? green : red;
68}
69