Delete most of the comments.
[mesa.git] / src / mesa / shader / slang / library / slang_core.gc
1
2 //
3 // This file defines nearly all constructors and operators for built-in data types, using
4 // extended language syntax. In general, compiler treats constructors and operators as
5 // ordinary functions with some exceptions. For example, the language does not allow
6 // functions to be called in constant expressions - here the exception is made to allow it.
7 //
8 // Each implementation provides its own version of this file. Each implementation can define
9 // the required set of operators and constructors in its own fashion.
10 //
11 // The extended language syntax is only present when compiling this file. It is implicitly
12 // included at the very beginning of the compiled shader, so no built-in functions can be
13 // used.
14 //
15 // To communicate with the implementation, a special extended "__asm" keyword is used, followed
16 // by an instruction name (any valid identifier), a destination variable identifier and a
17 // a list of zero or more source variable identifiers. A variable identifier is a variable name
18 // declared earlier in the code (as a function parameter, local or global variable).
19 // An instruction name designates an instruction that must be exported by the implementation.
20 // Each instruction receives data from source variable identifiers and returns data in the
21 // destination variable identifier.
22 //
23 // It is up to the implementation how to define a particular operator or constructor. If it is
24 // expected to being used rarely, it can be defined in terms of other operators and constructors,
25 // for example:
26 //
27 // ivec2 __operator + (const ivec2 x, const ivec2 y) {
28 // return ivec2 (x[0] + y[0], x[1] + y[1]);
29 // }
30 //
31 // If a particular operator or constructor is expected to be used very often or is an atomic
32 // operation (that is, an operation that cannot be expressed in terms of other operations or
33 // would create a dependency cycle) it must be defined using one or more __asm constructs.
34 //
35 // Each implementation must define constructors for all scalar types (bool, float, int).
36 // There are 9 scalar-to-scalar constructors (including identity constructors). However,
37 // since the language introduces special constructors (like matrix constructor with a single
38 // scalar value), implementations must also implement these cases.
39 // The compiler provides the following algorithm when resolving a constructor:
40 // - try to find a constructor with a prototype matching ours,
41 // - if no constructor is found and this is a scalar-to-scalar constructor, raise an error,
42 // - if a constructor is found, execute it and return,
43 // - count the size of the constructor parameter list - if it is less than the size of
44 // our constructor's type, raise an error,
45 // - for each parameter in the list do a recursive constructor matching for appropriate
46 // scalar fields in the constructed variable,
47 //
48 // Each implementation must also define a set of operators that deal with built-in data types.
49 // There are four kinds of operators:
50 // 1) Operators that are implemented only by the compiler: "()" (function call), "," (sequence)
51 // and "?:" (selection).
52 // 2) Operators that are implemented by the compiler by expressing it in terms of other operators:
53 // - "." (field selection) - translated to subscript access,
54 // - "&&" (logical and) - translated to "<left_expr> ? <right_expr> : false",
55 // - "||" (logical or) - translated to "<left_expr> ? true : <right_expr>",
56 // 3) Operators that can be defined by the implementation and if the required prototype is not
57 // found, standard behaviour is used:
58 // - "==", "!=", "=" (equality, assignment) - compare or assign matching fields one-by-one;
59 // note that at least operators for scalar data types must be defined by the implementation
60 // to get it work,
61 // 4) All other operators not mentioned above. If no required prototype is found, an error is
62 // raised. An implementation must follow the language specification to provide all valid
63 // operator prototypes.
64 //
65
66 int __constructor (const float f) {
67 int i;
68 __asm float_to_int i, f;
69 return i;
70 }
71
72 bool __constructor (const int i) {
73 return i != 0;
74 }
75
76 bool __constructor (const float f) {
77 return f != 0.0;
78 }
79
80 int __constructor (const bool b) {
81 return b ? 1 : 0;
82 }
83
84 float __constructor (const bool b) {
85 return b ? 1.0 : 0.0;
86 }
87
88 float __constructor (const int i) {
89 float f;
90 __asm int_to_float f, i;
91 return f;
92 }
93
94 bool __constructor (const bool b) {
95 return b;
96 }
97
98 int __constructor (const int i) {
99 return i;
100 }
101
102 float __constructor (const float f) {
103 return f;
104 }
105
106 vec2 __constructor (const float f) {
107 vec2 u;
108 u.x = f;
109 u.y = f;
110 return u;
111 }
112
113 vec2 __constructor (const int i) {
114 float x;
115 __asm int_to_float x, i;
116 return vec2 (x);
117 }
118
119 vec2 __constructor (const bool b) {
120 return vec2 (b ? 1.0 : 0.0);
121 }
122
123 vec3 __constructor (const float f) {
124 vec3 u;
125 u.x = f;
126 u.y = f;
127 u.z = f;
128 return u;
129 }
130
131 vec3 __constructor (const int i) {
132 float x;
133 __asm int_to_float x, i;
134 return vec3 (x);
135 }
136
137 vec3 __constructor (const bool b) {
138 return vec3 (b ? 1.0 : 0.0);
139 }
140
141 vec4 __constructor (const float f) {
142 vec4 u;
143 u.x = f;
144 u.y = f;
145 u.z = f;
146 u.w = f;
147 return u;
148 }
149
150 vec4 __constructor (const int i) {
151 float x;
152 __asm int_to_float x, i;
153 return vec4 (x);
154 }
155
156 vec4 __constructor (const bool b) {
157 return vec4 (b ? 1.0 : 0.0);
158 }
159
160 ivec2 __constructor (const int i) {
161 ivec2 u;
162 u.x = i;
163 u.y = i;
164 return u;
165 }
166
167 ivec2 __constructor (const float f) {
168 return ivec2 (int (f));
169 }
170
171 ivec2 __constructor (const bool b) {
172 return ivec2 (int (b));
173 }
174
175 ivec3 __constructor (const int i) {
176 ivec3 u;
177 u.x = i;
178 u.y = i;
179 u.z = i;
180 return u;
181 }
182
183 ivec3 __constructor (const float f) {
184 return ivec3 (int (f));
185 }
186
187 ivec3 __constructor (const bool b) {
188 return ivec3 (int (b));
189 }
190
191 ivec4 __constructor (const int i) {
192 ivec4 u;
193 u.x = i;
194 u.y = i;
195 u.z = i;
196 u.w = i;
197 return u;
198 }
199
200 ivec4 __constructor (const float f) {
201 return ivec4 (int (f));
202 }
203
204 ivec4 __constructor (const bool b) {
205 return ivec4 (int (b));
206 }
207
208 bvec2 __constructor (const bool b) {
209 bvec2 u;
210 u.x = b;
211 u.y = b;
212 return u;
213 }
214
215 bvec2 __constructor (const float f) {
216 return bvec2 (bool (f));
217 }
218
219 bvec2 __constructor (const int i) {
220 return bvec2 (bool (i));
221 }
222
223 bvec3 __constructor (const bool b) {
224 bvec3 u;
225 u.x = b;
226 u.y = b;
227 u.z = b;
228 return u;
229 }
230
231 bvec3 __constructor (const float f) {
232 return bvec3 (bool (f));
233 }
234
235 bvec3 __constructor (const int i) {
236 return bvec3 (bool (i));
237 }
238
239 bvec4 __constructor (const bool b) {
240 bvec4 u;
241 u.x = b;
242 u.y = b;
243 u.z = b;
244 u.w = b;
245 return u;
246 }
247
248 bvec4 __constructor (const float f) {
249 return bvec4 (bool (f));
250 }
251
252 bvec4 __constructor (const int i) {
253 return bvec4 (bool (i));
254 }
255
256 mat2 __constructor (const float f) {
257 mat2 m;
258 m[0].x = f;
259 m[0].y = 0.0;
260 m[1].x = 0.0;
261 m[1].y = f;
262 return m;
263 }
264
265 mat2 __constructor (const int i) {
266 float x;
267 __asm int_to_float x, i;
268 return mat2 (x);
269 }
270
271 mat2 __constructor (const bool b) {
272 return mat2 (b ? 1.0 : 0.0);
273 }
274
275 mat3 __constructor (const float f) {
276 mat3 m;
277 m[0].x = f;
278 m[0].y = 0.0;
279 m[0].z = 0.0;
280 m[1].x = 0.0;
281 m[1].y = f;
282 m[1].z = 0.0;
283 m[2].x = 0.0;
284 m[2].y = 0.0;
285 m[2].z = f;
286 return m;
287 }
288
289 mat3 __constructor (const int i) {
290 float x;
291 __asm int_to_float x, i;
292 return mat3 (x);
293 }
294
295 mat3 __constructor (const bool b) {
296 return mat3 (b ? 1.0 : 0.0);
297 }
298
299 mat4 __constructor (const float f) {
300 mat4 m;
301 m[0].x = f;
302 m[0].y = 0.0;
303 m[0].z = 0.0;
304 m[0].w = 0.0;
305 m[1].x = 0.0;
306 m[1].y = f;
307 m[1].z = 0.0;
308 m[1].w = 0.0;
309 m[2].x = 0.0;
310 m[2].y = 0.0;
311 m[2].z = f;
312 m[2].w = 0.0;
313 m[3].x = 0.0;
314 m[3].y = 0.0;
315 m[3].z = 0.0;
316 m[3].w = f;
317 return m;
318 }
319
320 mat4 __constructor (const int i) {
321 float x;
322 __asm int_to_float x, i;
323 return mat4 (x);
324 }
325
326 mat4 __constructor (const bool b) {
327 return mat4 (b ? 1.0 : 0.0);
328 }
329
330 void __operator += (inout float a, const float b) {
331 __asm float_add a, a, b;
332 }
333
334 float __operator - (const float a) {
335 float b;
336 __asm float_negate b, a;
337 return b;
338 }
339
340 void __operator -= (inout float a, const float b) {
341 float c;
342 __asm float_negate c, b;
343 __asm float_add a, a, c;
344 }
345
346 void __operator *= (inout float a, const float b) {
347 __asm float_multiply a, a, b;
348 }
349
350 void __operator /= (inout float a, const float b) {
351 __asm float_divide a, a, b;
352 }
353
354 float __operator + (const float a, const float b) {
355 float c;
356 __asm float_add c, a, b;
357 return c;
358 }
359
360 void __operator += (inout int a, const int b) {
361 a = int (float (a) + float (b));
362 }
363
364 int __operator - (const int a) {
365 float x;
366 int b;
367 __asm int_to_float x, a;
368 __asm float_negate x, x;
369 __asm float_to_int b, x;
370 return b;
371 }
372
373 void __operator -= (inout int a, const int b) {
374 a += -b;
375 }
376
377 float __operator * (const float a, const float b) {
378 float c;
379 __asm float_multiply c, a, b;
380 return c;
381 }
382
383 void __operator *= (inout int a, const int b) {
384 a = int (float (a) * float (b));
385 }
386
387 float __operator / (const float a, const float b) {
388 float c;
389 __asm float_divide c, a, b;
390 return c;
391 }
392
393 void __operator /= (inout int a, const int b) {
394 a = int (float (a) / float (b));
395 }
396
397 void __operator += (inout vec2 v, const vec2 u) {
398 v.x += u.x;
399 v.y += u.y;
400 }
401
402 void __operator -= (inout vec2 v, const vec2 u) {
403 v.x -= u.x;
404 v.y -= u.y;
405 }
406
407 void __operator *= (inout vec2 v, const vec2 u) {
408 v.x *= u.x;
409 v.y *= u.y;
410 }
411
412 void __operator /= (inout vec2 v, const vec2 u) {
413 v.x /= u.x;
414 v.y /= u.y;
415 }
416
417 void __operator += (inout vec3 v, const vec3 u) {
418 v.x += u.x;
419 v.y += u.y;
420 v.z += u.z;
421 }
422
423 void __operator -= (inout vec3 v, const vec3 u) {
424 v.x -= u.x;
425 v.y -= u.y;
426 v.z -= u.z;
427 }
428
429 void __operator *= (inout vec3 v, const vec3 u) {
430 v.x *= u.x;
431 v.y *= u.y;
432 v.z *= u.z;
433 }
434
435 void __operator /= (inout vec3 v, const vec3 u) {
436 v.x /= u.x;
437 v.y /= u.y;
438 v.z /= u.z;
439 }
440
441 void __operator += (inout vec4 v, const vec4 u) {
442 v.x += u.x;
443 v.y += u.y;
444 v.z += u.z;
445 v.w += u.w;
446 }
447
448 void __operator -= (inout vec4 v, const vec4 u) {
449 v.x -= u.x;
450 v.y -= u.y;
451 v.z -= u.z;
452 v.w -= u.w;
453 }
454
455 void __operator *= (inout vec4 v, const vec4 u) {
456 v.x *= u.x;
457 v.y *= u.y;
458 v.z *= u.z;
459 v.w *= u.w;
460 }
461
462 void __operator /= (inout vec4 v, const vec4 u) {
463 v.x /= u.x;
464 v.y /= u.y;
465 v.z /= u.z;
466 v.w /= u.w;
467 }
468
469 void __operator += (inout ivec2 v, const ivec2 u) {
470 v.x += u.x;
471 v.y += u.y;
472 }
473
474 void __operator -= (inout ivec2 v, const ivec2 u) {
475 v.x -= u.x;
476 v.y -= u.y;
477 }
478
479 void __operator *= (inout ivec2 v, const ivec2 u) {
480 v.x *= u.x;
481 v.y *= u.y;
482 }
483
484 void __operator /= (inout ivec2 v, const ivec2 u) {
485 v.x /= u.x;
486 v.y /= u.y;
487 }
488
489 void __operator += (inout ivec3 v, const ivec3 u) {
490 v.x += u.x;
491 v.y += u.y;
492 v.z += u.z;
493 }
494
495 void __operator -= (inout ivec3 v, const ivec3 u) {
496 v.x -= u.x;
497 v.y -= u.y;
498 v.z -= u.z;
499 }
500
501 void __operator *= (inout ivec3 v, const ivec3 u) {
502 v.x *= u.x;
503 v.y *= u.y;
504 v.z *= u.z;
505 }
506
507 void __operator /= (inout ivec3 v, const ivec3 u) {
508 v.x /= u.x;
509 v.y /= u.y;
510 v.z /= u.z;
511 }
512
513 void __operator += (inout ivec4 v, const ivec4 u) {
514 v.x += u.x;
515 v.y += u.y;
516 v.z += u.z;
517 v.w += u.w;
518 }
519
520 void __operator -= (inout ivec4 v, const ivec4 u) {
521 v.x -= u.x;
522 v.y -= u.y;
523 v.z -= u.z;
524 v.w -= u.w;
525 }
526
527 void __operator *= (inout ivec4 v, const ivec4 u) {
528 v.x *= u.x;
529 v.y *= u.y;
530 v.z *= u.z;
531 v.w *= u.w;
532 }
533
534 void __operator /= (inout ivec4 v, const ivec4 u) {
535 v.x /= u.x;
536 v.y /= u.y;
537 v.z /= u.z;
538 v.w /= u.w;
539 }
540
541 void __operator += (inout mat2 m, const mat2 n) {
542 m[0] += n[0];
543 m[1] += n[1];
544 }
545
546 void __operator -= (inout mat2 m, const mat2 n) {
547 m[0] -= n[0];
548 m[1] -= n[1];
549 }
550
551 vec2 __operator * (const mat2 m, const vec2 v) {
552 vec2 u;
553 u.x = v.x * m[0].x + v.y * m[1].x;
554 u.y = v.x * m[0].y + v.y * m[1].y;
555 return u;
556 }
557
558 mat2 __operator * (const mat2 m, const mat2 n) {
559 mat2 o;
560 o[0] = m * n[0];
561 o[1] = m * n[1];
562 return o;
563 }
564
565 void __operator *= (inout mat2 m, const mat2 n) {
566 m = m * n;
567 }
568
569 void __operator /= (inout mat2 m, const mat2 n) {
570 m[0] /= n[0];
571 m[1] /= n[1];
572 }
573
574 void __operator += (inout mat3 m, const mat3 n) {
575 m[0] += n[0];
576 m[1] += n[1];
577 m[2] += n[2];
578 }
579
580 void __operator -= (inout mat3 m, const mat3 n) {
581 m[0] -= n[0];
582 m[1] -= n[1];
583 m[2] -= n[2];
584 }
585
586 vec3 __operator * (const mat3 m, const vec3 v) {
587 vec3 u;
588 u.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x;
589 u.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y;
590 u.z = v.x * m[0].z + v.y * m[1].z + v.z * m[2].z;
591 return u;
592 }
593
594 mat3 __operator * (const mat3 m, const mat3 n) {
595 mat3 o;
596 o[0] = m * n[0];
597 o[1] = m * n[1];
598 o[2] = m * n[2];
599 return o;
600 }
601
602 void __operator *= (inout mat3 m, const mat3 n) {
603 m = m * n;
604 }
605
606 void __operator /= (inout mat3 m, const mat3 n) {
607 m[0] /= n[0];
608 m[1] /= n[1];
609 m[2] /= n[2];
610 }
611
612 void __operator += (inout mat4 m, const mat4 n) {
613 m[0] += n[0];
614 m[1] += n[1];
615 m[2] += n[2];
616 m[3] += n[3];
617 }
618
619 void __operator -= (inout mat4 m, const mat4 n) {
620 m[0] -= n[0];
621 m[1] -= n[1];
622 m[2] -= n[2];
623 m[3] -= n[3];
624 }
625
626 vec4 __operator * (const mat4 m, const vec4 v) {
627 vec4 u;
628 u.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x;
629 u.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y;
630 u.z = v.x * m[0].z + v.y * m[1].z + v.z * m[2].z + v.w * m[3].z;
631 u.w = v.x * m[0].w + v.y * m[1].w + v.z * m[2].w + v.w * m[3].w;
632 return u;
633 }
634
635 mat4 __operator * (const mat4 m, const mat4 n) {
636 mat4 o;
637 o[0] = m * n[0];
638 o[1] = m * n[1];
639 o[2] = m * n[2];
640 o[3] = m * n[3];
641 return o;
642 }
643
644 void __operator *= (inout mat4 m, const mat4 n) {
645 m = m * n;
646 }
647
648 void __operator /= (inout mat4 m, const mat4 n) {
649 m[0] /= n[0];
650 m[1] /= n[1];
651 m[2] /= n[2];
652 m[3] /= n[3];
653 }
654
655 void __operator += (inout vec2 v, const float a) {
656 v.x += a;
657 v.y += a;
658 }
659
660 void __operator -= (inout vec2 v, const float a) {
661 v.x -= a;
662 v.y -= a;
663 }
664
665 void __operator *= (inout vec2 v, const float a) {
666 v.x *= a;
667 v.y *= a;
668 }
669
670 void __operator /= (inout vec2 v, const float a) {
671 v.x /= a;
672 v.y /= a;
673 }
674
675 void __operator += (inout vec3 v, const float a) {
676 v.x += a;
677 v.y += a;
678 v.z += a;
679 }
680
681 void __operator -= (inout vec3 v, const float a) {
682 v.x -= a;
683 v.y -= a;
684 v.z -= a;
685 }
686
687 void __operator *= (inout vec3 v, const float a) {
688 v.x *= a;
689 v.y *= a;
690 v.z *= a;
691 }
692
693 void __operator /= (inout vec3 v, const float a) {
694 v.x /= a;
695 v.y /= a;
696 v.z /= a;
697 }
698
699 void __operator += (inout vec4 v, const float a) {
700 v.x += a;
701 v.y += a;
702 v.z += a;
703 v.w += a;
704 }
705
706 void __operator -= (inout vec4 v, const float a) {
707 v.x -= a;
708 v.y -= a;
709 v.z -= a;
710 v.w -= a;
711 }
712
713 void __operator *= (inout vec4 v, const float a) {
714 v.x *= a;
715 v.y *= a;
716 v.z *= a;
717 v.w *= a;
718 }
719
720 void __operator /= (inout vec4 v, const float a) {
721 v.x /= a;
722 v.y /= a;
723 v.z /= a;
724 v.w /= a;
725 }
726
727 void __operator += (inout mat2 m, const float a) {
728 m[0] += a;
729 m[1] += a;
730 }
731
732 void __operator -= (inout mat2 m, const float a) {
733 m[0] -= a;
734 m[1] -= a;
735 }
736
737 void __operator *= (inout mat2 m, const float a) {
738 m[0] *= a;
739 m[1] *= a;
740 }
741
742 void __operator /= (inout mat2 m, const float a) {
743 m[0] /= a;
744 m[1] /= a;
745 }
746
747 void __operator += (inout mat3 m, const float a) {
748 m[0] += a;
749 m[1] += a;
750 m[2] += a;
751 }
752
753 void __operator -= (inout mat3 m, const float a) {
754 m[0] -= a;
755 m[1] -= a;
756 m[2] -= a;
757 }
758
759 void __operator *= (inout mat3 m, const float a) {
760 m[0] *= a;
761 m[1] *= a;
762 m[2] *= a;
763 }
764
765 void __operator /= (inout mat3 m, const float a) {
766 m[0] /= a;
767 m[1] /= a;
768 m[2] /= a;
769 }
770
771 void __operator += (inout mat4 m, const float a) {
772 m[0] += a;
773 m[1] += a;
774 m[2] += a;
775 m[3] += a;
776 }
777
778 void __operator -= (inout mat4 m, const float a) {
779 m[0] -= a;
780 m[1] -= a;
781 m[2] -= a;
782 m[3] -= a;
783 }
784
785 void __operator *= (inout mat4 m, const float a) {
786 m[0] *= a;
787 m[1] *= a;
788 m[2] *= a;
789 m[3] *= a;
790 }
791
792 void __operator /= (inout mat4 m, const float a) {
793 m[0] /= a;
794 m[1] /= a;
795 m[2] /= a;
796 m[3] /= a;
797 }
798
799 vec2 __operator * (const vec2 v, const mat2 m) {
800 vec2 u;
801 u.x = v.x * m[0].x + v.y * m[0].y;
802 u.y = v.x * m[1].x + v.y * m[1].y;
803 return u;
804 }
805
806 void __operator *= (inout vec2 v, const mat2 m) {
807 v = v * m;
808 }
809
810 vec3 __operator * (const vec3 v, const mat3 m) {
811 vec3 u;
812 u.x = v.x * m[0].x + v.y * m[0].y + v.z * m[0].z;
813 u.y = v.x * m[1].x + v.y * m[1].y + v.z * m[1].z;
814 u.z = v.x * m[2].x + v.y * m[2].y + v.z * m[2].z;
815 return u;
816 }
817
818 void __operator *= (inout vec3 v, const mat3 m) {
819 v = v * m;
820 }
821
822 vec4 __operator * (const vec4 v, const mat4 m) {
823 vec4 u;
824 u.x = v.x * m[0].x + v.y * m[0].y + v.z * m[0].z + v.w * m[0].w;
825 u.y = v.x * m[1].x + v.y * m[1].y + v.z * m[1].z + v.w * m[1].w;
826 u.z = v.x * m[2].x + v.y * m[2].y + v.z * m[2].z + v.w * m[2].w;
827 u.w = v.x * m[3].x + v.y * m[3].y + v.z * m[3].z + v.w * m[3].w;
828 return u;
829 }
830
831 void __operator *= (inout vec4 v, const mat4 m) {
832 v = v * m;
833 }
834
835 float __operator - (const float a, const float b) {
836 float c;
837 __asm float_negate c, b;
838 __asm float_add c, a, c;
839 return c;
840 }
841
842 int __operator + (const int a, const int b) {
843 float x, y;
844 int c;
845 __asm int_to_float x, a;
846 __asm int_to_float y, b;
847 __asm float_add x, x, y;
848 __asm float_to_int c, x;
849 return c;
850 }
851
852 int __operator - (const int a, const int b) {
853 float x, y;
854 int c;
855 __asm int_to_float x, a;
856 __asm int_to_float y, b;
857 __asm float_negate y, y;
858 __asm float_add x, x, y;
859 __asm float_to_int c, x;
860 return c;
861 }
862
863 int __operator * (const int a, const int b) {
864 float x, y;
865 int c;
866 __asm int_to_float x, a;
867 __asm int_to_float y, b;
868 __asm float_multiply x, x, y;
869 __asm float_to_int c, x;
870 return c;
871 }
872
873 int __operator / (const int a, const int b) {
874 float x, y;
875 int c;
876 __asm int_to_float x, a;
877 __asm int_to_float y, b;
878 __asm float_divide x, x, y;
879 __asm float_to_int c, x;
880 return c;
881 }
882
883 vec2 __operator + (const vec2 v, const vec2 u) {
884 vec2 t;
885 t.x = v.x + u.x;
886 t.y = v.y + u.y;
887 return t;
888 }
889
890 vec2 __operator - (const vec2 v, const vec2 u) {
891 vec2 t;
892 t.x = v.x - u.x;
893 t.y = v.y - u.y;
894 return t;
895 }
896
897 vec2 __operator * (const vec2 v, const vec2 u) {
898 vec2 t;
899 t.x = v.x * u.x;
900 t.y = v.y * u.y;
901 return t;
902 }
903
904 vec2 __operator / (const vec2 v, const vec2 u) {
905 vec2 t;
906 t.x = v.x / u.x;
907 t.y = v.y / u.y;
908 return t;
909 }
910
911 vec3 __operator + (const vec3 v, const vec3 u) {
912 vec3 t;
913 t.x = v.x + u.x;
914 t.y = v.y + u.y;
915 t.z = v.z + u.z;
916 return t;
917 }
918
919 vec3 __operator - (const vec3 v, const vec3 u) {
920 vec3 t;
921 t.x = v.x - u.x;
922 t.y = v.y - u.y;
923 t.z = v.z - u.z;
924 return t;
925 }
926
927 vec3 __operator * (const vec3 v, const vec3 u) {
928 vec3 t;
929 t.x = v.x * u.x;
930 t.y = v.y * u.y;
931 t.z = v.z * u.z;
932 return t;
933 }
934
935 vec3 __operator / (const vec3 v, const vec3 u) {
936 vec3 t;
937 t.x = v.x / u.x;
938 t.y = v.y / u.y;
939 t.z = v.z / u.z;
940 return t;
941 }
942
943 vec4 __operator + (const vec4 v, const vec4 u) {
944 vec4 t;
945 t.x = v.x + u.x;
946 t.y = v.y + u.y;
947 t.z = v.z + u.z;
948 t.w = v.w + u.w;
949 return t;
950 }
951
952 vec4 __operator - (const vec4 v, const vec4 u) {
953 vec4 t;
954 t.x = v.x - u.x;
955 t.y = v.y - u.y;
956 t.z = v.z - u.z;
957 t.w = v.w - u.w;
958 return t;
959 }
960
961 vec4 __operator * (const vec4 v, const vec4 u) {
962 vec4 t;
963 t.x = v.x * u.x;
964 t.y = v.y * u.y;
965 t.z = v.z * u.z;
966 t.w = v.w * u.w;
967 return t;
968 }
969
970 vec4 __operator / (const vec4 v, const vec4 u) {
971 vec4 t;
972 t.x = v.x / u.x;
973 t.y = v.y / u.y;
974 t.z = v.z / u.z;
975 t.w = v.w / u.w;
976 return t;
977 }
978
979 ivec2 __operator + (const ivec2 v, const ivec2 u) {
980 ivec2 t;
981 t.x = v.x + u.x;
982 t.y = v.y + u.y;
983 return t;
984 }
985
986 ivec2 __operator - (const ivec2 v, const ivec2 u) {
987 ivec2 t;
988 t.x = v.x - u.x;
989 t.y = v.y - u.y;
990 return t;
991 }
992
993 ivec2 __operator * (const ivec2 v, const ivec2 u) {
994 ivec2 t;
995 t.x = v.x * u.x;
996 t.y = v.y * u.y;
997 return t;
998 }
999
1000 ivec2 __operator / (const ivec2 v, const ivec2 u) {
1001 ivec2 t;
1002 t.x = v.x / u.x;
1003 t.y = v.y / u.y;
1004 return t;
1005 }
1006
1007 ivec3 __operator + (const ivec3 v, const ivec3 u) {
1008 ivec3 t;
1009 t.x = v.x + u.x;
1010 t.y = v.y + u.y;
1011 t.z = v.z + u.z;
1012 return t;
1013 }
1014
1015 ivec3 __operator - (const ivec3 v, const ivec3 u) {
1016 ivec3 t;
1017 t.x = v.x - u.x;
1018 t.y = v.y - u.y;
1019 t.z = v.z - u.z;
1020 return t;
1021 }
1022
1023 ivec3 __operator * (const ivec3 v, const ivec3 u) {
1024 ivec3 t;
1025 t.x = v.x * u.x;
1026 t.y = v.y * u.y;
1027 t.z = v.z * u.z;
1028 return t;
1029 }
1030
1031 ivec3 __operator / (const ivec3 v, const ivec3 u) {
1032 ivec3 t;
1033 t.x = v.x / u.x;
1034 t.y = v.y / u.y;
1035 t.z = v.z / u.z;
1036 return t;
1037 }
1038
1039 ivec4 __operator + (const ivec4 v, const ivec4 u) {
1040 ivec4 t;
1041 t.x = v.x + u.x;
1042 t.y = v.y + u.y;
1043 t.z = v.z + u.z;
1044 t.w = v.w + u.w;
1045 return t;
1046 }
1047
1048 ivec4 __operator - (const ivec4 v, const ivec4 u) {
1049 ivec4 t;
1050 t.x = v.x - u.x;
1051 t.y = v.y - u.y;
1052 t.z = v.z - u.z;
1053 t.w = v.w - u.w;
1054 return t;
1055 }
1056
1057 ivec4 __operator * (const ivec4 v, const ivec4 u) {
1058 ivec4 t;
1059 t.x = v.x * u.x;
1060 t.y = v.y * u.y;
1061 t.z = v.z * u.z;
1062 t.w = v.w * u.w;
1063 return t;
1064 }
1065
1066 ivec4 __operator / (const ivec4 v, const ivec4 u) {
1067 ivec4 t;
1068 t.x = v.x / u.x;
1069 t.y = v.y / u.y;
1070 t.z = v.z / u.z;
1071 t.w = v.w / u.w;
1072 return t;
1073 }
1074
1075 mat2 __operator + (const mat2 m, const mat2 n) {
1076 mat2 o;
1077 o[0] = m[0] + n[0];
1078 o[1] = m[1] + n[1];
1079 return o;
1080 }
1081
1082 mat2 __operator - (const mat2 m, const mat2 n) {
1083 mat2 o;
1084 o[0] = m[0] - n[0];
1085 o[1] = m[1] - n[1];
1086 return o;
1087 }
1088
1089 mat2 __operator / (const mat2 m, const mat2 n) {
1090 mat2 o;
1091 o[0] = m[0] / n[0];
1092 o[1] = m[1] / n[1];
1093 return o;
1094 }
1095
1096 mat3 __operator + (const mat3 m, const mat3 n) {
1097 mat3 o;
1098 o[0] = m[0] + n[0];
1099 o[1] = m[1] + n[1];
1100 o[2] = m[2] + n[2];
1101 return o;
1102 }
1103
1104 mat3 __operator - (const mat3 m, const mat3 n) {
1105 mat3 o;
1106 o[0] = m[0] - n[0];
1107 o[1] = m[1] - n[1];
1108 o[2] = m[2] - n[2];
1109 return o;
1110 }
1111
1112 mat3 __operator / (const mat3 m, const mat3 n) {
1113 mat3 o;
1114 o[0] = m[0] / n[0];
1115 o[1] = m[1] / n[1];
1116 o[2] = m[2] / n[2];
1117 return o;
1118 }
1119
1120 mat4 __operator + (const mat4 m, const mat4 n) {
1121 mat4 o;
1122 o[0] = m[0] + n[0];
1123 o[1] = m[1] + n[1];
1124 o[2] = m[2] + n[2];
1125 o[3] = m[3] + n[3];
1126 return o;
1127 }
1128
1129 mat4 __operator - (const mat4 m, const mat4 n) {
1130 mat4 o;
1131 o[0] = m[0] - n[0];
1132 o[1] = m[1] - n[1];
1133 o[2] = m[2] - n[2];
1134 o[3] = m[3] - n[3];
1135 return o;
1136 }
1137
1138 mat4 __operator / (const mat4 m, const mat4 n) {
1139 mat4 o;
1140 o[0] = m[0] / n[0];
1141 o[1] = m[1] / n[1];
1142 o[2] = m[2] / n[2];
1143 o[3] = m[3] / n[3];
1144 return o;
1145 }
1146
1147 vec2 __operator + (const float a, const vec2 u) {
1148 vec2 t;
1149 t.x = a + u.x;
1150 t.y = a + u.y;
1151 return t;
1152 }
1153
1154 vec2 __operator + (const vec2 v, const float b) {
1155 vec2 t;
1156 t.x = v.x + b;
1157 t.y = v.y + b;
1158 return t;
1159 }
1160
1161 vec2 __operator - (const float a, const vec2 u) {
1162 vec2 t;
1163 t.x = a - u.x;
1164 t.y = a - u.y;
1165 return t;
1166 }
1167
1168 vec2 __operator - (const vec2 v, const float b) {
1169 vec2 t;
1170 t.x = v.x - b;
1171 t.y = v.y - b;
1172 return t;
1173 }
1174
1175 vec2 __operator * (const float a, const vec2 u) {
1176 vec2 t;
1177 t.x = a * u.x;
1178 t.y = a * u.y;
1179 return t;
1180 }
1181
1182 vec2 __operator * (const vec2 v, const float b) {
1183 vec2 t;
1184 t.x = v.x * b;
1185 t.y = v.y * b;
1186 return t;
1187 }
1188
1189 vec2 __operator / (const float a, const vec2 u) {
1190 vec2 t;
1191 t.x = a / u.x;
1192 t.y = a / u.y;
1193 return t;
1194 }
1195
1196 vec2 __operator / (const vec2 v, const float b) {
1197 vec2 t;
1198 t.x = v.x / b;
1199 t.y = v.y / b;
1200 return t;
1201 }
1202
1203 vec3 __operator + (const float a, const vec3 u) {
1204 vec3 t;
1205 t.x = a + u.x;
1206 t.y = a + u.y;
1207 t.z = a + u.z;
1208 return t;
1209 }
1210
1211 vec3 __operator + (const vec3 v, const float b) {
1212 vec3 t;
1213 t.x = v.x + b;
1214 t.y = v.y + b;
1215 t.z = v.z + b;
1216 return t;
1217 }
1218
1219 vec3 __operator - (const float a, const vec3 u) {
1220 vec3 t;
1221 t.x = a - u.x;
1222 t.y = a - u.y;
1223 t.z = a - u.z;
1224 return t;
1225 }
1226
1227 vec3 __operator - (const vec3 v, const float b) {
1228 vec3 t;
1229 t.x = v.x - b;
1230 t.y = v.y - b;
1231 t.z = v.z - b;
1232 return t;
1233 }
1234
1235 vec3 __operator * (const float a, const vec3 u) {
1236 vec3 t;
1237 t.x = a * u.x;
1238 t.y = a * u.y;
1239 t.z = a * u.z;
1240 return t;
1241 }
1242
1243 vec3 __operator * (const vec3 v, const float b) {
1244 vec3 t;
1245 t.x = v.x * b;
1246 t.y = v.y * b;
1247 t.z = v.z * b;
1248 return t;
1249 }
1250
1251 vec3 __operator / (const float a, const vec3 u) {
1252 vec3 t;
1253 t.x = a / u.x;
1254 t.y = a / u.y;
1255 t.z = a / u.z;
1256 return t;
1257 }
1258
1259 vec3 __operator / (const vec3 v, const float b) {
1260 vec3 t;
1261 t.x = v.x / b;
1262 t.y = v.y / b;
1263 t.z = v.z / b;
1264 return t;
1265 }
1266
1267 vec4 __operator + (const float a, const vec4 u) {
1268 vec4 t;
1269 t.x = a + u.x;
1270 t.y = a + u.y;
1271 t.z = a + u.z;
1272 t.w = a + u.w;
1273 return t;
1274 }
1275
1276 vec4 __operator + (const vec4 v, const float b) {
1277 vec4 t;
1278 t.x = v.x + b;
1279 t.y = v.y + b;
1280 t.z = v.z + b;
1281 t.w = v.w + b;
1282 return t;
1283 }
1284
1285 vec4 __operator - (const float a, const vec4 u) {
1286 vec4 t;
1287 t.x = a - u.x;
1288 t.y = a - u.y;
1289 t.z = a - u.z;
1290 t.w = a - u.w;
1291 return t;
1292 }
1293
1294 vec4 __operator - (const vec4 v, const float b) {
1295 vec4 t;
1296 t.x = v.x - b;
1297 t.y = v.y - b;
1298 t.z = v.z - b;
1299 t.w = v.w - b;
1300 return t;
1301 }
1302
1303 vec4 __operator * (const float a, const vec4 u) {
1304 vec4 t;
1305 t.x = a * u.x;
1306 t.y = a * u.y;
1307 t.z = a * u.z;
1308 t.w = a * u.w;
1309 return t;
1310 }
1311
1312 vec4 __operator * (const vec4 v, const float b) {
1313 vec4 t;
1314 t.x = v.x * b;
1315 t.y = v.y * b;
1316 t.z = v.z * b;
1317 t.w = v.w * b;
1318 return t;
1319 }
1320
1321 vec4 __operator / (const float a, const vec4 u) {
1322 vec4 t;
1323 t.x = a / u.x;
1324 t.y = a / u.y;
1325 t.z = a / u.z;
1326 t.w = a / u.w;
1327 return t;
1328 }
1329
1330 vec4 __operator / (const vec4 v, const float b) {
1331 vec4 t;
1332 t.x = v.x / b;
1333 t.y = v.y / b;
1334 t.z = v.z / b;
1335 t.w = v.w / b;
1336 return t;
1337 }
1338
1339 mat2 __operator + (const float a, const mat2 n) {
1340 mat2 o;
1341 o[0] = a + n[0];
1342 o[1] = a + n[1];
1343 return o;
1344 }
1345
1346 mat2 __operator + (const mat2 m, const float b) {
1347 mat2 o;
1348 o[0] = m[0] + b;
1349 o[1] = m[1] + b;
1350 return o;
1351 }
1352
1353 mat2 __operator - (const float a, const mat2 n) {
1354 mat2 o;
1355 o[0] = a - n[0];
1356 o[1] = a - n[1];
1357 return o;
1358 }
1359
1360 mat2 __operator - (const mat2 m, const float b) {
1361 mat2 o;
1362 o[0] = m[0] - b;
1363 o[1] = m[1] - b;
1364 return o;
1365 }
1366
1367 mat2 __operator * (const float a, const mat2 n) {
1368 mat2 o;
1369 o[0] = a * n[0];
1370 o[1] = a * n[1];
1371 return o;
1372 }
1373
1374 mat2 __operator * (const mat2 m, const float b) {
1375 mat2 o;
1376 o[0] = m[0] * b;
1377 o[1] = m[1] * b;
1378 return o;
1379 }
1380
1381 mat2 __operator / (const float a, const mat2 n) {
1382 mat2 o;
1383 o[0] = a / n[0];
1384 o[1] = a / n[1];
1385 return o;
1386 }
1387
1388 mat2 __operator / (const mat2 m, const float b) {
1389 mat2 o;
1390 o[0] = m[0] / b;
1391 o[1] = m[1] / b;
1392 return o;
1393 }
1394
1395 mat3 __operator + (const float a, const mat3 n) {
1396 mat3 o;
1397 o[0] = a + n[0];
1398 o[1] = a + n[1];
1399 o[2] = a + n[2];
1400 return o;
1401 }
1402
1403 mat3 __operator + (const mat3 m, const float b) {
1404 mat3 o;
1405 o[0] = m[0] + b;
1406 o[1] = m[1] + b;
1407 o[2] = m[2] + b;
1408 return o;
1409 }
1410
1411 mat3 __operator - (const float a, const mat3 n) {
1412 mat3 o;
1413 o[0] = a - n[0];
1414 o[1] = a - n[1];
1415 o[2] = a - n[2];
1416 return o;
1417 }
1418
1419 mat3 __operator - (const mat3 m, const float b) {
1420 mat3 o;
1421 o[0] = m[0] - b;
1422 o[1] = m[1] - b;
1423 o[2] = m[2] - b;
1424 return o;
1425 }
1426
1427 mat3 __operator * (const float a, const mat3 n) {
1428 mat3 o;
1429 o[0] = a * n[0];
1430 o[1] = a * n[1];
1431 o[2] = a * n[2];
1432 return o;
1433 }
1434
1435 mat3 __operator * (const mat3 m, const float b) {
1436 mat3 o;
1437 o[0] = m[0] * b;
1438 o[1] = m[1] * b;
1439 o[2] = m[2] * b;
1440 return o;
1441 }
1442
1443 mat3 __operator / (const float a, const mat3 n) {
1444 mat3 o;
1445 o[0] = a / n[0];
1446 o[1] = a / n[1];
1447 o[2] = a / n[2];
1448 return o;
1449 }
1450
1451 mat3 __operator / (const mat3 m, const float b) {
1452 mat3 o;
1453 o[0] = m[0] / b;
1454 o[1] = m[1] / b;
1455 o[2] = m[2] / b;
1456 return o;
1457 }
1458
1459 mat4 __operator + (const float a, const mat4 n) {
1460 mat4 o;
1461 o[0] = a + n[0];
1462 o[1] = a + n[1];
1463 o[2] = a + n[2];
1464 o[3] = a + n[3];
1465 return o;
1466 }
1467
1468 mat4 __operator + (const mat4 m, const float b) {
1469 mat4 o;
1470 o[0] = m[0] + b;
1471 o[1] = m[1] + b;
1472 o[2] = m[2] + b;
1473 o[3] = m[3] + b;
1474 return o;
1475 }
1476
1477 mat4 __operator - (const float a, const mat4 n) {
1478 mat4 o;
1479 o[0] = a - n[0];
1480 o[1] = a - n[1];
1481 o[2] = a - n[2];
1482 o[3] = a - n[3];
1483 return o;
1484 }
1485
1486 mat4 __operator - (const mat4 m, const float b) {
1487 mat4 o;
1488 o[0] = m[0] - b;
1489 o[1] = m[1] - b;
1490 o[2] = m[2] - b;
1491 o[3] = m[3] - b;
1492 return o;
1493 }
1494
1495 mat4 __operator * (const float a, const mat4 n) {
1496 mat4 o;
1497 o[0] = a * n[0];
1498 o[1] = a * n[1];
1499 o[2] = a * n[2];
1500 o[3] = a * n[3];
1501 return o;
1502 }
1503
1504 mat4 __operator * (const mat4 m, const float b) {
1505 mat4 o;
1506 o[0] = m[0] * b;
1507 o[1] = m[1] * b;
1508 o[2] = m[2] * b;
1509 o[3] = m[3] * b;
1510 return o;
1511 }
1512
1513 mat4 __operator / (const float a, const mat4 n) {
1514 mat4 o;
1515 o[0] = a / n[0];
1516 o[1] = a / n[1];
1517 o[2] = a / n[2];
1518 o[3] = a / n[3];
1519 return o;
1520 }
1521
1522 mat4 __operator / (const mat4 m, const float b) {
1523 mat4 o;
1524 o[0] = m[0] / b;
1525 o[1] = m[1] / b;
1526 o[2] = m[2] / b;
1527 o[3] = m[3] / b;
1528 return o;
1529 }
1530
1531 ivec2 __operator + (const int a, const ivec2 u) {
1532 return ivec2 (a) + u;
1533 }
1534
1535 ivec2 __operator + (const ivec2 v, const int b) {
1536 return v + ivec2 (b);
1537 }
1538
1539 ivec2 __operator - (const int a, const ivec2 u) {
1540 return ivec2 (a) - u;
1541 }
1542
1543 ivec2 __operator - (const ivec2 v, const int b) {
1544 return v - ivec2 (b);
1545 }
1546
1547 ivec2 __operator * (const int a, const ivec2 u) {
1548 return ivec2 (a) * u;
1549 }
1550
1551 ivec2 __operator * (const ivec2 v, const int b) {
1552 return v * ivec2 (b);
1553 }
1554
1555 ivec2 __operator / (const int a, const ivec2 u) {
1556 return ivec2 (a) / u;
1557 }
1558
1559 ivec2 __operator / (const ivec2 v, const int b) {
1560 return v / ivec2 (b);
1561 }
1562
1563 ivec3 __operator + (const int a, const ivec3 u) {
1564 return ivec3 (a) + u;
1565 }
1566
1567 ivec3 __operator + (const ivec3 v, const int b) {
1568 return v + ivec3 (b);
1569 }
1570
1571 ivec3 __operator - (const int a, const ivec3 u) {
1572 return ivec3 (a) - u;
1573 }
1574
1575 ivec3 __operator - (const ivec3 v, const int b) {
1576 return v - ivec3 (b);
1577 }
1578
1579 ivec3 __operator * (const int a, const ivec3 u) {
1580 return ivec3 (a) * u;
1581 }
1582
1583 ivec3 __operator * (const ivec3 v, const int b) {
1584 return v * ivec3 (b);
1585 }
1586
1587 ivec3 __operator / (const int a, const ivec3 u) {
1588 return ivec3 (a) / u;
1589 }
1590
1591 ivec3 __operator / (const ivec3 v, const int b) {
1592 return v / ivec3 (b);
1593 }
1594
1595 ivec4 __operator + (const int a, const ivec4 u) {
1596 return ivec4 (a) + u;
1597 }
1598
1599 ivec4 __operator + (const ivec4 v, const int b) {
1600 return v + ivec4 (b);
1601 }
1602
1603 ivec4 __operator - (const int a, const ivec4 u) {
1604 return ivec4 (a) - u;
1605 }
1606
1607 ivec4 __operator - (const ivec4 v, const int b) {
1608 return v - ivec4 (b);
1609 }
1610
1611 ivec4 __operator * (const int a, const ivec4 u) {
1612 return ivec4 (a) * u;
1613 }
1614
1615 ivec4 __operator * (const ivec4 v, const int b) {
1616 return v * ivec4 (b);
1617 }
1618
1619 ivec4 __operator / (const int a, const ivec4 u) {
1620 return ivec4 (a) / u;
1621 }
1622
1623 ivec4 __operator / (const ivec4 v, const int b) {
1624 return v / ivec4 (b);
1625 }
1626
1627 vec2 __operator - (const vec2 v) {
1628 vec2 u;
1629 u.x = -v.x;
1630 u.y = -v.y;
1631 return u;
1632 }
1633
1634 vec3 __operator - (const vec3 v) {
1635 vec3 u;
1636 u.x = -v.x;
1637 u.y = -v.y;
1638 u.z = -v.z;
1639 return u;
1640 }
1641
1642 vec4 __operator - (const vec4 v) {
1643 vec4 u;
1644 u.x = -v.x;
1645 u.y = -v.y;
1646 u.z = -v.z;
1647 u.w = -v.w;
1648 return u;
1649 }
1650
1651 ivec2 __operator - (const ivec2 v) {
1652 ivec2 u;
1653 u.x = -v.x;
1654 u.y = -v.y;
1655 return u;
1656 }
1657
1658 ivec3 __operator - (const ivec3 v) {
1659 ivec3 u;
1660 u.x = -v.x;
1661 u.y = -v.y;
1662 u.z = -v.z;
1663 return u;
1664 }
1665
1666 ivec4 __operator - (const ivec4 v) {
1667 ivec4 u;
1668 u.x = -v.x;
1669 u.y = -v.y;
1670 u.z = -v.z;
1671 u.w = -v.w;
1672 return u;
1673 }
1674
1675 mat2 __operator - (const mat2 m) {
1676 mat2 n;
1677 n[0] = -m[0];
1678 n[1] = -m[1];
1679 return n;
1680 }
1681
1682 mat3 __operator - (const mat3 m) {
1683 mat3 n;
1684 n[0] = -m[0];
1685 n[1] = -m[1];
1686 n[2] = -m[2];
1687 return n;
1688 }
1689
1690 mat4 __operator - (const mat4 m) {
1691 mat4 n;
1692 n[0] = -m[0];
1693 n[1] = -m[1];
1694 n[2] = -m[2];
1695 n[3] = -m[3];
1696 return n;
1697 }
1698
1699 void __operator -- (inout float a) {
1700 a -= 1.0;
1701 }
1702
1703 void __operator -- (inout int a) {
1704 a -= 1;
1705 }
1706
1707 void __operator -- (inout vec2 v) {
1708 --v.x;
1709 --v.y;
1710 }
1711
1712 void __operator -- (inout vec3 v) {
1713 --v.x;
1714 --v.y;
1715 --v.z;
1716 }
1717
1718 void __operator -- (inout vec4 v) {
1719 --v.x;
1720 --v.y;
1721 --v.z;
1722 --v.w;
1723 }
1724
1725 void __operator -- (inout ivec2 v) {
1726 --v.x;
1727 --v.y;
1728 }
1729
1730 void __operator -- (inout ivec3 v) {
1731 --v.x;
1732 --v.y;
1733 --v.z;
1734 }
1735
1736 void __operator -- (inout ivec4 v) {
1737 --v.x;
1738 --v.y;
1739 --v.z;
1740 --v.w;
1741 }
1742
1743 void __operator -- (inout mat2 m) {
1744 --m[0];
1745 --m[1];
1746 }
1747
1748 void __operator -- (inout mat3 m) {
1749 --m[0];
1750 --m[1];
1751 --m[2];
1752 }
1753
1754 void __operator -- (inout mat4 m) {
1755 --m[0];
1756 --m[1];
1757 --m[2];
1758 --m[3];
1759 }
1760
1761 void __operator ++ (inout float a) {
1762 a += 1.0;
1763 }
1764
1765 void __operator ++ (inout int a) {
1766 a += 1;
1767 }
1768
1769 void __operator ++ (inout vec2 v) {
1770 ++v.x;
1771 ++v.y;
1772 }
1773
1774 void __operator ++ (inout vec3 v) {
1775 ++v.x;
1776 ++v.y;
1777 ++v.z;
1778 }
1779
1780 void __operator ++ (inout vec4 v) {
1781 ++v.x;
1782 ++v.y;
1783 ++v.z;
1784 ++v.w;
1785 }
1786
1787 void __operator ++ (inout ivec2 v) {
1788 ++v.x;
1789 ++v.y;
1790 }
1791
1792 void __operator ++ (inout ivec3 v) {
1793 ++v.x;
1794 ++v.y;
1795 ++v.z;
1796 }
1797
1798 void __operator ++ (inout ivec4 v) {
1799 ++v.x;
1800 ++v.y;
1801 ++v.z;
1802 ++v.w;
1803 }
1804
1805 void __operator ++ (inout mat2 m) {
1806 ++m[0];
1807 ++m[1];
1808 }
1809
1810 void __operator ++ (inout mat3 m) {
1811 ++m[0];
1812 ++m[1];
1813 ++m[2];
1814 }
1815
1816 void __operator ++ (inout mat4 m) {
1817 ++m[0];
1818 ++m[1];
1819 ++m[2];
1820 ++m[3];
1821 }
1822
1823 //
1824 // NOTE: postfix increment and decrement operators take additional dummy int parameter to
1825 // distinguish their prototypes from prefix ones.
1826 //
1827
1828 float __operator -- (inout float a, const int) {
1829 float b;
1830 b = a;
1831 --a;
1832 return b;
1833 }
1834
1835 int __operator -- (inout int a, const int) {
1836 int b;
1837 b = a;
1838 --a;
1839 return b;
1840 }
1841
1842 vec2 __operator -- (inout vec2 v, const int) {
1843 vec2 u;
1844 u = v;
1845 --v.x;
1846 --v.y;
1847 return u;
1848 }
1849
1850 vec3 __operator -- (inout vec3 v, const int) {
1851 vec3 u;
1852 u = v;
1853 --v.x;
1854 --v.y;
1855 --v.z;
1856 return u;
1857 }
1858
1859 vec4 __operator -- (inout vec4 v, const int) {
1860 vec4 u;
1861 u = v;
1862 --v.x;
1863 --v.y;
1864 --v.z;
1865 --v.w;
1866 return u;
1867 }
1868
1869 ivec2 __operator -- (inout ivec2 v, const int) {
1870 ivec2 u;
1871 u = v;
1872 --v.x;
1873 --v.y;
1874 return u;
1875 }
1876
1877 ivec3 __operator -- (inout ivec3 v, const int) {
1878 ivec3 u;
1879 u = v;
1880 --v.x;
1881 --v.y;
1882 --v.z;
1883 return u;
1884 }
1885
1886 ivec4 __operator -- (inout ivec4 v, const int) {
1887 ivec4 u;
1888 u = v;
1889 --v.x;
1890 --v.y;
1891 --v.z;
1892 --v.w;
1893 return u;
1894 }
1895
1896 mat2 __operator -- (inout mat2 m, const int) {
1897 mat2 n;
1898 n = m;
1899 --m[0];
1900 --m[1];
1901 return n;
1902 }
1903
1904 mat3 __operator -- (inout mat3 m, const int) {
1905 mat3 n;
1906 n = m;
1907 --m[0];
1908 --m[1];
1909 --m[2];
1910 return n;
1911 }
1912
1913 mat4 __operator -- (inout mat4 m, const int) {
1914 mat4 n;
1915 n = m;
1916 --m[0];
1917 --m[1];
1918 --m[2];
1919 --m[3];
1920 return n;
1921 }
1922
1923 float __operator ++ (inout float a, const int) {
1924 float b;
1925 b = a;
1926 ++a;
1927 return b;
1928 }
1929
1930 int __operator ++ (inout int a, const int) {
1931 int b;
1932 b = a;
1933 ++a;
1934 return b;
1935 }
1936
1937 vec2 __operator ++ (inout vec2 v, const int) {
1938 vec2 u;
1939 u = v;
1940 ++v.x;
1941 ++v.y;
1942 return u;
1943 }
1944
1945 vec3 __operator ++ (inout vec3 v, const int) {
1946 vec3 u;
1947 u = v;
1948 ++v.x;
1949 ++v.y;
1950 ++v.z;
1951 return u;
1952 }
1953
1954 vec4 __operator ++ (inout vec4 v, const int) {
1955 vec4 u;
1956 u = v;
1957 ++v.x;
1958 ++v.y;
1959 ++v.z;
1960 ++v.w;
1961 return u;
1962 }
1963
1964 ivec2 __operator ++ (inout ivec2 v, const int) {
1965 ivec2 u;
1966 u = v;
1967 ++v.x;
1968 ++v.y;
1969 return u;
1970 }
1971
1972 ivec3 __operator ++ (inout ivec3 v, const int) {
1973 ivec3 u;
1974 u = v;
1975 ++v.x;
1976 ++v.y;
1977 ++v.z;
1978 return u;
1979 }
1980
1981 ivec4 __operator ++ (inout ivec4 v, const int) {
1982 ivec4 u;
1983 u = v;
1984 ++v.x;
1985 ++v.y;
1986 ++v.z;
1987 ++v.w;
1988 return u;
1989 }
1990
1991 mat2 __operator ++ (inout mat2 m, const int) {
1992 mat2 n;
1993 n = m;
1994 --m[0];
1995 --m[1];
1996 return n;
1997 }
1998
1999 mat3 __operator ++ (inout mat3 m, const int) {
2000 mat3 n;
2001 n = m;
2002 --m[0];
2003 --m[1];
2004 --m[2];
2005 return n;
2006 }
2007
2008 mat4 __operator ++ (inout mat4 m, const int) {
2009 mat4 n;
2010 n = m;
2011 --m[0];
2012 --m[1];
2013 --m[2];
2014 --m[3];
2015 return n;
2016 }
2017
2018 bool __operator < (const float a, const float b) {
2019 bool c;
2020 __asm float_less c, a, b;
2021 return c;
2022 }
2023
2024 bool __operator < (const int a, const int b) {
2025 return float (a) < float (b);
2026 }
2027
2028 bool __operator > (const float a, const float b) {
2029 bool c;
2030 __asm float_less c, b, a;
2031 return c;
2032 }
2033
2034 bool __operator > (const int a, const int b) {
2035 return float (a) > float (b);
2036 }
2037
2038 bool __operator >= (const float a, const float b) {
2039 bool g, e;
2040 __asm float_less g, b, a;
2041 __asm float_equal e, a, b;
2042 return g || e;
2043 }
2044
2045 bool __operator >= (const int a, const int b) {
2046 return float (a) >= float (b);
2047 }
2048
2049 bool __operator <= (const float a, const float b) {
2050 bool g, e;
2051 __asm float_less g, a, b;
2052 __asm float_equal e, a, b;
2053 return g || e;
2054 }
2055
2056 bool __operator <= (const int a, const int b) {
2057 return float (a) <= float (b);
2058 }
2059
2060 bool __operator ^^ (const bool a, const bool b) {
2061 return a != b;
2062 }
2063
2064 //
2065 // These operators are handled internally by the compiler:
2066 //
2067 // bool __operator && (bool a, bool b) {
2068 // return a ? b : false;
2069 // }
2070 // bool __operator || (bool a, bool b) {
2071 // return a ? true : b;
2072 // }
2073 //
2074
2075 bool __operator ! (const bool a) {
2076 return a == false;
2077 }
2078
2079 //
2080 // mesa-specific extension functions.
2081 //
2082
2083 void print (const float f) {
2084 __asm float_print f;
2085 }
2086
2087 void print (const int i) {
2088 __asm int_print i;
2089 }
2090
2091 void print (const bool b) {
2092 __asm bool_print b;
2093 }
2094
2095 void print (const vec2 v) {
2096 print (v.x);
2097 print (v.y);
2098 }
2099
2100 void print (const vec3 v) {
2101 print (v.x);
2102 print (v.y);
2103 print (v.z);
2104 }
2105
2106 void print (const vec4 v) {
2107 print (v.x);
2108 print (v.y);
2109 print (v.z);
2110 print (v.w);
2111 }
2112
2113 void print (const ivec2 v) {
2114 print (v.x);
2115 print (v.y);
2116 }
2117
2118 void print (const ivec3 v) {
2119 print (v.x);
2120 print (v.y);
2121 print (v.z);
2122 }
2123
2124 void print (const ivec4 v) {
2125 print (v.x);
2126 print (v.y);
2127 print (v.z);
2128 print (v.w);
2129 }
2130
2131 void print (const bvec2 v) {
2132 print (v.x);
2133 print (v.y);
2134 }
2135
2136 void print (const bvec3 v) {
2137 print (v.x);
2138 print (v.y);
2139 print (v.z);
2140 }
2141
2142 void print (const bvec4 v) {
2143 print (v.x);
2144 print (v.y);
2145 print (v.z);
2146 print (v.w);
2147 }
2148
2149 void print (const mat2 m) {
2150 print (m[0]);
2151 print (m[1]);
2152 }
2153
2154 void print (const mat3 m) {
2155 print (m[0]);
2156 print (m[1]);
2157 print (m[2]);
2158 }
2159
2160 void print (const mat4 m) {
2161 print (m[0]);
2162 print (m[1]);
2163 print (m[2]);
2164 print (m[3]);
2165 }
2166
2167 void print (const sampler1D e) {
2168 __asm int_print e;
2169 }
2170
2171 void print (const sampler2D e) {
2172 __asm int_print e;
2173 }
2174
2175 void print (const sampler3D e) {
2176 __asm int_print e;
2177 }
2178
2179 void print (const samplerCube e) {
2180 __asm int_print e;
2181 }
2182
2183 void print (const sampler1DShadow e) {
2184 __asm int_print e;
2185 }
2186
2187 void print (const sampler2DShadow e) {
2188 __asm int_print e;
2189 }
2190