ARB prog parser: fix parameter binding type
[mesa.git] / progs / slang / cltest.txt
1 $ /*
2 $ Shader test script.
3 $
4 $ Author: Michal Krol
5 $
6 $ Comment line starts with dollar sign and white space.
7 $
8 $ $program <name> starts a new test program section called <name>. Contains all other sections.
9 $
10 $ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of
11 $ four values that form single vertex attrib.
12 $
13 $ $vertex starts vertex shader section. Contains $code and &output sections.
14 $
15 $ $code starts source code section. All text in this section gets compiled into appropriate
16 $ shader object.
17 $
18 $ $output starts shader execution results section. These are compared, value-by-value,
19 $ with results of executing printMESA() functions within a shader.
20 $ */
21
22
23 $ /*
24 $ --------------------------------------------------------------------------------------------------
25 $ Test printMESA() function.
26 $ */
27
28 $program PRINT TEST
29
30 $vertex
31
32 $code
33
34 #version 110
35
36 #extension MESA_shader_debug: require
37
38 void main () {
39 gl_Position = gl_ModelViewMatrix * gl_Vertex;
40 gl_FrontColor = vec4 (1.0);
41
42 printMESA (11.1);
43 printMESA (111);
44 printMESA (true);
45
46 printMESA (vec2 (22.1, 22.2));
47 printMESA (vec3 (33.1, 33.2, 33.3));
48 printMESA (vec4 (44.1, 44.2, 44.3, 44.4));
49
50 printMESA (ivec2 (221, 222));
51 printMESA (ivec3 (331, 332, 333));
52 printMESA (ivec4 (441, 442, 443, 444));
53
54 printMESA (bvec2 (false, true));
55 printMESA (bvec3 (true, true, false));
56 printMESA (bvec4 (true, false, true, false));
57
58 printMESA (mat2 (55.11, 55.12, 55.21, 55.22));
59 printMESA (mat3 (66.11, 66.12, 66.13,
60 66.21, 66.22, 66.23,
61 66.31, 66.32, 66.33));
62 printMESA (mat4 (77.11, 77.12, 77.13, 77.14,
63 77.21, 77.22, 77.23, 77.24,
64 77.31, 77.32, 77.33, 77.34,
65 77.41, 77.42, 77.43, 77.44));
66 }
67
68 $output
69
70 11.1
71 111
72 true
73
74 22.1
75 22.2
76 33.1
77 33.2
78 33.3
79 44.1
80 44.2
81 44.3
82 44.4
83
84 221
85 222
86 331
87 332
88 333
89 441
90 442
91 443
92 444
93
94 false
95 true
96 true
97 true
98 false
99 true
100 false
101 true
102 false
103
104 55.11
105 55.12
106 55.21
107 55.22
108
109 66.11
110 66.12
111 66.13
112 66.21
113 66.22
114 66.23
115 66.31
116 66.32
117 66.33
118
119 77.11
120 77.12
121 77.13
122 77.14
123 77.21
124 77.22
125 77.23
126 77.24
127 77.31
128 77.32
129 77.33
130 77.34
131 77.41
132 77.42
133 77.43
134 77.44
135
136
137 $ /*
138 $ --------------------------------------------------------------------------------------------------
139 $ Test type casting.
140 $ */
141
142 $program TYPE CAST TEST
143
144 $attrib gl_Vertex
145 0.0 0.0 0.0 1.0
146
147 $attrib _Zero
148 0.0 0.0 0.0 0.0
149
150 $attrib _One
151 1.1 0.0 0.0 0.0
152
153 $attrib _Two
154 2.2 0.0 0.0 0.0
155
156 $attrib _MinusThree
157 -3.3 0.0 0.0 0.0
158
159 $vertex
160
161 $code
162
163 #version 110
164
165 #extension MESA_shader_debug: require
166
167 attribute float _Zero;
168 attribute float _One;
169 attribute float _Two;
170 attribute float _MinusThree;
171
172 void main () {
173 gl_Position = gl_ModelViewMatrix * gl_Vertex;
174 gl_FrontColor = vec4 (1.0);
175
176 printMESA (_Zero);
177 printMESA (_One);
178 printMESA (_Two);
179 printMESA (_MinusThree);
180
181 printMESA (float (_Zero));
182 printMESA (float (_One));
183 printMESA (float (_Two));
184 printMESA (float (_MinusThree));
185 printMESA (float (45.99));
186 printMESA (float (-6.17));
187
188 printMESA (bool (_Zero));
189 printMESA (bool (_One));
190 printMESA (bool (_Two));
191 printMESA (bool (_MinusThree));
192 printMESA (bool (45.99));
193 printMESA (bool (-6.17));
194 printMESA (bool (0.0001));
195 printMESA (bool (0.0));
196
197 printMESA (int (_Zero));
198 printMESA (int (_One));
199 printMESA (int (_Two));
200 printMESA (int (_MinusThree));
201 printMESA (int (45.99));
202 printMESA (int (45.22));
203 printMESA (int (-6.17));
204 printMESA (int (-6.87));
205 }
206
207 $output
208
209 0.0
210 1.1
211 2.2
212 -3.3
213
214 0.0
215 1.1
216 2.2
217 -3.3
218 45.99
219 -6.17
220
221 false
222 true
223 true
224 true
225 true
226 true
227 true
228 false
229
230 0
231 1
232 2
233 -3
234 45
235 45
236 -6
237 -6
238
239 $ /*
240 $ --------------------------------------------------------------------------------------------------
241 $ Test vector swizzles.
242 $ */
243
244 $program SWIZZLE TEST
245
246 $attrib gl_Vertex
247 0.0 0.0 0.0 1.0
248
249 $attrib _One
250 1.1 1.2 1.3 1.4
251
252 $attrib _Two
253 2.1 2.2 2.3 2.4
254
255 $vertex
256
257 $code
258
259 #version 110
260
261 #extension MESA_shader_debug: require
262
263 attribute vec4 _One;
264 attribute vec4 _Two;
265
266 void assign5678 (out vec4 v)
267 {
268 v.x = 5.5;
269 v.y = 6.6;
270 v.z = 7.7;
271 v.w = 8.8;
272 }
273
274 void main () {
275 gl_Position = gl_ModelViewMatrix * gl_Vertex;
276 gl_FrontColor = vec4 (1.0);
277
278 printMESA (_One);
279 printMESA (_Two);
280
281 printMESA (_One.x);
282 printMESA (_One.y);
283 printMESA (_One.z);
284 printMESA (_One.w);
285
286 printMESA (_Two.xy);
287 printMESA (_Two.yx);
288 printMESA (_Two.xw);
289 printMESA (_Two.wx);
290 printMESA (_Two.yz);
291 printMESA (_Two.zy);
292 printMESA (_Two.xz);
293 printMESA (_Two.zx);
294 printMESA (_Two.zw);
295 printMESA (_Two.wz);
296
297 printMESA (_One.xyz);
298 printMESA (_One.yzx);
299 printMESA (_One.zxy);
300 printMESA (_One.xzy);
301 printMESA (_One.yzw);
302 printMESA (_One.zwx);
303
304 printMESA (_Two.xyzw);
305 printMESA (_Two.yzwx);
306 printMESA (_Two.wzyx);
307 printMESA (_Two.zwyx);
308
309 printMESA (_One.xx);
310 printMESA (_One.zz);
311 printMESA (_One.ww);
312
313 printMESA (_Two.xxx);
314 printMESA (_Two.yyy);
315 printMESA (_Two.www);
316
317 printMESA (_One.xxxx);
318 printMESA (_One.zzzz);
319
320 printMESA (_Two.xxyy);
321 printMESA (_Two.wwxx);
322 printMESA (_Two.zxxw);
323
324 vec4 v;
325
326 v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);
327 printMESA (v);
328
329 assign5678 (v.ywxz);
330 printMESA (v);
331 }
332
333 $output
334
335 1.1
336 1.2
337 1.3
338 1.4
339 2.1
340 2.2
341 2.3
342 2.4
343
344 1.1
345 1.2
346 1.3
347 1.4
348
349 2.1
350 2.2
351 2.2
352 2.1
353 2.1
354 2.4
355 2.4
356 2.1
357 2.2
358 2.3
359 2.3
360 2.2
361 2.1
362 2.3
363 2.3
364 2.1
365 2.3
366 2.4
367 2.4
368 2.3
369
370 1.1
371 1.2
372 1.3
373 1.2
374 1.3
375 1.1
376 1.3
377 1.1
378 1.2
379 1.1
380 1.3
381 1.2
382 1.2
383 1.3
384 1.4
385 1.3
386 1.4
387 1.1
388
389 2.1
390 2.2
391 2.3
392 2.4
393 2.2
394 2.3
395 2.4
396 2.1
397 2.4
398 2.3
399 2.2
400 2.1
401 2.3
402 2.4
403 2.2
404 2.1
405
406 1.1
407 1.1
408 1.3
409 1.3
410 1.4
411 1.4
412
413 2.1
414 2.1
415 2.1
416 2.2
417 2.2
418 2.2
419 2.4
420 2.4
421 2.4
422
423 1.1
424 1.1
425 1.1
426 1.1
427 1.3
428 1.3
429 1.3
430 1.3
431
432 2.1
433 2.1
434 2.2
435 2.2
436 2.4
437 2.4
438 2.1
439 2.1
440 2.3
441 2.1
442 2.1
443 2.4
444
445 6.6
446 8.8
447 5.5
448 7.7
449
450 7.7
451 5.5
452 8.8
453 6.6
454
455
456 $ /*
457 $ --------------------------------------------------------------------------------------------------
458 $ Test relational operators.
459 $ */
460
461 $program RELATIONAL OPERATOR TEST
462
463 $attrib gl_Vertex
464 0.0 0.0 0.0 1.0
465
466 $attrib _Two
467 2.0 0.0 0.0 0.0
468
469 $attrib _Two2
470 2.0 0.0 0.0 0.0
471
472 $attrib _MinusThree
473 -3.0 0.0 0.0 0.0
474
475 $vertex
476
477 $code
478
479 #version 110
480
481 #extension MESA_shader_debug: require
482
483 attribute float _Two;
484 attribute float _Two2;
485 attribute float _MinusThree;
486
487 struct foo
488 {
489 float f;
490 vec4 v4;
491 vec3 v3;
492 mat4 m4;
493 int i;
494 bool b;
495 };
496
497 void printMESA (const in foo bar)
498 {
499 printMESA (bar.f);
500 printMESA (bar.v4);
501 printMESA (bar.v3);
502 printMESA (bar.m4);
503 printMESA (bar.i);
504 printMESA (bar.b);
505 }
506
507 void main () {
508 gl_Position = gl_ModelViewMatrix * gl_Vertex;
509 gl_FrontColor = vec4 (1.0);
510
511 int iTwo = int (_Two);
512 int iTwo2 = int (_Two2);
513 int iMinusThree = int (_MinusThree);
514
515 printMESA (_Two <= _Two);
516 printMESA (_Two <= _Two2);
517 printMESA (_Two <= _MinusThree);
518 printMESA (_MinusThree <= _Two);
519 printMESA (iTwo <= iTwo);
520 printMESA (iTwo <= iTwo2);
521 printMESA (iTwo <= iMinusThree);
522 printMESA (iMinusThree <= iTwo);
523
524 printMESA (_Two >= _Two);
525 printMESA (_Two >= _Two2);
526 printMESA (_Two >= _MinusThree);
527 printMESA (_MinusThree >= _Two);
528 printMESA (iTwo >= iTwo);
529 printMESA (iTwo >= iTwo2);
530 printMESA (iTwo >= iMinusThree);
531 printMESA (iMinusThree >= iTwo);
532
533 printMESA (_Two < _Two);
534 printMESA (_Two < _Two2);
535 printMESA (_Two < _MinusThree);
536 printMESA (_MinusThree < _Two);
537 printMESA (iTwo < iTwo);
538 printMESA (iTwo < iTwo2);
539 printMESA (iTwo < iMinusThree);
540 printMESA (iMinusThree < iTwo);
541
542 printMESA (_Two > _Two);
543 printMESA (_Two > _Two2);
544 printMESA (_Two > _MinusThree);
545 printMESA (_MinusThree > _Two);
546 printMESA (iTwo > iTwo);
547 printMESA (iTwo > iTwo2);
548 printMESA (iTwo > iMinusThree);
549 printMESA (iMinusThree > iTwo);
550
551 printMESA (_Two == _Two);
552 printMESA (_Two == _Two2);
553 printMESA (_Two == _MinusThree);
554 printMESA (_MinusThree == _MinusThree);
555 printMESA (iTwo == iTwo);
556 printMESA (iTwo == iTwo2);
557 printMESA (iTwo == iMinusThree);
558 printMESA (iMinusThree == iMinusThree);
559
560 printMESA (_Two != _Two);
561 printMESA (_Two != _Two2);
562 printMESA (_Two != _MinusThree);
563 printMESA (_MinusThree != _MinusThree);
564 printMESA (iTwo != iTwo);
565 printMESA (iTwo != iTwo2);
566 printMESA (iTwo != iMinusThree);
567 printMESA (iMinusThree != iMinusThree);
568
569 foo foo1;
570 foo1.f = 13.31;
571 foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
572 foo1.v3 = vec3 (33.11, 33.22, 33.33);
573 foo1.m4 = mat4 (17.88);
574 foo1.i = 666;
575 foo1.b = true;
576 printMESA (foo1);
577
578 // make foo2 the same as foo1
579 foo foo2;
580 foo2.f = 13.31;
581 foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
582 foo2.v3 = vec3 (33.11, 33.22, 33.33);
583 foo2.m4 = mat4 (17.88);
584 foo2.i = 666;
585 foo2.b = true;
586
587 printMESA (foo1 == foo2);
588 printMESA (foo1 != foo2);
589
590 // make them a little bit different
591 foo2.m4[2].y = 333.333;
592 printMESA (foo2);
593
594 printMESA (foo1 == foo2);
595 printMESA (foo1 != foo2);
596 }
597
598 $output
599
600 true
601 true
602 false
603 true
604 true
605 true
606 false
607 true
608
609 true
610 true
611 true
612 false
613 true
614 true
615 true
616 false
617
618 false
619 false
620 false
621 true
622 false
623 false
624 false
625 true
626
627 false
628 false
629 true
630 false
631 false
632 false
633 true
634 false
635
636 true
637 true
638 false
639 true
640 true
641 true
642 false
643 true
644
645 false
646 false
647 true
648 false
649 false
650 false
651 true
652 false
653
654 13.31
655 44.11
656 44.22
657 44.33
658 44.44
659 33.11
660 33.22
661 33.33
662 17.88
663 0.0
664 0.0
665 0.0
666 0.0
667 17.88
668 0.0
669 0.0
670 0.0
671 0.0
672 17.88
673 0.0
674 0.0
675 0.0
676 0.0
677 17.88
678 666
679 true
680
681 true
682 false
683
684 13.31
685 44.11
686 44.22
687 44.33
688 44.44
689 33.11
690 33.22
691 33.33
692 17.88
693 0.0
694 0.0
695 0.0
696 0.0
697 17.88
698 0.0
699 0.0
700 0.0
701 333.333
702 17.88
703 0.0
704 0.0
705 0.0
706 0.0
707 17.88
708 666
709 true
710
711 false
712 true
713
714
715 $ /*
716 $ --------------------------------------------------------------------------------------------------
717 $ Test logical operators.
718 $ */
719
720 $program LOGICAL OPERATOR TEST
721
722 $attrib gl_Vertex
723 0.0 0.0 0.0 1.0
724
725 $attrib _False
726 0.0 0.0 0.0 0.0
727
728 $attrib _True
729 1.0 0.0 0.0 0.0
730
731 $attrib _False2
732 0.0 0.0 0.0 0.0
733
734 $attrib _True2
735 1.0 0.0 0.0 0.0
736
737 $vertex
738
739 $code
740
741 #version 110
742
743 #extension MESA_shader_debug: require
744
745 attribute float _False;
746 attribute float _True;
747 attribute float _False2;
748 attribute float _True2;
749
750 void main () {
751 gl_Position = gl_ModelViewMatrix * gl_Vertex;
752 gl_FrontColor = vec4 (1.0);
753
754 printMESA (_False);
755 printMESA (_True);
756 printMESA (_False2);
757 printMESA (_True2);
758
759 bool False = bool (_False);
760 bool True = bool (_True);
761 bool False2 = bool (_False2);
762 bool True2 = bool (_True2);
763
764 //
765 // It is important to test each operator with the following argument types:
766 // * Both arguments are different variables, even if they have the same values.
767 // False and False2 are distinct attributes, but are the same in value.
768 // * Both arguments may be the same variables. This case tests possible
769 // optimizations, e.g. X && X --> X.
770 // * Both arguments are constant. This tests constant folding.
771 //
772
773 printMESA (!False);
774 printMESA (!True);
775 printMESA (!false);
776 printMESA (!true);
777
778 printMESA (False ^^ False2);
779 printMESA (False ^^ True2);
780 printMESA (True ^^ False2);
781 printMESA (True ^^ True2);
782 printMESA (False ^^ False);
783 printMESA (False ^^ True);
784 printMESA (True ^^ False);
785 printMESA (True ^^ True);
786 printMESA (false ^^ false);
787 printMESA (false ^^ true);
788 printMESA (true ^^ false);
789 printMESA (true ^^ true);
790
791 printMESA (False && False2);
792 printMESA (False && True2);
793 printMESA (True && False2);
794 printMESA (True && True2);
795 printMESA (False && False);
796 printMESA (False && True);
797 printMESA (True && False);
798 printMESA (True && True);
799 printMESA (false && false);
800 printMESA (false && true);
801 printMESA (true && false);
802 printMESA (true && true);
803
804 printMESA (False || False2);
805 printMESA (False || True2);
806 printMESA (True || False2);
807 printMESA (True || True2);
808 printMESA (False || False);
809 printMESA (False || True);
810 printMESA (True || False);
811 printMESA (True || True);
812 printMESA (false || false);
813 printMESA (false || true);
814 printMESA (true || false);
815 printMESA (true || true);
816
817 //
818 // Test short-circuit evaluation of && and ||. The right expression evaluation depends
819 // on the value of the left expression. If the right expression has side effects, we
820 // can easily test if it happened.
821 //
822
823 bool x;
824
825 x = false;
826 printMESA (x);
827 printMESA (False && (x = true));
828 printMESA (x);
829
830 x = false;
831 printMESA (x);
832 printMESA (false && (x = true));
833 printMESA (x);
834
835 x = true;
836 printMESA (x);
837 printMESA (True || (x = false));
838 printMESA (x);
839
840 x = true;
841 printMESA (x);
842 printMESA (true || (x = false));
843 printMESA (x);
844 }
845
846 $output
847
848 0.0
849 1.0
850 0.0
851 1.0
852
853 true
854 false
855 true
856 false
857
858 false
859 true
860 true
861 false
862 false
863 true
864 true
865 false
866 false
867 true
868 true
869 false
870
871 false
872 false
873 false
874 true
875 false
876 false
877 false
878 true
879 false
880 false
881 false
882 true
883
884 false
885 true
886 true
887 true
888 false
889 true
890 true
891 true
892 false
893 true
894 true
895 true
896
897 false
898 false
899 false
900
901 false
902 false
903 false
904
905 true
906 true
907 true
908
909 true
910 true
911 true
912
913
914 $ /*
915 $ --------------------------------------------------------------------------------------------------
916 $ Test subscript operator/array access.
917 $ */
918
919 $program ARRAY ACCESS TEST
920
921 $attrib gl_Vertex
922 0.0 0.0 0.0 1.0
923
924 $attrib _Zero
925 0.0 0.0 0.0 0.0
926
927 $attrib _One
928 1.1 0.0 0.0 0.0
929
930 $attrib _Two
931 2.9 0.0 0.0 0.0
932
933 $attrib _Vec
934 11.11 22.22 33.33 44.44
935
936 $vertex
937
938 $code
939
940 #version 110
941
942 #extension MESA_shader_debug: require
943
944 attribute float _Zero;
945 attribute float _One;
946 attribute float _Two;
947 attribute vec4 _Vec;
948
949 void main () {
950 gl_Position = gl_ModelViewMatrix * gl_Vertex;
951 gl_FrontColor = vec4 (1.0);
952
953 printMESA (_Zero);
954 printMESA (_One);
955 printMESA (_Two);
956 printMESA (_Vec);
957
958 printMESA (_Vec[0]);
959 printMESA (_Vec[1]);
960 printMESA (_Vec[2]);
961 printMESA (_Vec[3]);
962
963 printMESA (_Vec[int (_Zero)]);
964 printMESA (_Vec[int (_One)]);
965 printMESA (_Vec[int (_Two)]);
966 }
967
968 $output
969
970 0.0
971 1.1
972 2.9
973 11.11
974 22.22
975 33.33
976 44.44
977
978 11.11
979 22.22
980 33.33
981 44.44
982
983 11.11
984 22.22
985 33.33
986
987
988 $ /*
989 $ --------------------------------------------------------------------------------------------------
990 $ Test pre/post-increment/decrement operators.
991 $ Note: assumes relational operators being correct.
992 $ */
993
994 $program PRE/POST-INC/DEC OPERATOR TEST
995
996 $attrib gl_Vertex
997 0.0 0.0 0.0 1.0
998
999 $attrib _Zero
1000 0.0 0.0 0.0 0.0
1001
1002 $attrib _One
1003 1.1 0.0 0.0 0.0
1004
1005 $attrib _Two4
1006 2.1 2.2 2.3 2.4
1007
1008 $vertex
1009
1010 $code
1011
1012 #version 110
1013
1014 #extension MESA_shader_debug: require
1015
1016 attribute float _Zero;
1017 attribute float _One;
1018 attribute vec4 _Two4;
1019
1020 float fZero, fOne;
1021 vec4 fTwo4;
1022 int iZero, iOne;
1023 ivec4 iTwo4;
1024
1025 void reset () {
1026 fZero = _Zero;
1027 fOne = _One;
1028 fTwo4 = _Two4;
1029 iZero = int (_Zero);
1030 iOne = int (_One);
1031 iTwo4 = ivec4 (_Two4);
1032 }
1033
1034 void main () {
1035 gl_Position = gl_ModelViewMatrix * gl_Vertex;
1036 gl_FrontColor = vec4 (1.0);
1037
1038 printMESA (_Zero);
1039 printMESA (_One);
1040 printMESA (_Two4);
1041
1042 // pre-increment
1043 reset ();
1044 printMESA (++fZero);
1045 printMESA (++fOne);
1046 printMESA (++iZero);
1047 printMESA (++iOne);
1048 printMESA (fZero);
1049 printMESA (fOne);
1050 printMESA (iZero);
1051 printMESA (iOne);
1052 printMESA (++fTwo4 == _Two4 + 1.0);
1053 printMESA (++iTwo4 == ivec4 (_Two4) + 1);
1054
1055 // pre-decrement
1056 reset ();
1057 printMESA (--fZero);
1058 printMESA (--fOne);
1059 printMESA (--iZero);
1060 printMESA (--iOne);
1061 printMESA (fZero);
1062 printMESA (fOne);
1063 printMESA (iZero);
1064 printMESA (iOne);
1065 printMESA (--fTwo4 == _Two4 - 1.0);
1066 printMESA (--iTwo4 == ivec4 (_Two4) - 1);
1067
1068 // post-increment
1069 reset ();
1070 printMESA (fZero++);
1071 printMESA (fOne++);
1072 printMESA (iZero++);
1073 printMESA (iOne++);
1074 printMESA (fZero);
1075 printMESA (fOne);
1076 printMESA (iZero);
1077 printMESA (iOne);
1078 printMESA (fTwo4++ == _Two4);
1079 printMESA (iTwo4++ == ivec4 (_Two4));
1080
1081 // post-decrement
1082 reset ();
1083 printMESA (fZero--);
1084 printMESA (fOne--);
1085 printMESA (iZero--);
1086 printMESA (iOne--);
1087 printMESA (fZero);
1088 printMESA (fOne);
1089 printMESA (iZero);
1090 printMESA (iOne);
1091 printMESA (fTwo4-- == _Two4);
1092 printMESA (iTwo4-- == ivec4 (_Two4));
1093 }
1094
1095 $output
1096
1097 0.0
1098 1.1
1099 2.1
1100 2.2
1101 2.3
1102 2.4
1103
1104 1.0
1105 2.1
1106 1
1107 2
1108 1.0
1109 2.1
1110 1
1111 2
1112 true
1113 true
1114
1115 -1.0
1116 0.1
1117 -1
1118 0
1119 -1.0
1120 0.1
1121 -1
1122 0
1123 true
1124 true
1125
1126 0.0
1127 1.1
1128 0
1129 1
1130 1.0
1131 2.1
1132 1
1133 2
1134 true
1135 true
1136
1137 0.0
1138 1.1
1139 0
1140 1
1141 -1.0
1142 0.1
1143 -1
1144 0
1145 true
1146 true
1147
1148
1149 $ /*
1150 $ --------------------------------------------------------------------------------------------------
1151 $ Test arithmetical operators.
1152 $ */
1153
1154 $program ARITHMETICAL OPERATOR TEST
1155
1156 $attrib gl_Vertex
1157 0.0 0.0 0.0 1.0
1158
1159 $attrib _Zero
1160 0.0 0.0 0.0 0.0
1161
1162 $attrib _One
1163 1.1 0.0 0.0 0.0
1164
1165 $attrib _Two4
1166 2.1 2.2 2.3 2.4
1167
1168 $vertex
1169
1170 $code
1171
1172 #version 110
1173
1174 #extension MESA_shader_debug: require
1175
1176 attribute float _Zero;
1177 attribute float _One;
1178 attribute vec4 _Two4;
1179
1180 void main () {
1181 gl_Position = gl_ModelViewMatrix * gl_Vertex;
1182 gl_FrontColor = vec4 (1.0);
1183
1184 printMESA (_Zero);
1185 printMESA (_One);
1186 printMESA (_Two4);
1187
1188 int iZero = int (_Zero);
1189 int iOne = int (_One);
1190 ivec4 iTwo4 = ivec4 (_Two4);
1191
1192 printMESA (-_Zero);
1193 printMESA (-_One);
1194 printMESA (-_Two4);
1195 printMESA (-_Two4.z);
1196
1197 printMESA (_Zero + 0.0);
1198 printMESA (_One + 0.0);
1199 printMESA (_Two4 + 0.0);
1200 printMESA (_Two4.y + 0.0);
1201
1202 printMESA (_Zero + _Zero);
1203 printMESA (_Zero + _One);
1204 printMESA (_Zero + _Two4);
1205 printMESA (_One + _Zero);
1206 printMESA (_One + _Two4);
1207 printMESA (_Two4 + _Two4);
1208
1209 printMESA (_Zero - 0.0);
1210 printMESA (_One - 0.0);
1211 printMESA (_Two4 - 0.0);
1212 printMESA (_Two4.y - 0.0);
1213
1214 printMESA (_Zero - _Zero);
1215 printMESA (_Zero - _One);
1216 printMESA (_Zero - _Two4);
1217 printMESA (_One - _Zero);
1218 printMESA (_One - _Two4);
1219 printMESA (_Two4 - _Two4);
1220
1221 printMESA (_Zero * 1.0);
1222 printMESA (_One * 1.0);
1223 printMESA (_Two4 * 1.0);
1224 printMESA (_Two4.x * 1.0);
1225
1226 printMESA (_Zero * _Zero);
1227 printMESA (_Zero * _One);
1228 printMESA (_Zero * _Two4);
1229 printMESA (_One * _Zero);
1230 printMESA (_One * _One);
1231 printMESA (_One * _Two4);
1232 printMESA (_Two4 * _Two4);
1233
1234 printMESA (_Zero / 1.0);
1235 printMESA (_One / 1.0);
1236 printMESA (_Two4 / 1.0);
1237 printMESA (_Two4.x / 1.0);
1238
1239 printMESA (_Zero / _One);
1240 printMESA (_Zero / _Two4);
1241 printMESA (_One / _One);
1242 printMESA (_One / _Two4);
1243 printMESA (_Two4 / _Two4);
1244 }
1245
1246 $output
1247
1248 0.0
1249 1.1
1250 2.1
1251 2.2
1252 2.3
1253 2.4
1254
1255 0.0
1256 -1.1
1257 -2.1
1258 -2.2
1259 -2.3
1260 -2.4
1261 -2.3
1262
1263 0.0
1264 1.1
1265 2.1
1266 2.2
1267 2.3
1268 2.4
1269 2.2
1270
1271 0.0
1272 1.1
1273 2.1
1274 2.2
1275 2.3
1276 2.4
1277 1.1
1278 3.2
1279 3.3
1280 3.4
1281 3.5
1282 4.2
1283 4.4
1284 4.6
1285 4.8
1286
1287 0.0
1288 1.1
1289 2.1
1290 2.2
1291 2.3
1292 2.4
1293 2.2
1294
1295 0.0
1296 -1.1
1297 -2.1
1298 -2.2
1299 -2.3
1300 -2.4
1301 1.1
1302 -1.0
1303 -1.1
1304 -1.2
1305 -1.3
1306 0.0
1307 0.0
1308 0.0
1309 0.0
1310
1311 0.0
1312 1.1
1313 2.1
1314 2.2
1315 2.3
1316 2.4
1317 2.1
1318
1319 0.0
1320 0.0
1321 0.0
1322 0.0
1323 0.0
1324 0.0
1325 0.0
1326 1.21
1327 2.31
1328 2.42
1329 2.53
1330 2.64
1331 4.41
1332 4.84
1333 5.29
1334 5.76
1335
1336 0.0
1337 1.1
1338 2.1
1339 2.2
1340 2.3
1341 2.4
1342 2.1
1343
1344 0.0
1345 0.0
1346 0.0
1347 0.0
1348 0.0
1349 1.0
1350 0.52381
1351 0.5
1352 0.47826
1353 0.45833
1354 1.0
1355 1.0
1356 1.0
1357 1.0
1358
1359
1360 $ /*
1361 $ --------------------------------------------------------------------------------------------------
1362 $ Test matrix operations.
1363 $ Note: assumes relational operators being correct.
1364 $ */
1365
1366 $program MATRIX TEST
1367
1368 $attrib gl_Vertex
1369 0.0 0.0 0.0 1.0
1370
1371 $attrib _Zero
1372 0.0 0.0 0.0 0.0
1373
1374 $attrib _One
1375 1.0 1.0 1.0 1.0
1376
1377 $attrib _Two
1378 2.0 2.0 2.0 2.0
1379
1380 $vertex
1381
1382 $code
1383
1384 #version 110
1385
1386 #extension MESA_shader_debug: require
1387
1388 attribute vec4 _Zero;
1389 attribute vec4 _One;
1390 attribute vec4 _Two;
1391
1392 void main () {
1393 gl_Position = gl_ModelViewMatrix * gl_Vertex;
1394 gl_FrontColor = vec4 (1.0);
1395
1396 printMESA (_Zero);
1397 printMESA (_One);
1398 printMESA (_Two);
1399
1400 mat4 Identity = mat4 (_One.x);
1401
1402 printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,
1403 0.0, 1.0, 0.0, 0.0,
1404 0.0, 0.0, 1.0, 0.0,
1405 0.0, 0.0, 0.0, 1.0));
1406 printMESA (Identity * _Two == _Two);
1407
1408 mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,
1409 2.1, 2.2, 2.3, 2.4,
1410 3.1, 3.2, 3.3, 3.4,
1411 4.1, 4.2, 4.3, 4.4);
1412
1413 printMESA (Matrix[2].y);
1414 printMESA (Matrix[1]);
1415 }
1416
1417 $output
1418
1419 0.0
1420 0.0
1421 0.0
1422 0.0
1423 1.0
1424 1.0
1425 1.0
1426 1.0
1427 2.0
1428 2.0
1429 2.0
1430 2.0
1431 true
1432 true
1433 3.2
1434 2.1
1435 2.2
1436 2.3
1437 2.4
1438
1439
1440 $ /*
1441 $ --------------------------------------------------------------------------------------------------
1442 $ Test vec4 extension operations.
1443 $ */
1444
1445 $program VEC4 EXTENSION OPERATIONS
1446
1447 $attrib gl_Vertex
1448 0.0 0.0 0.0 1.0
1449
1450 $attrib _One
1451 1.1 0.0 0.0 0.0
1452
1453 $attrib _Two4
1454 2.1 2.2 2.3 2.4
1455
1456 $attrib _Three4
1457 3.1 3.2 3.3 3.4
1458
1459 $vertex
1460
1461 $code
1462
1463 #version 110
1464
1465 #extension MESA_shader_debug: require
1466
1467 attribute float _One;
1468 attribute vec4 _Two4;
1469 attribute vec4 _Three4;
1470
1471 void main () {
1472 gl_Position = gl_ModelViewMatrix * gl_Vertex;
1473 gl_FrontColor = vec4 (1.0);
1474
1475 printMESA (_One);
1476 printMESA (_Two4);
1477 printMESA (_Three4);
1478
1479 printMESA (vec4 (_One));
1480
1481 printMESA (_Two4 + _Three4);
1482 printMESA (_Two4 - _Three4);
1483 printMESA (_Two4 * _Three4);
1484 printMESA (_Two4 / _Three4);
1485
1486 printMESA (_Two4 + _One);
1487 printMESA (_Two4 - _One);
1488 printMESA (_Two4 * _One);
1489 printMESA (_Two4 / _One);
1490
1491 printMESA (_One + _Two4);
1492 printMESA (_One - _Two4);
1493 printMESA (_One * _Two4);
1494 printMESA (_One / _Two4);
1495
1496 printMESA (-_Three4);
1497
1498 printMESA (dot (_Two4.xyz, _Three4.xyz));
1499 printMESA (dot (_Two4, _Three4));
1500
1501 printMESA (length (_Two4.xyz));
1502 printMESA (length (_Three4));
1503
1504 printMESA (normalize (_Two4.xyz));
1505 printMESA (normalize (_Three4));
1506
1507 vec4 tmp = _Two4;
1508 printMESA (tmp);
1509
1510 printMESA (_Two4 == _Three4);
1511 printMESA (_Two4 != _Three4);
1512 printMESA (_Two4 == _Two4);
1513 printMESA (_Three4 != _Three4);
1514 printMESA (_Two4 != vec4 (_Two4.xyz, 999.0));
1515 printMESA (_Two4 != vec4 (999.0, _Two4.yzw));
1516 }
1517
1518 $output
1519
1520 1.1
1521 2.1
1522 2.2
1523 2.3
1524 2.4
1525 3.1
1526 3.2
1527 3.3
1528 3.4
1529
1530 1.1
1531 1.1
1532 1.1
1533 1.1
1534
1535 5.2
1536 5.4
1537 5.6
1538 5.8
1539 -1.0
1540 -1.0
1541 -1.0
1542 -1.0
1543 6.51
1544 7.04
1545 7.59
1546 8.16
1547 0.677419
1548 0.6875
1549 0.69697
1550 0.705882
1551
1552 3.2
1553 3.3
1554 3.4
1555 3.5
1556 1.0
1557 1.1
1558 1.2
1559 1.3
1560 2.31
1561 2.42
1562 2.53
1563 2.64
1564 1.909091
1565 2.0
1566 2.090909
1567 2.181818
1568
1569 3.2
1570 3.3
1571 3.4
1572 3.5
1573 -1.0
1574 -1.1
1575 -1.2
1576 -1.3
1577 2.31
1578 2.42
1579 2.53
1580 2.64
1581 0.52381
1582 0.5
1583 0.478261
1584 0.458333
1585
1586 -3.1
1587 -3.2
1588 -3.3
1589 -3.4
1590
1591 21.14
1592 29.3
1593
1594 3.813135
1595 6.503845
1596
1597 0.550728
1598 0.576953
1599 0.603178
1600 0.476641
1601 0.492017
1602 0.507392
1603 0.522768
1604
1605 2.1
1606 2.2
1607 2.3
1608 2.4
1609
1610 false
1611 true
1612 true
1613 false
1614 true
1615 true