docs: Start mathifying TGSI insts.
[mesa.git] / src / gallium / docs / source / tgsi.rst
1 TGSI
2 ====
3
4 TGSI, Tungsten Graphics Shader Instructions, is an intermediate language
5 for describing shaders. Since Gallium is inherently shaderful, shaders are
6 an important part of the API. TGSI is the only intermediate representation
7 used by all drivers.
8
9 From GL_NV_vertex_program
10 -------------------------
11
12
13 ARL - Address Register Load
14
15 .. math::
16
17 dst.x = floor(src.x)
18
19 dst.y = floor(src.y)
20
21 dst.z = floor(src.z)
22
23 dst.w = floor(src.w)
24
25
26 MOV - Move
27
28 .. math::
29
30 dst.x = src.x
31
32 dst.y = src.y
33
34 dst.z = src.z
35
36 dst.w = src.w
37
38
39 LIT - Light Coefficients
40
41 .. math::
42
43 dst.x = 1.0
44
45 dst.y = max(src.x, 0.0)
46
47 dst.z = (src.x > 0.0) ? pow(max(src.y, 0.0), clamp(src.w, -128.0, 128.0)) : 0.0
48
49 dst.w = 1.0
50
51
52 RCP - Reciprocal
53
54 .. math::
55
56 dst.x = 1.0 / src.x
57
58 dst.y = 1.0 / src.x
59
60 dst.z = 1.0 / src.x
61
62 dst.w = 1.0 / src.x
63
64
65 RSQ - Reciprocal Square Root
66
67 .. math::
68
69 dst.x = 1.0 / sqrt(abs(src.x))
70
71 dst.y = 1.0 / sqrt(abs(src.x))
72
73 dst.z = 1.0 / sqrt(abs(src.x))
74
75 dst.w = 1.0 / sqrt(abs(src.x))
76
77
78 EXP - Approximate Exponential Base 2
79
80 .. math::
81
82 dst.x = pow(2.0, floor(src.x))
83
84 dst.y = src.x - floor(src.x)
85
86 dst.z = pow(2.0, src.x)
87
88 dst.w = 1.0
89
90
91 LOG - Approximate Logarithm Base 2
92
93 .. math::
94
95 dst.x = floor(lg2(abs(src.x)))
96
97 dst.y = abs(src.x) / pow(2.0, floor(lg2(abs(src.x))))
98
99 dst.z = lg2(abs(src.x))
100
101 dst.w = 1.0
102
103
104 MUL - Multiply
105
106 .. math::
107
108 dst.x = src0.x * src1.x
109
110 dst.y = src0.y * src1.y
111
112 dst.z = src0.z * src1.z
113
114 dst.w = src0.w * src1.w
115
116
117 ADD - Add
118
119 .. math::
120
121 dst.x = src0.x + src1.x
122
123 dst.y = src0.y + src1.y
124
125 dst.z = src0.z + src1.z
126
127 dst.w = src0.w + src1.w
128
129
130 DP3 - 3-component Dot Product
131
132 .. math::
133
134 dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
135
136 dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
137
138 dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
139
140 dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
141
142
143 DP4 - 4-component Dot Product
144
145 .. math::
146
147 dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
148
149 dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
150
151 dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
152
153 dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
154
155
156 DST - Distance Vector
157
158 .. math::
159
160 dst.x = 1.0
161
162 dst.y = src0.y * src1.y
163
164 dst.z = src0.z
165
166 dst.w = src1.w
167
168
169 MIN - Minimum
170
171 .. math::
172
173 dst.x = min(src0.x, src1.x)
174
175 dst.y = min(src0.y, src1.y)
176
177 dst.z = min(src0.z, src1.z)
178
179 dst.w = min(src0.w, src1.w)
180
181
182 MAX - Maximum
183
184 .. math::
185
186 dst.x = max(src0.x, src1.x)
187
188 dst.y = max(src0.y, src1.y)
189
190 dst.z = max(src0.z, src1.z)
191
192 dst.w = max(src0.w, src1.w)
193
194
195 SLT - Set On Less Than
196
197 .. math::
198
199 dst.x = (src0.x < src1.x) ? 1.0 : 0.0
200
201 dst.y = (src0.y < src1.y) ? 1.0 : 0.0
202
203 dst.z = (src0.z < src1.z) ? 1.0 : 0.0
204
205 dst.w = (src0.w < src1.w) ? 1.0 : 0.0
206
207
208 SGE - Set On Greater Equal Than
209
210 .. math::
211
212 dst.x = (src0.x >= src1.x) ? 1.0 : 0.0
213
214 dst.y = (src0.y >= src1.y) ? 1.0 : 0.0
215
216 dst.z = (src0.z >= src1.z) ? 1.0 : 0.0
217
218 dst.w = (src0.w >= src1.w) ? 1.0 : 0.0
219
220
221 MAD - Multiply And Add
222
223 .. math::
224
225 dst.x = src0.x * src1.x + src2.x
226
227 dst.y = src0.y * src1.y + src2.y
228
229 dst.z = src0.z * src1.z + src2.z
230
231 dst.w = src0.w * src1.w + src2.w
232
233
234 SUB - Subtract
235
236 .. math::
237
238 dst.x = src0.x - src1.x
239
240 dst.y = src0.y - src1.y
241
242 dst.z = src0.z - src1.z
243
244 dst.w = src0.w - src1.w
245
246
247 LRP - Linear Interpolate
248
249 .. math::
250
251 dst.x = src0.x * (src1.x - src2.x) + src2.x
252
253 dst.y = src0.y * (src1.y - src2.y) + src2.y
254
255 dst.z = src0.z * (src1.z - src2.z) + src2.z
256
257 dst.w = src0.w * (src1.w - src2.w) + src2.w
258
259
260 CND - Condition
261
262 .. math::
263
264 dst.x = (src2.x > 0.5) ? src0.x : src1.x
265
266 dst.y = (src2.y > 0.5) ? src0.y : src1.y
267
268 dst.z = (src2.z > 0.5) ? src0.z : src1.z
269
270 dst.w = (src2.w > 0.5) ? src0.w : src1.w
271
272
273 DP2A - 2-component Dot Product And Add
274
275 .. math::
276
277 dst.x = src0.x * src1.x + src0.y * src1.y + src2.x
278
279 dst.y = src0.x * src1.x + src0.y * src1.y + src2.x
280
281 dst.z = src0.x * src1.x + src0.y * src1.y + src2.x
282
283 dst.w = src0.x * src1.x + src0.y * src1.y + src2.x
284
285
286 FRAC - Fraction
287
288 .. math::
289
290 dst.x = src.x - floor(src.x)
291
292 dst.y = src.y - floor(src.y)
293
294 dst.z = src.z - floor(src.z)
295
296 dst.w = src.w - floor(src.w)
297
298
299 CLAMP - Clamp
300
301 .. math::
302
303 dst.x = clamp(src0.x, src1.x, src2.x)
304 dst.y = clamp(src0.y, src1.y, src2.y)
305 dst.z = clamp(src0.z, src1.z, src2.z)
306 dst.w = clamp(src0.w, src1.w, src2.w)
307
308
309 1.3.8 FLR - Floor
310
311 .. math::
312
313 dst.x = floor(src.x)
314 dst.y = floor(src.y)
315 dst.z = floor(src.z)
316 dst.w = floor(src.w)
317
318
319 1.3.9 ROUND - Round
320
321 .. math::
322
323 dst.x = round(src.x)
324 dst.y = round(src.y)
325 dst.z = round(src.z)
326 dst.w = round(src.w)
327
328
329 1.3.10 EX2 - Exponential Base 2
330
331 .. math::
332
333 dst.x = pow(2.0, src.x)
334 dst.y = pow(2.0, src.x)
335 dst.z = pow(2.0, src.x)
336 dst.w = pow(2.0, src.x)
337
338
339 1.3.11 LG2 - Logarithm Base 2
340
341 .. math::
342
343 dst.x = lg2(src.x)
344 dst.y = lg2(src.x)
345 dst.z = lg2(src.x)
346 dst.w = lg2(src.x)
347
348
349 1.3.12 POW - Power
350
351 .. math::
352
353 dst.x = pow(src0.x, src1.x)
354 dst.y = pow(src0.x, src1.x)
355 dst.z = pow(src0.x, src1.x)
356 dst.w = pow(src0.x, src1.x)
357
358 1.3.15 XPD - Cross Product
359
360 .. math::
361
362 dst.x = src0.y * src1.z - src1.y * src0.z
363 dst.y = src0.z * src1.x - src1.z * src0.x
364 dst.z = src0.x * src1.y - src1.x * src0.y
365 dst.w = 1.0
366
367
368 1.4.1 ABS - Absolute
369
370 .. math::
371
372 dst.x = abs(src.x)
373 dst.y = abs(src.y)
374 dst.z = abs(src.z)
375 dst.w = abs(src.w)
376
377
378 1.4.2 RCC - Reciprocal Clamped
379
380 .. math::
381
382 dst.x = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
383 dst.y = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
384 dst.z = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
385 dst.w = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
386
387
388 1.4.3 DPH - Homogeneous Dot Product
389
390 .. math::
391
392 dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
393 dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
394 dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
395 dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
396
397
398 1.5.1 COS - Cosine
399
400 .. math::
401
402 dst.x = cos(src.x)
403 dst.y = cos(src.x)
404 dst.z = cos(src.x)
405 dst.w = cos(src.w)
406
407
408 1.5.2 DDX - Derivative Relative To X
409
410 .. math::
411
412 dst.x = partialx(src.x)
413 dst.y = partialx(src.y)
414 dst.z = partialx(src.z)
415 dst.w = partialx(src.w)
416
417
418 1.5.3 DDY - Derivative Relative To Y
419
420 .. math::
421
422 dst.x = partialy(src.x)
423 dst.y = partialy(src.y)
424 dst.z = partialy(src.z)
425 dst.w = partialy(src.w)
426
427
428 1.5.7 KILP - Predicated Discard
429
430 .. math::
431
432 discard
433
434
435 1.5.10 PK2H - Pack Two 16-bit Floats
436
437 TBD
438
439
440 1.5.11 PK2US - Pack Two Unsigned 16-bit Scalars
441
442 TBD
443
444
445 1.5.12 PK4B - Pack Four Signed 8-bit Scalars
446
447 TBD
448
449
450 1.5.13 PK4UB - Pack Four Unsigned 8-bit Scalars
451
452 TBD
453
454
455 1.5.15 RFL - Reflection Vector
456
457 .. math::
458
459 dst.x = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.x - src1.x
460 dst.y = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.y - src1.y
461 dst.z = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.z - src1.z
462 dst.w = 1.0
463
464 Considered for removal.
465
466
467 1.5.16 SEQ - Set On Equal
468
469 .. math::
470
471 dst.x = (src0.x == src1.x) ? 1.0 : 0.0
472 dst.y = (src0.y == src1.y) ? 1.0 : 0.0
473 dst.z = (src0.z == src1.z) ? 1.0 : 0.0
474 dst.w = (src0.w == src1.w) ? 1.0 : 0.0
475
476
477 1.5.17 SFL - Set On False
478
479 .. math::
480
481 dst.x = 0.0
482 dst.y = 0.0
483 dst.z = 0.0
484 dst.w = 0.0
485
486 Considered for removal.
487
488 1.5.18 SGT - Set On Greater Than
489
490 .. math::
491
492 dst.x = (src0.x > src1.x) ? 1.0 : 0.0
493 dst.y = (src0.y > src1.y) ? 1.0 : 0.0
494 dst.z = (src0.z > src1.z) ? 1.0 : 0.0
495 dst.w = (src0.w > src1.w) ? 1.0 : 0.0
496
497
498 1.5.19 SIN - Sine
499
500 .. math::
501
502 dst.x = sin(src.x)
503 dst.y = sin(src.x)
504 dst.z = sin(src.x)
505 dst.w = sin(src.w)
506
507
508 1.5.20 SLE - Set On Less Equal Than
509
510 .. math::
511
512 dst.x = (src0.x <= src1.x) ? 1.0 : 0.0
513 dst.y = (src0.y <= src1.y) ? 1.0 : 0.0
514 dst.z = (src0.z <= src1.z) ? 1.0 : 0.0
515 dst.w = (src0.w <= src1.w) ? 1.0 : 0.0
516
517
518 1.5.21 SNE - Set On Not Equal
519
520 .. math::
521
522 dst.x = (src0.x != src1.x) ? 1.0 : 0.0
523 dst.y = (src0.y != src1.y) ? 1.0 : 0.0
524 dst.z = (src0.z != src1.z) ? 1.0 : 0.0
525 dst.w = (src0.w != src1.w) ? 1.0 : 0.0
526
527
528 1.5.22 STR - Set On True
529
530 .. math::
531
532 dst.x = 1.0
533 dst.y = 1.0
534 dst.z = 1.0
535 dst.w = 1.0
536
537
538 1.5.23 TEX - Texture Lookup
539
540 TBD
541
542
543 1.5.24 TXD - Texture Lookup with Derivatives
544
545 TBD
546
547
548 1.5.25 TXP - Projective Texture Lookup
549
550 TBD
551
552
553 1.5.26 UP2H - Unpack Two 16-Bit Floats
554
555 TBD
556
557 Considered for removal.
558
559 1.5.27 UP2US - Unpack Two Unsigned 16-Bit Scalars
560
561 TBD
562
563 Considered for removal.
564
565 1.5.28 UP4B - Unpack Four Signed 8-Bit Values
566
567 TBD
568
569 Considered for removal.
570
571 1.5.29 UP4UB - Unpack Four Unsigned 8-Bit Scalars
572
573 TBD
574
575 Considered for removal.
576
577 1.5.30 X2D - 2D Coordinate Transformation
578
579 .. math::
580
581 dst.x = src0.x + src1.x * src2.x + src1.y * src2.y
582 dst.y = src0.y + src1.x * src2.z + src1.y * src2.w
583 dst.z = src0.x + src1.x * src2.x + src1.y * src2.y
584 dst.w = src0.y + src1.x * src2.z + src1.y * src2.w
585
586 Considered for removal.
587
588
589 1.6 GL_NV_vertex_program2
590 --------------------------
591
592
593 1.6.1 ARA - Address Register Add
594
595 TBD
596
597 Considered for removal.
598
599 1.6.2 ARR - Address Register Load With Round
600
601 .. math::
602
603 dst.x = round(src.x)
604 dst.y = round(src.y)
605 dst.z = round(src.z)
606 dst.w = round(src.w)
607
608
609 1.6.3 BRA - Branch
610
611 pc = target
612
613 Considered for removal.
614
615 1.6.4 CAL - Subroutine Call
616
617 push(pc)
618 pc = target
619
620
621 1.6.5 RET - Subroutine Call Return
622
623 pc = pop()
624
625 Potential restrictions:
626 * Only occurs at end of function.
627
628 1.6.6 SSG - Set Sign
629
630 .. math::
631
632 dst.x = (src.x > 0.0) ? 1.0 : (src.x < 0.0) ? -1.0 : 0.0
633 dst.y = (src.y > 0.0) ? 1.0 : (src.y < 0.0) ? -1.0 : 0.0
634 dst.z = (src.z > 0.0) ? 1.0 : (src.z < 0.0) ? -1.0 : 0.0
635 dst.w = (src.w > 0.0) ? 1.0 : (src.w < 0.0) ? -1.0 : 0.0
636
637
638 1.8.1 CMP - Compare
639
640 .. math::
641
642 dst.x = (src0.x < 0.0) ? src1.x : src2.x
643 dst.y = (src0.y < 0.0) ? src1.y : src2.y
644 dst.z = (src0.z < 0.0) ? src1.z : src2.z
645 dst.w = (src0.w < 0.0) ? src1.w : src2.w
646
647
648 1.8.2 KIL - Conditional Discard
649
650 .. math::
651
652 if (src.x < 0.0 || src.y < 0.0 || src.z < 0.0 || src.w < 0.0)
653 discard
654 endif
655
656
657 1.8.3 SCS - Sine Cosine
658
659 .. math::
660
661 dst.x = cos(src.x)
662 dst.y = sin(src.x)
663 dst.z = 0.0
664 dst.y = 1.0
665
666
667 1.8.4 TXB - Texture Lookup With Bias
668
669 TBD
670
671
672 1.9.1 NRM - 3-component Vector Normalise
673
674 .. math::
675
676 dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z)
677 dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z)
678 dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z)
679 dst.w = 1.0
680
681
682 1.9.2 DIV - Divide
683
684 .. math::
685
686 dst.x = src0.x / src1.x
687 dst.y = src0.y / src1.y
688 dst.z = src0.z / src1.z
689 dst.w = src0.w / src1.w
690
691
692 1.9.3 DP2 - 2-component Dot Product
693
694 .. math::
695
696 dst.x = src0.x * src1.x + src0.y * src1.y
697 dst.y = src0.x * src1.x + src0.y * src1.y
698 dst.z = src0.x * src1.x + src0.y * src1.y
699 dst.w = src0.x * src1.x + src0.y * src1.y
700
701
702 1.9.5 TXL - Texture Lookup With LOD
703
704 TBD
705
706
707 1.9.6 BRK - Break
708
709 TBD
710
711
712 1.9.7 IF - If
713
714 TBD
715
716
717 1.9.8 BGNFOR - Begin a For-Loop
718
719 dst.x = floor(src.x)
720 dst.y = floor(src.y)
721 dst.z = floor(src.z)
722
723 if (dst.y <= 0)
724 pc = [matching ENDFOR] + 1
725 endif
726
727 Note: The destination must be a loop register.
728 The source must be a constant register.
729
730 Considered for cleanup / removal.
731
732
733 1.9.9 REP - Repeat
734
735 TBD
736
737
738 1.9.10 ELSE - Else
739
740 TBD
741
742
743 1.9.11 ENDIF - End If
744
745 TBD
746
747
748 1.9.12 ENDFOR - End a For-Loop
749
750 dst.x = dst.x + dst.z
751 dst.y = dst.y - 1.0
752
753 if (dst.y > 0)
754 pc = [matching BGNFOR instruction] + 1
755 endif
756
757 Note: The destination must be a loop register.
758
759 Considered for cleanup / removal.
760
761 1.9.13 ENDREP - End Repeat
762
763 TBD
764
765
766 1.10.1 PUSHA - Push Address Register On Stack
767
768 push(src.x)
769 push(src.y)
770 push(src.z)
771 push(src.w)
772
773 Considered for cleanup / removal.
774
775 1.10.2 POPA - Pop Address Register From Stack
776
777 dst.w = pop()
778 dst.z = pop()
779 dst.y = pop()
780 dst.x = pop()
781
782 Considered for cleanup / removal.
783
784
785 1.11 GL_NV_gpu_program4
786 ------------------------
787
788 Support for these opcodes indicated by a special pipe capability bit (TBD).
789
790 1.11.1 CEIL - Ceiling
791
792 .. math::
793
794 dst.x = ceil(src.x)
795 dst.y = ceil(src.y)
796 dst.z = ceil(src.z)
797 dst.w = ceil(src.w)
798
799
800 1.11.2 I2F - Integer To Float
801
802 .. math::
803
804 dst.x = (float) src.x
805 dst.y = (float) src.y
806 dst.z = (float) src.z
807 dst.w = (float) src.w
808
809
810 1.11.3 NOT - Bitwise Not
811
812 .. math::
813
814 dst.x = ~src.x
815 dst.y = ~src.y
816 dst.z = ~src.z
817 dst.w = ~src.w
818
819
820 1.11.4 TRUNC - Truncate
821
822 .. math::
823
824 dst.x = trunc(src.x)
825 dst.y = trunc(src.y)
826 dst.z = trunc(src.z)
827 dst.w = trunc(src.w)
828
829
830 1.11.5 SHL - Shift Left
831
832 .. math::
833
834 dst.x = src0.x << src1.x
835 dst.y = src0.y << src1.x
836 dst.z = src0.z << src1.x
837 dst.w = src0.w << src1.x
838
839
840 1.11.6 SHR - Shift Right
841
842 .. math::
843
844 dst.x = src0.x >> src1.x
845 dst.y = src0.y >> src1.x
846 dst.z = src0.z >> src1.x
847 dst.w = src0.w >> src1.x
848
849
850 1.11.7 AND - Bitwise And
851
852 .. math::
853
854 dst.x = src0.x & src1.x
855 dst.y = src0.y & src1.y
856 dst.z = src0.z & src1.z
857 dst.w = src0.w & src1.w
858
859
860 1.11.8 OR - Bitwise Or
861
862 .. math::
863
864 dst.x = src0.x | src1.x
865 dst.y = src0.y | src1.y
866 dst.z = src0.z | src1.z
867 dst.w = src0.w | src1.w
868
869
870 1.11.9 MOD - Modulus
871
872 .. math::
873
874 dst.x = src0.x % src1.x
875 dst.y = src0.y % src1.y
876 dst.z = src0.z % src1.z
877 dst.w = src0.w % src1.w
878
879
880 1.11.10 XOR - Bitwise Xor
881
882 .. math::
883
884 dst.x = src0.x ^ src1.x
885 dst.y = src0.y ^ src1.y
886 dst.z = src0.z ^ src1.z
887 dst.w = src0.w ^ src1.w
888
889
890 1.11.11 SAD - Sum Of Absolute Differences
891
892 .. math::
893
894 dst.x = abs(src0.x - src1.x) + src2.x
895 dst.y = abs(src0.y - src1.y) + src2.y
896 dst.z = abs(src0.z - src1.z) + src2.z
897 dst.w = abs(src0.w - src1.w) + src2.w
898
899
900 1.11.12 TXF - Texel Fetch
901
902 TBD
903
904
905 1.11.13 TXQ - Texture Size Query
906
907 TBD
908
909
910 1.11.14 CONT - Continue
911
912 TBD
913
914
915 1.12 GL_NV_geometry_program4
916 -----------------------------
917
918
919 1.12.1 EMIT - Emit
920
921 TBD
922
923
924 1.12.2 ENDPRIM - End Primitive
925
926 TBD
927
928
929 1.13 GLSL
930 ----------
931
932
933 1.13.1 BGNLOOP - Begin a Loop
934
935 TBD
936
937
938 1.13.2 BGNSUB - Begin Subroutine
939
940 TBD
941
942
943 1.13.3 ENDLOOP - End a Loop
944
945 TBD
946
947
948 1.13.4 ENDSUB - End Subroutine
949
950 TBD
951
952
953
954 1.13.10 NOP - No Operation
955
956 Do nothing.
957
958
959
960 1.16.7 NRM4 - 4-component Vector Normalise
961
962 .. math::
963
964 dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
965 dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
966 dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
967 dst.w = src.w / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
968
969
970 1.17 ps_2_x
971 ------------
972
973
974 1.17.2 CALLNZ - Subroutine Call If Not Zero
975
976 TBD
977
978
979 1.17.3 IFC - If
980
981 TBD
982
983
984 1.17.5 BREAKC - Break Conditional
985
986 TBD
987
988
989 2 Explanation of symbols used
990 ==============================
991
992
993 2.1 Functions
994 --------------
995
996
997 abs(x) Absolute value of x.
998 (x < 0.0) ? -x : x
999
1000 ceil(x) Ceiling of x.
1001
1002 clamp(x,y,z) Clamp x between y and z.
1003 (x < y) ? y : (x > z) ? z : x
1004
1005 cos(x) Cosine of x.
1006
1007 floor(x) Floor of x.
1008
1009 lg2(x) Logarithm base 2 of x.
1010
1011 max(x,y) Maximum of x and y.
1012 (x > y) ? x : y
1013
1014 min(x,y) Minimum of x and y.
1015 (x < y) ? x : y
1016
1017 partialx(x) Derivative of x relative to fragment's X.
1018
1019 partialy(x) Derivative of x relative to fragment's Y.
1020
1021 pop() Pop from stack.
1022
1023 pow(x,y) Raise x to power of y.
1024
1025 push(x) Push x on stack.
1026
1027 round(x) Round x.
1028
1029 sin(x) Sine of x.
1030
1031 sqrt(x) Square root of x.
1032
1033 trunc(x) Truncate x.
1034
1035
1036 2.2 Keywords
1037 -------------
1038
1039
1040 discard Discard fragment.
1041
1042 dst First destination register.
1043
1044 dst0 First destination register.
1045
1046 pc Program counter.
1047
1048 src First source register.
1049
1050 src0 First source register.
1051
1052 src1 Second source register.
1053
1054 src2 Third source register.
1055
1056 target Label of target instruction.
1057
1058
1059 3 Other tokens
1060 ===============
1061
1062
1063 3.1 Declaration Semantic
1064 -------------------------
1065
1066
1067 Follows Declaration token if Semantic bit is set.
1068
1069 Since its purpose is to link a shader with other stages of the pipeline,
1070 it is valid to follow only those Declaration tokens that declare a register
1071 either in INPUT or OUTPUT file.
1072
1073 SemanticName field contains the semantic name of the register being declared.
1074 There is no default value.
1075
1076 SemanticIndex is an optional subscript that can be used to distinguish
1077 different register declarations with the same semantic name. The default value
1078 is 0.
1079
1080 The meanings of the individual semantic names are explained in the following
1081 sections.
1082
1083
1084 3.1.1 FACE
1085
1086 Valid only in a fragment shader INPUT declaration.
1087
1088 FACE.x is negative when the primitive is back facing. FACE.x is positive
1089 when the primitive is front facing.