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