Merge pull request #2913 from greg-lunarg/i2905
[platform/upstream/glslang.git] / Test / precision.frag
1 #version 100\r
2 \r
3 varying vec3 color;       // ERRROR, there is no default qualifier for float\r
4 \r
5 lowp vec2 foo(mediump vec3 mv3)\r
6 {\r
7     highp vec4 hv4;\r
8     return hv4.xy;\r
9 }\r
10 \r
11 int global_medium;\r
12 \r
13 uniform lowp sampler2D samplerLow;\r
14 uniform mediump sampler2D samplerMed;\r
15 uniform highp sampler2D samplerHigh;\r
16 \r
17 precision highp int; \r
18 precision highp ivec2;     // ERROR\r
19 precision mediump int[2];  // ERROR\r
20 vec4 uint;                 // okay\r
21 precision mediump vec4;    // ERROR\r
22 \r
23 int global_high;\r
24 \r
25 void main()\r
26 {\r
27     lowp int sum = global_medium + global_high;\r
28 \r
29     gl_FragColor = vec4(color, 1.0);\r
30 \r
31     int level1_high;\r
32     sum += level1_high;\r
33 \r
34     precision lowp int;\r
35     int level1_low;\r
36     sum += level1_low;\r
37     \r
38     // test maxing precisions of args to get precision of builtin\r
39     lowp float arg1;\r
40     mediump float arg2;\r
41     lowp float d = distance(arg1, arg2);\r
42 \r
43     {\r
44         int level2_low;\r
45         sum += level2_low;\r
46         \r
47         precision highp int;\r
48         int level2_high;\r
49         sum += level2_high;\r
50         do {\r
51             if (true) {\r
52                 precision mediump int;\r
53                 int level4_medium;\r
54                 sum += level4_medium;\r
55             }\r
56             int level3_high;\r
57             sum += level3_high;\r
58         } while (true); \r
59         int level2_high2;\r
60         sum += level2_high2;\r
61     }\r
62     int level1_low3;\r
63     sum += level1_low3;\r
64 \r
65     sum += 4 + ((ivec2(level1_low3) * ivec2(level1_high) + ivec2((/* comma operator */level1_low3, level1_high)))).x;\r
66     \r
67     texture2D(samplerLow, vec2(0.1, 0.2));\r
68     texture2D(samplerMed, vec2(0.1, 0.2));\r
69     texture2D(samplerHigh, vec2(0.1, 0.2));\r
70 }\r
71 \r
72 precision mediump bool;                 // ERROR\r
73 //precision mediump struct { int a; } s;  // ERROR\r
74 struct s {int a;};\r
75 precision mediump s;                    // ERROR\r
76 mediump bvec2 b2;                       // ERROR\r