gallium/docs: document that TXF is used with PIPE_BUFFER resources
[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:`doubleopcodes`.
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 Modifiers
27 ^^^^^^^^^^^^^^^
28
29 TGSI supports modifiers on inputs (as well as saturate modifier on instructions).
30
31 For inputs which have a floating point type, both absolute value and
32 negation modifiers are supported (with absolute value being applied
33 first). The only source of TGSI_OPCODE_MOV and the second and third
34 sources of TGSI_OPCODE_UCMP are considered to have float type for
35 applying modifiers.
36
37 For inputs which have signed or unsigned type only the negate modifier is
38 supported.
39
40 Instruction Set
41 ---------------
42
43 Core ISA
44 ^^^^^^^^^^^^^^^^^^^^^^^^^
45
46 These opcodes are guaranteed to be available regardless of the driver being
47 used.
48
49 .. opcode:: ARL - Address Register Load
50
51 .. math::
52
53 dst.x = (int) \lfloor src.x\rfloor
54
55 dst.y = (int) \lfloor src.y\rfloor
56
57 dst.z = (int) \lfloor src.z\rfloor
58
59 dst.w = (int) \lfloor src.w\rfloor
60
61
62 .. opcode:: MOV - Move
63
64 .. math::
65
66 dst.x = src.x
67
68 dst.y = src.y
69
70 dst.z = src.z
71
72 dst.w = src.w
73
74
75 .. opcode:: LIT - Light Coefficients
76
77 .. math::
78
79 dst.x &= 1 \\
80 dst.y &= max(src.x, 0) \\
81 dst.z &= (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 \\
82 dst.w &= 1
83
84
85 .. opcode:: RCP - Reciprocal
86
87 This instruction replicates its result.
88
89 .. math::
90
91 dst = \frac{1}{src.x}
92
93
94 .. opcode:: RSQ - Reciprocal Square Root
95
96 This instruction replicates its result. The results are undefined for src <= 0.
97
98 .. math::
99
100 dst = \frac{1}{\sqrt{src.x}}
101
102
103 .. opcode:: SQRT - Square Root
104
105 This instruction replicates its result. The results are undefined for src < 0.
106
107 .. math::
108
109 dst = {\sqrt{src.x}}
110
111
112 .. opcode:: EXP - Approximate Exponential Base 2
113
114 .. math::
115
116 dst.x &= 2^{\lfloor src.x\rfloor} \\
117 dst.y &= src.x - \lfloor src.x\rfloor \\
118 dst.z &= 2^{src.x} \\
119 dst.w &= 1
120
121
122 .. opcode:: LOG - Approximate Logarithm Base 2
123
124 .. math::
125
126 dst.x &= \lfloor\log_2{|src.x|}\rfloor \\
127 dst.y &= \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} \\
128 dst.z &= \log_2{|src.x|} \\
129 dst.w &= 1
130
131
132 .. opcode:: MUL - Multiply
133
134 .. math::
135
136 dst.x = src0.x \times src1.x
137
138 dst.y = src0.y \times src1.y
139
140 dst.z = src0.z \times src1.z
141
142 dst.w = src0.w \times src1.w
143
144
145 .. opcode:: ADD - Add
146
147 .. math::
148
149 dst.x = src0.x + src1.x
150
151 dst.y = src0.y + src1.y
152
153 dst.z = src0.z + src1.z
154
155 dst.w = src0.w + src1.w
156
157
158 .. opcode:: DP3 - 3-component Dot Product
159
160 This instruction replicates its result.
161
162 .. math::
163
164 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
165
166
167 .. opcode:: DP4 - 4-component Dot Product
168
169 This instruction replicates its result.
170
171 .. math::
172
173 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
174
175
176 .. opcode:: DST - Distance Vector
177
178 .. math::
179
180 dst.x &= 1\\
181 dst.y &= src0.y \times src1.y\\
182 dst.z &= src0.z\\
183 dst.w &= src1.w
184
185
186 .. opcode:: MIN - Minimum
187
188 .. math::
189
190 dst.x = min(src0.x, src1.x)
191
192 dst.y = min(src0.y, src1.y)
193
194 dst.z = min(src0.z, src1.z)
195
196 dst.w = min(src0.w, src1.w)
197
198
199 .. opcode:: MAX - Maximum
200
201 .. math::
202
203 dst.x = max(src0.x, src1.x)
204
205 dst.y = max(src0.y, src1.y)
206
207 dst.z = max(src0.z, src1.z)
208
209 dst.w = max(src0.w, src1.w)
210
211
212 .. opcode:: SLT - Set On Less Than
213
214 .. math::
215
216 dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
217
218 dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
219
220 dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
221
222 dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
223
224
225 .. opcode:: SGE - Set On Greater Equal Than
226
227 .. math::
228
229 dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
230
231 dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
232
233 dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
234
235 dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
236
237
238 .. opcode:: MAD - Multiply And Add
239
240 .. math::
241
242 dst.x = src0.x \times src1.x + src2.x
243
244 dst.y = src0.y \times src1.y + src2.y
245
246 dst.z = src0.z \times src1.z + src2.z
247
248 dst.w = src0.w \times src1.w + src2.w
249
250
251 .. opcode:: LRP - Linear Interpolate
252
253 .. math::
254
255 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
256
257 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
258
259 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
260
261 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
262
263
264 .. opcode:: FMA - Fused Multiply-Add
265
266 Perform a * b + c with no intermediate rounding step.
267
268 .. math::
269
270 dst.x = src0.x \times src1.x + src2.x
271
272 dst.y = src0.y \times src1.y + src2.y
273
274 dst.z = src0.z \times src1.z + src2.z
275
276 dst.w = src0.w \times src1.w + src2.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:: FLR - Floor
306
307 .. math::
308
309 dst.x = \lfloor src.x\rfloor
310
311 dst.y = \lfloor src.y\rfloor
312
313 dst.z = \lfloor src.z\rfloor
314
315 dst.w = \lfloor src.w\rfloor
316
317
318 .. opcode:: ROUND - Round
319
320 .. math::
321
322 dst.x = round(src.x)
323
324 dst.y = round(src.y)
325
326 dst.z = round(src.z)
327
328 dst.w = round(src.w)
329
330
331 .. opcode:: EX2 - Exponential Base 2
332
333 This instruction replicates its result.
334
335 .. math::
336
337 dst = 2^{src.x}
338
339
340 .. opcode:: LG2 - Logarithm Base 2
341
342 This instruction replicates its result.
343
344 .. math::
345
346 dst = \log_2{src.x}
347
348
349 .. opcode:: POW - Power
350
351 This instruction replicates its result.
352
353 .. math::
354
355 dst = src0.x^{src1.x}
356
357 .. opcode:: XPD - Cross Product
358
359 .. math::
360
361 dst.x = src0.y \times src1.z - src1.y \times src0.z
362
363 dst.y = src0.z \times src1.x - src1.z \times src0.x
364
365 dst.z = src0.x \times src1.y - src1.x \times src0.y
366
367 dst.w = 1
368
369
370 .. opcode:: DPH - Homogeneous Dot Product
371
372 This instruction replicates its result.
373
374 .. math::
375
376 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
377
378
379 .. opcode:: COS - Cosine
380
381 This instruction replicates its result.
382
383 .. math::
384
385 dst = \cos{src.x}
386
387
388 .. opcode:: DDX, DDX_FINE - Derivative Relative To X
389
390 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
391 advertised. When it is, the fine version guarantees one derivative per row
392 while DDX is allowed to be the same for the entire 2x2 quad.
393
394 .. math::
395
396 dst.x = partialx(src.x)
397
398 dst.y = partialx(src.y)
399
400 dst.z = partialx(src.z)
401
402 dst.w = partialx(src.w)
403
404
405 .. opcode:: DDY, DDY_FINE - Derivative Relative To Y
406
407 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
408 advertised. When it is, the fine version guarantees one derivative per column
409 while DDY is allowed to be the same for the entire 2x2 quad.
410
411 .. math::
412
413 dst.x = partialy(src.x)
414
415 dst.y = partialy(src.y)
416
417 dst.z = partialy(src.z)
418
419 dst.w = partialy(src.w)
420
421
422 .. opcode:: PK2H - Pack Two 16-bit Floats
423
424 This instruction replicates its result.
425
426 .. math::
427
428 dst = f32\_to\_f16(src.x) | f32\_to\_f16(src.y) << 16
429
430
431 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
432
433 TBD
434
435
436 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
437
438 TBD
439
440
441 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
442
443 TBD
444
445
446 .. opcode:: SEQ - Set On Equal
447
448 .. math::
449
450 dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
451
452 dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
453
454 dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
455
456 dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
457
458
459 .. opcode:: SGT - Set On Greater Than
460
461 .. math::
462
463 dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
464
465 dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
466
467 dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
468
469 dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
470
471
472 .. opcode:: SIN - Sine
473
474 This instruction replicates its result.
475
476 .. math::
477
478 dst = \sin{src.x}
479
480
481 .. opcode:: SLE - Set On Less Equal Than
482
483 .. math::
484
485 dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
486
487 dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
488
489 dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
490
491 dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
492
493
494 .. opcode:: SNE - Set On Not Equal
495
496 .. math::
497
498 dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
499
500 dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
501
502 dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
503
504 dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
505
506
507 .. opcode:: TEX - Texture Lookup
508
509 for array textures src0.y contains the slice for 1D,
510 and src0.z contain the slice for 2D.
511
512 for shadow textures with no arrays (and not cube map),
513 src0.z contains the reference value.
514
515 for shadow textures with arrays, src0.z contains
516 the reference value for 1D arrays, and src0.w contains
517 the reference value for 2D arrays and cube maps.
518
519 for cube map array shadow textures, the reference value
520 cannot be passed in src0.w, and TEX2 must be used instead.
521
522 .. math::
523
524 coord = src0
525
526 shadow_ref = src0.z or src0.w (optional)
527
528 unit = src1
529
530 dst = texture\_sample(unit, coord, shadow_ref)
531
532
533 .. opcode:: TEX2 - Texture Lookup (for shadow cube map arrays only)
534
535 this is the same as TEX, but uses another reg to encode the
536 reference value.
537
538 .. math::
539
540 coord = src0
541
542 shadow_ref = src1.x
543
544 unit = src2
545
546 dst = texture\_sample(unit, coord, shadow_ref)
547
548
549
550
551 .. opcode:: TXD - Texture Lookup with Derivatives
552
553 .. math::
554
555 coord = src0
556
557 ddx = src1
558
559 ddy = src2
560
561 unit = src3
562
563 dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
564
565
566 .. opcode:: TXP - Projective Texture Lookup
567
568 .. math::
569
570 coord.x = src0.x / src0.w
571
572 coord.y = src0.y / src0.w
573
574 coord.z = src0.z / src0.w
575
576 coord.w = src0.w
577
578 unit = src1
579
580 dst = texture\_sample(unit, coord)
581
582
583 .. opcode:: UP2H - Unpack Two 16-Bit Floats
584
585 .. math::
586
587 dst.x = f16\_to\_f32(src0.x \& 0xffff)
588
589 dst.y = f16\_to\_f32(src0.x >> 16)
590
591 dst.z = f16\_to\_f32(src0.x \& 0xffff)
592
593 dst.w = f16\_to\_f32(src0.x >> 16)
594
595 .. note::
596
597 Considered for removal.
598
599 .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
600
601 TBD
602
603 .. note::
604
605 Considered for removal.
606
607 .. opcode:: UP4B - Unpack Four Signed 8-Bit Values
608
609 TBD
610
611 .. note::
612
613 Considered for removal.
614
615 .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
616
617 TBD
618
619 .. note::
620
621 Considered for removal.
622
623
624 .. opcode:: ARR - Address Register Load With Round
625
626 .. math::
627
628 dst.x = (int) round(src.x)
629
630 dst.y = (int) round(src.y)
631
632 dst.z = (int) round(src.z)
633
634 dst.w = (int) round(src.w)
635
636
637 .. opcode:: SSG - Set Sign
638
639 .. math::
640
641 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
642
643 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
644
645 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
646
647 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
648
649
650 .. opcode:: CMP - Compare
651
652 .. math::
653
654 dst.x = (src0.x < 0) ? src1.x : src2.x
655
656 dst.y = (src0.y < 0) ? src1.y : src2.y
657
658 dst.z = (src0.z < 0) ? src1.z : src2.z
659
660 dst.w = (src0.w < 0) ? src1.w : src2.w
661
662
663 .. opcode:: KILL_IF - Conditional Discard
664
665 Conditional discard. Allowed in fragment shaders only.
666
667 .. math::
668
669 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
670 discard
671 endif
672
673
674 .. opcode:: KILL - Discard
675
676 Unconditional discard. Allowed in fragment shaders only.
677
678
679 .. opcode:: SCS - Sine Cosine
680
681 .. math::
682
683 dst.x = \cos{src.x}
684
685 dst.y = \sin{src.x}
686
687 dst.z = 0
688
689 dst.w = 1
690
691
692 .. opcode:: TXB - Texture Lookup With Bias
693
694 for cube map array textures and shadow cube maps, the bias value
695 cannot be passed in src0.w, and TXB2 must be used instead.
696
697 if the target is a shadow texture, the reference value is always
698 in src.z (this prevents shadow 3d and shadow 2d arrays from
699 using this instruction, but this is not needed).
700
701 .. math::
702
703 coord.x = src0.x
704
705 coord.y = src0.y
706
707 coord.z = src0.z
708
709 coord.w = none
710
711 bias = src0.w
712
713 unit = src1
714
715 dst = texture\_sample(unit, coord, bias)
716
717
718 .. opcode:: TXB2 - Texture Lookup With Bias (some cube maps only)
719
720 this is the same as TXB, but uses another reg to encode the
721 lod bias value for cube map arrays and shadow cube maps.
722 Presumably shadow 2d arrays and shadow 3d targets could use
723 this encoding too, but this is not legal.
724
725 shadow cube map arrays are neither possible nor required.
726
727 .. math::
728
729 coord = src0
730
731 bias = src1.x
732
733 unit = src2
734
735 dst = texture\_sample(unit, coord, bias)
736
737
738 .. opcode:: DIV - Divide
739
740 .. math::
741
742 dst.x = \frac{src0.x}{src1.x}
743
744 dst.y = \frac{src0.y}{src1.y}
745
746 dst.z = \frac{src0.z}{src1.z}
747
748 dst.w = \frac{src0.w}{src1.w}
749
750
751 .. opcode:: DP2 - 2-component Dot Product
752
753 This instruction replicates its result.
754
755 .. math::
756
757 dst = src0.x \times src1.x + src0.y \times src1.y
758
759
760 .. opcode:: TEX_LZ - Texture Lookup With LOD = 0
761
762 This is the same as TXL with LOD = 0. Like every texture opcode, it obeys
763 pipe_sampler_view::u.tex.first_level and pipe_sampler_state::min_lod.
764 There is no way to override those two in shaders.
765
766 .. math::
767
768 coord.x = src0.x
769
770 coord.y = src0.y
771
772 coord.z = src0.z
773
774 coord.w = none
775
776 lod = 0
777
778 unit = src1
779
780 dst = texture\_sample(unit, coord, lod)
781
782
783 .. opcode:: TXL - Texture Lookup With explicit LOD
784
785 for cube map array textures, the explicit lod value
786 cannot be passed in src0.w, and TXL2 must be used instead.
787
788 if the target is a shadow texture, the reference value is always
789 in src.z (this prevents shadow 3d / 2d array / cube targets from
790 using this instruction, but this is not needed).
791
792 .. math::
793
794 coord.x = src0.x
795
796 coord.y = src0.y
797
798 coord.z = src0.z
799
800 coord.w = none
801
802 lod = src0.w
803
804 unit = src1
805
806 dst = texture\_sample(unit, coord, lod)
807
808
809 .. opcode:: TXL2 - Texture Lookup With explicit LOD (for cube map arrays only)
810
811 this is the same as TXL, but uses another reg to encode the
812 explicit lod value.
813 Presumably shadow 3d / 2d array / cube targets could use
814 this encoding too, but this is not legal.
815
816 shadow cube map arrays are neither possible nor required.
817
818 .. math::
819
820 coord = src0
821
822 lod = src1.x
823
824 unit = src2
825
826 dst = texture\_sample(unit, coord, lod)
827
828
829 .. opcode:: PUSHA - Push Address Register On Stack
830
831 push(src.x)
832 push(src.y)
833 push(src.z)
834 push(src.w)
835
836 .. note::
837
838 Considered for cleanup.
839
840 .. note::
841
842 Considered for removal.
843
844 .. opcode:: POPA - Pop Address Register From Stack
845
846 dst.w = pop()
847 dst.z = pop()
848 dst.y = pop()
849 dst.x = pop()
850
851 .. note::
852
853 Considered for cleanup.
854
855 .. note::
856
857 Considered for removal.
858
859
860 .. opcode:: CALLNZ - Subroutine Call If Not Zero
861
862 TBD
863
864 .. note::
865
866 Considered for cleanup.
867
868 .. note::
869
870 Considered for removal.
871
872
873 Compute ISA
874 ^^^^^^^^^^^^^^^^^^^^^^^^
875
876 These opcodes are primarily provided for special-use computational shaders.
877 Support for these opcodes indicated by a special pipe capability bit (TBD).
878
879 XXX doesn't look like most of the opcodes really belong here.
880
881 .. opcode:: CEIL - Ceiling
882
883 .. math::
884
885 dst.x = \lceil src.x\rceil
886
887 dst.y = \lceil src.y\rceil
888
889 dst.z = \lceil src.z\rceil
890
891 dst.w = \lceil src.w\rceil
892
893
894 .. opcode:: TRUNC - Truncate
895
896 .. math::
897
898 dst.x = trunc(src.x)
899
900 dst.y = trunc(src.y)
901
902 dst.z = trunc(src.z)
903
904 dst.w = trunc(src.w)
905
906
907 .. opcode:: MOD - Modulus
908
909 .. math::
910
911 dst.x = src0.x \bmod src1.x
912
913 dst.y = src0.y \bmod src1.y
914
915 dst.z = src0.z \bmod src1.z
916
917 dst.w = src0.w \bmod src1.w
918
919
920 .. opcode:: UARL - Integer Address Register Load
921
922 Moves the contents of the source register, assumed to be an integer, into the
923 destination register, which is assumed to be an address (ADDR) register.
924
925
926 .. opcode:: SAD - Sum Of Absolute Differences
927
928 .. math::
929
930 dst.x = |src0.x - src1.x| + src2.x
931
932 dst.y = |src0.y - src1.y| + src2.y
933
934 dst.z = |src0.z - src1.z| + src2.z
935
936 dst.w = |src0.w - src1.w| + src2.w
937
938
939 .. opcode:: TXF - Texel Fetch
940
941 As per NV_gpu_shader4, extract a single texel from a specified texture
942 image or PIPE_BUFFER resource. The source sampler may not be a CUBE or
943 SHADOW. src 0 is a
944 four-component signed integer vector used to identify the single texel
945 accessed. 3 components + level. Just like texture instructions, an optional
946 offset vector is provided, which is subject to various driver restrictions
947 (regarding range, source of offsets). This instruction ignores the sampler
948 state.
949
950 TXF(uint_vec coord, int_vec offset).
951
952
953 .. opcode:: TXF_LZ - Texel Fetch
954
955 This is the same as TXF with level = 0. Like TXF, it obeys
956 pipe_sampler_view::u.tex.first_level.
957
958
959 .. opcode:: TXQ - Texture Size Query
960
961 As per NV_gpu_program4, retrieve the dimensions of the texture depending on
962 the target. For 1D (width), 2D/RECT/CUBE (width, height), 3D (width, height,
963 depth), 1D array (width, layers), 2D array (width, height, layers).
964 Also return the number of accessible levels (last_level - first_level + 1)
965 in W.
966
967 For components which don't return a resource dimension, their value
968 is undefined.
969
970 .. math::
971
972 lod = src0.x
973
974 dst.x = texture\_width(unit, lod)
975
976 dst.y = texture\_height(unit, lod)
977
978 dst.z = texture\_depth(unit, lod)
979
980 dst.w = texture\_levels(unit)
981
982
983 .. opcode:: TXQS - Texture Samples Query
984
985 This retrieves the number of samples in the texture, and stores it
986 into the x component as an unsigned integer. The other components are
987 undefined. If the texture is not multisampled, this function returns
988 (1, undef, undef, undef).
989
990 .. math::
991
992 dst.x = texture\_samples(unit)
993
994
995 .. opcode:: TG4 - Texture Gather
996
997 As per ARB_texture_gather, gathers the four texels to be used in a bi-linear
998 filtering operation and packs them into a single register. Only works with
999 2D, 2D array, cubemaps, and cubemaps arrays. For 2D textures, only the
1000 addressing modes of the sampler and the top level of any mip pyramid are
1001 used. Set W to zero. It behaves like the TEX instruction, but a filtered
1002 sample is not generated. The four samples that contribute to filtering are
1003 placed into xyzw in clockwise order, starting with the (u,v) texture
1004 coordinate delta at the following locations (-, +), (+, +), (+, -), (-, -),
1005 where the magnitude of the deltas are half a texel.
1006
1007 PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
1008 depth compares, single component selection, and a non-constant offset. It
1009 doesn't allow support for the GL independent offset to get i0,j0. This would
1010 require another CAP is hw can do it natively. For now we lower that before
1011 TGSI.
1012
1013 .. math::
1014
1015 coord = src0
1016
1017 component = src1
1018
1019 dst = texture\_gather4 (unit, coord, component)
1020
1021 (with SM5 - cube array shadow)
1022
1023 .. math::
1024
1025 coord = src0
1026
1027 compare = src1
1028
1029 dst = texture\_gather (uint, coord, compare)
1030
1031 .. opcode:: LODQ - level of detail query
1032
1033 Compute the LOD information that the texture pipe would use to access the
1034 texture. The Y component contains the computed LOD lambda_prime. The X
1035 component contains the LOD that will be accessed, based on min/max lod's
1036 and mipmap filters.
1037
1038 .. math::
1039
1040 coord = src0
1041
1042 dst.xy = lodq(uint, coord);
1043
1044 .. opcode:: CLOCK - retrieve the current shader time
1045
1046 Invoking this instruction multiple times in the same shader should
1047 cause monotonically increasing values to be returned. The values
1048 are implicitly 64-bit, so if fewer than 64 bits of precision are
1049 available, to provide expected wraparound semantics, the value
1050 should be shifted up so that the most significant bit of the time
1051 is the most significant bit of the 64-bit value.
1052
1053 .. math::
1054
1055 dst.xy = clock()
1056
1057
1058 Integer ISA
1059 ^^^^^^^^^^^^^^^^^^^^^^^^
1060 These opcodes are used for integer operations.
1061 Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
1062
1063
1064 .. opcode:: I2F - Signed Integer To Float
1065
1066 Rounding is unspecified (round to nearest even suggested).
1067
1068 .. math::
1069
1070 dst.x = (float) src.x
1071
1072 dst.y = (float) src.y
1073
1074 dst.z = (float) src.z
1075
1076 dst.w = (float) src.w
1077
1078
1079 .. opcode:: U2F - Unsigned Integer To Float
1080
1081 Rounding is unspecified (round to nearest even suggested).
1082
1083 .. math::
1084
1085 dst.x = (float) src.x
1086
1087 dst.y = (float) src.y
1088
1089 dst.z = (float) src.z
1090
1091 dst.w = (float) src.w
1092
1093
1094 .. opcode:: F2I - Float to Signed Integer
1095
1096 Rounding is towards zero (truncate).
1097 Values outside signed range (including NaNs) produce undefined results.
1098
1099 .. math::
1100
1101 dst.x = (int) src.x
1102
1103 dst.y = (int) src.y
1104
1105 dst.z = (int) src.z
1106
1107 dst.w = (int) src.w
1108
1109
1110 .. opcode:: F2U - Float to Unsigned Integer
1111
1112 Rounding is towards zero (truncate).
1113 Values outside unsigned range (including NaNs) produce undefined results.
1114
1115 .. math::
1116
1117 dst.x = (unsigned) src.x
1118
1119 dst.y = (unsigned) src.y
1120
1121 dst.z = (unsigned) src.z
1122
1123 dst.w = (unsigned) src.w
1124
1125
1126 .. opcode:: UADD - Integer Add
1127
1128 This instruction works the same for signed and unsigned integers.
1129 The low 32bit of the result is returned.
1130
1131 .. math::
1132
1133 dst.x = src0.x + src1.x
1134
1135 dst.y = src0.y + src1.y
1136
1137 dst.z = src0.z + src1.z
1138
1139 dst.w = src0.w + src1.w
1140
1141
1142 .. opcode:: UMAD - Integer Multiply And Add
1143
1144 This instruction works the same for signed and unsigned integers.
1145 The multiplication returns the low 32bit (as does the result itself).
1146
1147 .. math::
1148
1149 dst.x = src0.x \times src1.x + src2.x
1150
1151 dst.y = src0.y \times src1.y + src2.y
1152
1153 dst.z = src0.z \times src1.z + src2.z
1154
1155 dst.w = src0.w \times src1.w + src2.w
1156
1157
1158 .. opcode:: UMUL - Integer Multiply
1159
1160 This instruction works the same for signed and unsigned integers.
1161 The low 32bit of the result is returned.
1162
1163 .. math::
1164
1165 dst.x = src0.x \times src1.x
1166
1167 dst.y = src0.y \times src1.y
1168
1169 dst.z = src0.z \times src1.z
1170
1171 dst.w = src0.w \times src1.w
1172
1173
1174 .. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1175
1176 The high 32bits of the multiplication of 2 signed integers are returned.
1177
1178 .. math::
1179
1180 dst.x = (src0.x \times src1.x) >> 32
1181
1182 dst.y = (src0.y \times src1.y) >> 32
1183
1184 dst.z = (src0.z \times src1.z) >> 32
1185
1186 dst.w = (src0.w \times src1.w) >> 32
1187
1188
1189 .. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1190
1191 The high 32bits of the multiplication of 2 unsigned integers are returned.
1192
1193 .. math::
1194
1195 dst.x = (src0.x \times src1.x) >> 32
1196
1197 dst.y = (src0.y \times src1.y) >> 32
1198
1199 dst.z = (src0.z \times src1.z) >> 32
1200
1201 dst.w = (src0.w \times src1.w) >> 32
1202
1203
1204 .. opcode:: IDIV - Signed Integer Division
1205
1206 TBD: behavior for division by zero.
1207
1208 .. math::
1209
1210 dst.x = \frac{src0.x}{src1.x}
1211
1212 dst.y = \frac{src0.y}{src1.y}
1213
1214 dst.z = \frac{src0.z}{src1.z}
1215
1216 dst.w = \frac{src0.w}{src1.w}
1217
1218
1219 .. opcode:: UDIV - Unsigned Integer Division
1220
1221 For division by zero, 0xffffffff is returned.
1222
1223 .. math::
1224
1225 dst.x = \frac{src0.x}{src1.x}
1226
1227 dst.y = \frac{src0.y}{src1.y}
1228
1229 dst.z = \frac{src0.z}{src1.z}
1230
1231 dst.w = \frac{src0.w}{src1.w}
1232
1233
1234 .. opcode:: UMOD - Unsigned Integer Remainder
1235
1236 If second arg is zero, 0xffffffff is returned.
1237
1238 .. math::
1239
1240 dst.x = src0.x \bmod src1.x
1241
1242 dst.y = src0.y \bmod src1.y
1243
1244 dst.z = src0.z \bmod src1.z
1245
1246 dst.w = src0.w \bmod src1.w
1247
1248
1249 .. opcode:: NOT - Bitwise Not
1250
1251 .. math::
1252
1253 dst.x = \sim src.x
1254
1255 dst.y = \sim src.y
1256
1257 dst.z = \sim src.z
1258
1259 dst.w = \sim src.w
1260
1261
1262 .. opcode:: AND - Bitwise And
1263
1264 .. math::
1265
1266 dst.x = src0.x \& src1.x
1267
1268 dst.y = src0.y \& src1.y
1269
1270 dst.z = src0.z \& src1.z
1271
1272 dst.w = src0.w \& src1.w
1273
1274
1275 .. opcode:: OR - Bitwise Or
1276
1277 .. math::
1278
1279 dst.x = src0.x | src1.x
1280
1281 dst.y = src0.y | src1.y
1282
1283 dst.z = src0.z | src1.z
1284
1285 dst.w = src0.w | src1.w
1286
1287
1288 .. opcode:: XOR - Bitwise Xor
1289
1290 .. math::
1291
1292 dst.x = src0.x \oplus src1.x
1293
1294 dst.y = src0.y \oplus src1.y
1295
1296 dst.z = src0.z \oplus src1.z
1297
1298 dst.w = src0.w \oplus src1.w
1299
1300
1301 .. opcode:: IMAX - Maximum of Signed Integers
1302
1303 .. math::
1304
1305 dst.x = max(src0.x, src1.x)
1306
1307 dst.y = max(src0.y, src1.y)
1308
1309 dst.z = max(src0.z, src1.z)
1310
1311 dst.w = max(src0.w, src1.w)
1312
1313
1314 .. opcode:: UMAX - Maximum of Unsigned Integers
1315
1316 .. math::
1317
1318 dst.x = max(src0.x, src1.x)
1319
1320 dst.y = max(src0.y, src1.y)
1321
1322 dst.z = max(src0.z, src1.z)
1323
1324 dst.w = max(src0.w, src1.w)
1325
1326
1327 .. opcode:: IMIN - Minimum of Signed Integers
1328
1329 .. math::
1330
1331 dst.x = min(src0.x, src1.x)
1332
1333 dst.y = min(src0.y, src1.y)
1334
1335 dst.z = min(src0.z, src1.z)
1336
1337 dst.w = min(src0.w, src1.w)
1338
1339
1340 .. opcode:: UMIN - Minimum of Unsigned Integers
1341
1342 .. math::
1343
1344 dst.x = min(src0.x, src1.x)
1345
1346 dst.y = min(src0.y, src1.y)
1347
1348 dst.z = min(src0.z, src1.z)
1349
1350 dst.w = min(src0.w, src1.w)
1351
1352
1353 .. opcode:: SHL - Shift Left
1354
1355 The shift count is masked with 0x1f before the shift is applied.
1356
1357 .. math::
1358
1359 dst.x = src0.x << (0x1f \& src1.x)
1360
1361 dst.y = src0.y << (0x1f \& src1.y)
1362
1363 dst.z = src0.z << (0x1f \& src1.z)
1364
1365 dst.w = src0.w << (0x1f \& src1.w)
1366
1367
1368 .. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1369
1370 The shift count is masked with 0x1f before the shift is applied.
1371
1372 .. math::
1373
1374 dst.x = src0.x >> (0x1f \& src1.x)
1375
1376 dst.y = src0.y >> (0x1f \& src1.y)
1377
1378 dst.z = src0.z >> (0x1f \& src1.z)
1379
1380 dst.w = src0.w >> (0x1f \& src1.w)
1381
1382
1383 .. opcode:: USHR - Logical Shift Right
1384
1385 The shift count is masked with 0x1f before the shift is applied.
1386
1387 .. math::
1388
1389 dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1390
1391 dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1392
1393 dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1394
1395 dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
1396
1397
1398 .. opcode:: UCMP - Integer Conditional Move
1399
1400 .. math::
1401
1402 dst.x = src0.x ? src1.x : src2.x
1403
1404 dst.y = src0.y ? src1.y : src2.y
1405
1406 dst.z = src0.z ? src1.z : src2.z
1407
1408 dst.w = src0.w ? src1.w : src2.w
1409
1410
1411
1412 .. opcode:: ISSG - Integer Set Sign
1413
1414 .. math::
1415
1416 dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1417
1418 dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1419
1420 dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1421
1422 dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1423
1424
1425
1426 .. opcode:: FSLT - Float Set On Less Than (ordered)
1427
1428 Same comparison as SLT but returns integer instead of 1.0/0.0 float
1429
1430 .. math::
1431
1432 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1433
1434 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1435
1436 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1437
1438 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1439
1440
1441 .. opcode:: ISLT - Signed Integer Set On Less Than
1442
1443 .. math::
1444
1445 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1446
1447 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1448
1449 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1450
1451 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1452
1453
1454 .. opcode:: USLT - Unsigned Integer Set On Less Than
1455
1456 .. math::
1457
1458 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1459
1460 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1461
1462 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1463
1464 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1465
1466
1467 .. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1468
1469 Same comparison as SGE but returns integer instead of 1.0/0.0 float
1470
1471 .. math::
1472
1473 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1474
1475 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1476
1477 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1478
1479 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1480
1481
1482 .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1483
1484 .. math::
1485
1486 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1487
1488 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1489
1490 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1491
1492 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1493
1494
1495 .. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1496
1497 .. math::
1498
1499 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1500
1501 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1502
1503 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1504
1505 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1506
1507
1508 .. opcode:: FSEQ - Float Set On Equal (ordered)
1509
1510 Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1511
1512 .. math::
1513
1514 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1515
1516 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1517
1518 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1519
1520 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1521
1522
1523 .. opcode:: USEQ - Integer Set On Equal
1524
1525 .. math::
1526
1527 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1528
1529 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1530
1531 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1532
1533 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1534
1535
1536 .. opcode:: FSNE - Float Set On Not Equal (unordered)
1537
1538 Same comparison as SNE but returns integer instead of 1.0/0.0 float
1539
1540 .. math::
1541
1542 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1543
1544 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1545
1546 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1547
1548 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1549
1550
1551 .. opcode:: USNE - Integer Set On Not Equal
1552
1553 .. math::
1554
1555 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1556
1557 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1558
1559 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1560
1561 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1562
1563
1564 .. opcode:: INEG - Integer Negate
1565
1566 Two's complement.
1567
1568 .. math::
1569
1570 dst.x = -src.x
1571
1572 dst.y = -src.y
1573
1574 dst.z = -src.z
1575
1576 dst.w = -src.w
1577
1578
1579 .. opcode:: IABS - Integer Absolute Value
1580
1581 .. math::
1582
1583 dst.x = |src.x|
1584
1585 dst.y = |src.y|
1586
1587 dst.z = |src.z|
1588
1589 dst.w = |src.w|
1590
1591 Bitwise ISA
1592 ^^^^^^^^^^^
1593 These opcodes are used for bit-level manipulation of integers.
1594
1595 .. opcode:: IBFE - Signed Bitfield Extract
1596
1597 Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
1598 sign-extends them if the high bit of the extracted window is set.
1599
1600 Pseudocode::
1601
1602 def ibfe(value, offset, bits):
1603 if offset < 0 or bits < 0 or offset + bits > 32:
1604 return undefined
1605 if bits == 0: return 0
1606 # Note: >> sign-extends
1607 return (value << (32 - offset - bits)) >> (32 - bits)
1608
1609 .. opcode:: UBFE - Unsigned Bitfield Extract
1610
1611 Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
1612 any sign-extension.
1613
1614 Pseudocode::
1615
1616 def ubfe(value, offset, bits):
1617 if offset < 0 or bits < 0 or offset + bits > 32:
1618 return undefined
1619 if bits == 0: return 0
1620 # Note: >> does not sign-extend
1621 return (value << (32 - offset - bits)) >> (32 - bits)
1622
1623 .. opcode:: BFI - Bitfield Insert
1624
1625 Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
1626 of 'insert'.
1627
1628 Pseudocode::
1629
1630 def bfi(base, insert, offset, bits):
1631 if offset < 0 or bits < 0 or offset + bits > 32:
1632 return undefined
1633 # << defined such that mask == ~0 when bits == 32, offset == 0
1634 mask = ((1 << bits) - 1) << offset
1635 return ((insert << offset) & mask) | (base & ~mask)
1636
1637 .. opcode:: BREV - Bitfield Reverse
1638
1639 See SM5 instruction BFREV. Reverses the bits of the argument.
1640
1641 .. opcode:: POPC - Population Count
1642
1643 See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1644
1645 .. opcode:: LSB - Index of lowest set bit
1646
1647 See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1648 bit of the argument. Returns -1 if none are set.
1649
1650 .. opcode:: IMSB - Index of highest non-sign bit
1651
1652 See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1653 non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1654 highest 1 bit for positive numbers). Returns -1 if all bits are the same
1655 (i.e. for inputs 0 and -1).
1656
1657 .. opcode:: UMSB - Index of highest set bit
1658
1659 See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1660 set bit of the argument. Returns -1 if none are set.
1661
1662 Geometry ISA
1663 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1664
1665 These opcodes are only supported in geometry shaders; they have no meaning
1666 in any other type of shader.
1667
1668 .. opcode:: EMIT - Emit
1669
1670 Generate a new vertex for the current primitive into the specified vertex
1671 stream using the values in the output registers.
1672
1673
1674 .. opcode:: ENDPRIM - End Primitive
1675
1676 Complete the current primitive in the specified vertex stream (consisting of
1677 the emitted vertices), and start a new one.
1678
1679
1680 GLSL ISA
1681 ^^^^^^^^^^
1682
1683 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1684 opcodes is determined by a special capability bit, ``GLSL``.
1685 Some require glsl version 1.30 (UIF/BREAKC/SWITCH/CASE/DEFAULT/ENDSWITCH).
1686
1687 .. opcode:: CAL - Subroutine Call
1688
1689 push(pc)
1690 pc = target
1691
1692
1693 .. opcode:: RET - Subroutine Call Return
1694
1695 pc = pop()
1696
1697
1698 .. opcode:: CONT - Continue
1699
1700 Unconditionally moves the point of execution to the instruction after the
1701 last bgnloop. The instruction must appear within a bgnloop/endloop.
1702
1703 .. note::
1704
1705 Support for CONT is determined by a special capability bit,
1706 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1707
1708
1709 .. opcode:: BGNLOOP - Begin a Loop
1710
1711 Start a loop. Must have a matching endloop.
1712
1713
1714 .. opcode:: BGNSUB - Begin Subroutine
1715
1716 Starts definition of a subroutine. Must have a matching endsub.
1717
1718
1719 .. opcode:: ENDLOOP - End a Loop
1720
1721 End a loop started with bgnloop.
1722
1723
1724 .. opcode:: ENDSUB - End Subroutine
1725
1726 Ends definition of a subroutine.
1727
1728
1729 .. opcode:: NOP - No Operation
1730
1731 Do nothing.
1732
1733
1734 .. opcode:: BRK - Break
1735
1736 Unconditionally moves the point of execution to the instruction after the
1737 next endloop or endswitch. The instruction must appear within a loop/endloop
1738 or switch/endswitch.
1739
1740
1741 .. opcode:: BREAKC - Break Conditional
1742
1743 Conditionally moves the point of execution to the instruction after the
1744 next endloop or endswitch. The instruction must appear within a loop/endloop
1745 or switch/endswitch.
1746 Condition evaluates to true if src0.x != 0 where src0.x is interpreted
1747 as an integer register.
1748
1749 .. note::
1750
1751 Considered for removal as it's quite inconsistent wrt other opcodes
1752 (could emulate with UIF/BRK/ENDIF).
1753
1754
1755 .. opcode:: IF - Float If
1756
1757 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
1758
1759 src0.x != 0.0
1760
1761 where src0.x is interpreted as a floating point register.
1762
1763
1764 .. opcode:: UIF - Bitwise If
1765
1766 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1767
1768 src0.x != 0
1769
1770 where src0.x is interpreted as an integer register.
1771
1772
1773 .. opcode:: ELSE - Else
1774
1775 Starts an else block, after an IF or UIF statement.
1776
1777
1778 .. opcode:: ENDIF - End If
1779
1780 Ends an IF or UIF block.
1781
1782
1783 .. opcode:: SWITCH - Switch
1784
1785 Starts a C-style switch expression. The switch consists of one or multiple
1786 CASE statements, and at most one DEFAULT statement. Execution of a statement
1787 ends when a BRK is hit, but just like in C falling through to other cases
1788 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
1789 just as last statement, and fallthrough is allowed into/from it.
1790 CASE src arguments are evaluated at bit level against the SWITCH src argument.
1791
1792 Example::
1793
1794 SWITCH src[0].x
1795 CASE src[0].x
1796 (some instructions here)
1797 (optional BRK here)
1798 DEFAULT
1799 (some instructions here)
1800 (optional BRK here)
1801 CASE src[0].x
1802 (some instructions here)
1803 (optional BRK here)
1804 ENDSWITCH
1805
1806
1807 .. opcode:: CASE - Switch case
1808
1809 This represents a switch case label. The src arg must be an integer immediate.
1810
1811
1812 .. opcode:: DEFAULT - Switch default
1813
1814 This represents the default case in the switch, which is taken if no other
1815 case matches.
1816
1817
1818 .. opcode:: ENDSWITCH - End of switch
1819
1820 Ends a switch expression.
1821
1822
1823 Interpolation ISA
1824 ^^^^^^^^^^^^^^^^^
1825
1826 The interpolation instructions allow an input to be interpolated in a
1827 different way than its declaration. This corresponds to the GLSL 4.00
1828 interpolateAt* functions. The first argument of each of these must come from
1829 ``TGSI_FILE_INPUT``.
1830
1831 .. opcode:: INTERP_CENTROID - Interpolate at the centroid
1832
1833 Interpolates the varying specified by src0 at the centroid
1834
1835 .. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
1836
1837 Interpolates the varying specified by src0 at the sample id specified by
1838 src1.x (interpreted as an integer)
1839
1840 .. opcode:: INTERP_OFFSET - Interpolate at the specified offset
1841
1842 Interpolates the varying specified by src0 at the offset src1.xy from the
1843 pixel center (interpreted as floats)
1844
1845
1846 .. _doubleopcodes:
1847
1848 Double ISA
1849 ^^^^^^^^^^^^^^^
1850
1851 The double-precision opcodes reinterpret four-component vectors into
1852 two-component vectors with doubled precision in each component.
1853
1854 .. opcode:: DABS - Absolute
1855
1856 .. math::
1857
1858 dst.xy = |src0.xy|
1859
1860 dst.zw = |src0.zw|
1861
1862 .. opcode:: DADD - Add
1863
1864 .. math::
1865
1866 dst.xy = src0.xy + src1.xy
1867
1868 dst.zw = src0.zw + src1.zw
1869
1870 .. opcode:: DSEQ - Set on Equal
1871
1872 .. math::
1873
1874 dst.x = src0.xy == src1.xy ? \sim 0 : 0
1875
1876 dst.z = src0.zw == src1.zw ? \sim 0 : 0
1877
1878 .. opcode:: DSNE - Set on Equal
1879
1880 .. math::
1881
1882 dst.x = src0.xy != src1.xy ? \sim 0 : 0
1883
1884 dst.z = src0.zw != src1.zw ? \sim 0 : 0
1885
1886 .. opcode:: DSLT - Set on Less than
1887
1888 .. math::
1889
1890 dst.x = src0.xy < src1.xy ? \sim 0 : 0
1891
1892 dst.z = src0.zw < src1.zw ? \sim 0 : 0
1893
1894 .. opcode:: DSGE - Set on Greater equal
1895
1896 .. math::
1897
1898 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
1899
1900 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
1901
1902 .. opcode:: DFRAC - Fraction
1903
1904 .. math::
1905
1906 dst.xy = src.xy - \lfloor src.xy\rfloor
1907
1908 dst.zw = src.zw - \lfloor src.zw\rfloor
1909
1910 .. opcode:: DTRUNC - Truncate
1911
1912 .. math::
1913
1914 dst.xy = trunc(src.xy)
1915
1916 dst.zw = trunc(src.zw)
1917
1918 .. opcode:: DCEIL - Ceiling
1919
1920 .. math::
1921
1922 dst.xy = \lceil src.xy\rceil
1923
1924 dst.zw = \lceil src.zw\rceil
1925
1926 .. opcode:: DFLR - Floor
1927
1928 .. math::
1929
1930 dst.xy = \lfloor src.xy\rfloor
1931
1932 dst.zw = \lfloor src.zw\rfloor
1933
1934 .. opcode:: DROUND - Fraction
1935
1936 .. math::
1937
1938 dst.xy = round(src.xy)
1939
1940 dst.zw = round(src.zw)
1941
1942 .. opcode:: DSSG - Set Sign
1943
1944 .. math::
1945
1946 dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
1947
1948 dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
1949
1950 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1951
1952 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1953 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1954 :math:`dst1 \times 2^{dst0} = src` .
1955
1956 .. math::
1957
1958 dst0.xy = exp(src.xy)
1959
1960 dst1.xy = frac(src.xy)
1961
1962 dst0.zw = exp(src.zw)
1963
1964 dst1.zw = frac(src.zw)
1965
1966 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1967
1968 This opcode is the inverse of :opcode:`DFRACEXP`. The second
1969 source is an integer.
1970
1971 .. math::
1972
1973 dst.xy = src0.xy \times 2^{src1.x}
1974
1975 dst.zw = src0.zw \times 2^{src1.y}
1976
1977 .. opcode:: DMIN - Minimum
1978
1979 .. math::
1980
1981 dst.xy = min(src0.xy, src1.xy)
1982
1983 dst.zw = min(src0.zw, src1.zw)
1984
1985 .. opcode:: DMAX - Maximum
1986
1987 .. math::
1988
1989 dst.xy = max(src0.xy, src1.xy)
1990
1991 dst.zw = max(src0.zw, src1.zw)
1992
1993 .. opcode:: DMUL - Multiply
1994
1995 .. math::
1996
1997 dst.xy = src0.xy \times src1.xy
1998
1999 dst.zw = src0.zw \times src1.zw
2000
2001
2002 .. opcode:: DMAD - Multiply And Add
2003
2004 .. math::
2005
2006 dst.xy = src0.xy \times src1.xy + src2.xy
2007
2008 dst.zw = src0.zw \times src1.zw + src2.zw
2009
2010
2011 .. opcode:: DFMA - Fused Multiply-Add
2012
2013 Perform a * b + c with no intermediate rounding step.
2014
2015 .. math::
2016
2017 dst.xy = src0.xy \times src1.xy + src2.xy
2018
2019 dst.zw = src0.zw \times src1.zw + src2.zw
2020
2021
2022 .. opcode:: DDIV - Divide
2023
2024 .. math::
2025
2026 dst.xy = \frac{src0.xy}{src1.xy}
2027
2028 dst.zw = \frac{src0.zw}{src1.zw}
2029
2030
2031 .. opcode:: DRCP - Reciprocal
2032
2033 .. math::
2034
2035 dst.xy = \frac{1}{src.xy}
2036
2037 dst.zw = \frac{1}{src.zw}
2038
2039 .. opcode:: DSQRT - Square Root
2040
2041 .. math::
2042
2043 dst.xy = \sqrt{src.xy}
2044
2045 dst.zw = \sqrt{src.zw}
2046
2047 .. opcode:: DRSQ - Reciprocal Square Root
2048
2049 .. math::
2050
2051 dst.xy = \frac{1}{\sqrt{src.xy}}
2052
2053 dst.zw = \frac{1}{\sqrt{src.zw}}
2054
2055 .. opcode:: F2D - Float to Double
2056
2057 .. math::
2058
2059 dst.xy = double(src0.x)
2060
2061 dst.zw = double(src0.y)
2062
2063 .. opcode:: D2F - Double to Float
2064
2065 .. math::
2066
2067 dst.x = float(src0.xy)
2068
2069 dst.y = float(src0.zw)
2070
2071 .. opcode:: I2D - Int to Double
2072
2073 .. math::
2074
2075 dst.xy = double(src0.x)
2076
2077 dst.zw = double(src0.y)
2078
2079 .. opcode:: D2I - Double to Int
2080
2081 .. math::
2082
2083 dst.x = int(src0.xy)
2084
2085 dst.y = int(src0.zw)
2086
2087 .. opcode:: U2D - Unsigned Int to Double
2088
2089 .. math::
2090
2091 dst.xy = double(src0.x)
2092
2093 dst.zw = double(src0.y)
2094
2095 .. opcode:: D2U - Double to Unsigned Int
2096
2097 .. math::
2098
2099 dst.x = unsigned(src0.xy)
2100
2101 dst.y = unsigned(src0.zw)
2102
2103 64-bit Integer ISA
2104 ^^^^^^^^^^^^^^^^^^
2105
2106 The 64-bit integer opcodes reinterpret four-component vectors into
2107 two-component vectors with 64-bits in each component.
2108
2109 .. opcode:: I64ABS - 64-bit Integer Absolute Value
2110
2111 .. math::
2112
2113 dst.xy = |src0.xy|
2114
2115 dst.zw = |src0.zw|
2116
2117 .. opcode:: I64NEG - 64-bit Integer Negate
2118
2119 Two's complement.
2120
2121 .. math::
2122
2123 dst.xy = -src.xy
2124
2125 dst.zw = -src.zw
2126
2127 .. opcode:: I64SSG - 64-bit Integer Set Sign
2128
2129 .. math::
2130
2131 dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
2132
2133 dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
2134
2135 .. opcode:: U64ADD - 64-bit Integer Add
2136
2137 .. math::
2138
2139 dst.xy = src0.xy + src1.xy
2140
2141 dst.zw = src0.zw + src1.zw
2142
2143 .. opcode:: U64MUL - 64-bit Integer Multiply
2144
2145 .. math::
2146
2147 dst.xy = src0.xy * src1.xy
2148
2149 dst.zw = src0.zw * src1.zw
2150
2151 .. opcode:: U64SEQ - 64-bit Integer Set on Equal
2152
2153 .. math::
2154
2155 dst.x = src0.xy == src1.xy ? \sim 0 : 0
2156
2157 dst.z = src0.zw == src1.zw ? \sim 0 : 0
2158
2159 .. opcode:: U64SNE - 64-bit Integer Set on Not Equal
2160
2161 .. math::
2162
2163 dst.x = src0.xy != src1.xy ? \sim 0 : 0
2164
2165 dst.z = src0.zw != src1.zw ? \sim 0 : 0
2166
2167 .. opcode:: U64SLT - 64-bit Unsigned Integer Set on Less Than
2168
2169 .. math::
2170
2171 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2172
2173 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2174
2175 .. opcode:: U64SGE - 64-bit Unsigned Integer Set on Greater Equal
2176
2177 .. math::
2178
2179 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2180
2181 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2182
2183 .. opcode:: I64SLT - 64-bit Signed Integer Set on Less Than
2184
2185 .. math::
2186
2187 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2188
2189 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2190
2191 .. opcode:: I64SGE - 64-bit Signed Integer Set on Greater Equal
2192
2193 .. math::
2194
2195 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2196
2197 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2198
2199 .. opcode:: I64MIN - Minimum of 64-bit Signed Integers
2200
2201 .. math::
2202
2203 dst.xy = min(src0.xy, src1.xy)
2204
2205 dst.zw = min(src0.zw, src1.zw)
2206
2207 .. opcode:: U64MIN - Minimum of 64-bit Unsigned Integers
2208
2209 .. math::
2210
2211 dst.xy = min(src0.xy, src1.xy)
2212
2213 dst.zw = min(src0.zw, src1.zw)
2214
2215 .. opcode:: I64MAX - Maximum of 64-bit Signed Integers
2216
2217 .. math::
2218
2219 dst.xy = max(src0.xy, src1.xy)
2220
2221 dst.zw = max(src0.zw, src1.zw)
2222
2223 .. opcode:: U64MAX - Maximum of 64-bit Unsigned Integers
2224
2225 .. math::
2226
2227 dst.xy = max(src0.xy, src1.xy)
2228
2229 dst.zw = max(src0.zw, src1.zw)
2230
2231 .. opcode:: U64SHL - Shift Left 64-bit Unsigned Integer
2232
2233 The shift count is masked with 0x3f before the shift is applied.
2234
2235 .. math::
2236
2237 dst.xy = src0.xy << (0x3f \& src1.x)
2238
2239 dst.zw = src0.zw << (0x3f \& src1.y)
2240
2241 .. opcode:: I64SHR - Arithmetic Shift Right (of 64-bit Signed Integer)
2242
2243 The shift count is masked with 0x3f before the shift is applied.
2244
2245 .. math::
2246
2247 dst.xy = src0.xy >> (0x3f \& src1.x)
2248
2249 dst.zw = src0.zw >> (0x3f \& src1.y)
2250
2251 .. opcode:: U64SHR - Logical Shift Right (of 64-bit Unsigned Integer)
2252
2253 The shift count is masked with 0x3f before the shift is applied.
2254
2255 .. math::
2256
2257 dst.xy = src0.xy >> (unsigned) (0x3f \& src1.x)
2258
2259 dst.zw = src0.zw >> (unsigned) (0x3f \& src1.y)
2260
2261 .. opcode:: I64DIV - 64-bit Signed Integer Division
2262
2263 .. math::
2264
2265 dst.xy = \frac{src0.xy}{src1.xy}
2266
2267 dst.zw = \frac{src0.zw}{src1.zw}
2268
2269 .. opcode:: U64DIV - 64-bit Unsigned Integer Division
2270
2271 .. math::
2272
2273 dst.xy = \frac{src0.xy}{src1.xy}
2274
2275 dst.zw = \frac{src0.zw}{src1.zw}
2276
2277 .. opcode:: U64MOD - 64-bit Unsigned Integer Remainder
2278
2279 .. math::
2280
2281 dst.xy = src0.xy \bmod src1.xy
2282
2283 dst.zw = src0.zw \bmod src1.zw
2284
2285 .. opcode:: I64MOD - 64-bit Signed Integer Remainder
2286
2287 .. math::
2288
2289 dst.xy = src0.xy \bmod src1.xy
2290
2291 dst.zw = src0.zw \bmod src1.zw
2292
2293 .. opcode:: F2U64 - Float to 64-bit Unsigned Int
2294
2295 .. math::
2296
2297 dst.xy = (uint64_t) src0.x
2298
2299 dst.zw = (uint64_t) src0.y
2300
2301 .. opcode:: F2I64 - Float to 64-bit Int
2302
2303 .. math::
2304
2305 dst.xy = (int64_t) src0.x
2306
2307 dst.zw = (int64_t) src0.y
2308
2309 .. opcode:: U2I64 - Unsigned Integer to 64-bit Integer
2310
2311 This is a zero extension.
2312
2313 .. math::
2314
2315 dst.xy = (uint64_t) src0.x
2316
2317 dst.zw = (uint64_t) src0.y
2318
2319 .. opcode:: I2I64 - Signed Integer to 64-bit Integer
2320
2321 This is a sign extension.
2322
2323 .. math::
2324
2325 dst.xy = (int64_t) src0.x
2326
2327 dst.zw = (int64_t) src0.y
2328
2329 .. opcode:: D2U64 - Double to 64-bit Unsigned Int
2330
2331 .. math::
2332
2333 dst.xy = (uint64_t) src0.xy
2334
2335 dst.zw = (uint64_t) src0.zw
2336
2337 .. opcode:: D2I64 - Double to 64-bit Int
2338
2339 .. math::
2340
2341 dst.xy = (int64_t) src0.xy
2342
2343 dst.zw = (int64_t) src0.zw
2344
2345 .. opcode:: U642F - 64-bit unsigned integer to float
2346
2347 .. math::
2348
2349 dst.x = (float) src0.xy
2350
2351 dst.y = (float) src0.zw
2352
2353 .. opcode:: I642F - 64-bit Int to Float
2354
2355 .. math::
2356
2357 dst.x = (float) src0.xy
2358
2359 dst.y = (float) src0.zw
2360
2361 .. opcode:: U642D - 64-bit unsigned integer to double
2362
2363 .. math::
2364
2365 dst.xy = (double) src0.xy
2366
2367 dst.zw = (double) src0.zw
2368
2369 .. opcode:: I642D - 64-bit Int to double
2370
2371 .. math::
2372
2373 dst.xy = (double) src0.xy
2374
2375 dst.zw = (double) src0.zw
2376
2377 .. _samplingopcodes:
2378
2379 Resource Sampling Opcodes
2380 ^^^^^^^^^^^^^^^^^^^^^^^^^
2381
2382 Those opcodes follow very closely semantics of the respective Direct3D
2383 instructions. If in doubt double check Direct3D documentation.
2384 Note that the swizzle on SVIEW (src1) determines texel swizzling
2385 after lookup.
2386
2387 .. opcode:: SAMPLE
2388
2389 Using provided address, sample data from the specified texture using the
2390 filtering mode identified by the given sampler. The source data may come from
2391 any resource type other than buffers.
2392
2393 Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2394
2395 Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2396
2397 .. opcode:: SAMPLE_I
2398
2399 Simplified alternative to the SAMPLE instruction. Using the provided
2400 integer address, SAMPLE_I fetches data from the specified sampler view
2401 without any filtering. The source data may come from any resource type
2402 other than CUBE.
2403
2404 Syntax: ``SAMPLE_I dst, address, sampler_view``
2405
2406 Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2407
2408 The 'address' is specified as unsigned integers. If the 'address' is out of
2409 range [0...(# texels - 1)] the result of the fetch is always 0 in all
2410 components. As such the instruction doesn't honor address wrap modes, in
2411 cases where that behavior is desirable 'SAMPLE' instruction should be used.
2412 address.w always provides an unsigned integer mipmap level. If the value is
2413 out of the range then the instruction always returns 0 in all components.
2414 address.yz are ignored for buffers and 1d textures. address.z is ignored
2415 for 1d texture arrays and 2d textures.
2416
2417 For 1D texture arrays address.y provides the array index (also as unsigned
2418 integer). If the value is out of the range of available array indices
2419 [0... (array size - 1)] then the opcode always returns 0 in all components.
2420 For 2D texture arrays address.z provides the array index, otherwise it
2421 exhibits the same behavior as in the case for 1D texture arrays. The exact
2422 semantics of the source address are presented in the table below:
2423
2424 +---------------------------+----+-----+-----+---------+
2425 | resource type | X | Y | Z | W |
2426 +===========================+====+=====+=====+=========+
2427 | ``PIPE_BUFFER`` | x | | | ignored |
2428 +---------------------------+----+-----+-----+---------+
2429 | ``PIPE_TEXTURE_1D`` | x | | | mpl |
2430 +---------------------------+----+-----+-----+---------+
2431 | ``PIPE_TEXTURE_2D`` | x | y | | mpl |
2432 +---------------------------+----+-----+-----+---------+
2433 | ``PIPE_TEXTURE_3D`` | x | y | z | mpl |
2434 +---------------------------+----+-----+-----+---------+
2435 | ``PIPE_TEXTURE_RECT`` | x | y | | mpl |
2436 +---------------------------+----+-----+-----+---------+
2437 | ``PIPE_TEXTURE_CUBE`` | not allowed as source |
2438 +---------------------------+----+-----+-----+---------+
2439 | ``PIPE_TEXTURE_1D_ARRAY`` | x | idx | | mpl |
2440 +---------------------------+----+-----+-----+---------+
2441 | ``PIPE_TEXTURE_2D_ARRAY`` | x | y | idx | mpl |
2442 +---------------------------+----+-----+-----+---------+
2443
2444 Where 'mpl' is a mipmap level and 'idx' is the array index.
2445
2446 .. opcode:: SAMPLE_I_MS
2447
2448 Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2449
2450 Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2451
2452 .. opcode:: SAMPLE_B
2453
2454 Just like the SAMPLE instruction with the exception that an additional bias
2455 is applied to the level of detail computed as part of the instruction
2456 execution.
2457
2458 Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2459
2460 Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2461
2462 .. opcode:: SAMPLE_C
2463
2464 Similar to the SAMPLE instruction but it performs a comparison filter. The
2465 operands to SAMPLE_C are identical to SAMPLE, except that there is an
2466 additional float32 operand, reference value, which must be a register with
2467 single-component, or a scalar literal. SAMPLE_C makes the hardware use the
2468 current samplers compare_func (in pipe_sampler_state) to compare reference
2469 value against the red component value for the surce resource at each texel
2470 that the currently configured texture filter covers based on the provided
2471 coordinates.
2472
2473 Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2474
2475 Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2476
2477 .. opcode:: SAMPLE_C_LZ
2478
2479 Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2480 for level-zero.
2481
2482 Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2483
2484 Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2485
2486
2487 .. opcode:: SAMPLE_D
2488
2489 SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2490 the source address in the x direction and the y direction are provided by
2491 extra parameters.
2492
2493 Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2494
2495 Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2496
2497 .. opcode:: SAMPLE_L
2498
2499 SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2500 directly as a scalar value, representing no anisotropy.
2501
2502 Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2503
2504 Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2505
2506 .. opcode:: GATHER4
2507
2508 Gathers the four texels to be used in a bi-linear filtering operation and
2509 packs them into a single register. Only works with 2D, 2D array, cubemaps,
2510 and cubemaps arrays. For 2D textures, only the addressing modes of the
2511 sampler and the top level of any mip pyramid are used. Set W to zero. It
2512 behaves like the SAMPLE instruction, but a filtered sample is not
2513 generated. The four samples that contribute to filtering are placed into
2514 xyzw in counter-clockwise order, starting with the (u,v) texture coordinate
2515 delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2516 magnitude of the deltas are half a texel.
2517
2518
2519 .. opcode:: SVIEWINFO
2520
2521 Query the dimensions of a given sampler view. dst receives width, height,
2522 depth or array size and number of mipmap levels as int4. The dst can have a
2523 writemask which will specify what info is the caller interested in.
2524
2525 Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2526
2527 Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2528
2529 src_mip_level is an unsigned integer scalar. If it's out of range then
2530 returns 0 for width, height and depth/array size but the total number of
2531 mipmap is still returned correctly for the given sampler view. The returned
2532 width, height and depth values are for the mipmap level selected by the
2533 src_mip_level and are in the number of texels. For 1d texture array width
2534 is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2535 still in dst.w. In contrast to d3d10 resinfo, there's no way in the tgsi
2536 instruction encoding to specify the return type (float/rcpfloat/uint), hence
2537 always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2538 resinfo allowing swizzling dst values is ignored (due to the interaction
2539 with rcpfloat modifier which requires some swizzle handling in the state
2540 tracker anyway).
2541
2542 .. opcode:: SAMPLE_POS
2543
2544 Query the position of a sample in the given resource or render target
2545 when per-sample fragment shading is in effect.
2546
2547 Syntax: ``SAMPLE_POS dst, source, sample_index``
2548
2549 dst receives float4 (x, y, undef, undef) indicated where the sample is
2550 located. Sample locations are in the range [0, 1] where 0.5 is the center
2551 of the fragment.
2552
2553 source is either a sampler view (to indicate a shader resource) or temp
2554 register (to indicate the render target). The source register may have
2555 an optional swizzle to apply to the returned result
2556
2557 sample_index is an integer scalar indicating which sample position is to
2558 be queried.
2559
2560 If per-sample shading is not in effect or the source resource or render
2561 target is not multisampled, the result is (0.5, 0.5, undef, undef).
2562
2563 NOTE: no driver has implemented this opcode yet (and no state tracker
2564 emits it). This information is subject to change.
2565
2566 .. opcode:: SAMPLE_INFO
2567
2568 Query the number of samples in a multisampled resource or render target.
2569
2570 Syntax: ``SAMPLE_INFO dst, source``
2571
2572 dst receives int4 (n, 0, 0, 0) where n is the number of samples in a
2573 resource or the render target.
2574
2575 source is either a sampler view (to indicate a shader resource) or temp
2576 register (to indicate the render target). The source register may have
2577 an optional swizzle to apply to the returned result
2578
2579 If per-sample shading is not in effect or the source resource or render
2580 target is not multisampled, the result is (1, 0, 0, 0).
2581
2582 NOTE: no driver has implemented this opcode yet (and no state tracker
2583 emits it). This information is subject to change.
2584
2585 .. _resourceopcodes:
2586
2587 Resource Access Opcodes
2588 ^^^^^^^^^^^^^^^^^^^^^^^
2589
2590 For these opcodes, the resource can be a BUFFER, IMAGE, or MEMORY.
2591
2592 .. opcode:: LOAD - Fetch data from a shader buffer or image
2593
2594 Syntax: ``LOAD dst, resource, address``
2595
2596 Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
2597
2598 Using the provided integer address, LOAD fetches data
2599 from the specified buffer or texture without any
2600 filtering.
2601
2602 The 'address' is specified as a vector of unsigned
2603 integers. If the 'address' is out of range the result
2604 is unspecified.
2605
2606 Only the first mipmap level of a resource can be read
2607 from using this instruction.
2608
2609 For 1D or 2D texture arrays, the array index is
2610 provided as an unsigned integer in address.y or
2611 address.z, respectively. address.yz are ignored for
2612 buffers and 1D textures. address.z is ignored for 1D
2613 texture arrays and 2D textures. address.w is always
2614 ignored.
2615
2616 A swizzle suffix may be added to the resource argument
2617 this will cause the resource data to be swizzled accordingly.
2618
2619 .. opcode:: STORE - Write data to a shader resource
2620
2621 Syntax: ``STORE resource, address, src``
2622
2623 Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
2624
2625 Using the provided integer address, STORE writes data
2626 to the specified buffer or texture.
2627
2628 The 'address' is specified as a vector of unsigned
2629 integers. If the 'address' is out of range the result
2630 is unspecified.
2631
2632 Only the first mipmap level of a resource can be
2633 written to using this instruction.
2634
2635 For 1D or 2D texture arrays, the array index is
2636 provided as an unsigned integer in address.y or
2637 address.z, respectively. address.yz are ignored for
2638 buffers and 1D textures. address.z is ignored for 1D
2639 texture arrays and 2D textures. address.w is always
2640 ignored.
2641
2642 .. opcode:: RESQ - Query information about a resource
2643
2644 Syntax: ``RESQ dst, resource``
2645
2646 Example: ``RESQ TEMP[0], BUFFER[0]``
2647
2648 Returns information about the buffer or image resource. For buffer
2649 resources, the size (in bytes) is returned in the x component. For
2650 image resources, .xyz will contain the width/height/layers of the
2651 image, while .w will contain the number of samples for multi-sampled
2652 images.
2653
2654 .. opcode:: FBFETCH - Load data from framebuffer
2655
2656 Syntax: ``FBFETCH dst, output``
2657
2658 Example: ``FBFETCH TEMP[0], OUT[0]``
2659
2660 This is only valid on ``COLOR`` semantic outputs. Returns the color
2661 of the current position in the framebuffer from before this fragment
2662 shader invocation. May return the same value from multiple calls for
2663 a particular output within a single invocation. Note that result may
2664 be undefined if a fragment is drawn multiple times without a blend
2665 barrier in between.
2666
2667
2668 .. _threadsyncopcodes:
2669
2670 Inter-thread synchronization opcodes
2671 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2672
2673 These opcodes are intended for communication between threads running
2674 within the same compute grid. For now they're only valid in compute
2675 programs.
2676
2677 .. opcode:: MFENCE - Memory fence
2678
2679 Syntax: ``MFENCE resource``
2680
2681 Example: ``MFENCE RES[0]``
2682
2683 This opcode forces strong ordering between any memory access
2684 operations that affect the specified resource. This means that
2685 previous loads and stores (and only those) will be performed and
2686 visible to other threads before the program execution continues.
2687
2688
2689 .. opcode:: LFENCE - Load memory fence
2690
2691 Syntax: ``LFENCE resource``
2692
2693 Example: ``LFENCE RES[0]``
2694
2695 Similar to MFENCE, but it only affects the ordering of memory loads.
2696
2697
2698 .. opcode:: SFENCE - Store memory fence
2699
2700 Syntax: ``SFENCE resource``
2701
2702 Example: ``SFENCE RES[0]``
2703
2704 Similar to MFENCE, but it only affects the ordering of memory stores.
2705
2706
2707 .. opcode:: BARRIER - Thread group barrier
2708
2709 ``BARRIER``
2710
2711 This opcode suspends the execution of the current thread until all
2712 the remaining threads in the working group reach the same point of
2713 the program. Results are unspecified if any of the remaining
2714 threads terminates or never reaches an executed BARRIER instruction.
2715
2716 .. opcode:: MEMBAR - Memory barrier
2717
2718 ``MEMBAR type``
2719
2720 This opcode waits for the completion of all memory accesses based on
2721 the type passed in. The type is an immediate bitfield with the following
2722 meaning:
2723
2724 Bit 0: Shader storage buffers
2725 Bit 1: Atomic buffers
2726 Bit 2: Images
2727 Bit 3: Shared memory
2728 Bit 4: Thread group
2729
2730 These may be passed in in any combination. An implementation is free to not
2731 distinguish between these as it sees fit. However these map to all the
2732 possibilities made available by GLSL.
2733
2734 .. _atomopcodes:
2735
2736 Atomic opcodes
2737 ^^^^^^^^^^^^^^
2738
2739 These opcodes provide atomic variants of some common arithmetic and
2740 logical operations. In this context atomicity means that another
2741 concurrent memory access operation that affects the same memory
2742 location is guaranteed to be performed strictly before or after the
2743 entire execution of the atomic operation. The resource may be a BUFFER,
2744 IMAGE, or MEMORY. In the case of an image, the offset works the same as for
2745 ``LOAD`` and ``STORE``, specified above. These atomic operations may
2746 only be used with 32-bit integer image formats.
2747
2748 .. opcode:: ATOMUADD - Atomic integer addition
2749
2750 Syntax: ``ATOMUADD dst, resource, offset, src``
2751
2752 Example: ``ATOMUADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2753
2754 The following operation is performed atomically:
2755
2756 .. math::
2757
2758 dst_x = resource[offset]
2759
2760 resource[offset] = dst_x + src_x
2761
2762
2763 .. opcode:: ATOMXCHG - Atomic exchange
2764
2765 Syntax: ``ATOMXCHG dst, resource, offset, src``
2766
2767 Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2768
2769 The following operation is performed atomically:
2770
2771 .. math::
2772
2773 dst_x = resource[offset]
2774
2775 resource[offset] = src_x
2776
2777
2778 .. opcode:: ATOMCAS - Atomic compare-and-exchange
2779
2780 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2781
2782 Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
2783
2784 The following operation is performed atomically:
2785
2786 .. math::
2787
2788 dst_x = resource[offset]
2789
2790 resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
2791
2792
2793 .. opcode:: ATOMAND - Atomic bitwise And
2794
2795 Syntax: ``ATOMAND dst, resource, offset, src``
2796
2797 Example: ``ATOMAND TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2798
2799 The following operation is performed atomically:
2800
2801 .. math::
2802
2803 dst_x = resource[offset]
2804
2805 resource[offset] = dst_x \& src_x
2806
2807
2808 .. opcode:: ATOMOR - Atomic bitwise Or
2809
2810 Syntax: ``ATOMOR dst, resource, offset, src``
2811
2812 Example: ``ATOMOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2813
2814 The following operation is performed atomically:
2815
2816 .. math::
2817
2818 dst_x = resource[offset]
2819
2820 resource[offset] = dst_x | src_x
2821
2822
2823 .. opcode:: ATOMXOR - Atomic bitwise Xor
2824
2825 Syntax: ``ATOMXOR dst, resource, offset, src``
2826
2827 Example: ``ATOMXOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2828
2829 The following operation is performed atomically:
2830
2831 .. math::
2832
2833 dst_x = resource[offset]
2834
2835 resource[offset] = dst_x \oplus src_x
2836
2837
2838 .. opcode:: ATOMUMIN - Atomic unsigned minimum
2839
2840 Syntax: ``ATOMUMIN dst, resource, offset, src``
2841
2842 Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2843
2844 The following operation is performed atomically:
2845
2846 .. math::
2847
2848 dst_x = resource[offset]
2849
2850 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2851
2852
2853 .. opcode:: ATOMUMAX - Atomic unsigned maximum
2854
2855 Syntax: ``ATOMUMAX dst, resource, offset, src``
2856
2857 Example: ``ATOMUMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2858
2859 The following operation is performed atomically:
2860
2861 .. math::
2862
2863 dst_x = resource[offset]
2864
2865 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2866
2867
2868 .. opcode:: ATOMIMIN - Atomic signed minimum
2869
2870 Syntax: ``ATOMIMIN dst, resource, offset, src``
2871
2872 Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2873
2874 The following operation is performed atomically:
2875
2876 .. math::
2877
2878 dst_x = resource[offset]
2879
2880 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2881
2882
2883 .. opcode:: ATOMIMAX - Atomic signed maximum
2884
2885 Syntax: ``ATOMIMAX dst, resource, offset, src``
2886
2887 Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2888
2889 The following operation is performed atomically:
2890
2891 .. math::
2892
2893 dst_x = resource[offset]
2894
2895 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2896
2897
2898 .. _interlaneopcodes:
2899
2900 Inter-lane opcodes
2901 ^^^^^^^^^^^^^^^^^^
2902
2903 These opcodes reduce the given value across the shader invocations
2904 running in the current SIMD group. Every thread in the subgroup will receive
2905 the same result. The BALLOT operations accept a single-channel argument that
2906 is treated as a boolean and produce a 64-bit value.
2907
2908 .. opcode:: VOTE_ANY - Value is set in any of the active invocations
2909
2910 Syntax: ``VOTE_ANY dst, value``
2911
2912 Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
2913
2914
2915 .. opcode:: VOTE_ALL - Value is set in all of the active invocations
2916
2917 Syntax: ``VOTE_ALL dst, value``
2918
2919 Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
2920
2921
2922 .. opcode:: VOTE_EQ - Value is the same in all of the active invocations
2923
2924 Syntax: ``VOTE_EQ dst, value``
2925
2926 Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
2927
2928
2929 .. opcode:: BALLOT - Lanemask of whether the value is set in each active
2930 invocation
2931
2932 Syntax: ``BALLOT dst, value``
2933
2934 Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
2935
2936 When the argument is a constant true, this produces a bitmask of active
2937 invocations. In fragment shaders, this can include helper invocations
2938 (invocations whose outputs and writes to memory are discarded, but which
2939 are used to compute derivatives).
2940
2941
2942 .. opcode:: READ_FIRST - Broadcast the value from the first active
2943 invocation to all active lanes
2944
2945 Syntax: ``READ_FIRST dst, value``
2946
2947 Example: ``READ_FIRST TEMP[0], TEMP[1]``
2948
2949
2950 .. opcode:: READ_INVOC - Retrieve the value from the given invocation
2951 (need not be uniform)
2952
2953 Syntax: ``READ_INVOC dst, value, invocation``
2954
2955 Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
2956
2957 invocation.x controls the invocation number to read from for all channels.
2958 The invocation number must be the same across all active invocations in a
2959 sub-group; otherwise, the results are undefined.
2960
2961
2962 Explanation of symbols used
2963 ------------------------------
2964
2965
2966 Functions
2967 ^^^^^^^^^^^^^^
2968
2969
2970 :math:`|x|` Absolute value of `x`.
2971
2972 :math:`\lceil x \rceil` Ceiling of `x`.
2973
2974 clamp(x,y,z) Clamp x between y and z.
2975 (x < y) ? y : (x > z) ? z : x
2976
2977 :math:`\lfloor x\rfloor` Floor of `x`.
2978
2979 :math:`\log_2{x}` Logarithm of `x`, base 2.
2980
2981 max(x,y) Maximum of x and y.
2982 (x > y) ? x : y
2983
2984 min(x,y) Minimum of x and y.
2985 (x < y) ? x : y
2986
2987 partialx(x) Derivative of x relative to fragment's X.
2988
2989 partialy(x) Derivative of x relative to fragment's Y.
2990
2991 pop() Pop from stack.
2992
2993 :math:`x^y` `x` to the power `y`.
2994
2995 push(x) Push x on stack.
2996
2997 round(x) Round x.
2998
2999 trunc(x) Truncate x, i.e. drop the fraction bits.
3000
3001
3002 Keywords
3003 ^^^^^^^^^^^^^
3004
3005
3006 discard Discard fragment.
3007
3008 pc Program counter.
3009
3010 target Label of target instruction.
3011
3012
3013 Other tokens
3014 ---------------
3015
3016
3017 Declaration
3018 ^^^^^^^^^^^
3019
3020
3021 Declares a register that is will be referenced as an operand in Instruction
3022 tokens.
3023
3024 File field contains register file that is being declared and is one
3025 of TGSI_FILE.
3026
3027 UsageMask field specifies which of the register components can be accessed
3028 and is one of TGSI_WRITEMASK.
3029
3030 The Local flag specifies that a given value isn't intended for
3031 subroutine parameter passing and, as a result, the implementation
3032 isn't required to give any guarantees of it being preserved across
3033 subroutine boundaries. As it's merely a compiler hint, the
3034 implementation is free to ignore it.
3035
3036 If Dimension flag is set to 1, a Declaration Dimension token follows.
3037
3038 If Semantic flag is set to 1, a Declaration Semantic token follows.
3039
3040 If Interpolate flag is set to 1, a Declaration Interpolate token follows.
3041
3042 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
3043
3044 If Array flag is set to 1, a Declaration Array token follows.
3045
3046 Array Declaration
3047 ^^^^^^^^^^^^^^^^^^^^^^^^
3048
3049 Declarations can optional have an ArrayID attribute which can be referred by
3050 indirect addressing operands. An ArrayID of zero is reserved and treated as
3051 if no ArrayID is specified.
3052
3053 If an indirect addressing operand refers to a specific declaration by using
3054 an ArrayID only the registers in this declaration are guaranteed to be
3055 accessed, accessing any register outside this declaration results in undefined
3056 behavior. Note that for compatibility the effective index is zero-based and
3057 not relative to the specified declaration
3058
3059 If no ArrayID is specified with an indirect addressing operand the whole
3060 register file might be accessed by this operand. This is strongly discouraged
3061 and will prevent packing of scalar/vec2 arrays and effective alias analysis.
3062 This is only legal for TEMP and CONST register files.
3063
3064 Declaration Semantic
3065 ^^^^^^^^^^^^^^^^^^^^^^^^
3066
3067 Vertex and fragment shader input and output registers may be labeled
3068 with semantic information consisting of a name and index.
3069
3070 Follows Declaration token if Semantic bit is set.
3071
3072 Since its purpose is to link a shader with other stages of the pipeline,
3073 it is valid to follow only those Declaration tokens that declare a register
3074 either in INPUT or OUTPUT file.
3075
3076 SemanticName field contains the semantic name of the register being declared.
3077 There is no default value.
3078
3079 SemanticIndex is an optional subscript that can be used to distinguish
3080 different register declarations with the same semantic name. The default value
3081 is 0.
3082
3083 The meanings of the individual semantic names are explained in the following
3084 sections.
3085
3086 TGSI_SEMANTIC_POSITION
3087 """"""""""""""""""""""
3088
3089 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
3090 output register which contains the homogeneous vertex position in the clip
3091 space coordinate system. After clipping, the X, Y and Z components of the
3092 vertex will be divided by the W value to get normalized device coordinates.
3093
3094 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
3095 fragment shader input (or system value, depending on which one is
3096 supported by the driver) contains the fragment's window position. The X
3097 component starts at zero and always increases from left to right.
3098 The Y component starts at zero and always increases but Y=0 may either
3099 indicate the top of the window or the bottom depending on the fragment
3100 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
3101 The Z coordinate ranges from 0 to 1 to represent depth from the front
3102 to the back of the Z buffer. The W component contains the interpolated
3103 reciprocal of the vertex position W component (corresponding to gl_Fragcoord,
3104 but unlike d3d10 which interpolates the same 1/w but then gives back
3105 the reciprocal of the interpolated value).
3106
3107 Fragment shaders may also declare an output register with
3108 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
3109 the fragment shader to change the fragment's Z position.
3110
3111
3112
3113 TGSI_SEMANTIC_COLOR
3114 """""""""""""""""""
3115
3116 For vertex shader outputs or fragment shader inputs/outputs, this
3117 label indicates that the register contains an R,G,B,A color.
3118
3119 Several shader inputs/outputs may contain colors so the semantic index
3120 is used to distinguish them. For example, color[0] may be the diffuse
3121 color while color[1] may be the specular color.
3122
3123 This label is needed so that the flat/smooth shading can be applied
3124 to the right interpolants during rasterization.
3125
3126
3127
3128 TGSI_SEMANTIC_BCOLOR
3129 """"""""""""""""""""
3130
3131 Back-facing colors are only used for back-facing polygons, and are only valid
3132 in vertex shader outputs. After rasterization, all polygons are front-facing
3133 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
3134 so all BCOLORs effectively become regular COLORs in the fragment shader.
3135
3136
3137 TGSI_SEMANTIC_FOG
3138 """""""""""""""""
3139
3140 Vertex shader inputs and outputs and fragment shader inputs may be
3141 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
3142 a fog coordinate. Typically, the fragment shader will use the fog coordinate
3143 to compute a fog blend factor which is used to blend the normal fragment color
3144 with a constant fog color. But fog coord really is just an ordinary vec4
3145 register like regular semantics.
3146
3147
3148 TGSI_SEMANTIC_PSIZE
3149 """""""""""""""""""
3150
3151 Vertex shader input and output registers may be labeled with
3152 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
3153 in the form (S, 0, 0, 1). The point size controls the width or diameter
3154 of points for rasterization. This label cannot be used in fragment
3155 shaders.
3156
3157 When using this semantic, be sure to set the appropriate state in the
3158 :ref:`rasterizer` first.
3159
3160
3161 TGSI_SEMANTIC_TEXCOORD
3162 """"""""""""""""""""""
3163
3164 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3165
3166 Vertex shader outputs and fragment shader inputs may be labeled with
3167 this semantic to make them replaceable by sprite coordinates via the
3168 sprite_coord_enable state in the :ref:`rasterizer`.
3169 The semantic index permitted with this semantic is limited to <= 7.
3170
3171 If the driver does not support TEXCOORD, sprite coordinate replacement
3172 applies to inputs with the GENERIC semantic instead.
3173
3174 The intended use case for this semantic is gl_TexCoord.
3175
3176
3177 TGSI_SEMANTIC_PCOORD
3178 """"""""""""""""""""
3179
3180 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3181
3182 Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
3183 that the register contains sprite coordinates in the form (x, y, 0, 1), if
3184 the current primitive is a point and point sprites are enabled. Otherwise,
3185 the contents of the register are undefined.
3186
3187 The intended use case for this semantic is gl_PointCoord.
3188
3189
3190 TGSI_SEMANTIC_GENERIC
3191 """""""""""""""""""""
3192
3193 All vertex/fragment shader inputs/outputs not labeled with any other
3194 semantic label can be considered to be generic attributes. Typical
3195 uses of generic inputs/outputs are texcoords and user-defined values.
3196
3197
3198 TGSI_SEMANTIC_NORMAL
3199 """"""""""""""""""""
3200
3201 Indicates that a vertex shader input is a normal vector. This is
3202 typically only used for legacy graphics APIs.
3203
3204
3205 TGSI_SEMANTIC_FACE
3206 """"""""""""""""""
3207
3208 This label applies to fragment shader inputs (or system values,
3209 depending on which one is supported by the driver) and indicates that
3210 the register contains front/back-face information.
3211
3212 If it is an input, it will be a floating-point vector in the form (F, 0, 0, 1),
3213 where F will be positive when the fragment belongs to a front-facing polygon,
3214 and negative when the fragment belongs to a back-facing polygon.
3215
3216 If it is a system value, it will be an integer vector in the form (F, 0, 0, 1),
3217 where F is 0xffffffff when the fragment belongs to a front-facing polygon and
3218 0 when the fragment belongs to a back-facing polygon.
3219
3220
3221 TGSI_SEMANTIC_EDGEFLAG
3222 """"""""""""""""""""""
3223
3224 For vertex shaders, this sematic label indicates that an input or
3225 output is a boolean edge flag. The register layout is [F, x, x, x]
3226 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
3227 simply copies the edge flag input to the edgeflag output.
3228
3229 Edge flags are used to control which lines or points are actually
3230 drawn when the polygon mode converts triangles/quads/polygons into
3231 points or lines.
3232
3233
3234 TGSI_SEMANTIC_STENCIL
3235 """""""""""""""""""""
3236
3237 For fragment shaders, this semantic label indicates that an output
3238 is a writable stencil reference value. Only the Y component is writable.
3239 This allows the fragment shader to change the fragments stencilref value.
3240
3241
3242 TGSI_SEMANTIC_VIEWPORT_INDEX
3243 """"""""""""""""""""""""""""
3244
3245 For geometry shaders, this semantic label indicates that an output
3246 contains the index of the viewport (and scissor) to use.
3247 This is an integer value, and only the X component is used.
3248
3249 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3250 supported, then this semantic label can also be used in vertex or
3251 tessellation evaluation shaders, respectively. Only the value written in the
3252 last vertex processing stage is used.
3253
3254
3255 TGSI_SEMANTIC_LAYER
3256 """""""""""""""""""
3257
3258 For geometry shaders, this semantic label indicates that an output
3259 contains the layer value to use for the color and depth/stencil surfaces.
3260 This is an integer value, and only the X component is used.
3261 (Also known as rendertarget array index.)
3262
3263 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3264 supported, then this semantic label can also be used in vertex or
3265 tessellation evaluation shaders, respectively. Only the value written in the
3266 last vertex processing stage is used.
3267
3268
3269 TGSI_SEMANTIC_CULLDIST
3270 """"""""""""""""""""""
3271
3272 Used as distance to plane for performing application-defined culling
3273 of individual primitives against a plane. When components of vertex
3274 elements are given this label, these values are assumed to be a
3275 float32 signed distance to a plane. Primitives will be completely
3276 discarded if the plane distance for all of the vertices in the
3277 primitive are < 0. If a vertex has a cull distance of NaN, that
3278 vertex counts as "out" (as if its < 0);
3279 The limits on both clip and cull distances are bound
3280 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3281 the maximum number of components that can be used to hold the
3282 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3283 which specifies the maximum number of registers which can be
3284 annotated with those semantics.
3285
3286
3287 TGSI_SEMANTIC_CLIPDIST
3288 """"""""""""""""""""""
3289
3290 Note this covers clipping and culling distances.
3291
3292 When components of vertex elements are identified this way, these
3293 values are each assumed to be a float32 signed distance to a plane.
3294
3295 For clip distances:
3296 Primitive setup only invokes rasterization on pixels for which
3297 the interpolated plane distances are >= 0.
3298
3299 For cull distances:
3300 Primitives will be completely discarded if the plane distance
3301 for all of the vertices in the primitive are < 0.
3302 If a vertex has a cull distance of NaN, that vertex counts as "out"
3303 (as if its < 0);
3304
3305 Multiple clip/cull planes can be implemented simultaneously, by
3306 annotating multiple components of one or more vertex elements with
3307 the above specified semantic.
3308 The limits on both clip and cull distances are bound
3309 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3310 the maximum number of components that can be used to hold the
3311 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3312 which specifies the maximum number of registers which can be
3313 annotated with those semantics.
3314 The properties NUM_CLIPDIST_ENABLED and NUM_CULLDIST_ENABLED
3315 are used to divide up the 2 x vec4 space between clipping and culling.
3316
3317 TGSI_SEMANTIC_SAMPLEID
3318 """"""""""""""""""""""
3319
3320 For fragment shaders, this semantic label indicates that a system value
3321 contains the current sample id (i.e. gl_SampleID) as an unsigned int.
3322 Only the X component is used. If per-sample shading is not enabled,
3323 the result is (0, undef, undef, undef).
3324
3325 TGSI_SEMANTIC_SAMPLEPOS
3326 """""""""""""""""""""""
3327
3328 For fragment shaders, this semantic label indicates that a system
3329 value contains the current sample's position as float4(x, y, undef, undef)
3330 in the render target (i.e. gl_SamplePosition) when per-fragment shading
3331 is in effect. Position values are in the range [0, 1] where 0.5 is
3332 the center of the fragment.
3333
3334 TGSI_SEMANTIC_SAMPLEMASK
3335 """"""""""""""""""""""""
3336
3337 For fragment shaders, this semantic label can be applied to either a
3338 shader system value input or output.
3339
3340 For a system value, the sample mask indicates the set of samples covered by
3341 the current primitive. If MSAA is not enabled, the value is (1, 0, 0, 0).
3342
3343 For an output, the sample mask is used to disable further sample processing.
3344
3345 For both, the register type is uint[4] but only the X component is used
3346 (i.e. gl_SampleMask[0]). Each bit corresponds to one sample position (up
3347 to 32x MSAA is supported).
3348
3349 TGSI_SEMANTIC_INVOCATIONID
3350 """"""""""""""""""""""""""
3351
3352 For geometry shaders, this semantic label indicates that a system value
3353 contains the current invocation id (i.e. gl_InvocationID).
3354 This is an integer value, and only the X component is used.
3355
3356 TGSI_SEMANTIC_INSTANCEID
3357 """"""""""""""""""""""""
3358
3359 For vertex shaders, this semantic label indicates that a system value contains
3360 the current instance id (i.e. gl_InstanceID). It does not include the base
3361 instance. This is an integer value, and only the X component is used.
3362
3363 TGSI_SEMANTIC_VERTEXID
3364 """"""""""""""""""""""
3365
3366 For vertex shaders, this semantic label indicates that a system value contains
3367 the current vertex id (i.e. gl_VertexID). It does (unlike in d3d10) include the
3368 base vertex. This is an integer value, and only the X component is used.
3369
3370 TGSI_SEMANTIC_VERTEXID_NOBASE
3371 """""""""""""""""""""""""""""""
3372
3373 For vertex shaders, this semantic label indicates that a system value contains
3374 the current vertex id without including the base vertex (this corresponds to
3375 d3d10 vertex id, so TGSI_SEMANTIC_VERTEXID_NOBASE + TGSI_SEMANTIC_BASEVERTEX
3376 == TGSI_SEMANTIC_VERTEXID). This is an integer value, and only the X component
3377 is used.
3378
3379 TGSI_SEMANTIC_BASEVERTEX
3380 """"""""""""""""""""""""
3381
3382 For vertex shaders, this semantic label indicates that a system value contains
3383 the base vertex (i.e. gl_BaseVertex). Note that for non-indexed draw calls,
3384 this contains the first (or start) value instead.
3385 This is an integer value, and only the X component is used.
3386
3387 TGSI_SEMANTIC_PRIMID
3388 """"""""""""""""""""
3389
3390 For geometry and fragment shaders, this semantic label indicates the value
3391 contains the primitive id (i.e. gl_PrimitiveID). This is an integer value,
3392 and only the X component is used.
3393 FIXME: This right now can be either a ordinary input or a system value...
3394
3395
3396 TGSI_SEMANTIC_PATCH
3397 """""""""""""""""""
3398
3399 For tessellation evaluation/control shaders, this semantic label indicates a
3400 generic per-patch attribute. Such semantics will not implicitly be per-vertex
3401 arrays.
3402
3403 TGSI_SEMANTIC_TESSCOORD
3404 """""""""""""""""""""""
3405
3406 For tessellation evaluation shaders, this semantic label indicates the
3407 coordinates of the vertex being processed. This is available in XYZ; W is
3408 undefined.
3409
3410 TGSI_SEMANTIC_TESSOUTER
3411 """""""""""""""""""""""
3412
3413 For tessellation evaluation/control shaders, this semantic label indicates the
3414 outer tessellation levels of the patch. Isoline tessellation will only have XY
3415 defined, triangle will have XYZ and quads will have XYZW defined. This
3416 corresponds to gl_TessLevelOuter.
3417
3418 TGSI_SEMANTIC_TESSINNER
3419 """""""""""""""""""""""
3420
3421 For tessellation evaluation/control shaders, this semantic label indicates the
3422 inner tessellation levels of the patch. The X value is only defined for
3423 triangle tessellation, while quads will have XY defined. This is entirely
3424 undefined for isoline tessellation.
3425
3426 TGSI_SEMANTIC_VERTICESIN
3427 """"""""""""""""""""""""
3428
3429 For tessellation evaluation/control shaders, this semantic label indicates the
3430 number of vertices provided in the input patch. Only the X value is defined.
3431
3432 TGSI_SEMANTIC_HELPER_INVOCATION
3433 """""""""""""""""""""""""""""""
3434
3435 For fragment shaders, this semantic indicates whether the current
3436 invocation is covered or not. Helper invocations are created in order
3437 to properly compute derivatives, however it may be desirable to skip
3438 some of the logic in those cases. See ``gl_HelperInvocation`` documentation.
3439
3440 TGSI_SEMANTIC_BASEINSTANCE
3441 """"""""""""""""""""""""""
3442
3443 For vertex shaders, the base instance argument supplied for this
3444 draw. This is an integer value, and only the X component is used.
3445
3446 TGSI_SEMANTIC_DRAWID
3447 """"""""""""""""""""
3448
3449 For vertex shaders, the zero-based index of the current draw in a
3450 ``glMultiDraw*`` invocation. This is an integer value, and only the X
3451 component is used.
3452
3453
3454 TGSI_SEMANTIC_WORK_DIM
3455 """"""""""""""""""""""
3456
3457 For compute shaders started via opencl this retrieves the work_dim
3458 parameter to the clEnqueueNDRangeKernel call with which the shader
3459 was started.
3460
3461
3462 TGSI_SEMANTIC_GRID_SIZE
3463 """""""""""""""""""""""
3464
3465 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3466 of a grid of thread blocks.
3467
3468
3469 TGSI_SEMANTIC_BLOCK_ID
3470 """"""""""""""""""""""
3471
3472 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3473 current block inside of the grid.
3474
3475
3476 TGSI_SEMANTIC_BLOCK_SIZE
3477 """"""""""""""""""""""""
3478
3479 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3480 of a block in threads.
3481
3482
3483 TGSI_SEMANTIC_THREAD_ID
3484 """""""""""""""""""""""
3485
3486 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3487 current thread inside of the block.
3488
3489
3490 TGSI_SEMANTIC_SUBGROUP_SIZE
3491 """""""""""""""""""""""""""
3492
3493 This semantic indicates the subgroup size for the current invocation. This is
3494 an integer of at most 64, as it indicates the width of lanemasks. It does not
3495 depend on the number of invocations that are active.
3496
3497
3498 TGSI_SEMANTIC_SUBGROUP_INVOCATION
3499 """""""""""""""""""""""""""""""""
3500
3501 The index of the current invocation within its subgroup.
3502
3503
3504 TGSI_SEMANTIC_SUBGROUP_EQ_MASK
3505 """"""""""""""""""""""""""""""
3506
3507 A bit mask of ``bit index == TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3508 ``1 << subgroup_invocation`` in arbitrary precision arithmetic.
3509
3510
3511 TGSI_SEMANTIC_SUBGROUP_GE_MASK
3512 """"""""""""""""""""""""""""""
3513
3514 A bit mask of ``bit index >= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3515 ``((1 << (subgroup_size - subgroup_invocation)) - 1) << subgroup_invocation``
3516 in arbitrary precision arithmetic.
3517
3518
3519 TGSI_SEMANTIC_SUBGROUP_GT_MASK
3520 """"""""""""""""""""""""""""""
3521
3522 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3523 ``((1 << (subgroup_size - subgroup_invocation - 1)) - 1) << (subgroup_invocation + 1)``
3524 in arbitrary precision arithmetic.
3525
3526
3527 TGSI_SEMANTIC_SUBGROUP_LE_MASK
3528 """"""""""""""""""""""""""""""
3529
3530 A bit mask of ``bit index <= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3531 ``(1 << (subgroup_invocation + 1)) - 1`` in arbitrary precision arithmetic.
3532
3533
3534 TGSI_SEMANTIC_SUBGROUP_LT_MASK
3535 """"""""""""""""""""""""""""""
3536
3537 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3538 ``(1 << subgroup_invocation) - 1`` in arbitrary precision arithmetic.
3539
3540
3541 Declaration Interpolate
3542 ^^^^^^^^^^^^^^^^^^^^^^^
3543
3544 This token is only valid for fragment shader INPUT declarations.
3545
3546 The Interpolate field specifes the way input is being interpolated by
3547 the rasteriser and is one of TGSI_INTERPOLATE_*.
3548
3549 The Location field specifies the location inside the pixel that the
3550 interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. Note that
3551 when per-sample shading is enabled, the implementation may choose to
3552 interpolate at the sample irrespective of the Location field.
3553
3554 The CylindricalWrap bitfield specifies which register components
3555 should be subject to cylindrical wrapping when interpolating by the
3556 rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
3557 should be interpolated according to cylindrical wrapping rules.
3558
3559
3560 Declaration Sampler View
3561 ^^^^^^^^^^^^^^^^^^^^^^^^
3562
3563 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
3564
3565 DCL SVIEW[#], resource, type(s)
3566
3567 Declares a shader input sampler view and assigns it to a SVIEW[#]
3568 register.
3569
3570 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
3571
3572 type must be 1 or 4 entries (if specifying on a per-component
3573 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
3574
3575 For TEX\* style texture sample opcodes (as opposed to SAMPLE\* opcodes
3576 which take an explicit SVIEW[#] source register), there may be optionally
3577 SVIEW[#] declarations. In this case, the SVIEW index is implied by the
3578 SAMP index, and there must be a corresponding SVIEW[#] declaration for
3579 each SAMP[#] declaration. Drivers are free to ignore this if they wish.
3580 But note in particular that some drivers need to know the sampler type
3581 (float/int/unsigned) in order to generate the correct code, so cases
3582 where integer textures are sampled, SVIEW[#] declarations should be
3583 used.
3584
3585 NOTE: It is NOT legal to mix SAMPLE\* style opcodes and TEX\* opcodes
3586 in the same shader.
3587
3588 Declaration Resource
3589 ^^^^^^^^^^^^^^^^^^^^
3590
3591 Follows Declaration token if file is TGSI_FILE_RESOURCE.
3592
3593 DCL RES[#], resource [, WR] [, RAW]
3594
3595 Declares a shader input resource and assigns it to a RES[#]
3596 register.
3597
3598 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
3599 2DArray.
3600
3601 If the RAW keyword is not specified, the texture data will be
3602 subject to conversion, swizzling and scaling as required to yield
3603 the specified data type from the physical data format of the bound
3604 resource.
3605
3606 If the RAW keyword is specified, no channel conversion will be
3607 performed: the values read for each of the channels (X,Y,Z,W) will
3608 correspond to consecutive words in the same order and format
3609 they're found in memory. No element-to-address conversion will be
3610 performed either: the value of the provided X coordinate will be
3611 interpreted in byte units instead of texel units. The result of
3612 accessing a misaligned address is undefined.
3613
3614 Usage of the STORE opcode is only allowed if the WR (writable) flag
3615 is set.
3616
3617
3618 Properties
3619 ^^^^^^^^^^^^^^^^^^^^^^^^
3620
3621 Properties are general directives that apply to the whole TGSI program.
3622
3623 FS_COORD_ORIGIN
3624 """""""""""""""
3625
3626 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
3627 The default value is UPPER_LEFT.
3628
3629 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
3630 increase downward and rightward.
3631 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
3632 increase upward and rightward.
3633
3634 OpenGL defaults to LOWER_LEFT, and is configurable with the
3635 GL_ARB_fragment_coord_conventions extension.
3636
3637 DirectX 9/10 use UPPER_LEFT.
3638
3639 FS_COORD_PIXEL_CENTER
3640 """""""""""""""""""""
3641
3642 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
3643 The default value is HALF_INTEGER.
3644
3645 If HALF_INTEGER, the fractionary part of the position will be 0.5
3646 If INTEGER, the fractionary part of the position will be 0.0
3647
3648 Note that this does not affect the set of fragments generated by
3649 rasterization, which is instead controlled by half_pixel_center in the
3650 rasterizer.
3651
3652 OpenGL defaults to HALF_INTEGER, and is configurable with the
3653 GL_ARB_fragment_coord_conventions extension.
3654
3655 DirectX 9 uses INTEGER.
3656 DirectX 10 uses HALF_INTEGER.
3657
3658 FS_COLOR0_WRITES_ALL_CBUFS
3659 """"""""""""""""""""""""""
3660 Specifies that writes to the fragment shader color 0 are replicated to all
3661 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
3662 fragData is directed to a single color buffer, but fragColor is broadcast.
3663
3664 VS_PROHIBIT_UCPS
3665 """"""""""""""""""""""""""
3666 If this property is set on the program bound to the shader stage before the
3667 fragment shader, user clip planes should have no effect (be disabled) even if
3668 that shader does not write to any clip distance outputs and the rasterizer's
3669 clip_plane_enable is non-zero.
3670 This property is only supported by drivers that also support shader clip
3671 distance outputs.
3672 This is useful for APIs that don't have UCPs and where clip distances written
3673 by a shader cannot be disabled.
3674
3675 GS_INVOCATIONS
3676 """"""""""""""
3677
3678 Specifies the number of times a geometry shader should be executed for each
3679 input primitive. Each invocation will have a different
3680 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
3681 be 1.
3682
3683 VS_WINDOW_SPACE_POSITION
3684 """"""""""""""""""""""""""
3685 If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
3686 is assumed to contain window space coordinates.
3687 Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
3688 directly taken from the 4-th component of the shader output.
3689 Naturally, clipping is not performed on window coordinates either.
3690 The effect of this property is undefined if a geometry or tessellation shader
3691 are in use.
3692
3693 TCS_VERTICES_OUT
3694 """"""""""""""""
3695
3696 The number of vertices written by the tessellation control shader. This
3697 effectively defines the patch input size of the tessellation evaluation shader
3698 as well.
3699
3700 TES_PRIM_MODE
3701 """""""""""""
3702
3703 This sets the tessellation primitive mode, one of ``PIPE_PRIM_TRIANGLES``,
3704 ``PIPE_PRIM_QUADS``, or ``PIPE_PRIM_LINES``. (Unlike in GL, there is no
3705 separate isolines settings, the regular lines is assumed to mean isolines.)
3706
3707 TES_SPACING
3708 """""""""""
3709
3710 This sets the spacing mode of the tessellation generator, one of
3711 ``PIPE_TESS_SPACING_*``.
3712
3713 TES_VERTEX_ORDER_CW
3714 """""""""""""""""""
3715
3716 This sets the vertex order to be clockwise if the value is 1, or
3717 counter-clockwise if set to 0.
3718
3719 TES_POINT_MODE
3720 """"""""""""""
3721
3722 If set to a non-zero value, this turns on point mode for the tessellator,
3723 which means that points will be generated instead of primitives.
3724
3725 NUM_CLIPDIST_ENABLED
3726 """"""""""""""""""""
3727
3728 How many clip distance scalar outputs are enabled.
3729
3730 NUM_CULLDIST_ENABLED
3731 """"""""""""""""""""
3732
3733 How many cull distance scalar outputs are enabled.
3734
3735 FS_EARLY_DEPTH_STENCIL
3736 """"""""""""""""""""""
3737
3738 Whether depth test, stencil test, and occlusion query should run before
3739 the fragment shader (regardless of fragment shader side effects). Corresponds
3740 to GLSL early_fragment_tests.
3741
3742 NEXT_SHADER
3743 """""""""""
3744
3745 Which shader stage will MOST LIKELY follow after this shader when the shader
3746 is bound. This is only a hint to the driver and doesn't have to be precise.
3747 Only set for VS and TES.
3748
3749 CS_FIXED_BLOCK_WIDTH / HEIGHT / DEPTH
3750 """""""""""""""""""""""""""""""""""""
3751
3752 Threads per block in each dimension, if known at compile time. If the block size
3753 is known all three should be at least 1. If it is unknown they should all be set
3754 to 0 or not set.
3755
3756 MUL_ZERO_WINS
3757 """""""""""""
3758
3759 The MUL TGSI operation (FP32 multiplication) will return 0 if either
3760 of the operands are equal to 0. That means that 0 * Inf = 0. This
3761 should be set the same way for an entire pipeline. Note that this
3762 applies not only to the literal MUL TGSI opcode, but all FP32
3763 multiplications implied by other operations, such as MAD, FMA, DP2,
3764 DP3, DP4, DPH, DST, LOG, LRP, XPD, and possibly others. If there is a
3765 mismatch between shaders, then it is unspecified whether this behavior
3766 will be enabled.
3767
3768 FS_POST_DEPTH_COVERAGE
3769 """"""""""""""""""""""
3770
3771 When enabled, the input for TGSI_SEMANTIC_SAMPLEMASK will exclude samples
3772 that have failed the depth/stencil tests. This is only valid when
3773 FS_EARLY_DEPTH_STENCIL is also specified.
3774
3775
3776 Texture Sampling and Texture Formats
3777 ------------------------------------
3778
3779 This table shows how texture image components are returned as (x,y,z,w) tuples
3780 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
3781 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
3782 well.
3783
3784 +--------------------+--------------+--------------------+--------------+
3785 | Texture Components | Gallium | OpenGL | Direct3D 9 |
3786 +====================+==============+====================+==============+
3787 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
3788 +--------------------+--------------+--------------------+--------------+
3789 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
3790 +--------------------+--------------+--------------------+--------------+
3791 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
3792 +--------------------+--------------+--------------------+--------------+
3793 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
3794 +--------------------+--------------+--------------------+--------------+
3795 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
3796 +--------------------+--------------+--------------------+--------------+
3797 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
3798 +--------------------+--------------+--------------------+--------------+
3799 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
3800 +--------------------+--------------+--------------------+--------------+
3801 | I | (i, i, i, i) | (i, i, i, i) | N/A |
3802 +--------------------+--------------+--------------------+--------------+
3803 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
3804 | | | [#envmap-bumpmap]_ | |
3805 +--------------------+--------------+--------------------+--------------+
3806 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
3807 | | | [#depth-tex-mode]_ | |
3808 +--------------------+--------------+--------------------+--------------+
3809 | S | (s, s, s, s) | unknown | unknown |
3810 +--------------------+--------------+--------------------+--------------+
3811
3812 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
3813 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
3814 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.