summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/deqp/data/gles2/shaders/constant_expressions.test
blob: 355a4432a34d5697fbb2be63a5c1c5d3d74591fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
group trivial "Trivial expressions"

	case float
		values { output float out0 = 5.0; }
		both ""

			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const float a = 5.0;
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case int
		values { output int out0 = 5; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const int a = 5;
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case bool
		values { output bool out0 = true; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const bool a = true;
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case cast
		values { output float out0 = 1.0; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const float a = float(int(bool(true)));
				out0 = a;
				${OUTPUT}
			}
		""
	end

end # trivial

group operators "Operators"

	case math_float
		values { output float out0 = 2.19; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const float a = 6.0/3.5 + 1.8*2.6 - 4.2;
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case math_vec
		values { output float out0 = 15.0; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const vec3 a = (vec4(1.0, 2.0, 3.0, 4.0).zyx * vec3(1.0, 1.5, 3.0).xyz).xzy + (vec2(5.0)/vec2(2.5)).xxy;
				out0 = a.x + a.y + a.z;
				${OUTPUT}
			}
		""
	end

	case math_int
		values { output int out0 = 7; }
		both ""
			precision highp int;
			${DECLARATIONS}

			void main()
			{
				const int a = 5-1 + 2*3 - 9/3;
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case math_ivec
		values { output int out0 = 21; }
		both ""
			precision highp int;
			${DECLARATIONS}

			void main()
			{
				const ivec3 a = ivec2(5-1, 4).xxy + ivec4(1*3, 9/3, 1+2, 8/4).xyz;
				out0 = a.x + a.y + a.z;
				${OUTPUT}
			}
		""
	end

	case math_mat
		values { output float out0 = 8.0; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const mat3 a = mat3(3.0) * mat3(4.0);
				const mat4 b = mat4(a[1][1])*2.0;
				const mat2 c = mat2(b[0][0]) / 3.0;
				out0 = c[0][0]+c[1][0];
				${OUTPUT}
			}
		""
	end

	case logical
		values { output bool out0 = true; }
		both ""
			precision highp int;
			${DECLARATIONS}

			void main()
			{
				const bool a = (!false || false) && (true ^^ false);
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case compare
		values { output bool out0 = true; }
		both ""
			precision highp int;
			${DECLARATIONS}

			void main()
			{
				const bool a = (false == false) && (true != false) && (1 < 2) && (3 <= 3) && ((1 > 1) != (1 >= 1));
				out0 = a;
				${OUTPUT}
			}
		""
	end

	case selection
		values { output float out0 = 5.3; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const float a = false ? 0.0 : (true ? 5.3 : 1.0);
				out0 = a;
				${OUTPUT}
			}
		""
	end

end # operators

group complex_types "Arrays, structs & nested calls"

	case struct
		values { output float out0 = 260.922; }
		both ""
			precision highp float;
			${DECLARATIONS}

			struct S
			{
				vec4 a;
				int  b;
			};

			void main()
			{
				const S s = S(vec4(1.5), 123);
				out0 = length(s.a.xy)*float(s.b);
				${OUTPUT}
			}
		""
	end

	case nested_struct
		values { output float out0 = 965.9; }
		both ""
			precision highp float;
			${DECLARATIONS}

			struct S
			{
				vec4 v;
				int  i;
			};

			struct T
			{
				S s;
				bool b;
				int i;
			};

			struct U
			{
				S s;
				T t;
			};

			void main()
			{
				const S s = S(vec4(1.5), 123);
				const T t = T(s, false, 3);
				const U u = U(s, t);
				const U v = U(S(vec4(1.3), 4), T(S(vec4(2.0), 5), true, 6));
				out0 = float(u.s.i*v.t.i + v.t.s.i)*v.s.v.x; // float(123*6 + 5)*1.3
				${OUTPUT}
			}
		""
	end

	case array
		values
		{
			input float in0 = [ 0.0 | 1.0];
			output float out0 = [0.0 | 1.0];
		}
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				float a[int(max(-1.0, 2.0))];
				a[0] = -1.0;
				a[1] = in0;
				out0 = a[int(min(1.0, 2.0))];
				${OUTPUT}
			}
		""
	end

	case nested_builtin_funcs
		values { output float out0 = 3.05; }
		both ""
			precision highp float;
			${DECLARATIONS}

			void main()
			{
				const float a = sqrt( atan(sin(1.5)/cos(1.5)) /*1.5*/ * log2(exp2(log(exp(6.2) + 0.1)) + 0.1) /*~6.2*/);
				out0 = a;
				${OUTPUT}
			}
		""
	end

end # complex_types