Merge branch 'origin' into glsl-compiler-1
[mesa.git] / src / mesa / shader / slang / library / slang_core.gc
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 2006 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 //
26 // This file defines nearly all constructors and operators for built-in data
27 // types, using extended language syntax. In general, compiler treats
28 // constructors and operators as ordinary functions with some exceptions.
29 // For example, the language does not allow functions to be called in
30 // constant expressions - here the exception is made to allow it.
31 //
32 // Each implementation provides its own version of this file. Each
33 // implementation can define the required set of operators and constructors
34 // in its own fashion.
35 //
36 // The extended language syntax is only present when compiling this file.
37 // It is implicitly included at the very beginning of the compiled shader,
38 // so no built-in functions can be used.
39 //
40 // To communicate with the implementation, a special extended "__asm" keyword
41 // is used, followed by an instruction name (any valid identifier), a
42 // destination variable identifier and a list of zero or more source
43 // variable identifiers.
44 //
45 // A variable identifier is a variable name declared earlier in the code
46 // (as a function parameter, local or global variable).
47 //
48 // An instruction name designates an instruction that must be exported
49 // by the implementation. Each instruction receives data from source
50 // variable identifiers and returns data in the destination variable
51 // identifier.
52 //
53 // It is up to the implementation how to define a particular operator
54 // or constructor. If it is expected to being used rarely, it can be
55 // defined in terms of other operators and constructors,
56 // for example:
57 //
58 // ivec2 __operator + (const ivec2 x, const ivec2 y) {
59 // return ivec2 (x[0] + y[0], x[1] + y[1]);
60 // }
61 //
62 // If a particular operator or constructor is expected to be used very
63 // often or is an atomic operation (that is, an operation that cannot be
64 // expressed in terms of other operations or would create a dependency
65 // cycle) it must be defined using one or more __asm constructs.
66 //
67 // Each implementation must define constructors for all scalar types
68 // (bool, float, int). There are 9 scalar-to-scalar constructors
69 // (including identity constructors). However, since the language
70 // introduces special constructors (like matrix constructor with a single
71 // scalar value), implementations must also implement these cases.
72 // The compiler provides the following algorithm when resolving a constructor:
73 // - try to find a constructor with a prototype matching ours,
74 // - if no constructor is found and this is a scalar-to-scalar constructor,
75 // raise an error,
76 // - if a constructor is found, execute it and return,
77 // - count the size of the constructor parameter list - if it is less than
78 // the size of our constructor's type, raise an error,
79 // - for each parameter in the list do a recursive constructor matching for
80 // appropriate scalar fields in the constructed variable,
81 //
82 // Each implementation must also define a set of operators that deal with
83 // built-in data types.
84 // There are four kinds of operators:
85 // 1) Operators that are implemented only by the compiler: "()" (function
86 // call), "," (sequence) and "?:" (selection).
87 // 2) Operators that are implemented by the compiler by expressing it in
88 // terms of other operators:
89 // - "." (field selection) - translated to subscript access,
90 // - "&&" (logical and) - translated to "<left_expr> ? <right_expr> :
91 // false",
92 // - "||" (logical or) - translated to "<left_expr> ? true : <right_expr>",
93 // 3) Operators that can be defined by the implementation and if the required
94 // prototype is not found, standard behaviour is used:
95 // - "==", "!=", "=" (equality, assignment) - compare or assign
96 // matching fields one-by-one;
97 // note that at least operators for scalar data types must be defined
98 // by the implementation to get it work,
99 // 4) All other operators not mentioned above. If no required prototype is
100 // found, an error is raised. An implementation must follow the language
101 // specification to provide all valid operator prototypes.
102 //
103
104
105
106 //// Basic, scalar constructors/casts
107
108 int __constructor(const float f)
109 {
110 __asm float_to_int __retVal, f;
111 }
112
113 bool __constructor(const int i)
114 {
115 const float zero = 0.0;
116 __asm vec4_seq __retVal, i, zero;
117 }
118
119 bool __constructor(const float f)
120 {
121 const float zero = 0.0;
122 __asm vec4_seq __retVal, i, zero;
123 }
124
125 int __constructor(const bool b)
126 {
127 __retVal = b;
128 }
129
130 float __constructor(const bool b)
131 {
132 __retVal = b;
133 }
134
135 float __constructor(const int i)
136 {
137 __asm int_to_float __retVal, i;
138 }
139
140 bool __constructor(const bool b)
141 {
142 __retVal = b;
143 }
144
145 int __constructor(const int i)
146 {
147 __retVal = i;
148 }
149
150 float __constructor(const float f)
151 {
152 __retVal = f;
153 }
154
155
156 //// vec2 constructors
157
158 vec2 __constructor(const float x, const float y)
159 {
160 __retVal.x = x;
161 __retVal.y = y;
162 }
163
164 vec2 __constructor(const float f)
165 {
166 __retVal.xy = f.xx;
167 }
168
169 vec2 __constructor(const int i)
170 {
171 __retVal.xy = i.xx;
172 }
173
174 vec2 __constructor(const bool b)
175 {
176 __retVal.xy = b.xx;
177 }
178
179 vec2 __constructor(const vec3 v)
180 {
181 __retVal.xy = v.xy;
182 }
183
184
185 //// vec3 constructors
186
187 vec3 __constructor(const float x, const float y, const float z)
188 {
189 __retVal.x = x;
190 __retVal.y = y;
191 __retVal.z = z;
192 }
193
194 vec3 __constructor(const float f)
195 {
196 __retVal.xyz = f.xxx;
197 }
198
199 vec3 __constructor(const int i)
200 {
201 __asm int_to_float __retVal.xyz, i.xxx;
202 }
203
204 vec3 __constructor(const bool b)
205 {
206 __retVal.xyz = b.xxx;
207 }
208
209 vec3 __constructor(const vec4 v)
210 {
211 __retVal.xyz = v.xyz;
212 }
213
214
215 //// vec4 constructors
216
217 vec4 __constructor(const float x, const float y, const float z, const float w)
218 {
219 __retVal.x = x;
220 __retVal.y = y;
221 __retVal.z = z;
222 __retVal.w = w;
223 }
224
225 vec4 __constructor(const float f)
226 {
227 __retVal = f.xxxx;
228 }
229
230 vec4 __constructor(const int i)
231 {
232 __retVal = i.xxxx;
233 }
234
235 vec4 __constructor(const bool b)
236 {
237 __retVal = b.xxxx;
238 }
239
240 vec4 __constructor(const vec3 v3, const float f)
241 {
242 // XXX this constructor shouldn't be needed anymore
243 __retVal.xyz = v3;
244 __retVal.w = f;
245 }
246
247
248 //// ivec2 constructors
249
250 ivec2 __constructor(const int i, const int j)
251 {
252 __retVal.x = i;
253 __retVal.y = j;
254 }
255
256 ivec2 __constructor(const int i)
257 {
258 __retVal.xy = i.xx;
259 }
260
261 ivec2 __constructor(const float f)
262 {
263 __asm float_to_int __retVal.xy, f.xx;
264 }
265
266 ivec2 __constructor(const bool b)
267 {
268 __asm float_to_int __retVal.xy, b.xx;
269 }
270
271
272 //// ivec3 constructors
273
274 ivec3 __constructor(const int i, const int j, const int k)
275 {
276 __retVal.x = i;
277 __retVal.y = j;
278 __retVal.z = k;
279 }
280
281 ivec3 __constructor(const int i)
282 {
283 __retVal.xyz = i.xxx;
284 }
285
286 ivec3 __constructor(const float f)
287 {
288 __retVal.xyz = f.xxx;
289 }
290
291 ivec3 __constructor(const bool b)
292 {
293 __retVal.xyz = b.xxx;
294 }
295
296
297 //// ivec4 constructors
298
299 ivec4 __constructor(const int x, const int y, const int z, const int w)
300 {
301 __retVal.x = x;
302 __retVal.y = y;
303 __retVal.z = z;
304 __retVal.w = w;
305 }
306
307 ivec4 __constructor(const int i)
308 {
309 __retVal = i.xxxx;
310 }
311
312 ivec4 __constructor(const float f)
313 {
314 __asm float_to_int __retVal, f.xxxx;
315 }
316
317 ivec4 __constructor(const bool b)
318 {
319 __retVal = b.xxxx;
320 }
321
322
323 //// bvec2 constructors
324
325 bvec2 __constructor(const bool b1, const bool b2)
326 {
327 __retVal.x = b1;
328 __retVal.y = b2;
329 }
330
331 bvec2 __constructor(const bool b)
332 {
333 __retVal.xy = b.xx;
334 }
335
336 bvec2 __constructor(const float f)
337 {
338 const vec2 zero = vec2(0.0, 0.0);
339 __asm vec4_seq __retVal.xy, f.xx, zero;
340 }
341
342 bvec2 __constructor(const int i)
343 {
344 const ivec2 zero = ivec2(0, 0);
345 __asm vec4_seq __retVal.xy, i.xx, zero;
346 }
347
348
349 //// bvec3 constructors
350
351 bvec3 __constructor(const bool b1, const bool b2, const bool b3)
352 {
353 __retVal.x = b1;
354 __retVal.y = b2;
355 __retVal.z = b3;
356 }
357
358 bvec3 __constructor(const bool b)
359 {
360 __retVal.xyz = b.xxx;
361 }
362
363 bvec3 __constructor(const float f)
364 {
365 const vec3 zero = vec3(0.0, 0.0, 0.0);
366 __asm vec4_seq __retVal.xyz, f.xxx, zero;
367 }
368
369 bvec3 __constructor(const int i)
370 {
371 const ivec3 zero = ivec3(0, 0, 0);
372 __asm vec4_seq __retVal.xyz, i.xxx, zero;
373 }
374
375
376 //// bvec4 constructors
377
378 bvec4 __constructor(const bool b1, const bool b2, const bool b3, const bool b4)
379 {
380 __retVal.x = b1;
381 __retVal.y = b2;
382 __retVal.z = b3;
383 __retVal.w = b4;
384 }
385
386 bvec4 __constructor(const bool b)
387 {
388 __retVal.xyzw = b.xxxx;
389 }
390
391 bvec4 __constructor(const float f)
392 {
393 const vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
394 __asm vec4_seq __retVal, f.xxxx, zero;
395 }
396
397 bvec4 __constructor(const int i)
398 {
399 const ivec4 zero = ivec4(0, 0, 0, 0);
400 __asm vec4_seq __retVal, i.xxxx, zero;
401 }
402
403
404
405 //// mat2 constructors
406
407 mat2 __constructor(const float m00, const float m10,
408 const float m01, const float m11)
409 {
410 __retVal[0].x = m00;
411 __retVal[0].y = m10;
412 __retVal[1].x = m01;
413 __retVal[1].y = m11;
414 }
415
416 mat2 __constructor(const float f)
417 {
418 __retVal[0].x = f;
419 __retVal[0].y = 0.0;
420 __retVal[1].x = 0.0;
421 __retVal[1].y = f;
422 }
423
424 mat2 __constructor(const int i)
425 {
426 return mat2(float(i));
427 }
428
429 mat2 __constructor(const bool b)
430 {
431 return mat2(float(b));
432 }
433
434 mat2 __constructor(const vec2 c0, const vec2 c1)
435 {
436 __retVal[0] = c0;
437 __retVal[1] = c1;
438 }
439
440
441 //// mat3 constructors
442
443 mat3 __constructor(const float m00, const float m10, const float m20,
444 const float m01, const float m11, const float m21,
445 const float m02, const float m12, const float m22)
446 {
447 __retVal[0].x = m00;
448 __retVal[0].y = m10;
449 __retVal[0].z = m20;
450 __retVal[1].x = m01;
451 __retVal[1].y = m11;
452 __retVal[1].z = m21;
453 __retVal[2].x = m02;
454 __retVal[2].y = m12;
455 __retVal[2].z = m22;
456 }
457
458 mat3 __constructor(const float f)
459 {
460 vec2 v = vec2(f, 0.0);
461 __retVal[0] = v.xyy;
462 __retVal[1] = v.yxy;
463 __retVal[2] = v.yyx;
464 }
465
466 mat3 __constructor(const int i)
467 {
468 return mat3(float(i));
469 }
470
471 mat3 __constructor(const bool b)
472 {
473 return mat3(float(b));
474 }
475
476 mat3 __constructor(const vec3 c0, const vec3 c1, const vec3 c2)
477 {
478 __retVal[0] = c0;
479 __retVal[1] = c1;
480 __retVal[2] = c2;
481 }
482
483
484 //// mat4 constructors
485
486 mat4 __constructor(const float m00, const float m10, const float m20, const float m30,
487 const float m01, const float m11, const float m21, const float m31,
488 const float m02, const float m12, const float m22, const float m32,
489 const float m03, const float m13, const float m23, const float m33)
490 {
491 __retVal[0].x = m00;
492 __retVal[0].y = m10;
493 __retVal[0].z = m20;
494 __retVal[0].w = m30;
495 __retVal[1].x = m01;
496 __retVal[1].y = m11;
497 __retVal[1].z = m21;
498 __retVal[1].w = m31;
499 __retVal[2].x = m02;
500 __retVal[2].y = m12;
501 __retVal[2].z = m22;
502 __retVal[2].w = m32;
503 __retVal[3].x = m03;
504 __retVal[3].y = m13;
505 __retVal[3].z = m23;
506 __retVal[3].w = m33;
507 }
508
509
510 mat4 __constructor(const float f)
511 {
512 vec2 v = vec2(f, 0.0);
513 __retVal[0] = v.xyyy;
514 __retVal[1] = v.yxyy;
515 __retVal[2] = v.yyxy;
516 __retVal[3] = v.yyyx;
517 }
518
519 mat4 __constructor(const int i)
520 {
521 return mat4(float(i));
522 }
523
524 mat4 __constructor(const bool b)
525 {
526 return mat4(float(b));
527 }
528
529 mat4 __constructor(const vec4 c0, const vec4 c1, const vec4 c2, const vec4 c3)
530 {
531 __retVal[0] = c0;
532 __retVal[1] = c1;
533 __retVal[2] = c2;
534 __retVal[3] = c3;
535 }
536
537
538
539 //// Basic int operators
540
541 int __operator + (const int a, const int b)
542 {
543 // XXX If we ever have int registers, we'll do something like this:
544 // XXX For now, mostly treat ints as floats.
545 // float x, y;
546 // __asm int_to_float x, a;
547 // __asm int_to_float y, b;
548 // __asm vec4_add x.x, x.x, y.x;
549 // __asm float_to_int __retVal, x;
550 float x;
551 __asm vec4_add x, a, b;
552 __asm float_to_int __retVal, x;
553 }
554
555 int __operator - (const int a, const int b)
556 {
557 float x;
558 __asm vec4_subtract x, a, b;
559 __asm float_to_int __retVal, x;
560 }
561
562 int __operator * (const int a, const int b)
563 {
564 float x;
565 __asm vec4_multiply x, a, b;
566 __asm float_to_int __retVal, x;
567 }
568
569 int __operator / (const int a, const int b)
570 {
571 float bInv, x;
572 __asm float_rcp bInv, b;
573 __asm vec4_multiply x, a, bInv;
574 __asm float_to_int __retVal, x;
575 }
576
577
578 //// Basic ivec2 operators
579
580 ivec2 __operator + (const ivec2 a, const ivec2 b)
581 {
582 vec2 x;
583 __asm vec4_add x, a, b;
584 __asm float_to_int __retVal, x;
585 }
586
587 ivec2 __operator - (const ivec2 a, const ivec2 b)
588 {
589 vec2 x;
590 __asm vec4_subtract x, a, b;
591 __asm float_to_int __retVal, x;
592 }
593
594 ivec2 __operator * (const ivec2 a, const ivec2 b)
595 {
596 vec2 x;
597 __asm vec4_multiply x, a, b;
598 __asm float_to_int __retVal, x;
599 }
600
601 ivec2 __operator / (const ivec2 a, const ivec2 b)
602 {
603 vec2 bInv, x;
604 __asm float_rcp bInv.x, b.x;
605 __asm float_rcp bInv.y, b.y;
606 __asm vec4_multiply x, a, bInv;
607 __asm float_to_int __retVal, x;
608 }
609
610
611 //// Basic ivec3 operators
612
613 ivec3 __operator + (const ivec3 a, const ivec3 b)
614 {
615 vec3 x;
616 __asm vec4_add x, a, b;
617 __asm float_to_int __retVal, x;
618 }
619
620 ivec3 __operator - (const ivec3 a, const ivec3 b)
621 {
622 vec3 x;
623 __asm vec4_subtract x, a, b;
624 __asm float_to_int __retVal, x;
625 }
626
627 ivec3 __operator * (const ivec3 a, const ivec3 b)
628 {
629 vec3 x;
630 __asm vec4_multiply x, a, b;
631 __asm float_to_int __retVal, x;
632 }
633
634 ivec3 __operator / (const ivec3 a, const ivec3 b)
635 {
636 vec3 bInv, x;
637 __asm float_rcp bInv.x, b.x;
638 __asm float_rcp bInv.y, b.y;
639 __asm float_rcp bInv.z, b.z;
640 __asm vec4_multiply x, a, bInv;
641 __asm float_to_int __retVal, x;
642 }
643
644
645 //// Basic ivec4 operators
646
647 ivec4 __operator + (const ivec4 a, const ivec4 b)
648 {
649 vec3 x;
650 __asm vec4_add x, a, b;
651 __asm float_to_int __retVal, x;
652 }
653
654 ivec4 __operator - (const ivec4 a, const ivec4 b)
655 {
656 vec4 x;
657 __asm vec4_subtract x, a, b;
658 __asm float_to_int __retVal, x;
659 }
660
661 ivec4 __operator * (const ivec4 a, const ivec4 b)
662 {
663 vec4 x;
664 __asm vec4_multiply x, a, b;
665 __asm float_to_int __retVal, x;
666 }
667
668 ivec4 __operator / (const ivec4 a, const ivec4 b)
669 {
670 vec4 bInv, x;
671 __asm float_rcp bInv.x, b.x;
672 __asm float_rcp bInv.y, b.y;
673 __asm float_rcp bInv.z, b.z;
674 __asm float_rcp bInv.w, b.w;
675 __asm vec4_multiply x, a, bInv;
676 __asm float_to_int __retVal, x;
677 }
678
679
680 //// Basic float operators
681
682 float __operator + (const float a, const float b)
683 {
684 __asm vec4_add __retVal.x, a, b;
685 }
686
687 float __operator - (const float a, const float b)
688 {
689 __asm vec4_subtract __retVal.x, a, b;
690 }
691
692 float __operator * (const float a, const float b)
693 {
694 __asm float_multiply __retVal, a, b;
695 }
696
697 float __operator / (const float a, const float b)
698 {
699 float bInv;
700 __asm float_rcp bInv.x, b.x;
701 __asm vec4_multiply __retVal.x, a, bInv;
702 }
703
704
705 //// Basic vec2 operators
706
707 vec2 __operator + (const vec2 v, const vec2 u)
708 {
709 __asm vec4_add __retVal.xy, v, u;
710 }
711
712 vec2 __operator - (const vec2 v, const vec2 u)
713 {
714 __asm vec4_subtract __retVal.xy, v, u;
715 }
716
717 vec2 __operator * (const vec2 v, const vec2 u)
718 {
719 __asm vec4_multiply __retVal.xy, v, u;
720 }
721
722 vec2 __operator / (const vec2 v, const vec2 u)
723 {
724 vec2 w; // = 1 / u
725 __asm float_rcp w.x, u.x;
726 __asm float_rcp w.y, u.y;
727 __asm vec4_multiply __retVal.xy, v, w;
728 }
729
730
731 //// Basic vec3 operators
732
733 vec3 __operator + (const vec3 v, const vec3 u)
734 {
735 __asm vec4_add __retVal.xyz, v, u;
736 }
737
738 vec3 __operator - (const vec3 v, const vec3 u)
739 {
740 __asm vec4_subtract __retVal.xyz, v, u;
741 }
742
743 vec3 __operator * (const vec3 v, const vec3 u)
744 {
745 __asm vec4_multiply __retVal.xyz, v, u;
746 }
747
748 vec3 __operator / (const vec3 v, const vec3 u)
749 {
750 vec3 w; // = 1 / u
751 __asm float_rcp w.x, u.x;
752 __asm float_rcp w.y, u.y;
753 __asm float_rcp w.z, u.z;
754 __asm vec4_multiply __retVal.xyz, v, w;
755 }
756
757
758 //// Basic vec4 operators
759
760 vec4 __operator + (const vec4 v, const vec4 u)
761 {
762 __asm vec4_add __retVal, v, u;
763 }
764
765 vec4 __operator - (const vec4 v, const vec4 u)
766 {
767 __asm vec4_subtract __retVal, v, u;
768 }
769
770 vec4 __operator * (const vec4 v, const vec4 u)
771 {
772 __asm vec4_multiply __retVal, v, u;
773 }
774
775 vec4 __operator / (const vec4 v, const vec4 u)
776 {
777 vec4 w; // = 1 / u
778 __asm float_rcp w.x, u.x;
779 __asm float_rcp w.y, u.y;
780 __asm float_rcp w.z, u.z;
781 __asm float_rcp w.w, u.w;
782 __asm vec4_multiply __retVal, v, w;
783 }
784
785
786
787
788 //// Basic vec2/float operators
789
790 vec2 __operator + (const float a, const vec2 u)
791 {
792 __asm vec4_add __retVal.xy, a.xx, u.xy;
793 }
794
795 vec2 __operator + (const vec2 v, const float b)
796 {
797 __asm vec4_add __retVal.xy, v.xy, b.xx;
798 }
799
800 vec2 __operator - (const float a, const vec2 u)
801 {
802 __asm vec4_subtract __retVal.xy, a.xx, u.xy;
803 }
804
805 vec2 __operator - (const vec2 v, const float b)
806 {
807 __asm vec4_subtract __retVal.xy, v.xy, b.xx;
808 }
809
810 vec2 __operator * (const float a, const vec2 u)
811 {
812 __asm vec4_multiply __retVal.xy, a.xx, u.xy;
813 }
814
815 vec2 __operator * (const vec2 v, const float b)
816 {
817 __asm vec4_multiply __retVal.xy, v.xy, b.xx;
818 }
819
820 vec2 __operator / (const float a, const vec2 u)
821 {
822 vec2 invU;
823 __asm float_rcp invU.x, u.x;
824 __asm float_rcp invU.y, u.y;
825 __asm vec4_multiply __retVal.xy, a.xx, invU.xy;
826 }
827
828 vec2 __operator / (const vec2 v, const float b)
829 {
830 float invB;
831 __asm float_rcp invB, b;
832 __asm vec4_multiply __retVal.xy, v.xy, invB.xx;
833 }
834
835
836 //// Basic vec3/float operators
837
838 vec3 __operator + (const float a, const vec3 u)
839 {
840 __asm vec4_add __retVal.xyz, a.xxx, u.xyz;
841 }
842
843 vec3 __operator + (const vec3 v, const float b)
844 {
845 __asm vec4_add __retVal.xyz, v.xyz, b.xxx;
846 }
847
848 vec3 __operator - (const float a, const vec3 u)
849 {
850 __asm vec4_subtract __retVal.xyz, a.xxx, u.xyz;
851 }
852
853 vec3 __operator - (const vec3 v, const float b)
854 {
855 __asm vec4_subtract __retVal.xyz, v.xyz, b.xxx;
856 }
857
858 vec3 __operator * (const float a, const vec3 u)
859 {
860 __asm vec4_multiply __retVal.xyz, a.xxx, u.xyz;
861 }
862
863 vec3 __operator * (const vec3 v, const float b)
864 {
865 __asm vec4_multiply __retVal.xyz, v.xyz, b.xxx;
866 }
867
868 vec3 __operator / (const float a, const vec3 u)
869 {
870 vec3 invU;
871 __asm float_rcp invU.x, u.x;
872 __asm float_rcp invU.y, u.y;
873 __asm float_rcp invU.z, u.z;
874 __asm vec4_multiply __retVal.xyz, a.xxx, invU.xyz;
875 }
876
877 vec3 __operator / (const vec3 v, const float b)
878 {
879 float invB;
880 __asm float_rcp invB, b;
881 __asm vec4_multiply __retVal.xyz, v.xyz, invB.xxx;
882 }
883
884
885 //// Basic vec4/float operators
886
887 vec4 __operator + (const float a, const vec4 u)
888 {
889 __asm vec4_add __retVal, a.xxxx, u;
890 }
891
892 vec4 __operator + (const vec4 v, const float b)
893 {
894 __asm vec4_add __retVal, v, b.xxxx;
895 }
896
897 vec4 __operator - (const float a, const vec4 u)
898 {
899 __asm vec4_subtract __retVal, a.xxxx, u;
900 }
901
902 vec4 __operator - (const vec4 v, const float b)
903 {
904 __asm vec4_subtract __retVal, v, b.xxxx;
905 }
906
907 vec4 __operator * (const float a, const vec4 u)
908 {
909 __asm vec4_multiply __retVal, a.xxxx, u;
910 }
911
912 vec4 __operator * (const vec4 v, const float b)
913 {
914 __asm vec4_multiply __retVal, v, b.xxxx;
915 }
916
917 vec4 __operator / (const float a, const vec4 u)
918 {
919 vec4 invU;
920 __asm float_rcp invU.x, u.x;
921 __asm float_rcp invU.y, u.y;
922 __asm float_rcp invU.z, u.z;
923 __asm float_rcp invU.w, u.w;
924 __asm vec4_multiply __retVal, a.xxxx, invU;
925 }
926
927 vec4 __operator / (const vec4 v, const float b)
928 {
929 float invB;
930 __asm float_rcp invB, b;
931 __asm vec4_multiply __retVal, v, invB.xxxx;
932 }
933
934
935
936 //// Basic ivec2/int operators
937
938 ivec2 __operator + (const int a, const ivec2 u)
939 {
940 __retVal = ivec2(a) + u;
941 }
942
943 ivec2 __operator + (const ivec2 v, const int b)
944 {
945 __retVal = v + ivec2(b);
946 }
947
948 ivec2 __operator - (const int a, const ivec2 u)
949 {
950 __retVal = ivec2(a) - u;
951 }
952
953 ivec2 __operator - (const ivec2 v, const int b)
954 {
955 __retVal = v - ivec2(b);
956 }
957
958 ivec2 __operator * (const int a, const ivec2 u)
959 {
960 __retVal = ivec2(a) * u;
961 }
962
963 ivec2 __operator * (const ivec2 v, const int b)
964 {
965 __retVal = v * ivec2(b);
966 }
967
968 ivec2 __operator / (const int a, const ivec2 u)
969 {
970 __retVal = ivec2(a) / u;
971 }
972
973 ivec2 __operator / (const ivec2 v, const int b)
974 {
975 __retVal = v / ivec2(b);
976 }
977
978
979 //// Basic ivec3/int operators
980
981 ivec3 __operator + (const int a, const ivec3 u)
982 {
983 __retVal = ivec3(a) + u;
984 }
985
986 ivec3 __operator + (const ivec3 v, const int b)
987 {
988 __retVal = v + ivec3(b);
989 }
990
991 ivec3 __operator - (const int a, const ivec3 u)
992 {
993 __retVal = ivec3(a) - u;
994 }
995
996 ivec3 __operator - (const ivec3 v, const int b)
997 {
998 __retVal = v - ivec3(b);
999 }
1000
1001 ivec3 __operator * (const int a, const ivec3 u)
1002 {
1003 __retVal = ivec3(a) * u;
1004 }
1005
1006 ivec3 __operator * (const ivec3 v, const int b)
1007 {
1008 __retVal = v * ivec3(b);
1009 }
1010
1011 ivec3 __operator / (const int a, const ivec3 u)
1012 {
1013 __retVal = ivec3(a) / u;
1014 }
1015
1016 ivec3 __operator / (const ivec3 v, const int b)
1017 {
1018 __retVal = v / ivec3(b);
1019 }
1020
1021
1022 //// Basic ivec4/int operators
1023
1024 ivec4 __operator + (const int a, const ivec4 u)
1025 {
1026 __retVal = ivec4(a) + u;
1027 }
1028
1029 ivec4 __operator + (const ivec4 v, const int b)
1030 {
1031 __retVal = v + ivec4(b);
1032 }
1033
1034 ivec4 __operator - (const int a, const ivec4 u)
1035 {
1036 __retVal = ivec4(a) - u;
1037 }
1038
1039 ivec4 __operator - (const ivec4 v, const int b)
1040 {
1041 __retVal = v - ivec4(b);
1042 }
1043
1044 ivec4 __operator * (const int a, const ivec4 u)
1045 {
1046 __retVal = ivec4(a) * u;
1047 }
1048
1049 ivec4 __operator * (const ivec4 v, const int b)
1050 {
1051 __retVal = v * ivec4(b);
1052 }
1053
1054 ivec4 __operator / (const int a, const ivec4 u)
1055 {
1056 __retVal = ivec4(a) / u;
1057 }
1058
1059 ivec4 __operator / (const ivec4 v, const int b)
1060 {
1061 __retVal = v / ivec4(b);
1062 }
1063
1064
1065
1066
1067 //// Unary negation operator
1068
1069 int __operator - (const int a)
1070 {
1071 __asm vec4_negate __retVal.x, a;
1072 }
1073
1074 ivec2 __operator - (const ivec2 v)
1075 {
1076 __asm vec4_negate __retVal, v;
1077 }
1078
1079 ivec3 __operator - (const ivec3 v)
1080 {
1081 __asm vec4_negate __retVal, v;
1082 }
1083
1084 ivec4 __operator - (const ivec4 v)
1085 {
1086 __asm vec4_negate __retVal, v;
1087 }
1088
1089 float __operator - (const float a)
1090 {
1091 __asm vec4_negate __retVal.x, a;
1092 }
1093
1094 vec2 __operator - (const vec2 v)
1095 {
1096 __asm vec4_negate __retVal.xy, v.xy;
1097 }
1098
1099 vec3 __operator - (const vec3 v)
1100 {
1101 __asm vec4_negate __retVal.xyz, v.xyz;
1102 }
1103
1104 vec4 __operator - (const vec4 v)
1105 {
1106 __asm vec4_negate __retVal, v;
1107 }
1108
1109 mat2 __operator - (const mat2 m)
1110 {
1111 __retVal[0] = -m[0];
1112 __retVal[1] = -m[1];
1113 }
1114
1115 mat3 __operator - (const mat3 m)
1116 {
1117 __retVal[0] = -m[0];
1118 __retVal[1] = -m[1];
1119 __retVal[2] = -m[2];
1120 }
1121
1122 mat4 __operator - (const mat4 m)
1123 {
1124 __retVal[0] = -m[0];
1125 __retVal[1] = -m[1];
1126 __retVal[2] = -m[2];
1127 __retVal[3] = -m[3];
1128 }
1129
1130
1131
1132 //// dot product
1133
1134 float dot(const float a, const float b)
1135 {
1136 __retVal = a * b;
1137 }
1138
1139 float dot(const vec2 a, const vec2 b)
1140 {
1141 __retVal = a.x * b.x + a.y * b.y;
1142 }
1143
1144 float dot(const vec3 a, const vec3 b)
1145 {
1146 __asm vec3_dot __retVal, a, b;
1147 }
1148
1149 float dot(const vec4 a, const vec4 b)
1150 {
1151 __asm vec4_dot __retVal, a, b;
1152 }
1153
1154
1155
1156 //// int assignment operators
1157
1158 void __operator += (inout int a, const int b)
1159 {
1160 __asm vec4_add a, a, b;
1161 }
1162
1163 void __operator -= (inout int a, const int b)
1164 {
1165 __asm vec4_subtract a, a, b;
1166 }
1167
1168 void __operator *= (inout int a, const int b)
1169 {
1170 __asm vec4_multiply a, a, b;
1171 }
1172
1173 void __operator /= (inout int a, const int b)
1174 {
1175 float invB;
1176 __asm float_rcp invB, b;
1177 __asm vec4_multiply a, a, invB;
1178 }
1179
1180
1181 //// ivec2 assignment operators
1182
1183 void __operator += (inout ivec2 v, const ivec2 u)
1184 {
1185 __asm vec4_add v, v, u;
1186 }
1187
1188 void __operator -= (inout ivec2 v, const ivec2 u)
1189 {
1190 __asm vec4_subtract v, v, u;
1191 }
1192
1193 void __operator *= (inout ivec2 v, const ivec2 u)
1194 {
1195 __asm vec4_multiply v, v, u;
1196 }
1197
1198 void __operator /= (inout ivec2 v, const ivec2 u)
1199 {
1200 ivec2 inv, z;
1201 __asm float_rcp inv.x, u.x;
1202 __asm float_rcp inv.y, u.y;
1203 __asm vec4_multiply z, v, inv;
1204 __asm float_to_int __retVal, z;
1205 }
1206
1207
1208 //// ivec3 assignment operators
1209
1210 void __operator += (inout ivec3 v, const ivec3 u)
1211 {
1212 __asm vec4_add v, v, u;
1213 }
1214
1215 void __operator -= (inout ivec3 v, const ivec3 u)
1216 {
1217 __asm vec4_subtract v, v, u;
1218 }
1219
1220 void __operator *= (inout ivec3 v, const ivec3 u)
1221 {
1222 __asm vec4_multiply v, v, u;
1223 }
1224
1225 void __operator /= (inout ivec3 v, const ivec3 u)
1226 {
1227 ivec3 inv, z;
1228 __asm float_rcp inv.x, u.x;
1229 __asm float_rcp inv.y, u.y;
1230 __asm vec4_multiply z, v, inv;
1231 __asm float_to_int __retVal, z;
1232 }
1233
1234
1235 //// ivec4 assignment operators
1236
1237 void __operator += (inout ivec4 v, const ivec4 u)
1238 {
1239 __asm vec4_add v, v, u;
1240 }
1241
1242 void __operator -= (inout ivec4 v, const ivec4 u)
1243 {
1244 __asm vec4_subtract v, v, u;
1245 }
1246
1247 void __operator *= (inout ivec4 v, const ivec4 u)
1248 {
1249 __asm vec4_multiply v, v, u;
1250 }
1251
1252 void __operator /= (inout ivec4 v, const ivec4 u)
1253 {
1254 ivec4 inv, z;
1255 __asm float_rcp inv.x, u.x;
1256 __asm float_rcp inv.y, u.y;
1257 __asm vec4_multiply z, v, inv;
1258 __asm float_to_int __retVal, z;
1259 }
1260
1261
1262 //// float assignment operators
1263
1264 void __operator += (inout float a, const float b)
1265 {
1266 __asm vec4_add a.x, a.x, b;
1267 }
1268
1269 void __operator -= (inout float a, const float b)
1270 {
1271 __asm vec4_subtract a.x, a, b;
1272 }
1273
1274 void __operator *= (inout float a, const float b)
1275 {
1276 __asm vec4_multiply a.x, a, b;
1277 }
1278
1279 void __operator /= (inout float a, const float b)
1280 {
1281 float w; // = 1 / b
1282 __asm float_rcp w.x, b;
1283 __asm vec4_multiply a.x, a, w;
1284 }
1285
1286
1287 //// vec2 assignment operators
1288
1289 void __operator += (inout vec2 v, const vec2 u)
1290 {
1291 __asm vec4_add v.xy, v.xy, u.xy;
1292 }
1293
1294 void __operator -= (inout vec2 v, const vec2 u)
1295 {
1296 __asm vec4_subtract v.xy, v.xy, u.xy;
1297 }
1298
1299 void __operator *= (inout vec2 v, const vec2 u)
1300 {
1301 __asm vec4_multiply v.xy, v.xy, u.xy;
1302 }
1303
1304 void __operator /= (inout vec2 v, const vec2 u)
1305 {
1306 vec2 w;
1307 __asm float_rcp w.x, u.x;
1308 __asm float_rcp w.y, u.y;
1309 __asm vec4_multiply v.xy, v.xy, w.xy;
1310 }
1311
1312
1313 //// vec3 assignment operators
1314
1315 void __operator += (inout vec3 v, const vec3 u)
1316 {
1317 __asm vec4_add v.xyz, v, u;
1318 }
1319
1320 void __operator -= (inout vec3 v, const vec3 u)
1321 {
1322 __asm vec4_subtract v.xyz, v, u;
1323 }
1324
1325 void __operator *= (inout vec3 v, const vec3 u)
1326 {
1327 __asm vec4_multiply v.xyz, v, u;
1328 }
1329
1330 void __operator /= (inout vec3 v, const vec3 u)
1331 {
1332 vec3 w;
1333 __asm float_rcp w.x, u.x;
1334 __asm float_rcp w.y, u.y;
1335 __asm float_rcp w.z, u.z;
1336 __asm vec4_multiply v.xyz, v.xyz, w.xyz;
1337 }
1338
1339
1340 //// vec4 assignment operators
1341
1342 void __operator += (inout vec4 v, const vec4 u)
1343 {
1344 __asm vec4_add v, v, u;
1345 }
1346
1347 void __operator -= (inout vec4 v, const vec4 u)
1348 {
1349 __asm vec4_subtract v, v, u;
1350 }
1351
1352 void __operator *= (inout vec4 v, const vec4 u)
1353 {
1354 __asm vec4_multiply v, v, u;
1355 }
1356
1357 void __operator /= (inout vec4 v, const vec4 u)
1358 {
1359 vec4 w;
1360 __asm float_rcp w.x, u.x;
1361 __asm float_rcp w.y, u.y;
1362 __asm float_rcp w.z, u.z;
1363 __asm float_rcp w.w, u.w;
1364 __asm vec4_multiply v, v, w;
1365 }
1366
1367
1368
1369 //// ivec2/int assignment operators
1370
1371 void __operator += (inout ivec2 v, const int a)
1372 {
1373 __asm vec4_add v.xy, v.xy, a.xx;
1374 }
1375
1376 void __operator -= (inout ivec2 v, const int a)
1377 {
1378 __asm vec4_subtract v.xy, v.xy, a.xx;
1379 }
1380
1381 void __operator *= (inout ivec2 v, const int a)
1382 {
1383 __asm vec4_multiply v.xy, v.xy, a.xx;
1384 v.x *= a;
1385 v.y *= a;
1386 }
1387
1388 void __operator /= (inout ivec2 v, const int a)
1389 {
1390 // XXX rcp
1391 v.x /= a;
1392 v.y /= a;
1393 }
1394
1395
1396 //// ivec3/int assignment operators
1397
1398 void __operator += (inout ivec3 v, const int a)
1399 {
1400 __asm vec4_add v.xyz, v.xyz, a.xxx;
1401 }
1402
1403 void __operator -= (inout ivec3 v, const int a)
1404 {
1405 __asm vec4_subtract v.xyz, v.xyz, a.xxx;
1406 }
1407
1408 void __operator *= (inout ivec3 v, const int a)
1409 {
1410 __asm vec4_multiply v.xyz, v.xyz, a.xxx;
1411 }
1412
1413 void __operator /= (inout ivec3 v, const int a)
1414 {
1415 // XXX rcp
1416 v.x /= a;
1417 v.y /= a;
1418 v.z /= a;
1419 }
1420
1421
1422 //// ivec4/int assignment operators
1423
1424 void __operator += (inout ivec4 v, const int a)
1425 {
1426 __asm vec4_add v, v, a.xxxx;
1427 }
1428
1429 void __operator -= (inout ivec4 v, const int a)
1430 {
1431 __asm vec4_subtract v, v, a.xxxx;
1432 }
1433
1434 void __operator *= (inout ivec4 v, const int a)
1435 {
1436 __asm vec4_multiply v, v, a.xxxx;
1437 }
1438
1439 void __operator /= (inout ivec4 v, const int a)
1440 {
1441 v.x /= a;
1442 v.y /= a;
1443 v.z /= a;
1444 v.w /= a;
1445 }
1446
1447
1448
1449 //// vec2/float assignment operators
1450
1451 void __operator += (inout vec2 v, const float a)
1452 {
1453 __asm vec4_add v.xy, v, a.xx;
1454 }
1455
1456 void __operator -= (inout vec2 v, const float a)
1457 {
1458 __asm vec4_subtract v.xy, v, a.xx;
1459 }
1460
1461 void __operator *= (inout vec2 v, const float a)
1462 {
1463 __asm vec4_multiply v.xy, v, a.xx;
1464 }
1465
1466 void __operator /= (inout vec2 v, const float a)
1467 {
1468 float invA;
1469 __asm float_rcp invA, a;
1470 __asm vec4_multiply v.xy, v.xy, a.xx;
1471 }
1472
1473
1474 //// vec3/float assignment operators
1475
1476 void __operator += (inout vec3 v, const float a)
1477 {
1478 __asm vec4_add v.xyz, v, a.xxx;
1479 }
1480
1481 void __operator -= (inout vec3 v, const float a)
1482 {
1483 __asm vec4_subtract v.xyz, v, a.xxx;
1484 }
1485
1486 void __operator *= (inout vec3 v, const float a)
1487 {
1488 __asm vec4_multiply v.xyz, v, a.xxx;
1489 }
1490
1491 void __operator /= (inout vec3 v, const float a)
1492 {
1493 float invA;
1494 __asm float_rcp invA, a;
1495 __asm vec4_multiply v.xyz, v.xyz, a.xxx;
1496 }
1497
1498
1499 //// vec4/float assignment operators
1500
1501 void __operator += (inout vec4 v, const float a)
1502 {
1503 __asm vec4_add v, v, a.xxxx;
1504 }
1505
1506 void __operator -= (inout vec4 v, const float a)
1507 {
1508 __asm vec4_subtract v, v, a.xxxx;
1509 }
1510
1511 void __operator *= (inout vec4 v, const float a)
1512 {
1513 __asm vec4_multiply v, v, a.xxxx;
1514 }
1515
1516 void __operator /= (inout vec4 v, const float a)
1517 {
1518 float invA;
1519 __asm float_rcp invA, a;
1520 __asm vec4_multiply v, v, a.xxxx;
1521 }
1522
1523
1524
1525
1526
1527 //// Basic mat2 operations
1528
1529 mat2 __operator + (const mat2 m, const mat2 n)
1530 {
1531 __retVal[0] = m[0] + n[0];
1532 __retVal[1] = m[1] + n[1];
1533 }
1534
1535 mat2 __operator - (const mat2 m, const mat2 n)
1536 {
1537 __retVal[0] = m[0] - n[0];
1538 __retVal[1] = m[1] - n[1];
1539 }
1540
1541 mat2 __operator * (const mat2 m, const mat2 n)
1542 {
1543 vec2 mRow0, mRow1;
1544 mRow0.x = m[0].x;
1545 mRow0.y = m[1].x;
1546 mRow1.x = m[0].y;
1547 mRow1.y = m[1].y;
1548 __retVal[0].x = dot(mRow0, n[0]);
1549 __retVal[1].x = dot(mRow0, n[1]);
1550 __retVal[0].y = dot(mRow1, n[0]);
1551 __retVal[1].y = dot(mRow1, n[1]);
1552 }
1553
1554 mat2 __operator / (const mat2 m, const mat2 n)
1555 {
1556 __retVal[0] = m[0] / n[0];
1557 __retVal[1] = m[1] / n[1];
1558 }
1559
1560
1561 //// Basic mat3 operations
1562
1563 mat3 __operator + (const mat3 m, const mat3 n)
1564 {
1565 __retVal[0] = m[0] + n[0];
1566 __retVal[1] = m[1] + n[1];
1567 __retVal[2] = m[2] + n[2];
1568 }
1569
1570 mat3 __operator - (const mat3 m, const mat3 n)
1571 {
1572 __retVal[0] = m[0] - n[0];
1573 __retVal[1] = m[1] - n[1];
1574 __retVal[2] = m[2] - n[2];
1575 }
1576
1577 mat3 __operator * (const mat3 m, const mat3 n)
1578 {
1579 // sub-blocks to reduce register usage
1580 {
1581 vec3 mRow0;
1582 mRow0.x = m[0].x;
1583 mRow0.y = m[1].x;
1584 mRow0.z = m[2].x;
1585 __retVal[0].x = dot(mRow0, n[0]);
1586 __retVal[1].x = dot(mRow0, n[1]);
1587 __retVal[2].x = dot(mRow0, n[2]);
1588 }
1589 {
1590 vec3 mRow1;
1591 mRow1.x = m[0].y;
1592 mRow1.y = m[1].y;
1593 mRow1.z = m[2].y;
1594 __retVal[0].y = dot(mRow1, n[0]);
1595 __retVal[1].y = dot(mRow1, n[1]);
1596 __retVal[2].y = dot(mRow1, n[2]);
1597 }
1598 {
1599 vec3 mRow2;
1600 mRow2.x = m[0].z;
1601 mRow2.y = m[1].z;
1602 mRow2.z = m[2].z;
1603 __retVal[0].z = dot(mRow2, n[0]);
1604 __retVal[1].z = dot(mRow2, n[1]);
1605 __retVal[2].z = dot(mRow2, n[2]);
1606 }
1607 }
1608
1609 mat3 __operator / (const mat3 m, const mat3 n)
1610 {
1611 __retVal[0] = m[0] / n[0];
1612 __retVal[1] = m[1] / n[1];
1613 __retVal[2] = m[2] / n[2];
1614 }
1615
1616
1617 //// Basic mat4 operations
1618
1619 mat4 __operator + (const mat4 m, const mat4 n)
1620 {
1621 __retVal[0] = m[0] + n[0];
1622 __retVal[1] = m[1] + n[1];
1623 __retVal[2] = m[2] + n[2];
1624 __retVal[3] = m[3] + n[3];
1625 }
1626
1627 mat4 __operator - (const mat4 m, const mat4 n)
1628 {
1629 __retVal[0] = m[0] - n[0];
1630 __retVal[1] = m[1] - n[1];
1631 __retVal[2] = m[2] - n[2];
1632 __retVal[3] = m[3] - n[3];
1633 }
1634
1635 mat4 __operator * (const mat4 m, const mat4 n)
1636 {
1637 // sub-blocks to reduce temporary usage
1638 {
1639 vec4 mRow0;
1640 mRow0.x = m[0].x;
1641 mRow0.y = m[1].x;
1642 mRow0.z = m[2].x;
1643 mRow0.w = m[3].x;
1644 __retVal[0].x = dot(mRow0, n[0]);
1645 __retVal[1].x = dot(mRow0, n[1]);
1646 __retVal[2].x = dot(mRow0, n[2]);
1647 __retVal[3].x = dot(mRow0, n[3]);
1648 }
1649 {
1650 vec4 mRow1;
1651 mRow1.x = m[0].y;
1652 mRow1.y = m[1].y;
1653 mRow1.z = m[2].y;
1654 mRow1.w = m[3].y;
1655 __retVal[0].y = dot(mRow1, n[0]);
1656 __retVal[1].y = dot(mRow1, n[1]);
1657 __retVal[2].y = dot(mRow1, n[2]);
1658 __retVal[3].y = dot(mRow1, n[3]);
1659 }
1660 {
1661 vec4 mRow2;
1662 mRow2.x = m[0].z;
1663 mRow2.y = m[1].z;
1664 mRow2.z = m[2].z;
1665 mRow2.w = m[3].z;
1666 __retVal[0].z = dot(mRow2, n[0]);
1667 __retVal[1].z = dot(mRow2, n[1]);
1668 __retVal[2].z = dot(mRow2, n[2]);
1669 __retVal[3].z = dot(mRow2, n[3]);
1670 }
1671 {
1672 vec4 mRow3;
1673 mRow3.x = m[0].w;
1674 mRow3.y = m[1].w;
1675 mRow3.z = m[2].w;
1676 mRow3.w = m[3].w;
1677 __retVal[0].w = dot(mRow3, n[0]);
1678 __retVal[1].w = dot(mRow3, n[1]);
1679 __retVal[2].w = dot(mRow3, n[2]);
1680 __retVal[3].w = dot(mRow3, n[3]);
1681 }
1682 }
1683
1684 mat4 __operator / (const mat4 m, const mat4 n)
1685 {
1686 __retVal[0] = m[0] / n[0];
1687 __retVal[1] = m[1] / n[1];
1688 __retVal[2] = m[2] / n[2];
1689 __retVal[3] = m[3] / n[3];
1690 }
1691
1692
1693 //// mat2/float operations
1694
1695 mat2 __operator + (const float a, const mat2 n)
1696 {
1697 __retVal[0] = a + n[0];
1698 __retVal[1] = a + n[1];
1699 }
1700
1701 mat2 __operator + (const mat2 m, const float b)
1702 {
1703 __retVal[0] = m[0] + b;
1704 __retVal[1] = m[1] + b;
1705 }
1706
1707 mat2 __operator - (const float a, const mat2 n)
1708 {
1709 __retVal[0] = a - n[0];
1710 __retVal[1] = a - n[1];
1711 }
1712
1713 mat2 __operator - (const mat2 m, const float b)
1714 {
1715 __retVal[0] = m[0] - b;
1716 __retVal[1] = m[1] - b;
1717 }
1718
1719 mat2 __operator * (const float a, const mat2 n)
1720 {
1721 __retVal[0] = a * n[0];
1722 __retVal[1] = a * n[1];
1723 }
1724
1725 mat2 __operator * (const mat2 m, const float b)
1726 {
1727 __retVal[0] = m[0] * b;
1728 __retVal[1] = m[1] * b;
1729 }
1730
1731 mat2 __operator / (const float a, const mat2 n)
1732 {
1733 __retVal[0] = a / n[0];
1734 __retVal[1] = a / n[1];
1735 }
1736
1737 mat2 __operator / (const mat2 m, const float b)
1738 {
1739 __retVal[0] = m[0] / b;
1740 __retVal[1] = m[1] / b;
1741 }
1742
1743
1744 //// mat3/float operations
1745
1746 mat3 __operator + (const float a, const mat3 n)
1747 {
1748 __retVal[0] = a + n[0];
1749 __retVal[1] = a + n[1];
1750 __retVal[2] = a + n[2];
1751 }
1752
1753 mat3 __operator + (const mat3 m, const float b)
1754 {
1755 __retVal[0] = m[0] + b;
1756 __retVal[1] = m[1] + b;
1757 __retVal[2] = m[2] + b;
1758 }
1759
1760 mat3 __operator - (const float a, const mat3 n)
1761 {
1762 __retVal[0] = a - n[0];
1763 __retVal[1] = a - n[1];
1764 __retVal[2] = a - n[2];
1765 }
1766
1767 mat3 __operator - (const mat3 m, const float b)
1768 {
1769 __retVal[0] = m[0] - b;
1770 __retVal[1] = m[1] - b;
1771 __retVal[2] = m[2] - b;
1772 }
1773
1774 mat3 __operator * (const float a, const mat3 n)
1775 {
1776 __retVal[0] = a * n[0];
1777 __retVal[1] = a * n[1];
1778 __retVal[2] = a * n[2];
1779 }
1780
1781 mat3 __operator * (const mat3 m, const float b)
1782 {
1783 __retVal[0] = m[0] * b;
1784 __retVal[1] = m[1] * b;
1785 __retVal[2] = m[2] * b;
1786 }
1787
1788 mat3 __operator / (const float a, const mat3 n)
1789 {
1790 __retVal[0] = a / n[0];
1791 __retVal[1] = a / n[1];
1792 __retVal[2] = a / n[2];
1793 }
1794
1795 mat3 __operator / (const mat3 m, const float b)
1796 {
1797 __retVal[0] = m[0] / b;
1798 __retVal[1] = m[1] / b;
1799 __retVal[2] = m[2] / b;
1800 }
1801
1802
1803 //// mat4/float operations
1804
1805 mat4 __operator + (const float a, const mat4 n)
1806 {
1807 __retVal[0] = a + n[0];
1808 __retVal[1] = a + n[1];
1809 __retVal[2] = a + n[2];
1810 __retVal[3] = a + n[3];
1811 }
1812
1813 mat4 __operator + (const mat4 m, const float b)
1814 {
1815 __retVal[0] = m[0] + b;
1816 __retVal[1] = m[1] + b;
1817 __retVal[2] = m[2] + b;
1818 __retVal[3] = m[3] + b;
1819 }
1820
1821 mat4 __operator - (const float a, const mat4 n)
1822 {
1823 __retVal[0] = a - n[0];
1824 __retVal[1] = a - n[1];
1825 __retVal[2] = a - n[2];
1826 __retVal[3] = a - n[3];
1827 }
1828
1829 mat4 __operator - (const mat4 m, const float b)
1830 {
1831 __retVal[0] = m[0] - b;
1832 __retVal[1] = m[1] - b;
1833 __retVal[2] = m[2] - b;
1834 __retVal[3] = m[3] - b;
1835 }
1836
1837 mat4 __operator * (const float a, const mat4 n)
1838 {
1839 __retVal[0] = a * n[0];
1840 __retVal[1] = a * n[1];
1841 __retVal[2] = a * n[2];
1842 __retVal[3] = a * n[3];
1843 }
1844
1845 mat4 __operator * (const mat4 m, const float b)
1846 {
1847 __retVal[0] = m[0] * b;
1848 __retVal[1] = m[1] * b;
1849 __retVal[2] = m[2] * b;
1850 __retVal[3] = m[3] * b;
1851 }
1852
1853 mat4 __operator / (const float a, const mat4 n)
1854 {
1855 __retVal[0] = a / n[0];
1856 __retVal[1] = a / n[1];
1857 __retVal[2] = a / n[2];
1858 __retVal[3] = a / n[3];
1859 }
1860
1861 mat4 __operator / (const mat4 m, const float b)
1862 {
1863 __retVal[0] = m[0] / b;
1864 __retVal[1] = m[1] / b;
1865 __retVal[2] = m[2] / b;
1866 __retVal[3] = m[3] / b;
1867 }
1868
1869
1870
1871 //// matrix / vector products
1872
1873 vec2 __operator * (const mat2 m, const vec2 v)
1874 {
1875 vec2 r0, r1;
1876 r0.x = m[0].x;
1877 r0.y = m[1].x;
1878 r1.x = m[0].y;
1879 r1.y = m[1].y;
1880 __retVal.x = dot(r0, v);
1881 __retVal.y = dot(r1, v);
1882 }
1883
1884 vec2 __operator * (const vec2 v, const mat2 m)
1885 {
1886 __retVal.x = dot(v, m[0]);
1887 __retVal.y = dot(v, m[1]);
1888 }
1889
1890 vec3 __operator * (const mat3 m, const vec3 v)
1891 {
1892 {
1893 vec3 r0;
1894 r0.x = m[0].x;
1895 r0.y = m[1].x;
1896 r0.z = m[2].x;
1897 __asm vec3_dot __retVal.x, r0, v;
1898 }
1899 {
1900 vec3 r1;
1901 r1.x = m[0].y;
1902 r1.y = m[1].y;
1903 r1.z = m[2].y;
1904 __asm vec3_dot __retVal.y, r1, v;
1905 }
1906 {
1907 vec3 r2;
1908 r2.x = m[0].z;
1909 r2.y = m[1].z;
1910 r2.z = m[2].z;
1911 __asm vec3_dot __retVal.z, r2, v;
1912 }
1913 }
1914
1915 vec3 __operator * (const vec3 v, const mat3 m)
1916 {
1917 __retVal.x = dot(v, m[0]);
1918 __retVal.y = dot(v, m[1]);
1919 __retVal.z = dot(v, m[2]);
1920 }
1921
1922 vec4 __operator * (const mat4 m, const vec4 v)
1923 {
1924 // extract rows, then do dot product
1925 {
1926 vec4 r0;
1927 r0.x = m[0].x;
1928 r0.y = m[1].x;
1929 r0.z = m[2].x;
1930 r0.w = m[3].x;
1931 __asm vec4_dot __retVal.x, r0, v;
1932 }
1933 {
1934 vec4 r1;
1935 r1.x = m[0].y;
1936 r1.y = m[1].y;
1937 r1.z = m[2].y;
1938 r1.w = m[3].y;
1939 __asm vec4_dot __retVal.y, r1, v;
1940 }
1941 {
1942 vec4 r2;
1943 r2.x = m[0].z;
1944 r2.y = m[1].z;
1945 r2.z = m[2].z;
1946 r2.w = m[3].z;
1947 __asm vec4_dot __retVal.z, r2, v;
1948 }
1949 {
1950 vec4 r3;
1951 r3.x = m[0].w;
1952 r3.y = m[1].w;
1953 r3.z = m[2].w;
1954 r3.w = m[3].w;
1955 __asm vec4_dot __retVal.w, r3, v;
1956 }
1957 }
1958
1959 vec4 __operator * (const vec4 v, const mat4 m)
1960 {
1961 //mm
1962 __retVal.x = dot(v, m[0]);
1963 __retVal.y = dot(v, m[1]);
1964 __retVal.z = dot(v, m[2]);
1965 __retVal.w = dot(v, m[3]);
1966 }
1967
1968
1969
1970 //// mat2 assignment operators
1971
1972 void __operator += (inout mat2 m, const mat2 n)
1973 {
1974 m[0] += n[0];
1975 m[1] += n[1];
1976 }
1977
1978 void __operator -= (inout mat2 m, const mat2 n)
1979 {
1980 m[0] -= n[0];
1981 m[1] -= n[1];
1982 }
1983
1984 void __operator *= (inout mat2 m, const mat2 n)
1985 {
1986 m = m * n;
1987 }
1988
1989 void __operator /= (inout mat2 m, const mat2 n)
1990 {
1991 m[0] /= n[0];
1992 m[1] /= n[1];
1993 }
1994
1995
1996 //// mat3 assignment operators
1997
1998 void __operator += (inout mat3 m, const mat3 n)
1999 {
2000 m[0] += n[0];
2001 m[1] += n[1];
2002 m[2] += n[2];
2003 }
2004
2005 void __operator -= (inout mat3 m, const mat3 n)
2006 {
2007 m[0] -= n[0];
2008 m[1] -= n[1];
2009 m[2] -= n[2];
2010 }
2011
2012 void __operator *= (inout mat3 m, const mat3 n)
2013 {
2014 m = m * n;
2015 }
2016
2017 void __operator /= (inout mat3 m, const mat3 n)
2018 {
2019 m[0] /= n[0];
2020 m[1] /= n[1];
2021 m[2] /= n[2];
2022 }
2023
2024
2025 // mat4 assignment operators
2026
2027 void __operator += (inout mat4 m, const mat4 n)
2028 {
2029 m[0] += n[0];
2030 m[1] += n[1];
2031 m[2] += n[2];
2032 m[3] += n[3];
2033 }
2034
2035 void __operator -= (inout mat4 m, const mat4 n) {
2036 m[0] -= n[0];
2037 m[1] -= n[1];
2038 m[2] -= n[2];
2039 m[3] -= n[3];
2040 }
2041
2042 void __operator *= (inout mat4 m, const mat4 n)
2043 {
2044 m = m * n;
2045 }
2046
2047 void __operator /= (inout mat4 m, const mat4 n)
2048 {
2049 m[0] /= n[0];
2050 m[1] /= n[1];
2051 m[2] /= n[2];
2052 m[3] /= n[3];
2053 }
2054
2055
2056 //// mat2/float assignment operators
2057
2058 void __operator += (inout mat2 m, const float a) {
2059 m[0] += a;
2060 m[1] += a;
2061 }
2062
2063 void __operator -= (inout mat2 m, const float a) {
2064 m[0] -= a;
2065 m[1] -= a;
2066 }
2067
2068 void __operator *= (inout mat2 m, const float a) {
2069 m[0] *= a;
2070 m[1] *= a;
2071 }
2072
2073 void __operator /= (inout mat2 m, const float a) {
2074 m[0] /= a;
2075 m[1] /= a;
2076 }
2077
2078
2079 //// mat3/float assignment operators
2080
2081 void __operator += (inout mat3 m, const float a) {
2082 m[0] += a;
2083 m[1] += a;
2084 m[2] += a;
2085 }
2086
2087 void __operator -= (inout mat3 m, const float a) {
2088 m[0] -= a;
2089 m[1] -= a;
2090 m[2] -= a;
2091 }
2092
2093 void __operator *= (inout mat3 m, const float a) {
2094 m[0] *= a;
2095 m[1] *= a;
2096 m[2] *= a;
2097 }
2098
2099 void __operator /= (inout mat3 m, const float a) {
2100 m[0] /= a;
2101 m[1] /= a;
2102 m[2] /= a;
2103 }
2104
2105
2106 //// mat4/float assignment operators
2107
2108 void __operator += (inout mat4 m, const float a) {
2109 m[0] += a;
2110 m[1] += a;
2111 m[2] += a;
2112 m[3] += a;
2113 }
2114
2115 void __operator -= (inout mat4 m, const float a) {
2116 m[0] -= a;
2117 m[1] -= a;
2118 m[2] -= a;
2119 m[3] -= a;
2120 }
2121
2122 void __operator *= (inout mat4 m, const float a) {
2123 m[0] *= a;
2124 m[1] *= a;
2125 m[2] *= a;
2126 m[3] *= a;
2127 }
2128
2129 void __operator /= (inout mat4 m, const float a) {
2130 m[0] /= a;
2131 m[1] /= a;
2132 m[2] /= a;
2133 m[3] /= a;
2134 }
2135
2136
2137
2138 //// vec/mat assignment operators
2139
2140 void __operator *= (inout vec2 v, const mat2 m)
2141 {
2142 v = v * m;
2143 }
2144
2145 void __operator *= (inout vec3 v, const mat3 m)
2146 {
2147 v = v * m;
2148 }
2149
2150 void __operator *= (inout vec4 v, const mat4 m)
2151 {
2152 v = v * m;
2153 }
2154
2155
2156
2157 //// pre-decrement operators
2158
2159 int __operator --(inout int a)
2160 {
2161 a = a - 1;
2162 __retVal = a;
2163 }
2164
2165 ivec2 __operator --(inout ivec2 v)
2166 {
2167 v = v - ivec2(1);
2168 __retVal = v;
2169 }
2170
2171 ivec3 __operator --(inout ivec3 v)
2172 {
2173 v = v - ivec3(1);
2174 __retVal = v;
2175 }
2176
2177 ivec4 __operator --(inout ivec4 v)
2178 {
2179 v = v - ivec4(1);
2180 __retVal = v;
2181 }
2182
2183
2184 float __operator --(inout float a)
2185 {
2186 a = a - 1.0;
2187 __retVal = a;
2188 }
2189
2190 vec2 __operator --(inout vec2 v)
2191 {
2192 v = v - vec2(1.0);
2193 __retVal = v;
2194 }
2195
2196 vec3 __operator --(inout vec3 v)
2197 {
2198 v = v - vec3(1.0);
2199 __retVal = v;
2200 }
2201
2202 vec4 __operator --(inout vec4 v)
2203 {
2204 v = v - vec4(1.0);
2205 __retVal = v;
2206 }
2207
2208
2209 mat2 __operator --(inout mat2 m)
2210 {
2211 m[0] = m[0] - vec2(1.0);
2212 m[1] = m[1] - vec2(1.0);
2213 __retVal = m;
2214 }
2215
2216 mat3 __operator --(inout mat3 m)
2217 {
2218 m[0] = m[0] - vec3(1.0);
2219 m[1] = m[1] - vec3(1.0);
2220 m[2] = m[2] - vec3(1.0);
2221 __retVal = m;
2222 }
2223
2224 mat4 __operator --(inout mat4 m)
2225 {
2226 m[0] = m[0] - vec4(1.0);
2227 m[1] = m[1] - vec4(1.0);
2228 m[2] = m[2] - vec4(1.0);
2229 m[3] = m[3] - vec4(1.0);
2230 __retVal = m;
2231 }
2232
2233
2234 //// pre-increment operators
2235
2236 int __operator ++(inout int a)
2237 {
2238 a = a + 1;
2239 __retVal = a;
2240 }
2241
2242 ivec2 __operator ++(inout ivec2 v)
2243 {
2244 v = v + ivec2(1);
2245 __retVal = v;
2246 }
2247
2248 ivec3 __operator ++(inout ivec3 v)
2249 {
2250 v = v + ivec3(1);
2251 __retVal = v;
2252 }
2253
2254 ivec4 __operator ++(inout ivec4 v)
2255 {
2256 v = v + ivec4(1);
2257 __retVal = v;
2258 }
2259
2260
2261 float __operator ++(inout float a)
2262 {
2263 a = a + 1.0;
2264 __retVal = a;
2265 }
2266
2267 vec2 __operator ++(inout vec2 v)
2268 {
2269 v = v + vec2(1.0);
2270 __retVal = v;
2271 }
2272
2273 vec3 __operator ++(inout vec3 v)
2274 {
2275 v = v + vec3(1.0);
2276 __retVal = v;
2277 }
2278
2279 vec4 __operator ++(inout vec4 v)
2280 {
2281 v = v + vec4(1.0);
2282 __retVal = v;
2283 }
2284
2285
2286 mat2 __operator ++(inout mat2 m)
2287 {
2288 m[0] = m[0] + vec2(1.0);
2289 m[1] = m[1] + vec2(1.0);
2290 __retVal = m;
2291 }
2292
2293 mat3 __operator ++(inout mat3 m)
2294 {
2295 m[0] = m[0] + vec3(1.0);
2296 m[1] = m[1] + vec3(1.0);
2297 m[2] = m[2] + vec3(1.0);
2298 __retVal = m;
2299 }
2300
2301 mat4 __operator ++(inout mat4 m)
2302 {
2303 m[0] = m[0] + vec4(1.0);
2304 m[1] = m[1] + vec4(1.0);
2305 m[2] = m[2] + vec4(1.0);
2306 m[3] = m[3] + vec4(1.0);
2307 __retVal = m;
2308 }
2309
2310
2311
2312 //// post-decrement
2313
2314 int __postDecr(inout int a)
2315 {
2316 __retVal = a;
2317 a = a - 1;
2318 }
2319
2320 ivec2 __postDecr(inout ivec2 v)
2321 {
2322 __retVal = v;
2323 v = v - ivec2(1);
2324 }
2325
2326 ivec3 __postDecr(inout ivec3 v)
2327 {
2328 __retVal = v;
2329 v = v - ivec3(1);
2330 }
2331
2332 ivec4 __postDecr(inout ivec4 v)
2333 {
2334 __retVal = v;
2335 v = v - ivec4(1);
2336 }
2337
2338
2339 float __postDecr(inout float a)
2340 {
2341 __retVal = a;
2342 a = a - 1.0;
2343 }
2344
2345 vec2 __postDecr(inout vec2 v)
2346 {
2347 __retVal = v;
2348 v = v - vec2(1.0);
2349 }
2350
2351 vec3 __postDecr(inout vec3 v)
2352 {
2353 __retVal = v;
2354 v = v - vec3(1.0);
2355 }
2356
2357 vec4 __postDecr(inout vec4 v)
2358 {
2359 __retVal = v;
2360 v = v - vec4(1.0);
2361 }
2362
2363
2364 mat2 __postDecr(inout mat2 m)
2365 {
2366 __retVal = m;
2367 m[0] = m[0] - vec2(1.0);
2368 m[1] = m[1] - vec2(1.0);
2369 }
2370
2371 mat3 __postDecr(inout mat3 m)
2372 {
2373 __retVal = m;
2374 m[0] = m[0] - vec3(1.0);
2375 m[1] = m[1] - vec3(1.0);
2376 m[2] = m[2] - vec3(1.0);
2377 }
2378
2379 mat4 __postDecr(inout mat4 m)
2380 {
2381 __retVal = m;
2382 m[0] = m[0] - vec4(1.0);
2383 m[1] = m[1] - vec4(1.0);
2384 m[2] = m[2] - vec4(1.0);
2385 m[3] = m[3] - vec4(1.0);
2386 }
2387
2388
2389 //// post-increment
2390
2391 float __postIncr(inout float a)
2392 {
2393 __retVal = a;
2394 a = a + 1;
2395 }
2396
2397 vec2 __postIncr(inout vec2 v)
2398 {
2399 __retVal = v;
2400 v = v + vec2(1.0);
2401 }
2402
2403 vec3 __postIncr(inout vec3 v)
2404 {
2405 __retVal = v;
2406 v = v + vec3(1.0);
2407 }
2408
2409 vec4 __postIncr(inout vec4 v)
2410 {
2411 __retVal = v;
2412 v = v + vec4(1.0);
2413 }
2414
2415
2416 int __postIncr(inout int a)
2417 {
2418 __retVal = a;
2419 a = a + 1;
2420 }
2421
2422 ivec2 __postIncr(inout ivec2 v)
2423 {
2424 __retVal = v;
2425 v = v + ivec2(1);
2426 }
2427
2428 ivec3 __postIncr(inout ivec3 v)
2429 {
2430 __retVal = v;
2431 v = v + ivec3(1);
2432 }
2433
2434 ivec4 __postIncr(inout ivec4 v)
2435 {
2436 __retVal = v;
2437 v = v + ivec3(1);
2438 }
2439
2440
2441 mat2 __postIncr(inout mat2 m)
2442 {
2443 mat2 n = m;
2444 m[0] = m[0] + vec2(1.0);
2445 m[1] = m[1] + vec2(1.0);
2446 return n;
2447 }
2448
2449 mat3 __postIncr(inout mat3 m)
2450 {
2451 mat3 n = m;
2452 m[0] = m[0] + vec3(1.0);
2453 m[1] = m[1] + vec3(1.0);
2454 m[2] = m[2] + vec3(1.0);
2455 return n;
2456 }
2457
2458 mat4 __postIncr(inout mat4 m)
2459 {
2460 mat4 n = m;
2461 m[0] = m[0] + vec4(1.0);
2462 m[1] = m[1] + vec4(1.0);
2463 m[2] = m[2] + vec4(1.0);
2464 m[3] = m[3] + vec4(1.0);
2465 return n;
2466 }
2467
2468
2469
2470 //// inequality operators
2471
2472
2473 // XXX are the inequality operators for floats/ints really needed????
2474 bool __operator < (const float a, const float b)
2475 {
2476 __asm vec4_sgt __retVal.x, b, a;
2477 }
2478
2479
2480 bool __operator < (const int a, const int b) {
2481 return float (a) < float (b);
2482 }
2483
2484 bool __operator > (const float a, const float b) {
2485 bool c;
2486 __asm float_less c, b, a;
2487 return c;
2488 }
2489
2490 bool __operator > (const int a, const int b) {
2491 return float (a) > float (b);
2492 }
2493
2494 bool __operator >= (const float a, const float b) {
2495 bool g, e;
2496 __asm float_less g, b, a;
2497 __asm float_equal e, a, b;
2498 return g || e;
2499 }
2500
2501 bool __operator >= (const int a, const int b) {
2502 return float (a) >= float (b);
2503 }
2504
2505 bool __operator <= (const float a, const float b) {
2506 bool g, e;
2507 __asm float_less g, a, b;
2508 __asm float_equal e, a, b;
2509 return g || e;
2510 }
2511
2512 bool __operator <= (const int a, const int b) {
2513 return float (a) <= float (b);
2514 }
2515
2516
2517
2518 bool __logicalNot(const bool a)
2519 {
2520 if (a)
2521 return false;
2522 return true;
2523 }
2524
2525 bool __logicalXor(const bool a, const bool b)
2526 {
2527 // XXX return a != b;
2528 if (a)
2529 return __logicalNot(b);
2530 return b;
2531 }
2532
2533
2534
2535 //
2536 // MESA-specific extension functions.
2537 //
2538
2539 void printMESA (const float f) {
2540 __asm float_print f;
2541 }
2542
2543 void printMESA (const int i) {
2544 __asm int_print i;
2545 }
2546
2547 void printMESA (const bool b) {
2548 __asm bool_print b;
2549 }
2550
2551 void printMESA (const vec2 v) {
2552 printMESA (v.x);
2553 printMESA (v.y);
2554 }
2555
2556 void printMESA (const vec3 v) {
2557 printMESA (v.x);
2558 printMESA (v.y);
2559 printMESA (v.z);
2560 }
2561
2562 void printMESA (const vec4 v) {
2563 printMESA (v.x);
2564 printMESA (v.y);
2565 printMESA (v.z);
2566 printMESA (v.w);
2567 }
2568
2569 void printMESA (const ivec2 v) {
2570 printMESA (v.x);
2571 printMESA (v.y);
2572 }
2573
2574 void printMESA (const ivec3 v) {
2575 printMESA (v.x);
2576 printMESA (v.y);
2577 printMESA (v.z);
2578 }
2579
2580 void printMESA (const ivec4 v) {
2581 printMESA (v.x);
2582 printMESA (v.y);
2583 printMESA (v.z);
2584 printMESA (v.w);
2585 }
2586
2587 void printMESA (const bvec2 v) {
2588 printMESA (v.x);
2589 printMESA (v.y);
2590 }
2591
2592 void printMESA (const bvec3 v) {
2593 printMESA (v.x);
2594 printMESA (v.y);
2595 printMESA (v.z);
2596 }
2597
2598 void printMESA (const bvec4 v) {
2599 printMESA (v.x);
2600 printMESA (v.y);
2601 printMESA (v.z);
2602 printMESA (v.w);
2603 }
2604
2605 void printMESA (const mat2 m) {
2606 printMESA (m[0]);
2607 printMESA (m[1]);
2608 }
2609
2610 void printMESA (const mat3 m) {
2611 printMESA (m[0]);
2612 printMESA (m[1]);
2613 printMESA (m[2]);
2614 }
2615
2616 void printMESA (const mat4 m) {
2617 printMESA (m[0]);
2618 printMESA (m[1]);
2619 printMESA (m[2]);
2620 printMESA (m[3]);
2621 }
2622
2623 void printMESA (const sampler1D e) {
2624 __asm int_print e;
2625 }
2626
2627 void printMESA (const sampler2D e) {
2628 __asm int_print e;
2629 }
2630
2631 void printMESA (const sampler3D e) {
2632 __asm int_print e;
2633 }
2634
2635 void printMESA (const samplerCube e) {
2636 __asm int_print e;
2637 }
2638
2639 void printMESA (const sampler1DShadow e) {
2640 __asm int_print e;
2641 }
2642
2643 void printMESA (const sampler2DShadow e) {
2644 __asm int_print e;
2645 }
2646