gallium/tgsi: update the docs for the new opcodes a bit
[mesa.git] / src / gallium / docs / source / tgsi.rst
1 TGSI
2 ====
3
4 TGSI, Tungsten Graphics Shader Infrastructure, 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 Basics
10 ------
11
12 All TGSI instructions, known as *opcodes*, operate on arbitrary-precision
13 floating-point four-component vectors. An opcode may have up to one
14 destination register, known as *dst*, and between zero and three source
15 registers, called *src0* through *src2*, or simply *src* if there is only
16 one.
17
18 Some instructions, like :opcode:`I2F`, permit re-interpretation of vector
19 components as integers. Other instructions permit using registers as
20 two-component vectors with double precision; see :ref:`Double Opcodes`.
21
22 When an instruction has a scalar result, the result is usually copied into
23 each of the components of *dst*. When this happens, the result is said to be
24 *replicated* to *dst*. :opcode:`RCP` is one such instruction.
25
26 Instruction Set
27 ---------------
28
29 Core ISA
30 ^^^^^^^^^^^^^^^^^^^^^^^^^
31
32 These opcodes are guaranteed to be available regardless of the driver being
33 used.
34
35 .. opcode:: ARL - Address Register Load
36
37 .. math::
38
39 dst.x = \lfloor src.x\rfloor
40
41 dst.y = \lfloor src.y\rfloor
42
43 dst.z = \lfloor src.z\rfloor
44
45 dst.w = \lfloor src.w\rfloor
46
47
48 .. opcode:: MOV - Move
49
50 .. math::
51
52 dst.x = src.x
53
54 dst.y = src.y
55
56 dst.z = src.z
57
58 dst.w = src.w
59
60
61 .. opcode:: LIT - Light Coefficients
62
63 .. math::
64
65 dst.x = 1
66
67 dst.y = max(src.x, 0)
68
69 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
70
71 dst.w = 1
72
73
74 .. opcode:: RCP - Reciprocal
75
76 This instruction replicates its result.
77
78 .. math::
79
80 dst = \frac{1}{src.x}
81
82
83 .. opcode:: RSQ - Reciprocal Square Root
84
85 This instruction replicates its result.
86
87 .. math::
88
89 dst = \frac{1}{\sqrt{|src.x|}}
90
91
92 .. opcode:: EXP - Approximate Exponential Base 2
93
94 .. math::
95
96 dst.x = 2^{\lfloor src.x\rfloor}
97
98 dst.y = src.x - \lfloor src.x\rfloor
99
100 dst.z = 2^{src.x}
101
102 dst.w = 1
103
104
105 .. opcode:: LOG - Approximate Logarithm Base 2
106
107 .. math::
108
109 dst.x = \lfloor\log_2{|src.x|}\rfloor
110
111 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
112
113 dst.z = \log_2{|src.x|}
114
115 dst.w = 1
116
117
118 .. opcode:: MUL - Multiply
119
120 .. math::
121
122 dst.x = src0.x \times src1.x
123
124 dst.y = src0.y \times src1.y
125
126 dst.z = src0.z \times src1.z
127
128 dst.w = src0.w \times src1.w
129
130
131 .. opcode:: ADD - Add
132
133 .. math::
134
135 dst.x = src0.x + src1.x
136
137 dst.y = src0.y + src1.y
138
139 dst.z = src0.z + src1.z
140
141 dst.w = src0.w + src1.w
142
143
144 .. opcode:: DP3 - 3-component Dot Product
145
146 This instruction replicates its result.
147
148 .. math::
149
150 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
151
152
153 .. opcode:: DP4 - 4-component Dot Product
154
155 This instruction replicates its result.
156
157 .. math::
158
159 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
160
161
162 .. opcode:: DST - Distance Vector
163
164 .. math::
165
166 dst.x = 1
167
168 dst.y = src0.y \times src1.y
169
170 dst.z = src0.z
171
172 dst.w = src1.w
173
174
175 .. opcode:: MIN - Minimum
176
177 .. math::
178
179 dst.x = min(src0.x, src1.x)
180
181 dst.y = min(src0.y, src1.y)
182
183 dst.z = min(src0.z, src1.z)
184
185 dst.w = min(src0.w, src1.w)
186
187
188 .. opcode:: MAX - Maximum
189
190 .. math::
191
192 dst.x = max(src0.x, src1.x)
193
194 dst.y = max(src0.y, src1.y)
195
196 dst.z = max(src0.z, src1.z)
197
198 dst.w = max(src0.w, src1.w)
199
200
201 .. opcode:: SLT - Set On Less Than
202
203 .. math::
204
205 dst.x = (src0.x < src1.x) ? 1 : 0
206
207 dst.y = (src0.y < src1.y) ? 1 : 0
208
209 dst.z = (src0.z < src1.z) ? 1 : 0
210
211 dst.w = (src0.w < src1.w) ? 1 : 0
212
213
214 .. opcode:: SGE - Set On Greater Equal Than
215
216 .. math::
217
218 dst.x = (src0.x >= src1.x) ? 1 : 0
219
220 dst.y = (src0.y >= src1.y) ? 1 : 0
221
222 dst.z = (src0.z >= src1.z) ? 1 : 0
223
224 dst.w = (src0.w >= src1.w) ? 1 : 0
225
226
227 .. opcode:: MAD - Multiply And Add
228
229 .. math::
230
231 dst.x = src0.x \times src1.x + src2.x
232
233 dst.y = src0.y \times src1.y + src2.y
234
235 dst.z = src0.z \times src1.z + src2.z
236
237 dst.w = src0.w \times src1.w + src2.w
238
239
240 .. opcode:: SUB - Subtract
241
242 .. math::
243
244 dst.x = src0.x - src1.x
245
246 dst.y = src0.y - src1.y
247
248 dst.z = src0.z - src1.z
249
250 dst.w = src0.w - src1.w
251
252
253 .. opcode:: LRP - Linear Interpolate
254
255 .. math::
256
257 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
258
259 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
260
261 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
262
263 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
264
265
266 .. opcode:: CND - Condition
267
268 .. math::
269
270 dst.x = (src2.x > 0.5) ? src0.x : src1.x
271
272 dst.y = (src2.y > 0.5) ? src0.y : src1.y
273
274 dst.z = (src2.z > 0.5) ? src0.z : src1.z
275
276 dst.w = (src2.w > 0.5) ? src0.w : src1.w
277
278
279 .. opcode:: DP2A - 2-component Dot Product And Add
280
281 .. math::
282
283 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
284
285 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
286
287 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
288
289 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
290
291
292 .. opcode:: FRC - Fraction
293
294 .. math::
295
296 dst.x = src.x - \lfloor src.x\rfloor
297
298 dst.y = src.y - \lfloor src.y\rfloor
299
300 dst.z = src.z - \lfloor src.z\rfloor
301
302 dst.w = src.w - \lfloor src.w\rfloor
303
304
305 .. opcode:: CLAMP - Clamp
306
307 .. math::
308
309 dst.x = clamp(src0.x, src1.x, src2.x)
310
311 dst.y = clamp(src0.y, src1.y, src2.y)
312
313 dst.z = clamp(src0.z, src1.z, src2.z)
314
315 dst.w = clamp(src0.w, src1.w, src2.w)
316
317
318 .. opcode:: FLR - Floor
319
320 This is identical to :opcode:`ARL`.
321
322 .. math::
323
324 dst.x = \lfloor src.x\rfloor
325
326 dst.y = \lfloor src.y\rfloor
327
328 dst.z = \lfloor src.z\rfloor
329
330 dst.w = \lfloor src.w\rfloor
331
332
333 .. opcode:: ROUND - Round
334
335 .. math::
336
337 dst.x = round(src.x)
338
339 dst.y = round(src.y)
340
341 dst.z = round(src.z)
342
343 dst.w = round(src.w)
344
345
346 .. opcode:: EX2 - Exponential Base 2
347
348 This instruction replicates its result.
349
350 .. math::
351
352 dst = 2^{src.x}
353
354
355 .. opcode:: LG2 - Logarithm Base 2
356
357 This instruction replicates its result.
358
359 .. math::
360
361 dst = \log_2{src.x}
362
363
364 .. opcode:: POW - Power
365
366 This instruction replicates its result.
367
368 .. math::
369
370 dst = src0.x^{src1.x}
371
372 .. opcode:: XPD - Cross Product
373
374 .. math::
375
376 dst.x = src0.y \times src1.z - src1.y \times src0.z
377
378 dst.y = src0.z \times src1.x - src1.z \times src0.x
379
380 dst.z = src0.x \times src1.y - src1.x \times src0.y
381
382 dst.w = 1
383
384
385 .. opcode:: ABS - Absolute
386
387 .. math::
388
389 dst.x = |src.x|
390
391 dst.y = |src.y|
392
393 dst.z = |src.z|
394
395 dst.w = |src.w|
396
397
398 .. opcode:: RCC - Reciprocal Clamped
399
400 This instruction replicates its result.
401
402 XXX cleanup on aisle three
403
404 .. math::
405
406 dst = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
407
408
409 .. opcode:: DPH - Homogeneous Dot Product
410
411 This instruction replicates its result.
412
413 .. math::
414
415 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
416
417
418 .. opcode:: COS - Cosine
419
420 This instruction replicates its result.
421
422 .. math::
423
424 dst = \cos{src.x}
425
426
427 .. opcode:: DDX - Derivative Relative To X
428
429 .. math::
430
431 dst.x = partialx(src.x)
432
433 dst.y = partialx(src.y)
434
435 dst.z = partialx(src.z)
436
437 dst.w = partialx(src.w)
438
439
440 .. opcode:: DDY - Derivative Relative To Y
441
442 .. math::
443
444 dst.x = partialy(src.x)
445
446 dst.y = partialy(src.y)
447
448 dst.z = partialy(src.z)
449
450 dst.w = partialy(src.w)
451
452
453 .. opcode:: KILP - Predicated Discard
454
455 discard
456
457
458 .. opcode:: PK2H - Pack Two 16-bit Floats
459
460 TBD
461
462
463 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
464
465 TBD
466
467
468 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
469
470 TBD
471
472
473 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
474
475 TBD
476
477
478 .. opcode:: RFL - Reflection Vector
479
480 .. math::
481
482 dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x
483
484 dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
485
486 dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
487
488 dst.w = 1
489
490 .. note::
491
492 Considered for removal.
493
494
495 .. opcode:: SEQ - Set On Equal
496
497 .. math::
498
499 dst.x = (src0.x == src1.x) ? 1 : 0
500
501 dst.y = (src0.y == src1.y) ? 1 : 0
502
503 dst.z = (src0.z == src1.z) ? 1 : 0
504
505 dst.w = (src0.w == src1.w) ? 1 : 0
506
507
508 .. opcode:: SFL - Set On False
509
510 This instruction replicates its result.
511
512 .. math::
513
514 dst = 0
515
516 .. note::
517
518 Considered for removal.
519
520
521 .. opcode:: SGT - Set On Greater Than
522
523 .. math::
524
525 dst.x = (src0.x > src1.x) ? 1 : 0
526
527 dst.y = (src0.y > src1.y) ? 1 : 0
528
529 dst.z = (src0.z > src1.z) ? 1 : 0
530
531 dst.w = (src0.w > src1.w) ? 1 : 0
532
533
534 .. opcode:: SIN - Sine
535
536 This instruction replicates its result.
537
538 .. math::
539
540 dst = \sin{src.x}
541
542
543 .. opcode:: SLE - Set On Less Equal Than
544
545 .. math::
546
547 dst.x = (src0.x <= src1.x) ? 1 : 0
548
549 dst.y = (src0.y <= src1.y) ? 1 : 0
550
551 dst.z = (src0.z <= src1.z) ? 1 : 0
552
553 dst.w = (src0.w <= src1.w) ? 1 : 0
554
555
556 .. opcode:: SNE - Set On Not Equal
557
558 .. math::
559
560 dst.x = (src0.x != src1.x) ? 1 : 0
561
562 dst.y = (src0.y != src1.y) ? 1 : 0
563
564 dst.z = (src0.z != src1.z) ? 1 : 0
565
566 dst.w = (src0.w != src1.w) ? 1 : 0
567
568
569 .. opcode:: STR - Set On True
570
571 This instruction replicates its result.
572
573 .. math::
574
575 dst = 1
576
577
578 .. opcode:: TEX - Texture Lookup
579
580 .. math::
581
582 coord = src0
583
584 bias = 0.0
585
586 dst = texture_sample(unit, coord, bias)
587
588
589 .. opcode:: TXD - Texture Lookup with Derivatives
590
591 .. math::
592
593 coord = src0
594
595 ddx = src1
596
597 ddy = src2
598
599 bias = 0.0
600
601 dst = texture_sample_deriv(unit, coord, bias, ddx, ddy)
602
603
604 .. opcode:: TXP - Projective Texture Lookup
605
606 .. math::
607
608 coord.x = src0.x / src.w
609
610 coord.y = src0.y / src.w
611
612 coord.z = src0.z / src.w
613
614 coord.w = src0.w
615
616 bias = 0.0
617
618 dst = texture_sample(unit, coord, bias)
619
620
621 .. opcode:: UP2H - Unpack Two 16-Bit Floats
622
623 TBD
624
625 .. note::
626
627 Considered for removal.
628
629 .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
630
631 TBD
632
633 .. note::
634
635 Considered for removal.
636
637 .. opcode:: UP4B - Unpack Four Signed 8-Bit Values
638
639 TBD
640
641 .. note::
642
643 Considered for removal.
644
645 .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
646
647 TBD
648
649 .. note::
650
651 Considered for removal.
652
653 .. opcode:: X2D - 2D Coordinate Transformation
654
655 .. math::
656
657 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
658
659 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
660
661 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
662
663 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
664
665 .. note::
666
667 Considered for removal.
668
669
670 .. opcode:: ARA - Address Register Add
671
672 TBD
673
674 .. note::
675
676 Considered for removal.
677
678 .. opcode:: ARR - Address Register Load With Round
679
680 .. math::
681
682 dst.x = round(src.x)
683
684 dst.y = round(src.y)
685
686 dst.z = round(src.z)
687
688 dst.w = round(src.w)
689
690
691 .. opcode:: BRA - Branch
692
693 pc = target
694
695 .. note::
696
697 Considered for removal.
698
699 .. opcode:: CAL - Subroutine Call
700
701 push(pc)
702 pc = target
703
704
705 .. opcode:: RET - Subroutine Call Return
706
707 pc = pop()
708
709
710 .. opcode:: SSG - Set Sign
711
712 .. math::
713
714 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
715
716 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
717
718 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
719
720 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
721
722
723 .. opcode:: CMP - Compare
724
725 .. math::
726
727 dst.x = (src0.x < 0) ? src1.x : src2.x
728
729 dst.y = (src0.y < 0) ? src1.y : src2.y
730
731 dst.z = (src0.z < 0) ? src1.z : src2.z
732
733 dst.w = (src0.w < 0) ? src1.w : src2.w
734
735
736 .. opcode:: KIL - Conditional Discard
737
738 .. math::
739
740 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
741 discard
742 endif
743
744
745 .. opcode:: SCS - Sine Cosine
746
747 .. math::
748
749 dst.x = \cos{src.x}
750
751 dst.y = \sin{src.x}
752
753 dst.z = 0
754
755 dst.w = 1
756
757
758 .. opcode:: TXB - Texture Lookup With Bias
759
760 .. math::
761
762 coord.x = src.x
763
764 coord.y = src.y
765
766 coord.z = src.z
767
768 coord.w = 1.0
769
770 bias = src.z
771
772 dst = texture_sample(unit, coord, bias)
773
774
775 .. opcode:: NRM - 3-component Vector Normalise
776
777 .. math::
778
779 dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
780
781 dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
782
783 dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
784
785 dst.w = 1
786
787
788 .. opcode:: DIV - Divide
789
790 .. math::
791
792 dst.x = \frac{src0.x}{src1.x}
793
794 dst.y = \frac{src0.y}{src1.y}
795
796 dst.z = \frac{src0.z}{src1.z}
797
798 dst.w = \frac{src0.w}{src1.w}
799
800
801 .. opcode:: DP2 - 2-component Dot Product
802
803 This instruction replicates its result.
804
805 .. math::
806
807 dst = src0.x \times src1.x + src0.y \times src1.y
808
809
810 .. opcode:: TXL - Texture Lookup With explicit LOD
811
812 .. math::
813
814 coord.x = src0.x
815
816 coord.y = src0.y
817
818 coord.z = src0.z
819
820 coord.w = 1.0
821
822 lod = src0.w
823
824 dst = texture_sample(unit, coord, lod)
825
826
827 .. opcode:: BRK - Break
828
829 TBD
830
831
832 .. opcode:: IF - If
833
834 TBD
835
836
837 .. opcode:: ELSE - Else
838
839 TBD
840
841
842 .. opcode:: ENDIF - End If
843
844 TBD
845
846
847 .. opcode:: PUSHA - Push Address Register On Stack
848
849 push(src.x)
850 push(src.y)
851 push(src.z)
852 push(src.w)
853
854 .. note::
855
856 Considered for cleanup.
857
858 .. note::
859
860 Considered for removal.
861
862 .. opcode:: POPA - Pop Address Register From Stack
863
864 dst.w = pop()
865 dst.z = pop()
866 dst.y = pop()
867 dst.x = pop()
868
869 .. note::
870
871 Considered for cleanup.
872
873 .. note::
874
875 Considered for removal.
876
877
878 Compute ISA
879 ^^^^^^^^^^^^^^^^^^^^^^^^
880
881 These opcodes are primarily provided for special-use computational shaders.
882 Support for these opcodes indicated by a special pipe capability bit (TBD).
883
884 XXX so let's discuss it, yeah?
885
886 .. opcode:: CEIL - Ceiling
887
888 .. math::
889
890 dst.x = \lceil src.x\rceil
891
892 dst.y = \lceil src.y\rceil
893
894 dst.z = \lceil src.z\rceil
895
896 dst.w = \lceil src.w\rceil
897
898
899 .. opcode:: I2F - Integer To Float
900
901 .. math::
902
903 dst.x = (float) src.x
904
905 dst.y = (float) src.y
906
907 dst.z = (float) src.z
908
909 dst.w = (float) src.w
910
911
912 .. opcode:: NOT - Bitwise Not
913
914 .. math::
915
916 dst.x = ~src.x
917
918 dst.y = ~src.y
919
920 dst.z = ~src.z
921
922 dst.w = ~src.w
923
924
925 .. opcode:: TRUNC - Truncate
926
927 .. math::
928
929 dst.x = trunc(src.x)
930
931 dst.y = trunc(src.y)
932
933 dst.z = trunc(src.z)
934
935 dst.w = trunc(src.w)
936
937
938 .. opcode:: SHL - Shift Left
939
940 .. math::
941
942 dst.x = src0.x << src1.x
943
944 dst.y = src0.y << src1.x
945
946 dst.z = src0.z << src1.x
947
948 dst.w = src0.w << src1.x
949
950
951 .. opcode:: SHR - Shift Right
952
953 .. math::
954
955 dst.x = src0.x >> src1.x
956
957 dst.y = src0.y >> src1.x
958
959 dst.z = src0.z >> src1.x
960
961 dst.w = src0.w >> src1.x
962
963
964 .. opcode:: AND - Bitwise And
965
966 .. math::
967
968 dst.x = src0.x & src1.x
969
970 dst.y = src0.y & src1.y
971
972 dst.z = src0.z & src1.z
973
974 dst.w = src0.w & src1.w
975
976
977 .. opcode:: OR - Bitwise Or
978
979 .. math::
980
981 dst.x = src0.x | src1.x
982
983 dst.y = src0.y | src1.y
984
985 dst.z = src0.z | src1.z
986
987 dst.w = src0.w | src1.w
988
989
990 .. opcode:: MOD - Modulus
991
992 .. math::
993
994 dst.x = src0.x \bmod src1.x
995
996 dst.y = src0.y \bmod src1.y
997
998 dst.z = src0.z \bmod src1.z
999
1000 dst.w = src0.w \bmod src1.w
1001
1002
1003 .. opcode:: XOR - Bitwise Xor
1004
1005 .. math::
1006
1007 dst.x = src0.x \oplus src1.x
1008
1009 dst.y = src0.y \oplus src1.y
1010
1011 dst.z = src0.z \oplus src1.z
1012
1013 dst.w = src0.w \oplus src1.w
1014
1015
1016 .. opcode:: SAD - Sum Of Absolute Differences
1017
1018 .. math::
1019
1020 dst.x = |src0.x - src1.x| + src2.x
1021
1022 dst.y = |src0.y - src1.y| + src2.y
1023
1024 dst.z = |src0.z - src1.z| + src2.z
1025
1026 dst.w = |src0.w - src1.w| + src2.w
1027
1028
1029 .. opcode:: TXF - Texel Fetch
1030
1031 TBD
1032
1033
1034 .. opcode:: TXQ - Texture Size Query
1035
1036 TBD
1037
1038
1039 .. opcode:: CONT - Continue
1040
1041 TBD
1042
1043 .. note::
1044
1045 Support for CONT is determined by a special capability bit,
1046 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1047
1048
1049 Geometry ISA
1050 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1051
1052 These opcodes are only supported in geometry shaders; they have no meaning
1053 in any other type of shader.
1054
1055 .. opcode:: EMIT - Emit
1056
1057 TBD
1058
1059
1060 .. opcode:: ENDPRIM - End Primitive
1061
1062 TBD
1063
1064
1065 GLSL ISA
1066 ^^^^^^^^^^
1067
1068 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1069 opcodes is determined by a special capability bit, ``GLSL``.
1070
1071 .. opcode:: BGNLOOP - Begin a Loop
1072
1073 TBD
1074
1075
1076 .. opcode:: BGNSUB - Begin Subroutine
1077
1078 TBD
1079
1080
1081 .. opcode:: ENDLOOP - End a Loop
1082
1083 TBD
1084
1085
1086 .. opcode:: ENDSUB - End Subroutine
1087
1088 TBD
1089
1090
1091 .. opcode:: NOP - No Operation
1092
1093 Do nothing.
1094
1095
1096 .. opcode:: NRM4 - 4-component Vector Normalise
1097
1098 This instruction replicates its result.
1099
1100 .. math::
1101
1102 dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
1103
1104
1105 ps_2_x
1106 ^^^^^^^^^^^^
1107
1108 XXX wait what
1109
1110 .. opcode:: CALLNZ - Subroutine Call If Not Zero
1111
1112 TBD
1113
1114
1115 .. opcode:: IFC - If
1116
1117 TBD
1118
1119
1120 .. opcode:: BREAKC - Break Conditional
1121
1122 TBD
1123
1124 .. _doubleopcodes:
1125
1126 Double ISA
1127 ^^^^^^^^^^^^^^^
1128
1129 The double-precision opcodes reinterpret four-component vectors into
1130 two-component vectors with doubled precision in each component.
1131
1132 Support for these opcodes is XXX undecided. :T
1133
1134 .. opcode:: DADD - Add
1135
1136 .. math::
1137
1138 dst.xy = src0.xy + src1.xy
1139
1140 dst.zw = src0.zw + src1.zw
1141
1142
1143 .. opcode:: DDIV - Divide
1144
1145 .. math::
1146
1147 dst.xy = src0.xy / src1.xy
1148
1149 dst.zw = src0.zw / src1.zw
1150
1151 .. opcode:: DSEQ - Set on Equal
1152
1153 .. math::
1154
1155 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1156
1157 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1158
1159 .. opcode:: DSLT - Set on Less than
1160
1161 .. math::
1162
1163 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1164
1165 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1166
1167 .. opcode:: DFRAC - Fraction
1168
1169 .. math::
1170
1171 dst.xy = src.xy - \lfloor src.xy\rfloor
1172
1173 dst.zw = src.zw - \lfloor src.zw\rfloor
1174
1175
1176 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1177
1178 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1179 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1180 :math:`dst1 \times 2^{dst0} = src` .
1181
1182 .. math::
1183
1184 dst0.xy = exp(src.xy)
1185
1186 dst1.xy = frac(src.xy)
1187
1188 dst0.zw = exp(src.zw)
1189
1190 dst1.zw = frac(src.zw)
1191
1192 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1193
1194 This opcode is the inverse of :opcode:`DFRACEXP`.
1195
1196 .. math::
1197
1198 dst.xy = src0.xy \times 2^{src1.xy}
1199
1200 dst.zw = src0.zw \times 2^{src1.zw}
1201
1202 .. opcode:: DMIN - Minimum
1203
1204 .. math::
1205
1206 dst.xy = min(src0.xy, src1.xy)
1207
1208 dst.zw = min(src0.zw, src1.zw)
1209
1210 .. opcode:: DMAX - Maximum
1211
1212 .. math::
1213
1214 dst.xy = max(src0.xy, src1.xy)
1215
1216 dst.zw = max(src0.zw, src1.zw)
1217
1218 .. opcode:: DMUL - Multiply
1219
1220 .. math::
1221
1222 dst.xy = src0.xy \times src1.xy
1223
1224 dst.zw = src0.zw \times src1.zw
1225
1226
1227 .. opcode:: DMAD - Multiply And Add
1228
1229 .. math::
1230
1231 dst.xy = src0.xy \times src1.xy + src2.xy
1232
1233 dst.zw = src0.zw \times src1.zw + src2.zw
1234
1235
1236 .. opcode:: DRCP - Reciprocal
1237
1238 .. math::
1239
1240 dst.xy = \frac{1}{src.xy}
1241
1242 dst.zw = \frac{1}{src.zw}
1243
1244 .. opcode:: DSQRT - Square Root
1245
1246 .. math::
1247
1248 dst.xy = \sqrt{src.xy}
1249
1250 dst.zw = \sqrt{src.zw}
1251
1252
1253 .. _resourceopcodes:
1254
1255 Resource Access Opcodes
1256 ^^^^^^^^^^^^^^^^^^^^^^^^
1257
1258 Those opcodes follow very closely semantics of the respective Direct3D
1259 instructions. If in doubt double check Direct3D documentation.
1260
1261 .. opcode:: LOAD - Simplified alternative to the "SAMPLE" instruction.
1262 Using the provided integer address, LOAD fetches data
1263 from the specified buffer/texture without any filtering.
1264 The source data may come from any resource type other
1265 than CUBE.
1266 LOAD dst, address, resource
1267 e.g.
1268 LOAD TEMP[0], TEMP[1], RES[0]
1269 The 'address' is specified as unsigned integers. If the
1270 'address' is out of range [0...(# texels - 1)] the
1271 result of the fetch is always 0 in all components.
1272 As such the instruction doesn't honor address wrap
1273 modes, in cases where that behavior is desirable
1274 'sample' instruction should be used.
1275 address.w always provides an unsigned integer mipmap
1276 level. If the value is out of the range then the
1277 instruction always returns 0 in all components.
1278 address.yz are ignored for buffers and 1d textures.
1279 address.z is ignored for 1d texture arrays and 2d
1280 textures.
1281 For 1D texture arrays address.y provides the array
1282 index (also as unsigned integer). If the value is
1283 out of the range of available array indices
1284 [0... (array size - 1)] then the opcode always returns
1285 0 in all components.
1286 For 2D texture arrays address.z provides the array
1287 index, otherwise it exhibits the same behavior as in
1288 the case for 1D texture arrays.
1289 The exeact semantics of the source address are presented
1290 in the table below:
1291 resource type X Y Z W
1292 ------------- ------------------------
1293 PIPE_BUFFER x ignored
1294 PIPE_TEXTURE_1D x mpl
1295 PIPE_TEXTURE_2D x y mpl
1296 PIPE_TEXTURE_3D x y z mpl
1297 PIPE_TEXTURE_RECT x y mpl
1298 PIPE_TEXTURE_CUBE not allowed as source
1299 PIPE_TEXTURE_1D_ARRAY x idx mpl
1300 PIPE_TEXTURE_2D_ARRAY x y idx mpl
1301
1302 Where 'mpl' is a mipmap level and 'idx' is the
1303 array index.
1304
1305
1306 .. opcode:: LOAD_MS - Just like LOAD but allows fetch data from
1307 multi-sampled surfaces.
1308
1309 .. opcode:: SAMPLE - Using provided address, sample data from the
1310 specified texture using the filtering mode identified
1311 by the gven sampler. The source data may come from
1312 any resource type other than buffers.
1313 SAMPLE dst, address, resource, sampler
1314 e.g.
1315 SAMPLE TEMP[0], TEMP[1], RES[0], SAMP[0]
1316
1317 .. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the
1318 exception that an additiona bias is applied to the
1319 level of detail computed as part of the instruction
1320 execution.
1321 SAMPLE_B dst, address, resource, sampler, lod_bias
1322 e.g.
1323 SAMPLE_B TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2].x
1324
1325 .. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it
1326 performs a comparison filter. The operands to SAMPLE_C
1327 are identical to SAMPLE, except that tere is an additional
1328 float32 operand, reference value, which must be a register
1329 with single-component, or a scalar literal.
1330 SAMPLE_C makes the hardware use the current samplers
1331 compare_func (in pipe_sampler_state) to compare
1332 reference value against the red component value for the
1333 surce resource at each texel that the currently configured
1334 texture filter covers based on the provided coordinates.
1335 SAMPLE_C dst, address, resource.r, sampler, ref_value
1336 e.g.
1337 SAMPLE_C TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
1338
1339 .. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives
1340 are ignored. The LZ stands for level-zero.
1341 SAMPLE_C_LZ dst, address, resource.r, sampler, ref_value
1342 e.g.
1343 SAMPLE_C_LZ TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
1344
1345
1346 .. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except
1347 that the derivatives for the source address in the x
1348 direction and the y direction are provided by extra
1349 parameters.
1350 SAMPLE_D dst, address, resource, sampler, der_x, der_y
1351 e.g.
1352 SAMPLE_D TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2], TEMP[3]
1353
1354 .. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except
1355 that the LOD is provided directly as a scalar value,
1356 representing no anisotropy. Source addresses A channel
1357 is used as the LOD.
1358 SAMPLE_L dst, address, resource, sampler
1359 e.g.
1360 SAMPLE_L TEMP[0], TEMP[1], RES[0], SAMP[0]
1361
1362
1363 .. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear
1364 filtering operation and packs them into a single register.
1365 Only woth with 2D, 2D array, cubemaps, and cubemaps arrays.
1366 For 2D textures, only the addressing modes of the sampler and
1367 the top level of any mip pyramid are used. Set W to zero.
1368 It behaves like the SAMPLE instruction, but a filtered
1369 sample is not generated. The four samples that contribute
1370 to filtering are places into xyzw in cunter-clockwise order,
1371 starting with the (u,v) texture coordinate delta at the
1372 following locations (-, +), (+, +), (+, -), (-, -), where
1373 the magnitude of the deltas are half a texel.
1374
1375
1376 .. opcode:: RESINFO - query the dimensions of a given input buffer.
1377 dst receives width, height, depth or array size and
1378 number of mipmap levels. The dst can have a writemask
1379 which will specify what info is the caller interested
1380 in.
1381 RESINFO dst, src_mip_level, resource
1382 e.g.
1383 RESINFO TEMP[0], TEMP[1].x, RES[0]
1384 src_mip_level is an unsigned integer scalar. If it's
1385 out of range then returns 0 for width, height and
1386 depth/array size but the total number of mipmap is
1387 still returned correctly for the given resource.
1388 The returned width, height and depth values are for
1389 the mipmap level selected by the src_mip_level and
1390 are in the number of texels.
1391 For 1d texture array width is in dst.x, array size
1392 is in dst.y and dst.zw are always 0.
1393
1394 .. opcode:: SAMPLE_POS - query the position of a given sample.
1395 dst receives float4 (x, y, 0, 0) indicated where the
1396 sample is located. If the resource is not a multi-sample
1397 resource and not a render target, the result is 0.
1398
1399 .. opcode:: SAMPLE_INFO - dst receives number of samples in x.
1400 If the resource is not a multi-sample resource and
1401 not a render target, the result is 0.
1402
1403
1404 Explanation of symbols used
1405 ------------------------------
1406
1407
1408 Functions
1409 ^^^^^^^^^^^^^^
1410
1411
1412 :math:`|x|` Absolute value of `x`.
1413
1414 :math:`\lceil x \rceil` Ceiling of `x`.
1415
1416 clamp(x,y,z) Clamp x between y and z.
1417 (x < y) ? y : (x > z) ? z : x
1418
1419 :math:`\lfloor x\rfloor` Floor of `x`.
1420
1421 :math:`\log_2{x}` Logarithm of `x`, base 2.
1422
1423 max(x,y) Maximum of x and y.
1424 (x > y) ? x : y
1425
1426 min(x,y) Minimum of x and y.
1427 (x < y) ? x : y
1428
1429 partialx(x) Derivative of x relative to fragment's X.
1430
1431 partialy(x) Derivative of x relative to fragment's Y.
1432
1433 pop() Pop from stack.
1434
1435 :math:`x^y` `x` to the power `y`.
1436
1437 push(x) Push x on stack.
1438
1439 round(x) Round x.
1440
1441 trunc(x) Truncate x, i.e. drop the fraction bits.
1442
1443
1444 Keywords
1445 ^^^^^^^^^^^^^
1446
1447
1448 discard Discard fragment.
1449
1450 pc Program counter.
1451
1452 target Label of target instruction.
1453
1454
1455 Other tokens
1456 ---------------
1457
1458
1459 Declaration
1460 ^^^^^^^^^^^
1461
1462
1463 Declares a register that is will be referenced as an operand in Instruction
1464 tokens.
1465
1466 File field contains register file that is being declared and is one
1467 of TGSI_FILE.
1468
1469 UsageMask field specifies which of the register components can be accessed
1470 and is one of TGSI_WRITEMASK.
1471
1472 Interpolate field is only valid for fragment shader INPUT register files.
1473 It specifes the way input is being interpolated by the rasteriser and is one
1474 of TGSI_INTERPOLATE.
1475
1476 If Dimension flag is set to 1, a Declaration Dimension token follows.
1477
1478 If Semantic flag is set to 1, a Declaration Semantic token follows.
1479
1480 CylindricalWrap bitfield is only valid for fragment shader INPUT register
1481 files. It specifies which register components should be subject to cylindrical
1482 wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1483 is set to 1, the X component should be interpolated according to cylindrical
1484 wrapping rules.
1485
1486 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
1487
1488
1489 Declaration Semantic
1490 ^^^^^^^^^^^^^^^^^^^^^^^^
1491
1492 Vertex and fragment shader input and output registers may be labeled
1493 with semantic information consisting of a name and index.
1494
1495 Follows Declaration token if Semantic bit is set.
1496
1497 Since its purpose is to link a shader with other stages of the pipeline,
1498 it is valid to follow only those Declaration tokens that declare a register
1499 either in INPUT or OUTPUT file.
1500
1501 SemanticName field contains the semantic name of the register being declared.
1502 There is no default value.
1503
1504 SemanticIndex is an optional subscript that can be used to distinguish
1505 different register declarations with the same semantic name. The default value
1506 is 0.
1507
1508 The meanings of the individual semantic names are explained in the following
1509 sections.
1510
1511 TGSI_SEMANTIC_POSITION
1512 """"""""""""""""""""""
1513
1514 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
1515 output register which contains the homogeneous vertex position in the clip
1516 space coordinate system. After clipping, the X, Y and Z components of the
1517 vertex will be divided by the W value to get normalized device coordinates.
1518
1519 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
1520 fragment shader input contains the fragment's window position. The X
1521 component starts at zero and always increases from left to right.
1522 The Y component starts at zero and always increases but Y=0 may either
1523 indicate the top of the window or the bottom depending on the fragment
1524 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
1525 The Z coordinate ranges from 0 to 1 to represent depth from the front
1526 to the back of the Z buffer. The W component contains the reciprocol
1527 of the interpolated vertex position W component.
1528
1529 Fragment shaders may also declare an output register with
1530 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
1531 the fragment shader to change the fragment's Z position.
1532
1533
1534
1535 TGSI_SEMANTIC_COLOR
1536 """""""""""""""""""
1537
1538 For vertex shader outputs or fragment shader inputs/outputs, this
1539 label indicates that the resister contains an R,G,B,A color.
1540
1541 Several shader inputs/outputs may contain colors so the semantic index
1542 is used to distinguish them. For example, color[0] may be the diffuse
1543 color while color[1] may be the specular color.
1544
1545 This label is needed so that the flat/smooth shading can be applied
1546 to the right interpolants during rasterization.
1547
1548
1549
1550 TGSI_SEMANTIC_BCOLOR
1551 """"""""""""""""""""
1552
1553 Back-facing colors are only used for back-facing polygons, and are only valid
1554 in vertex shader outputs. After rasterization, all polygons are front-facing
1555 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
1556 so all BCOLORs effectively become regular COLORs in the fragment shader.
1557
1558
1559 TGSI_SEMANTIC_FOG
1560 """""""""""""""""
1561
1562 Vertex shader inputs and outputs and fragment shader inputs may be
1563 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
1564 a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
1565 shader will use the fog coordinate to compute a fog blend factor which
1566 is used to blend the normal fragment color with a constant fog color.
1567
1568 Only the first component matters when writing from the vertex shader;
1569 the driver will ensure that the coordinate is in this format when used
1570 as a fragment shader input.
1571
1572
1573 TGSI_SEMANTIC_PSIZE
1574 """""""""""""""""""
1575
1576 Vertex shader input and output registers may be labeled with
1577 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
1578 in the form (S, 0, 0, 1). The point size controls the width or diameter
1579 of points for rasterization. This label cannot be used in fragment
1580 shaders.
1581
1582 When using this semantic, be sure to set the appropriate state in the
1583 :ref:`rasterizer` first.
1584
1585
1586 TGSI_SEMANTIC_GENERIC
1587 """""""""""""""""""""
1588
1589 All vertex/fragment shader inputs/outputs not labeled with any other
1590 semantic label can be considered to be generic attributes. Typical
1591 uses of generic inputs/outputs are texcoords and user-defined values.
1592
1593
1594 TGSI_SEMANTIC_NORMAL
1595 """"""""""""""""""""
1596
1597 Indicates that a vertex shader input is a normal vector. This is
1598 typically only used for legacy graphics APIs.
1599
1600
1601 TGSI_SEMANTIC_FACE
1602 """"""""""""""""""
1603
1604 This label applies to fragment shader inputs only and indicates that
1605 the register contains front/back-face information of the form (F, 0,
1606 0, 1). The first component will be positive when the fragment belongs
1607 to a front-facing polygon, and negative when the fragment belongs to a
1608 back-facing polygon.
1609
1610
1611 TGSI_SEMANTIC_EDGEFLAG
1612 """"""""""""""""""""""
1613
1614 For vertex shaders, this sematic label indicates that an input or
1615 output is a boolean edge flag. The register layout is [F, x, x, x]
1616 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
1617 simply copies the edge flag input to the edgeflag output.
1618
1619 Edge flags are used to control which lines or points are actually
1620 drawn when the polygon mode converts triangles/quads/polygons into
1621 points or lines.
1622
1623 TGSI_SEMANTIC_STENCIL
1624 """"""""""""""""""""""
1625
1626 For fragment shaders, this semantic label indicates than an output
1627 is a writable stencil reference value. Only the Y component is writable.
1628 This allows the fragment shader to change the fragments stencilref value.
1629
1630
1631 Declaration Resource
1632 ^^^^^^^^^^^^^^^^^^^^^^^^
1633
1634 Follows Declaration token if file is TGSI_FILE_RESOURCE.
1635
1636 DCL RES[#], resource, type(s)
1637
1638 Declares a shader input resource and assigns it to a RES[#]
1639 register.
1640
1641 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
1642 2DArray.
1643
1644 type must be 1 or 4 entries (if specifying on a per-component
1645 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
1646
1647
1648 Properties
1649 ^^^^^^^^^^^^^^^^^^^^^^^^
1650
1651
1652 Properties are general directives that apply to the whole TGSI program.
1653
1654 FS_COORD_ORIGIN
1655 """""""""""""""
1656
1657 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1658 The default value is UPPER_LEFT.
1659
1660 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1661 increase downward and rightward.
1662 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1663 increase upward and rightward.
1664
1665 OpenGL defaults to LOWER_LEFT, and is configurable with the
1666 GL_ARB_fragment_coord_conventions extension.
1667
1668 DirectX 9/10 use UPPER_LEFT.
1669
1670 FS_COORD_PIXEL_CENTER
1671 """""""""""""""""""""
1672
1673 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1674 The default value is HALF_INTEGER.
1675
1676 If HALF_INTEGER, the fractionary part of the position will be 0.5
1677 If INTEGER, the fractionary part of the position will be 0.0
1678
1679 Note that this does not affect the set of fragments generated by
1680 rasterization, which is instead controlled by gl_rasterization_rules in the
1681 rasterizer.
1682
1683 OpenGL defaults to HALF_INTEGER, and is configurable with the
1684 GL_ARB_fragment_coord_conventions extension.
1685
1686 DirectX 9 uses INTEGER.
1687 DirectX 10 uses HALF_INTEGER.
1688
1689 FS_COLOR0_WRITES_ALL_CBUFS
1690 """"""""""""""""""""""""""
1691 Specifies that writes to the fragment shader color 0 are replicated to all
1692 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
1693 fragData is directed to a single color buffer, but fragColor is broadcast.
1694
1695
1696 Texture Sampling and Texture Formats
1697 ------------------------------------
1698
1699 This table shows how texture image components are returned as (x,y,z,w) tuples
1700 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1701 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1702 well.
1703
1704 +--------------------+--------------+--------------------+--------------+
1705 | Texture Components | Gallium | OpenGL | Direct3D 9 |
1706 +====================+==============+====================+==============+
1707 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
1708 +--------------------+--------------+--------------------+--------------+
1709 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
1710 +--------------------+--------------+--------------------+--------------+
1711 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1712 +--------------------+--------------+--------------------+--------------+
1713 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1714 +--------------------+--------------+--------------------+--------------+
1715 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1716 +--------------------+--------------+--------------------+--------------+
1717 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1718 +--------------------+--------------+--------------------+--------------+
1719 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1720 +--------------------+--------------+--------------------+--------------+
1721 | I | (i, i, i, i) | (i, i, i, i) | N/A |
1722 +--------------------+--------------+--------------------+--------------+
1723 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1724 | | | [#envmap-bumpmap]_ | |
1725 +--------------------+--------------+--------------------+--------------+
1726 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
1727 | | | [#depth-tex-mode]_ | |
1728 +--------------------+--------------+--------------------+--------------+
1729 | S | (s, s, s, s) | unknown | unknown |
1730 +--------------------+--------------+--------------------+--------------+
1731
1732 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
1733 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
1734 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.