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