c62ad6541b1115d96e250e80c2ab2cc35f7295dc
[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 = \lfloor src.x\rfloor
18
19 dst.y = \lfloor src.y\rfloor
20
21 dst.z = \lfloor src.z\rfloor
22
23 dst.w = \lfloor src.w\rfloor
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) ? 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 = 2^{\lfloor src.x\rfloor}
83
84 dst.y = src.x - \lfloor src.x\rfloor
85
86 dst.z = 2^{src.x}
87
88 dst.w = 1.0
89
90
91 LOG - Approximate Logarithm Base 2
92
93 .. math::
94
95 dst.x = \lfloor lg2(abs(src.x)))\rfloor
96
97 dst.y = abs(src.x) / 2^{\lfloor lg2(abs(src.x))\rfloor}
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 - \lfloor src.x\rfloor
291
292 dst.y = src.y - \lfloor src.y\rfloor
293
294 dst.z = src.z - \lfloor src.z\rfloor
295
296 dst.w = src.w - \lfloor src.w\rfloor
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 FLR - Floor
310
311 This is identical to ARL.
312
313 .. math::
314
315 dst.x = \lfloor src.x\rfloor
316
317 dst.y = \lfloor src.y\rfloor
318
319 dst.z = \lfloor src.z\rfloor
320
321 dst.w = \lfloor src.w\rfloor
322
323
324 1.3.9 ROUND - Round
325
326 .. math::
327
328 dst.x = round(src.x)
329 dst.y = round(src.y)
330 dst.z = round(src.z)
331 dst.w = round(src.w)
332
333
334 EX2 - Exponential Base 2
335
336 .. math::
337
338 dst.x = 2^{src.x}
339
340 dst.y = 2^{src.x}
341
342 dst.z = 2^{src.x}
343
344 dst.w = 2^{src.x}
345
346
347 1.3.11 LG2 - Logarithm Base 2
348
349 .. math::
350
351 dst.x = lg2(src.x)
352 dst.y = lg2(src.x)
353 dst.z = lg2(src.x)
354 dst.w = lg2(src.x)
355
356
357 POW - Power
358
359 .. math::
360
361 dst.x = src0.x^{src1.x}
362
363 dst.y = src0.x^{src1.x}
364
365 dst.z = src0.x^{src1.x}
366
367 dst.w = src0.x^{src1.x}
368
369 1.3.15 XPD - Cross Product
370
371 .. math::
372
373 dst.x = src0.y * src1.z - src1.y * src0.z
374 dst.y = src0.z * src1.x - src1.z * src0.x
375 dst.z = src0.x * src1.y - src1.x * src0.y
376 dst.w = 1.0
377
378
379 1.4.1 ABS - Absolute
380
381 .. math::
382
383 dst.x = abs(src.x)
384 dst.y = abs(src.y)
385 dst.z = abs(src.z)
386 dst.w = abs(src.w)
387
388
389 1.4.2 RCC - Reciprocal Clamped
390
391 .. math::
392
393 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)
394 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)
395 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)
396 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)
397
398
399 1.4.3 DPH - Homogeneous Dot Product
400
401 .. math::
402
403 dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
404 dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
405 dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
406 dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
407
408
409 COS - Cosine
410
411 .. math::
412
413 dst.x = \cos{src.x}
414
415 dst.y = \cos{src.x}
416
417 dst.z = \cos{src.x}
418
419 dst.w = \cos{src.w}
420
421
422 1.5.2 DDX - Derivative Relative To X
423
424 .. math::
425
426 dst.x = partialx(src.x)
427 dst.y = partialx(src.y)
428 dst.z = partialx(src.z)
429 dst.w = partialx(src.w)
430
431
432 1.5.3 DDY - Derivative Relative To Y
433
434 .. math::
435
436 dst.x = partialy(src.x)
437 dst.y = partialy(src.y)
438 dst.z = partialy(src.z)
439 dst.w = partialy(src.w)
440
441
442 1.5.7 KILP - Predicated Discard
443
444 .. math::
445
446 discard
447
448
449 1.5.10 PK2H - Pack Two 16-bit Floats
450
451 TBD
452
453
454 1.5.11 PK2US - Pack Two Unsigned 16-bit Scalars
455
456 TBD
457
458
459 1.5.12 PK4B - Pack Four Signed 8-bit Scalars
460
461 TBD
462
463
464 1.5.13 PK4UB - Pack Four Unsigned 8-bit Scalars
465
466 TBD
467
468
469 1.5.15 RFL - Reflection Vector
470
471 .. math::
472
473 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
474 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
475 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
476 dst.w = 1.0
477
478 Considered for removal.
479
480
481 1.5.16 SEQ - Set On Equal
482
483 .. math::
484
485 dst.x = (src0.x == src1.x) ? 1.0 : 0.0
486 dst.y = (src0.y == src1.y) ? 1.0 : 0.0
487 dst.z = (src0.z == src1.z) ? 1.0 : 0.0
488 dst.w = (src0.w == src1.w) ? 1.0 : 0.0
489
490
491 1.5.17 SFL - Set On False
492
493 .. math::
494
495 dst.x = 0.0
496 dst.y = 0.0
497 dst.z = 0.0
498 dst.w = 0.0
499
500 Considered for removal.
501
502 1.5.18 SGT - Set On Greater Than
503
504 .. math::
505
506 dst.x = (src0.x > src1.x) ? 1.0 : 0.0
507 dst.y = (src0.y > src1.y) ? 1.0 : 0.0
508 dst.z = (src0.z > src1.z) ? 1.0 : 0.0
509 dst.w = (src0.w > src1.w) ? 1.0 : 0.0
510
511
512 SIN - Sine
513
514 .. math::
515
516 dst.x = \sin{src.x}
517
518 dst.y = \sin{src.x}
519
520 dst.z = \sin{src.x}
521
522 dst.w = \sin{src.w}
523
524
525 1.5.20 SLE - Set On Less Equal Than
526
527 .. math::
528
529 dst.x = (src0.x <= src1.x) ? 1.0 : 0.0
530 dst.y = (src0.y <= src1.y) ? 1.0 : 0.0
531 dst.z = (src0.z <= src1.z) ? 1.0 : 0.0
532 dst.w = (src0.w <= src1.w) ? 1.0 : 0.0
533
534
535 1.5.21 SNE - Set On Not Equal
536
537 .. math::
538
539 dst.x = (src0.x != src1.x) ? 1.0 : 0.0
540 dst.y = (src0.y != src1.y) ? 1.0 : 0.0
541 dst.z = (src0.z != src1.z) ? 1.0 : 0.0
542 dst.w = (src0.w != src1.w) ? 1.0 : 0.0
543
544
545 1.5.22 STR - Set On True
546
547 .. math::
548
549 dst.x = 1.0
550 dst.y = 1.0
551 dst.z = 1.0
552 dst.w = 1.0
553
554
555 1.5.23 TEX - Texture Lookup
556
557 TBD
558
559
560 1.5.24 TXD - Texture Lookup with Derivatives
561
562 TBD
563
564
565 1.5.25 TXP - Projective Texture Lookup
566
567 TBD
568
569
570 1.5.26 UP2H - Unpack Two 16-Bit Floats
571
572 TBD
573
574 Considered for removal.
575
576 1.5.27 UP2US - Unpack Two Unsigned 16-Bit Scalars
577
578 TBD
579
580 Considered for removal.
581
582 1.5.28 UP4B - Unpack Four Signed 8-Bit Values
583
584 TBD
585
586 Considered for removal.
587
588 1.5.29 UP4UB - Unpack Four Unsigned 8-Bit Scalars
589
590 TBD
591
592 Considered for removal.
593
594 1.5.30 X2D - 2D Coordinate Transformation
595
596 .. math::
597
598 dst.x = src0.x + src1.x * src2.x + src1.y * src2.y
599 dst.y = src0.y + src1.x * src2.z + src1.y * src2.w
600 dst.z = src0.x + src1.x * src2.x + src1.y * src2.y
601 dst.w = src0.y + src1.x * src2.z + src1.y * src2.w
602
603 Considered for removal.
604
605
606 1.6 GL_NV_vertex_program2
607 --------------------------
608
609
610 1.6.1 ARA - Address Register Add
611
612 TBD
613
614 Considered for removal.
615
616 1.6.2 ARR - Address Register Load With Round
617
618 .. math::
619
620 dst.x = round(src.x)
621 dst.y = round(src.y)
622 dst.z = round(src.z)
623 dst.w = round(src.w)
624
625
626 1.6.3 BRA - Branch
627
628 pc = target
629
630 Considered for removal.
631
632 1.6.4 CAL - Subroutine Call
633
634 push(pc)
635 pc = target
636
637
638 1.6.5 RET - Subroutine Call Return
639
640 pc = pop()
641
642 Potential restrictions:
643 * Only occurs at end of function.
644
645 1.6.6 SSG - Set Sign
646
647 .. math::
648
649 dst.x = (src.x > 0.0) ? 1.0 : (src.x < 0.0) ? -1.0 : 0.0
650 dst.y = (src.y > 0.0) ? 1.0 : (src.y < 0.0) ? -1.0 : 0.0
651 dst.z = (src.z > 0.0) ? 1.0 : (src.z < 0.0) ? -1.0 : 0.0
652 dst.w = (src.w > 0.0) ? 1.0 : (src.w < 0.0) ? -1.0 : 0.0
653
654
655 1.8.1 CMP - Compare
656
657 .. math::
658
659 dst.x = (src0.x < 0.0) ? src1.x : src2.x
660 dst.y = (src0.y < 0.0) ? src1.y : src2.y
661 dst.z = (src0.z < 0.0) ? src1.z : src2.z
662 dst.w = (src0.w < 0.0) ? src1.w : src2.w
663
664
665 1.8.2 KIL - Conditional Discard
666
667 .. math::
668
669 if (src.x < 0.0 || src.y < 0.0 || src.z < 0.0 || src.w < 0.0)
670 discard
671 endif
672
673
674 SCS - Sine Cosine
675
676 .. math::
677
678 dst.x = \cos{src.x}
679
680 dst.y = \sin{src.x}
681
682 dst.z = 0.0
683
684 dst.y = 1.0
685
686
687 1.8.4 TXB - Texture Lookup With Bias
688
689 TBD
690
691
692 1.9.1 NRM - 3-component Vector Normalise
693
694 .. math::
695
696 dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z)
697 dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z)
698 dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z)
699 dst.w = 1.0
700
701
702 1.9.2 DIV - Divide
703
704 .. math::
705
706 dst.x = src0.x / src1.x
707 dst.y = src0.y / src1.y
708 dst.z = src0.z / src1.z
709 dst.w = src0.w / src1.w
710
711
712 1.9.3 DP2 - 2-component Dot Product
713
714 .. math::
715
716 dst.x = src0.x * src1.x + src0.y * src1.y
717 dst.y = src0.x * src1.x + src0.y * src1.y
718 dst.z = src0.x * src1.x + src0.y * src1.y
719 dst.w = src0.x * src1.x + src0.y * src1.y
720
721
722 1.9.5 TXL - Texture Lookup With LOD
723
724 TBD
725
726
727 1.9.6 BRK - Break
728
729 TBD
730
731
732 1.9.7 IF - If
733
734 TBD
735
736
737 1.9.8 BGNFOR - Begin a For-Loop
738
739 dst.x = floor(src.x)
740 dst.y = floor(src.y)
741 dst.z = floor(src.z)
742
743 if (dst.y <= 0)
744 pc = [matching ENDFOR] + 1
745 endif
746
747 Note: The destination must be a loop register.
748 The source must be a constant register.
749
750 Considered for cleanup / removal.
751
752
753 1.9.9 REP - Repeat
754
755 TBD
756
757
758 1.9.10 ELSE - Else
759
760 TBD
761
762
763 1.9.11 ENDIF - End If
764
765 TBD
766
767
768 1.9.12 ENDFOR - End a For-Loop
769
770 dst.x = dst.x + dst.z
771 dst.y = dst.y - 1.0
772
773 if (dst.y > 0)
774 pc = [matching BGNFOR instruction] + 1
775 endif
776
777 Note: The destination must be a loop register.
778
779 Considered for cleanup / removal.
780
781 1.9.13 ENDREP - End Repeat
782
783 TBD
784
785
786 1.10.1 PUSHA - Push Address Register On Stack
787
788 push(src.x)
789 push(src.y)
790 push(src.z)
791 push(src.w)
792
793 Considered for cleanup / removal.
794
795 1.10.2 POPA - Pop Address Register From Stack
796
797 dst.w = pop()
798 dst.z = pop()
799 dst.y = pop()
800 dst.x = pop()
801
802 Considered for cleanup / removal.
803
804
805 1.11 GL_NV_gpu_program4
806 ------------------------
807
808 Support for these opcodes indicated by a special pipe capability bit (TBD).
809
810 1.11.1 CEIL - Ceiling
811
812 .. math::
813
814 dst.x = ceil(src.x)
815 dst.y = ceil(src.y)
816 dst.z = ceil(src.z)
817 dst.w = ceil(src.w)
818
819
820 1.11.2 I2F - Integer To Float
821
822 .. math::
823
824 dst.x = (float) src.x
825 dst.y = (float) src.y
826 dst.z = (float) src.z
827 dst.w = (float) src.w
828
829
830 1.11.3 NOT - Bitwise Not
831
832 .. math::
833
834 dst.x = ~src.x
835 dst.y = ~src.y
836 dst.z = ~src.z
837 dst.w = ~src.w
838
839
840 1.11.4 TRUNC - Truncate
841
842 .. math::
843
844 dst.x = trunc(src.x)
845 dst.y = trunc(src.y)
846 dst.z = trunc(src.z)
847 dst.w = trunc(src.w)
848
849
850 1.11.5 SHL - Shift Left
851
852 .. math::
853
854 dst.x = src0.x << src1.x
855 dst.y = src0.y << src1.x
856 dst.z = src0.z << src1.x
857 dst.w = src0.w << src1.x
858
859
860 1.11.6 SHR - Shift Right
861
862 .. math::
863
864 dst.x = src0.x >> src1.x
865 dst.y = src0.y >> src1.x
866 dst.z = src0.z >> src1.x
867 dst.w = src0.w >> src1.x
868
869
870 1.11.7 AND - Bitwise And
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.8 OR - Bitwise Or
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.9 MOD - Modulus
891
892 .. math::
893
894 dst.x = src0.x % src1.x
895 dst.y = src0.y % src1.y
896 dst.z = src0.z % src1.z
897 dst.w = src0.w % src1.w
898
899
900 1.11.10 XOR - Bitwise Xor
901
902 .. math::
903
904 dst.x = src0.x ^ src1.x
905 dst.y = src0.y ^ src1.y
906 dst.z = src0.z ^ src1.z
907 dst.w = src0.w ^ src1.w
908
909
910 1.11.11 SAD - Sum Of Absolute Differences
911
912 .. math::
913
914 dst.x = abs(src0.x - src1.x) + src2.x
915 dst.y = abs(src0.y - src1.y) + src2.y
916 dst.z = abs(src0.z - src1.z) + src2.z
917 dst.w = abs(src0.w - src1.w) + src2.w
918
919
920 1.11.12 TXF - Texel Fetch
921
922 TBD
923
924
925 1.11.13 TXQ - Texture Size Query
926
927 TBD
928
929
930 1.11.14 CONT - Continue
931
932 TBD
933
934
935 1.12 GL_NV_geometry_program4
936 -----------------------------
937
938
939 1.12.1 EMIT - Emit
940
941 TBD
942
943
944 1.12.2 ENDPRIM - End Primitive
945
946 TBD
947
948
949 1.13 GLSL
950 ----------
951
952
953 1.13.1 BGNLOOP - Begin a Loop
954
955 TBD
956
957
958 1.13.2 BGNSUB - Begin Subroutine
959
960 TBD
961
962
963 1.13.3 ENDLOOP - End a Loop
964
965 TBD
966
967
968 1.13.4 ENDSUB - End Subroutine
969
970 TBD
971
972
973
974 1.13.10 NOP - No Operation
975
976 Do nothing.
977
978
979
980 1.16.7 NRM4 - 4-component Vector Normalise
981
982 .. math::
983
984 dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
985 dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
986 dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
987 dst.w = src.w / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
988
989
990 1.17 ps_2_x
991 ------------
992
993
994 1.17.2 CALLNZ - Subroutine Call If Not Zero
995
996 TBD
997
998
999 1.17.3 IFC - If
1000
1001 TBD
1002
1003
1004 1.17.5 BREAKC - Break Conditional
1005
1006 TBD
1007
1008
1009 2 Explanation of symbols used
1010 ==============================
1011
1012
1013 2.1 Functions
1014 --------------
1015
1016
1017 abs(x) Absolute value of x.
1018 (x < 0.0) ? -x : x
1019
1020 ceil(x) Ceiling of x.
1021
1022 clamp(x,y,z) Clamp x between y and z.
1023 (x < y) ? y : (x > z) ? z : x
1024
1025 :math:`\lfloor x\rfloor` Floor of `x`.
1026
1027 lg2(x) Logarithm base 2 of x.
1028
1029 max(x,y) Maximum of x and y.
1030 (x > y) ? x : y
1031
1032 min(x,y) Minimum of x and y.
1033 (x < y) ? x : y
1034
1035 partialx(x) Derivative of x relative to fragment's X.
1036
1037 partialy(x) Derivative of x relative to fragment's Y.
1038
1039 pop() Pop from stack.
1040
1041 :math:`x^y` `x` to the power `y`.
1042
1043 push(x) Push x on stack.
1044
1045 round(x) Round x.
1046
1047 trunc(x) Truncate x.
1048
1049
1050 2.2 Keywords
1051 -------------
1052
1053
1054 discard Discard fragment.
1055
1056 dst First destination register.
1057
1058 dst0 First destination register.
1059
1060 pc Program counter.
1061
1062 src First source register.
1063
1064 src0 First source register.
1065
1066 src1 Second source register.
1067
1068 src2 Third source register.
1069
1070 target Label of target instruction.
1071
1072
1073 3 Other tokens
1074 ===============
1075
1076
1077 3.1 Declaration Semantic
1078 -------------------------
1079
1080
1081 Follows Declaration token if Semantic bit is set.
1082
1083 Since its purpose is to link a shader with other stages of the pipeline,
1084 it is valid to follow only those Declaration tokens that declare a register
1085 either in INPUT or OUTPUT file.
1086
1087 SemanticName field contains the semantic name of the register being declared.
1088 There is no default value.
1089
1090 SemanticIndex is an optional subscript that can be used to distinguish
1091 different register declarations with the same semantic name. The default value
1092 is 0.
1093
1094 The meanings of the individual semantic names are explained in the following
1095 sections.
1096
1097
1098 3.1.1 FACE
1099
1100 Valid only in a fragment shader INPUT declaration.
1101
1102 FACE.x is negative when the primitive is back facing. FACE.x is positive
1103 when the primitive is front facing.