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
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
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`.
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.
29 TGSI supports modifiers on inputs (as well as saturate modifier on instructions).
31 For inputs which have a floating point type, both absolute value and
32 negation modifiers are supported (with absolute value being applied
33 first). The only source of TGSI_OPCODE_MOV and the second and third
34 sources of TGSI_OPCODE_UCMP are considered to have float type for
37 For inputs which have signed or unsigned type only the negate modifier is
44 ^^^^^^^^^^^^^^^^^^^^^^^^^
46 These opcodes are guaranteed to be available regardless of the driver being
49 .. opcode:: ARL - Address Register Load
53 dst.x = (int) \lfloor src.x\rfloor
55 dst.y = (int) \lfloor src.y\rfloor
57 dst.z = (int) \lfloor src.z\rfloor
59 dst.w = (int) \lfloor src.w\rfloor
62 .. opcode:: MOV - Move
75 .. opcode:: LIT - Light Coefficients
80 dst.y &= max(src.x, 0) \\
81 dst.z &= (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 \\
85 .. opcode:: RCP - Reciprocal
87 This instruction replicates its result.
94 .. opcode:: RSQ - Reciprocal Square Root
96 This instruction replicates its result. The results are undefined for src <= 0.
100 dst = \frac{1}{\sqrt{src.x}}
103 .. opcode:: SQRT - Square Root
105 This instruction replicates its result. The results are undefined for src < 0.
112 .. opcode:: EXP - Approximate Exponential Base 2
116 dst.x &= 2^{\lfloor src.x\rfloor} \\
117 dst.y &= src.x - \lfloor src.x\rfloor \\
118 dst.z &= 2^{src.x} \\
122 .. opcode:: LOG - Approximate Logarithm Base 2
126 dst.x &= \lfloor\log_2{|src.x|}\rfloor \\
127 dst.y &= \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} \\
128 dst.z &= \log_2{|src.x|} \\
132 .. opcode:: MUL - Multiply
136 dst.x = src0.x \times src1.x
138 dst.y = src0.y \times src1.y
140 dst.z = src0.z \times src1.z
142 dst.w = src0.w \times src1.w
145 .. opcode:: ADD - Add
149 dst.x = src0.x + src1.x
151 dst.y = src0.y + src1.y
153 dst.z = src0.z + src1.z
155 dst.w = src0.w + src1.w
158 .. opcode:: DP3 - 3-component Dot Product
160 This instruction replicates its result.
164 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
167 .. opcode:: DP4 - 4-component Dot Product
169 This instruction replicates its result.
173 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
176 .. opcode:: DST - Distance Vector
181 dst.y &= src0.y \times src1.y\\
186 .. opcode:: MIN - Minimum
190 dst.x = min(src0.x, src1.x)
192 dst.y = min(src0.y, src1.y)
194 dst.z = min(src0.z, src1.z)
196 dst.w = min(src0.w, src1.w)
199 .. opcode:: MAX - Maximum
203 dst.x = max(src0.x, src1.x)
205 dst.y = max(src0.y, src1.y)
207 dst.z = max(src0.z, src1.z)
209 dst.w = max(src0.w, src1.w)
212 .. opcode:: SLT - Set On Less Than
216 dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
218 dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
220 dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
222 dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
225 .. opcode:: SGE - Set On Greater Equal Than
229 dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
231 dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
233 dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
235 dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
238 .. opcode:: MAD - Multiply And Add
242 dst.x = src0.x \times src1.x + src2.x
244 dst.y = src0.y \times src1.y + src2.y
246 dst.z = src0.z \times src1.z + src2.z
248 dst.w = src0.w \times src1.w + src2.w
251 .. opcode:: LRP - Linear Interpolate
255 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
257 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
259 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
261 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
264 .. opcode:: FMA - Fused Multiply-Add
266 Perform a * b + c with no intermediate rounding step.
270 dst.x = src0.x \times src1.x + src2.x
272 dst.y = src0.y \times src1.y + src2.y
274 dst.z = src0.z \times src1.z + src2.z
276 dst.w = src0.w \times src1.w + src2.w
279 .. opcode:: DP2A - 2-component Dot Product And Add
283 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
285 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
287 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
289 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
292 .. opcode:: FRC - Fraction
296 dst.x = src.x - \lfloor src.x\rfloor
298 dst.y = src.y - \lfloor src.y\rfloor
300 dst.z = src.z - \lfloor src.z\rfloor
302 dst.w = src.w - \lfloor src.w\rfloor
305 .. opcode:: FLR - Floor
309 dst.x = \lfloor src.x\rfloor
311 dst.y = \lfloor src.y\rfloor
313 dst.z = \lfloor src.z\rfloor
315 dst.w = \lfloor src.w\rfloor
318 .. opcode:: ROUND - Round
331 .. opcode:: EX2 - Exponential Base 2
333 This instruction replicates its result.
340 .. opcode:: LG2 - Logarithm Base 2
342 This instruction replicates its result.
349 .. opcode:: POW - Power
351 This instruction replicates its result.
355 dst = src0.x^{src1.x}
357 .. opcode:: XPD - Cross Product
361 dst.x = src0.y \times src1.z - src1.y \times src0.z
363 dst.y = src0.z \times src1.x - src1.z \times src0.x
365 dst.z = src0.x \times src1.y - src1.x \times src0.y
370 .. opcode:: DPH - Homogeneous Dot Product
372 This instruction replicates its result.
376 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
379 .. opcode:: COS - Cosine
381 This instruction replicates its result.
388 .. opcode:: DDX, DDX_FINE - Derivative Relative To X
390 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
391 advertised. When it is, the fine version guarantees one derivative per row
392 while DDX is allowed to be the same for the entire 2x2 quad.
396 dst.x = partialx(src.x)
398 dst.y = partialx(src.y)
400 dst.z = partialx(src.z)
402 dst.w = partialx(src.w)
405 .. opcode:: DDY, DDY_FINE - Derivative Relative To Y
407 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
408 advertised. When it is, the fine version guarantees one derivative per column
409 while DDY is allowed to be the same for the entire 2x2 quad.
413 dst.x = partialy(src.x)
415 dst.y = partialy(src.y)
417 dst.z = partialy(src.z)
419 dst.w = partialy(src.w)
422 .. opcode:: PK2H - Pack Two 16-bit Floats
424 This instruction replicates its result.
428 dst = f32\_to\_f16(src.x) | f32\_to\_f16(src.y) << 16
431 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
436 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
441 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
446 .. opcode:: SEQ - Set On Equal
450 dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
452 dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
454 dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
456 dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
459 .. opcode:: SGT - Set On Greater Than
463 dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
465 dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
467 dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
469 dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
472 .. opcode:: SIN - Sine
474 This instruction replicates its result.
481 .. opcode:: SLE - Set On Less Equal Than
485 dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
487 dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
489 dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
491 dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
494 .. opcode:: SNE - Set On Not Equal
498 dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
500 dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
502 dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
504 dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
507 .. opcode:: TEX - Texture Lookup
509 for array textures src0.y contains the slice for 1D,
510 and src0.z contain the slice for 2D.
512 for shadow textures with no arrays (and not cube map),
513 src0.z contains the reference value.
515 for shadow textures with arrays, src0.z contains
516 the reference value for 1D arrays, and src0.w contains
517 the reference value for 2D arrays and cube maps.
519 for cube map array shadow textures, the reference value
520 cannot be passed in src0.w, and TEX2 must be used instead.
526 shadow_ref = src0.z or src0.w (optional)
530 dst = texture\_sample(unit, coord, shadow_ref)
533 .. opcode:: TEX2 - Texture Lookup (for shadow cube map arrays only)
535 this is the same as TEX, but uses another reg to encode the
546 dst = texture\_sample(unit, coord, shadow_ref)
551 .. opcode:: TXD - Texture Lookup with Derivatives
563 dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
566 .. opcode:: TXP - Projective Texture Lookup
570 coord.x = src0.x / src0.w
572 coord.y = src0.y / src0.w
574 coord.z = src0.z / src0.w
580 dst = texture\_sample(unit, coord)
583 .. opcode:: UP2H - Unpack Two 16-Bit Floats
587 dst.x = f16\_to\_f32(src0.x \& 0xffff)
589 dst.y = f16\_to\_f32(src0.x >> 16)
591 dst.z = f16\_to\_f32(src0.x \& 0xffff)
593 dst.w = f16\_to\_f32(src0.x >> 16)
597 Considered for removal.
599 .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
605 Considered for removal.
607 .. opcode:: UP4B - Unpack Four Signed 8-Bit Values
613 Considered for removal.
615 .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
621 Considered for removal.
624 .. opcode:: ARR - Address Register Load With Round
628 dst.x = (int) round(src.x)
630 dst.y = (int) round(src.y)
632 dst.z = (int) round(src.z)
634 dst.w = (int) round(src.w)
637 .. opcode:: SSG - Set Sign
641 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
643 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
645 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
647 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
650 .. opcode:: CMP - Compare
654 dst.x = (src0.x < 0) ? src1.x : src2.x
656 dst.y = (src0.y < 0) ? src1.y : src2.y
658 dst.z = (src0.z < 0) ? src1.z : src2.z
660 dst.w = (src0.w < 0) ? src1.w : src2.w
663 .. opcode:: KILL_IF - Conditional Discard
665 Conditional discard. Allowed in fragment shaders only.
669 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
674 .. opcode:: KILL - Discard
676 Unconditional discard. Allowed in fragment shaders only.
679 .. opcode:: SCS - Sine Cosine
692 .. opcode:: TXB - Texture Lookup With Bias
694 for cube map array textures and shadow cube maps, the bias value
695 cannot be passed in src0.w, and TXB2 must be used instead.
697 if the target is a shadow texture, the reference value is always
698 in src.z (this prevents shadow 3d and shadow 2d arrays from
699 using this instruction, but this is not needed).
715 dst = texture\_sample(unit, coord, bias)
718 .. opcode:: TXB2 - Texture Lookup With Bias (some cube maps only)
720 this is the same as TXB, but uses another reg to encode the
721 lod bias value for cube map arrays and shadow cube maps.
722 Presumably shadow 2d arrays and shadow 3d targets could use
723 this encoding too, but this is not legal.
725 shadow cube map arrays are neither possible nor required.
735 dst = texture\_sample(unit, coord, bias)
738 .. opcode:: DIV - Divide
742 dst.x = \frac{src0.x}{src1.x}
744 dst.y = \frac{src0.y}{src1.y}
746 dst.z = \frac{src0.z}{src1.z}
748 dst.w = \frac{src0.w}{src1.w}
751 .. opcode:: DP2 - 2-component Dot Product
753 This instruction replicates its result.
757 dst = src0.x \times src1.x + src0.y \times src1.y
760 .. opcode:: TEX_LZ - Texture Lookup With LOD = 0
762 This is the same as TXL with LOD = 0. Like every texture opcode, it obeys
763 pipe_sampler_view::u.tex.first_level and pipe_sampler_state::min_lod.
764 There is no way to override those two in shaders.
780 dst = texture\_sample(unit, coord, lod)
783 .. opcode:: TXL - Texture Lookup With explicit LOD
785 for cube map array textures, the explicit lod value
786 cannot be passed in src0.w, and TXL2 must be used instead.
788 if the target is a shadow texture, the reference value is always
789 in src.z (this prevents shadow 3d / 2d array / cube targets from
790 using this instruction, but this is not needed).
806 dst = texture\_sample(unit, coord, lod)
809 .. opcode:: TXL2 - Texture Lookup With explicit LOD (for cube map arrays only)
811 this is the same as TXL, but uses another reg to encode the
813 Presumably shadow 3d / 2d array / cube targets could use
814 this encoding too, but this is not legal.
816 shadow cube map arrays are neither possible nor required.
826 dst = texture\_sample(unit, coord, lod)
829 .. opcode:: PUSHA - Push Address Register On Stack
838 Considered for cleanup.
842 Considered for removal.
844 .. opcode:: POPA - Pop Address Register From Stack
853 Considered for cleanup.
857 Considered for removal.
860 .. opcode:: CALLNZ - Subroutine Call If Not Zero
866 Considered for cleanup.
870 Considered for removal.
874 ^^^^^^^^^^^^^^^^^^^^^^^^
876 These opcodes are primarily provided for special-use computational shaders.
877 Support for these opcodes indicated by a special pipe capability bit (TBD).
879 XXX doesn't look like most of the opcodes really belong here.
881 .. opcode:: CEIL - Ceiling
885 dst.x = \lceil src.x\rceil
887 dst.y = \lceil src.y\rceil
889 dst.z = \lceil src.z\rceil
891 dst.w = \lceil src.w\rceil
894 .. opcode:: TRUNC - Truncate
907 .. opcode:: MOD - Modulus
911 dst.x = src0.x \bmod src1.x
913 dst.y = src0.y \bmod src1.y
915 dst.z = src0.z \bmod src1.z
917 dst.w = src0.w \bmod src1.w
920 .. opcode:: UARL - Integer Address Register Load
922 Moves the contents of the source register, assumed to be an integer, into the
923 destination register, which is assumed to be an address (ADDR) register.
926 .. opcode:: SAD - Sum Of Absolute Differences
930 dst.x = |src0.x - src1.x| + src2.x
932 dst.y = |src0.y - src1.y| + src2.y
934 dst.z = |src0.z - src1.z| + src2.z
936 dst.w = |src0.w - src1.w| + src2.w
939 .. opcode:: TXF - Texel Fetch
941 As per NV_gpu_shader4, extract a single texel from a specified texture
942 image. The source sampler may not be a CUBE or SHADOW. src 0 is a
943 four-component signed integer vector used to identify the single texel
944 accessed. 3 components + level. Just like texture instructions, an optional
945 offset vector is provided, which is subject to various driver restrictions
946 (regarding range, source of offsets). This instruction ignores the sampler
949 TXF(uint_vec coord, int_vec offset).
952 .. opcode:: TXF_LZ - Texel Fetch
954 This is the same as TXF with level = 0. Like TXF, it obeys
955 pipe_sampler_view::u.tex.first_level.
958 .. opcode:: TXQ - Texture Size Query
960 As per NV_gpu_program4, retrieve the dimensions of the texture depending on
961 the target. For 1D (width), 2D/RECT/CUBE (width, height), 3D (width, height,
962 depth), 1D array (width, layers), 2D array (width, height, layers).
963 Also return the number of accessible levels (last_level - first_level + 1)
966 For components which don't return a resource dimension, their value
973 dst.x = texture\_width(unit, lod)
975 dst.y = texture\_height(unit, lod)
977 dst.z = texture\_depth(unit, lod)
979 dst.w = texture\_levels(unit)
982 .. opcode:: TXQS - Texture Samples Query
984 This retrieves the number of samples in the texture, and stores it
985 into the x component. The other components are undefined.
989 dst.x = texture\_samples(unit)
992 .. opcode:: TG4 - Texture Gather
994 As per ARB_texture_gather, gathers the four texels to be used in a bi-linear
995 filtering operation and packs them into a single register. Only works with
996 2D, 2D array, cubemaps, and cubemaps arrays. For 2D textures, only the
997 addressing modes of the sampler and the top level of any mip pyramid are
998 used. Set W to zero. It behaves like the TEX instruction, but a filtered
999 sample is not generated. The four samples that contribute to filtering are
1000 placed into xyzw in clockwise order, starting with the (u,v) texture
1001 coordinate delta at the following locations (-, +), (+, +), (+, -), (-, -),
1002 where the magnitude of the deltas are half a texel.
1004 PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
1005 depth compares, single component selection, and a non-constant offset. It
1006 doesn't allow support for the GL independent offset to get i0,j0. This would
1007 require another CAP is hw can do it natively. For now we lower that before
1016 dst = texture\_gather4 (unit, coord, component)
1018 (with SM5 - cube array shadow)
1026 dst = texture\_gather (uint, coord, compare)
1028 .. opcode:: LODQ - level of detail query
1030 Compute the LOD information that the texture pipe would use to access the
1031 texture. The Y component contains the computed LOD lambda_prime. The X
1032 component contains the LOD that will be accessed, based on min/max lod's
1039 dst.xy = lodq(uint, coord);
1041 .. opcode:: CLOCK - retrieve the current shader time
1043 Invoking this instruction multiple times in the same shader should
1044 cause monotonically increasing values to be returned. The values
1045 are implicitly 64-bit, so if fewer than 64 bits of precision are
1046 available, to provide expected wraparound semantics, the value
1047 should be shifted up so that the most significant bit of the time
1048 is the most significant bit of the 64-bit value.
1056 ^^^^^^^^^^^^^^^^^^^^^^^^
1057 These opcodes are used for integer operations.
1058 Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
1061 .. opcode:: I2F - Signed Integer To Float
1063 Rounding is unspecified (round to nearest even suggested).
1067 dst.x = (float) src.x
1069 dst.y = (float) src.y
1071 dst.z = (float) src.z
1073 dst.w = (float) src.w
1076 .. opcode:: U2F - Unsigned Integer To Float
1078 Rounding is unspecified (round to nearest even suggested).
1082 dst.x = (float) src.x
1084 dst.y = (float) src.y
1086 dst.z = (float) src.z
1088 dst.w = (float) src.w
1091 .. opcode:: F2I - Float to Signed Integer
1093 Rounding is towards zero (truncate).
1094 Values outside signed range (including NaNs) produce undefined results.
1107 .. opcode:: F2U - Float to Unsigned Integer
1109 Rounding is towards zero (truncate).
1110 Values outside unsigned range (including NaNs) produce undefined results.
1114 dst.x = (unsigned) src.x
1116 dst.y = (unsigned) src.y
1118 dst.z = (unsigned) src.z
1120 dst.w = (unsigned) src.w
1123 .. opcode:: UADD - Integer Add
1125 This instruction works the same for signed and unsigned integers.
1126 The low 32bit of the result is returned.
1130 dst.x = src0.x + src1.x
1132 dst.y = src0.y + src1.y
1134 dst.z = src0.z + src1.z
1136 dst.w = src0.w + src1.w
1139 .. opcode:: UMAD - Integer Multiply And Add
1141 This instruction works the same for signed and unsigned integers.
1142 The multiplication returns the low 32bit (as does the result itself).
1146 dst.x = src0.x \times src1.x + src2.x
1148 dst.y = src0.y \times src1.y + src2.y
1150 dst.z = src0.z \times src1.z + src2.z
1152 dst.w = src0.w \times src1.w + src2.w
1155 .. opcode:: UMUL - Integer Multiply
1157 This instruction works the same for signed and unsigned integers.
1158 The low 32bit of the result is returned.
1162 dst.x = src0.x \times src1.x
1164 dst.y = src0.y \times src1.y
1166 dst.z = src0.z \times src1.z
1168 dst.w = src0.w \times src1.w
1171 .. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1173 The high 32bits of the multiplication of 2 signed integers are returned.
1177 dst.x = (src0.x \times src1.x) >> 32
1179 dst.y = (src0.y \times src1.y) >> 32
1181 dst.z = (src0.z \times src1.z) >> 32
1183 dst.w = (src0.w \times src1.w) >> 32
1186 .. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1188 The high 32bits of the multiplication of 2 unsigned integers are returned.
1192 dst.x = (src0.x \times src1.x) >> 32
1194 dst.y = (src0.y \times src1.y) >> 32
1196 dst.z = (src0.z \times src1.z) >> 32
1198 dst.w = (src0.w \times src1.w) >> 32
1201 .. opcode:: IDIV - Signed Integer Division
1203 TBD: behavior for division by zero.
1207 dst.x = \frac{src0.x}{src1.x}
1209 dst.y = \frac{src0.y}{src1.y}
1211 dst.z = \frac{src0.z}{src1.z}
1213 dst.w = \frac{src0.w}{src1.w}
1216 .. opcode:: UDIV - Unsigned Integer Division
1218 For division by zero, 0xffffffff is returned.
1222 dst.x = \frac{src0.x}{src1.x}
1224 dst.y = \frac{src0.y}{src1.y}
1226 dst.z = \frac{src0.z}{src1.z}
1228 dst.w = \frac{src0.w}{src1.w}
1231 .. opcode:: UMOD - Unsigned Integer Remainder
1233 If second arg is zero, 0xffffffff is returned.
1237 dst.x = src0.x \bmod src1.x
1239 dst.y = src0.y \bmod src1.y
1241 dst.z = src0.z \bmod src1.z
1243 dst.w = src0.w \bmod src1.w
1246 .. opcode:: NOT - Bitwise Not
1259 .. opcode:: AND - Bitwise And
1263 dst.x = src0.x \& src1.x
1265 dst.y = src0.y \& src1.y
1267 dst.z = src0.z \& src1.z
1269 dst.w = src0.w \& src1.w
1272 .. opcode:: OR - Bitwise Or
1276 dst.x = src0.x | src1.x
1278 dst.y = src0.y | src1.y
1280 dst.z = src0.z | src1.z
1282 dst.w = src0.w | src1.w
1285 .. opcode:: XOR - Bitwise Xor
1289 dst.x = src0.x \oplus src1.x
1291 dst.y = src0.y \oplus src1.y
1293 dst.z = src0.z \oplus src1.z
1295 dst.w = src0.w \oplus src1.w
1298 .. opcode:: IMAX - Maximum of Signed Integers
1302 dst.x = max(src0.x, src1.x)
1304 dst.y = max(src0.y, src1.y)
1306 dst.z = max(src0.z, src1.z)
1308 dst.w = max(src0.w, src1.w)
1311 .. opcode:: UMAX - Maximum of Unsigned Integers
1315 dst.x = max(src0.x, src1.x)
1317 dst.y = max(src0.y, src1.y)
1319 dst.z = max(src0.z, src1.z)
1321 dst.w = max(src0.w, src1.w)
1324 .. opcode:: IMIN - Minimum of Signed Integers
1328 dst.x = min(src0.x, src1.x)
1330 dst.y = min(src0.y, src1.y)
1332 dst.z = min(src0.z, src1.z)
1334 dst.w = min(src0.w, src1.w)
1337 .. opcode:: UMIN - Minimum of Unsigned Integers
1341 dst.x = min(src0.x, src1.x)
1343 dst.y = min(src0.y, src1.y)
1345 dst.z = min(src0.z, src1.z)
1347 dst.w = min(src0.w, src1.w)
1350 .. opcode:: SHL - Shift Left
1352 The shift count is masked with 0x1f before the shift is applied.
1356 dst.x = src0.x << (0x1f \& src1.x)
1358 dst.y = src0.y << (0x1f \& src1.y)
1360 dst.z = src0.z << (0x1f \& src1.z)
1362 dst.w = src0.w << (0x1f \& src1.w)
1365 .. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1367 The shift count is masked with 0x1f before the shift is applied.
1371 dst.x = src0.x >> (0x1f \& src1.x)
1373 dst.y = src0.y >> (0x1f \& src1.y)
1375 dst.z = src0.z >> (0x1f \& src1.z)
1377 dst.w = src0.w >> (0x1f \& src1.w)
1380 .. opcode:: USHR - Logical Shift Right
1382 The shift count is masked with 0x1f before the shift is applied.
1386 dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1388 dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1390 dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1392 dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
1395 .. opcode:: UCMP - Integer Conditional Move
1399 dst.x = src0.x ? src1.x : src2.x
1401 dst.y = src0.y ? src1.y : src2.y
1403 dst.z = src0.z ? src1.z : src2.z
1405 dst.w = src0.w ? src1.w : src2.w
1409 .. opcode:: ISSG - Integer Set Sign
1413 dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1415 dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1417 dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1419 dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1423 .. opcode:: FSLT - Float Set On Less Than (ordered)
1425 Same comparison as SLT but returns integer instead of 1.0/0.0 float
1429 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1431 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1433 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1435 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1438 .. opcode:: ISLT - Signed Integer Set On Less Than
1442 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1444 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1446 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1448 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1451 .. opcode:: USLT - Unsigned Integer Set On Less Than
1455 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1457 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1459 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1461 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1464 .. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1466 Same comparison as SGE but returns integer instead of 1.0/0.0 float
1470 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1472 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1474 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1476 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1479 .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1483 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1485 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1487 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1489 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1492 .. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1496 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1498 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1500 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1502 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1505 .. opcode:: FSEQ - Float Set On Equal (ordered)
1507 Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1511 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1513 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1515 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1517 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1520 .. opcode:: USEQ - Integer Set On Equal
1524 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1526 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1528 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1530 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1533 .. opcode:: FSNE - Float Set On Not Equal (unordered)
1535 Same comparison as SNE but returns integer instead of 1.0/0.0 float
1539 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1541 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1543 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1545 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1548 .. opcode:: USNE - Integer Set On Not Equal
1552 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1554 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1556 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1558 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1561 .. opcode:: INEG - Integer Negate
1576 .. opcode:: IABS - Integer Absolute Value
1590 These opcodes are used for bit-level manipulation of integers.
1592 .. opcode:: IBFE - Signed Bitfield Extract
1594 Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
1595 sign-extends them if the high bit of the extracted window is set.
1599 def ibfe(value, offset, bits):
1600 if offset < 0 or bits < 0 or offset + bits > 32:
1602 if bits == 0: return 0
1603 # Note: >> sign-extends
1604 return (value << (32 - offset - bits)) >> (32 - bits)
1606 .. opcode:: UBFE - Unsigned Bitfield Extract
1608 Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
1613 def ubfe(value, offset, bits):
1614 if offset < 0 or bits < 0 or offset + bits > 32:
1616 if bits == 0: return 0
1617 # Note: >> does not sign-extend
1618 return (value << (32 - offset - bits)) >> (32 - bits)
1620 .. opcode:: BFI - Bitfield Insert
1622 Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
1627 def bfi(base, insert, offset, bits):
1628 if offset < 0 or bits < 0 or offset + bits > 32:
1630 # << defined such that mask == ~0 when bits == 32, offset == 0
1631 mask = ((1 << bits) - 1) << offset
1632 return ((insert << offset) & mask) | (base & ~mask)
1634 .. opcode:: BREV - Bitfield Reverse
1636 See SM5 instruction BFREV. Reverses the bits of the argument.
1638 .. opcode:: POPC - Population Count
1640 See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1642 .. opcode:: LSB - Index of lowest set bit
1644 See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1645 bit of the argument. Returns -1 if none are set.
1647 .. opcode:: IMSB - Index of highest non-sign bit
1649 See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1650 non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1651 highest 1 bit for positive numbers). Returns -1 if all bits are the same
1652 (i.e. for inputs 0 and -1).
1654 .. opcode:: UMSB - Index of highest set bit
1656 See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1657 set bit of the argument. Returns -1 if none are set.
1660 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1662 These opcodes are only supported in geometry shaders; they have no meaning
1663 in any other type of shader.
1665 .. opcode:: EMIT - Emit
1667 Generate a new vertex for the current primitive into the specified vertex
1668 stream using the values in the output registers.
1671 .. opcode:: ENDPRIM - End Primitive
1673 Complete the current primitive in the specified vertex stream (consisting of
1674 the emitted vertices), and start a new one.
1680 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1681 opcodes is determined by a special capability bit, ``GLSL``.
1682 Some require glsl version 1.30 (UIF/BREAKC/SWITCH/CASE/DEFAULT/ENDSWITCH).
1684 .. opcode:: CAL - Subroutine Call
1690 .. opcode:: RET - Subroutine Call Return
1695 .. opcode:: CONT - Continue
1697 Unconditionally moves the point of execution to the instruction after the
1698 last bgnloop. The instruction must appear within a bgnloop/endloop.
1702 Support for CONT is determined by a special capability bit,
1703 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1706 .. opcode:: BGNLOOP - Begin a Loop
1708 Start a loop. Must have a matching endloop.
1711 .. opcode:: BGNSUB - Begin Subroutine
1713 Starts definition of a subroutine. Must have a matching endsub.
1716 .. opcode:: ENDLOOP - End a Loop
1718 End a loop started with bgnloop.
1721 .. opcode:: ENDSUB - End Subroutine
1723 Ends definition of a subroutine.
1726 .. opcode:: NOP - No Operation
1731 .. opcode:: BRK - Break
1733 Unconditionally moves the point of execution to the instruction after the
1734 next endloop or endswitch. The instruction must appear within a loop/endloop
1735 or switch/endswitch.
1738 .. opcode:: BREAKC - Break Conditional
1740 Conditionally moves the point of execution to the instruction after the
1741 next endloop or endswitch. The instruction must appear within a loop/endloop
1742 or switch/endswitch.
1743 Condition evaluates to true if src0.x != 0 where src0.x is interpreted
1744 as an integer register.
1748 Considered for removal as it's quite inconsistent wrt other opcodes
1749 (could emulate with UIF/BRK/ENDIF).
1752 .. opcode:: IF - Float If
1754 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
1758 where src0.x is interpreted as a floating point register.
1761 .. opcode:: UIF - Bitwise If
1763 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1767 where src0.x is interpreted as an integer register.
1770 .. opcode:: ELSE - Else
1772 Starts an else block, after an IF or UIF statement.
1775 .. opcode:: ENDIF - End If
1777 Ends an IF or UIF block.
1780 .. opcode:: SWITCH - Switch
1782 Starts a C-style switch expression. The switch consists of one or multiple
1783 CASE statements, and at most one DEFAULT statement. Execution of a statement
1784 ends when a BRK is hit, but just like in C falling through to other cases
1785 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
1786 just as last statement, and fallthrough is allowed into/from it.
1787 CASE src arguments are evaluated at bit level against the SWITCH src argument.
1793 (some instructions here)
1796 (some instructions here)
1799 (some instructions here)
1804 .. opcode:: CASE - Switch case
1806 This represents a switch case label. The src arg must be an integer immediate.
1809 .. opcode:: DEFAULT - Switch default
1811 This represents the default case in the switch, which is taken if no other
1815 .. opcode:: ENDSWITCH - End of switch
1817 Ends a switch expression.
1823 The interpolation instructions allow an input to be interpolated in a
1824 different way than its declaration. This corresponds to the GLSL 4.00
1825 interpolateAt* functions. The first argument of each of these must come from
1826 ``TGSI_FILE_INPUT``.
1828 .. opcode:: INTERP_CENTROID - Interpolate at the centroid
1830 Interpolates the varying specified by src0 at the centroid
1832 .. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
1834 Interpolates the varying specified by src0 at the sample id specified by
1835 src1.x (interpreted as an integer)
1837 .. opcode:: INTERP_OFFSET - Interpolate at the specified offset
1839 Interpolates the varying specified by src0 at the offset src1.xy from the
1840 pixel center (interpreted as floats)
1848 The double-precision opcodes reinterpret four-component vectors into
1849 two-component vectors with doubled precision in each component.
1851 .. opcode:: DABS - Absolute
1859 .. opcode:: DADD - Add
1863 dst.xy = src0.xy + src1.xy
1865 dst.zw = src0.zw + src1.zw
1867 .. opcode:: DSEQ - Set on Equal
1871 dst.x = src0.xy == src1.xy ? \sim 0 : 0
1873 dst.z = src0.zw == src1.zw ? \sim 0 : 0
1875 .. opcode:: DSNE - Set on Equal
1879 dst.x = src0.xy != src1.xy ? \sim 0 : 0
1881 dst.z = src0.zw != src1.zw ? \sim 0 : 0
1883 .. opcode:: DSLT - Set on Less than
1887 dst.x = src0.xy < src1.xy ? \sim 0 : 0
1889 dst.z = src0.zw < src1.zw ? \sim 0 : 0
1891 .. opcode:: DSGE - Set on Greater equal
1895 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
1897 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
1899 .. opcode:: DFRAC - Fraction
1903 dst.xy = src.xy - \lfloor src.xy\rfloor
1905 dst.zw = src.zw - \lfloor src.zw\rfloor
1907 .. opcode:: DTRUNC - Truncate
1911 dst.xy = trunc(src.xy)
1913 dst.zw = trunc(src.zw)
1915 .. opcode:: DCEIL - Ceiling
1919 dst.xy = \lceil src.xy\rceil
1921 dst.zw = \lceil src.zw\rceil
1923 .. opcode:: DFLR - Floor
1927 dst.xy = \lfloor src.xy\rfloor
1929 dst.zw = \lfloor src.zw\rfloor
1931 .. opcode:: DROUND - Fraction
1935 dst.xy = round(src.xy)
1937 dst.zw = round(src.zw)
1939 .. opcode:: DSSG - Set Sign
1943 dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
1945 dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
1947 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1949 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1950 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1951 :math:`dst1 \times 2^{dst0} = src` .
1955 dst0.xy = exp(src.xy)
1957 dst1.xy = frac(src.xy)
1959 dst0.zw = exp(src.zw)
1961 dst1.zw = frac(src.zw)
1963 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1965 This opcode is the inverse of :opcode:`DFRACEXP`. The second
1966 source is an integer.
1970 dst.xy = src0.xy \times 2^{src1.x}
1972 dst.zw = src0.zw \times 2^{src1.y}
1974 .. opcode:: DMIN - Minimum
1978 dst.xy = min(src0.xy, src1.xy)
1980 dst.zw = min(src0.zw, src1.zw)
1982 .. opcode:: DMAX - Maximum
1986 dst.xy = max(src0.xy, src1.xy)
1988 dst.zw = max(src0.zw, src1.zw)
1990 .. opcode:: DMUL - Multiply
1994 dst.xy = src0.xy \times src1.xy
1996 dst.zw = src0.zw \times src1.zw
1999 .. opcode:: DMAD - Multiply And Add
2003 dst.xy = src0.xy \times src1.xy + src2.xy
2005 dst.zw = src0.zw \times src1.zw + src2.zw
2008 .. opcode:: DFMA - Fused Multiply-Add
2010 Perform a * b + c with no intermediate rounding step.
2014 dst.xy = src0.xy \times src1.xy + src2.xy
2016 dst.zw = src0.zw \times src1.zw + src2.zw
2019 .. opcode:: DDIV - Divide
2023 dst.xy = \frac{src0.xy}{src1.xy}
2025 dst.zw = \frac{src0.zw}{src1.zw}
2028 .. opcode:: DRCP - Reciprocal
2032 dst.xy = \frac{1}{src.xy}
2034 dst.zw = \frac{1}{src.zw}
2036 .. opcode:: DSQRT - Square Root
2040 dst.xy = \sqrt{src.xy}
2042 dst.zw = \sqrt{src.zw}
2044 .. opcode:: DRSQ - Reciprocal Square Root
2048 dst.xy = \frac{1}{\sqrt{src.xy}}
2050 dst.zw = \frac{1}{\sqrt{src.zw}}
2052 .. opcode:: F2D - Float to Double
2056 dst.xy = double(src0.x)
2058 dst.zw = double(src0.y)
2060 .. opcode:: D2F - Double to Float
2064 dst.x = float(src0.xy)
2066 dst.y = float(src0.zw)
2068 .. opcode:: I2D - Int to Double
2072 dst.xy = double(src0.x)
2074 dst.zw = double(src0.y)
2076 .. opcode:: D2I - Double to Int
2080 dst.x = int(src0.xy)
2082 dst.y = int(src0.zw)
2084 .. opcode:: U2D - Unsigned Int to Double
2088 dst.xy = double(src0.x)
2090 dst.zw = double(src0.y)
2092 .. opcode:: D2U - Double to Unsigned Int
2096 dst.x = unsigned(src0.xy)
2098 dst.y = unsigned(src0.zw)
2103 The 64-bit integer opcodes reinterpret four-component vectors into
2104 two-component vectors with 64-bits in each component.
2106 .. opcode:: I64ABS - 64-bit Integer Absolute Value
2114 .. opcode:: I64NEG - 64-bit Integer Negate
2124 .. opcode:: I64SSG - 64-bit Integer Set Sign
2128 dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
2130 dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
2132 .. opcode:: U64ADD - 64-bit Integer Add
2136 dst.xy = src0.xy + src1.xy
2138 dst.zw = src0.zw + src1.zw
2140 .. opcode:: U64MUL - 64-bit Integer Multiply
2144 dst.xy = src0.xy * src1.xy
2146 dst.zw = src0.zw * src1.zw
2148 .. opcode:: U64SEQ - 64-bit Integer Set on Equal
2152 dst.x = src0.xy == src1.xy ? \sim 0 : 0
2154 dst.z = src0.zw == src1.zw ? \sim 0 : 0
2156 .. opcode:: U64SNE - 64-bit Integer Set on Not Equal
2160 dst.x = src0.xy != src1.xy ? \sim 0 : 0
2162 dst.z = src0.zw != src1.zw ? \sim 0 : 0
2164 .. opcode:: U64SLT - 64-bit Unsigned Integer Set on Less Than
2168 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2170 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2172 .. opcode:: U64SGE - 64-bit Unsigned Integer Set on Greater Equal
2176 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2178 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2180 .. opcode:: I64SLT - 64-bit Signed Integer Set on Less Than
2184 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2186 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2188 .. opcode:: I64SGE - 64-bit Signed Integer Set on Greater Equal
2192 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2194 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2196 .. opcode:: I64MIN - Minimum of 64-bit Signed Integers
2200 dst.xy = min(src0.xy, src1.xy)
2202 dst.zw = min(src0.zw, src1.zw)
2204 .. opcode:: U64MIN - Minimum of 64-bit Unsigned Integers
2208 dst.xy = min(src0.xy, src1.xy)
2210 dst.zw = min(src0.zw, src1.zw)
2212 .. opcode:: I64MAX - Maximum of 64-bit Signed Integers
2216 dst.xy = max(src0.xy, src1.xy)
2218 dst.zw = max(src0.zw, src1.zw)
2220 .. opcode:: U64MAX - Maximum of 64-bit Unsigned Integers
2224 dst.xy = max(src0.xy, src1.xy)
2226 dst.zw = max(src0.zw, src1.zw)
2228 .. opcode:: U64SHL - Shift Left 64-bit Unsigned Integer
2230 The shift count is masked with 0x3f before the shift is applied.
2234 dst.xy = src0.xy << (0x3f \& src1.x)
2236 dst.zw = src0.zw << (0x3f \& src1.y)
2238 .. opcode:: I64SHR - Arithmetic Shift Right (of 64-bit Signed Integer)
2240 The shift count is masked with 0x3f before the shift is applied.
2244 dst.xy = src0.xy >> (0x3f \& src1.x)
2246 dst.zw = src0.zw >> (0x3f \& src1.y)
2248 .. opcode:: U64SHR - Logical Shift Right (of 64-bit Unsigned Integer)
2250 The shift count is masked with 0x3f before the shift is applied.
2254 dst.xy = src0.xy >> (unsigned) (0x3f \& src1.x)
2256 dst.zw = src0.zw >> (unsigned) (0x3f \& src1.y)
2258 .. opcode:: I64DIV - 64-bit Signed Integer Division
2262 dst.xy = \frac{src0.xy}{src1.xy}
2264 dst.zw = \frac{src0.zw}{src1.zw}
2266 .. opcode:: U64DIV - 64-bit Unsigned Integer Division
2270 dst.xy = \frac{src0.xy}{src1.xy}
2272 dst.zw = \frac{src0.zw}{src1.zw}
2274 .. opcode:: U64MOD - 64-bit Unsigned Integer Remainder
2278 dst.xy = src0.xy \bmod src1.xy
2280 dst.zw = src0.zw \bmod src1.zw
2282 .. opcode:: I64MOD - 64-bit Signed Integer Remainder
2286 dst.xy = src0.xy \bmod src1.xy
2288 dst.zw = src0.zw \bmod src1.zw
2290 .. opcode:: F2U64 - Float to 64-bit Unsigned Int
2294 dst.xy = (uint64_t) src0.x
2296 dst.zw = (uint64_t) src0.y
2298 .. opcode:: F2I64 - Float to 64-bit Int
2302 dst.xy = (int64_t) src0.x
2304 dst.zw = (int64_t) src0.y
2306 .. opcode:: U2I64 - Unsigned Integer to 64-bit Integer
2308 This is a zero extension.
2312 dst.xy = (uint64_t) src0.x
2314 dst.zw = (uint64_t) src0.y
2316 .. opcode:: I2I64 - Signed Integer to 64-bit Integer
2318 This is a sign extension.
2322 dst.xy = (int64_t) src0.x
2324 dst.zw = (int64_t) src0.y
2326 .. opcode:: D2U64 - Double to 64-bit Unsigned Int
2330 dst.xy = (uint64_t) src0.xy
2332 dst.zw = (uint64_t) src0.zw
2334 .. opcode:: D2I64 - Double to 64-bit Int
2338 dst.xy = (int64_t) src0.xy
2340 dst.zw = (int64_t) src0.zw
2342 .. opcode:: U642F - 64-bit unsigned integer to float
2346 dst.x = (float) src0.xy
2348 dst.y = (float) src0.zw
2350 .. opcode:: I642F - 64-bit Int to Float
2354 dst.x = (float) src0.xy
2356 dst.y = (float) src0.zw
2358 .. opcode:: U642D - 64-bit unsigned integer to double
2362 dst.xy = (double) src0.xy
2364 dst.zw = (double) src0.zw
2366 .. opcode:: I642D - 64-bit Int to double
2370 dst.xy = (double) src0.xy
2372 dst.zw = (double) src0.zw
2374 .. _samplingopcodes:
2376 Resource Sampling Opcodes
2377 ^^^^^^^^^^^^^^^^^^^^^^^^^
2379 Those opcodes follow very closely semantics of the respective Direct3D
2380 instructions. If in doubt double check Direct3D documentation.
2381 Note that the swizzle on SVIEW (src1) determines texel swizzling
2386 Using provided address, sample data from the specified texture using the
2387 filtering mode identified by the given sampler. The source data may come from
2388 any resource type other than buffers.
2390 Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2392 Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2394 .. opcode:: SAMPLE_I
2396 Simplified alternative to the SAMPLE instruction. Using the provided
2397 integer address, SAMPLE_I fetches data from the specified sampler view
2398 without any filtering. The source data may come from any resource type
2401 Syntax: ``SAMPLE_I dst, address, sampler_view``
2403 Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2405 The 'address' is specified as unsigned integers. If the 'address' is out of
2406 range [0...(# texels - 1)] the result of the fetch is always 0 in all
2407 components. As such the instruction doesn't honor address wrap modes, in
2408 cases where that behavior is desirable 'SAMPLE' instruction should be used.
2409 address.w always provides an unsigned integer mipmap level. If the value is
2410 out of the range then the instruction always returns 0 in all components.
2411 address.yz are ignored for buffers and 1d textures. address.z is ignored
2412 for 1d texture arrays and 2d textures.
2414 For 1D texture arrays address.y provides the array index (also as unsigned
2415 integer). If the value is out of the range of available array indices
2416 [0... (array size - 1)] then the opcode always returns 0 in all components.
2417 For 2D texture arrays address.z provides the array index, otherwise it
2418 exhibits the same behavior as in the case for 1D texture arrays. The exact
2419 semantics of the source address are presented in the table below:
2421 +---------------------------+----+-----+-----+---------+
2422 | resource type | X | Y | Z | W |
2423 +===========================+====+=====+=====+=========+
2424 | ``PIPE_BUFFER`` | x | | | ignored |
2425 +---------------------------+----+-----+-----+---------+
2426 | ``PIPE_TEXTURE_1D`` | x | | | mpl |
2427 +---------------------------+----+-----+-----+---------+
2428 | ``PIPE_TEXTURE_2D`` | x | y | | mpl |
2429 +---------------------------+----+-----+-----+---------+
2430 | ``PIPE_TEXTURE_3D`` | x | y | z | mpl |
2431 +---------------------------+----+-----+-----+---------+
2432 | ``PIPE_TEXTURE_RECT`` | x | y | | mpl |
2433 +---------------------------+----+-----+-----+---------+
2434 | ``PIPE_TEXTURE_CUBE`` | not allowed as source |
2435 +---------------------------+----+-----+-----+---------+
2436 | ``PIPE_TEXTURE_1D_ARRAY`` | x | idx | | mpl |
2437 +---------------------------+----+-----+-----+---------+
2438 | ``PIPE_TEXTURE_2D_ARRAY`` | x | y | idx | mpl |
2439 +---------------------------+----+-----+-----+---------+
2441 Where 'mpl' is a mipmap level and 'idx' is the array index.
2443 .. opcode:: SAMPLE_I_MS
2445 Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2447 Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2449 .. opcode:: SAMPLE_B
2451 Just like the SAMPLE instruction with the exception that an additional bias
2452 is applied to the level of detail computed as part of the instruction
2455 Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2457 Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2459 .. opcode:: SAMPLE_C
2461 Similar to the SAMPLE instruction but it performs a comparison filter. The
2462 operands to SAMPLE_C are identical to SAMPLE, except that there is an
2463 additional float32 operand, reference value, which must be a register with
2464 single-component, or a scalar literal. SAMPLE_C makes the hardware use the
2465 current samplers compare_func (in pipe_sampler_state) to compare reference
2466 value against the red component value for the surce resource at each texel
2467 that the currently configured texture filter covers based on the provided
2470 Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2472 Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2474 .. opcode:: SAMPLE_C_LZ
2476 Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2479 Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2481 Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2484 .. opcode:: SAMPLE_D
2486 SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2487 the source address in the x direction and the y direction are provided by
2490 Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2492 Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2494 .. opcode:: SAMPLE_L
2496 SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2497 directly as a scalar value, representing no anisotropy.
2499 Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2501 Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2505 Gathers the four texels to be used in a bi-linear filtering operation and
2506 packs them into a single register. Only works with 2D, 2D array, cubemaps,
2507 and cubemaps arrays. For 2D textures, only the addressing modes of the
2508 sampler and the top level of any mip pyramid are used. Set W to zero. It
2509 behaves like the SAMPLE instruction, but a filtered sample is not
2510 generated. The four samples that contribute to filtering are placed into
2511 xyzw in counter-clockwise order, starting with the (u,v) texture coordinate
2512 delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2513 magnitude of the deltas are half a texel.
2516 .. opcode:: SVIEWINFO
2518 Query the dimensions of a given sampler view. dst receives width, height,
2519 depth or array size and number of mipmap levels as int4. The dst can have a
2520 writemask which will specify what info is the caller interested in.
2522 Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2524 Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2526 src_mip_level is an unsigned integer scalar. If it's out of range then
2527 returns 0 for width, height and depth/array size but the total number of
2528 mipmap is still returned correctly for the given sampler view. The returned
2529 width, height and depth values are for the mipmap level selected by the
2530 src_mip_level and are in the number of texels. For 1d texture array width
2531 is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2532 still in dst.w. In contrast to d3d10 resinfo, there's no way in the tgsi
2533 instruction encoding to specify the return type (float/rcpfloat/uint), hence
2534 always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2535 resinfo allowing swizzling dst values is ignored (due to the interaction
2536 with rcpfloat modifier which requires some swizzle handling in the state
2539 .. opcode:: SAMPLE_POS
2541 Query the position of a given sample. dst receives float4 (x, y, 0, 0)
2542 indicated where the sample is located. If the resource is not a multi-sample
2543 resource and not a render target, the result is 0.
2545 .. opcode:: SAMPLE_INFO
2547 dst receives number of samples in x. If the resource is not a multi-sample
2548 resource and not a render target, the result is 0.
2551 .. _resourceopcodes:
2553 Resource Access Opcodes
2554 ^^^^^^^^^^^^^^^^^^^^^^^
2556 For these opcodes, the resource can be a BUFFER, IMAGE, or MEMORY.
2558 .. opcode:: LOAD - Fetch data from a shader buffer or image
2560 Syntax: ``LOAD dst, resource, address``
2562 Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
2564 Using the provided integer address, LOAD fetches data
2565 from the specified buffer or texture without any
2568 The 'address' is specified as a vector of unsigned
2569 integers. If the 'address' is out of range the result
2572 Only the first mipmap level of a resource can be read
2573 from using this instruction.
2575 For 1D or 2D texture arrays, the array index is
2576 provided as an unsigned integer in address.y or
2577 address.z, respectively. address.yz are ignored for
2578 buffers and 1D textures. address.z is ignored for 1D
2579 texture arrays and 2D textures. address.w is always
2582 A swizzle suffix may be added to the resource argument
2583 this will cause the resource data to be swizzled accordingly.
2585 .. opcode:: STORE - Write data to a shader resource
2587 Syntax: ``STORE resource, address, src``
2589 Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
2591 Using the provided integer address, STORE writes data
2592 to the specified buffer or texture.
2594 The 'address' is specified as a vector of unsigned
2595 integers. If the 'address' is out of range the result
2598 Only the first mipmap level of a resource can be
2599 written to using this instruction.
2601 For 1D or 2D texture arrays, the array index is
2602 provided as an unsigned integer in address.y or
2603 address.z, respectively. address.yz are ignored for
2604 buffers and 1D textures. address.z is ignored for 1D
2605 texture arrays and 2D textures. address.w is always
2608 .. opcode:: RESQ - Query information about a resource
2610 Syntax: ``RESQ dst, resource``
2612 Example: ``RESQ TEMP[0], BUFFER[0]``
2614 Returns information about the buffer or image resource. For buffer
2615 resources, the size (in bytes) is returned in the x component. For
2616 image resources, .xyz will contain the width/height/layers of the
2617 image, while .w will contain the number of samples for multi-sampled
2620 .. opcode:: FBFETCH - Load data from framebuffer
2622 Syntax: ``FBFETCH dst, output``
2624 Example: ``FBFETCH TEMP[0], OUT[0]``
2626 This is only valid on ``COLOR`` semantic outputs. Returns the color
2627 of the current position in the framebuffer from before this fragment
2628 shader invocation. May return the same value from multiple calls for
2629 a particular output within a single invocation. Note that result may
2630 be undefined if a fragment is drawn multiple times without a blend
2634 .. _threadsyncopcodes:
2636 Inter-thread synchronization opcodes
2637 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2639 These opcodes are intended for communication between threads running
2640 within the same compute grid. For now they're only valid in compute
2643 .. opcode:: MFENCE - Memory fence
2645 Syntax: ``MFENCE resource``
2647 Example: ``MFENCE RES[0]``
2649 This opcode forces strong ordering between any memory access
2650 operations that affect the specified resource. This means that
2651 previous loads and stores (and only those) will be performed and
2652 visible to other threads before the program execution continues.
2655 .. opcode:: LFENCE - Load memory fence
2657 Syntax: ``LFENCE resource``
2659 Example: ``LFENCE RES[0]``
2661 Similar to MFENCE, but it only affects the ordering of memory loads.
2664 .. opcode:: SFENCE - Store memory fence
2666 Syntax: ``SFENCE resource``
2668 Example: ``SFENCE RES[0]``
2670 Similar to MFENCE, but it only affects the ordering of memory stores.
2673 .. opcode:: BARRIER - Thread group barrier
2677 This opcode suspends the execution of the current thread until all
2678 the remaining threads in the working group reach the same point of
2679 the program. Results are unspecified if any of the remaining
2680 threads terminates or never reaches an executed BARRIER instruction.
2682 .. opcode:: MEMBAR - Memory barrier
2686 This opcode waits for the completion of all memory accesses based on
2687 the type passed in. The type is an immediate bitfield with the following
2690 Bit 0: Shader storage buffers
2691 Bit 1: Atomic buffers
2693 Bit 3: Shared memory
2696 These may be passed in in any combination. An implementation is free to not
2697 distinguish between these as it sees fit. However these map to all the
2698 possibilities made available by GLSL.
2705 These opcodes provide atomic variants of some common arithmetic and
2706 logical operations. In this context atomicity means that another
2707 concurrent memory access operation that affects the same memory
2708 location is guaranteed to be performed strictly before or after the
2709 entire execution of the atomic operation. The resource may be a BUFFER,
2710 IMAGE, or MEMORY. In the case of an image, the offset works the same as for
2711 ``LOAD`` and ``STORE``, specified above. These atomic operations may
2712 only be used with 32-bit integer image formats.
2714 .. opcode:: ATOMUADD - Atomic integer addition
2716 Syntax: ``ATOMUADD dst, resource, offset, src``
2718 Example: ``ATOMUADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2720 The following operation is performed atomically:
2724 dst_x = resource[offset]
2726 resource[offset] = dst_x + src_x
2729 .. opcode:: ATOMXCHG - Atomic exchange
2731 Syntax: ``ATOMXCHG dst, resource, offset, src``
2733 Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2735 The following operation is performed atomically:
2739 dst_x = resource[offset]
2741 resource[offset] = src_x
2744 .. opcode:: ATOMCAS - Atomic compare-and-exchange
2746 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2748 Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
2750 The following operation is performed atomically:
2754 dst_x = resource[offset]
2756 resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
2759 .. opcode:: ATOMAND - Atomic bitwise And
2761 Syntax: ``ATOMAND dst, resource, offset, src``
2763 Example: ``ATOMAND TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2765 The following operation is performed atomically:
2769 dst_x = resource[offset]
2771 resource[offset] = dst_x \& src_x
2774 .. opcode:: ATOMOR - Atomic bitwise Or
2776 Syntax: ``ATOMOR dst, resource, offset, src``
2778 Example: ``ATOMOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2780 The following operation is performed atomically:
2784 dst_x = resource[offset]
2786 resource[offset] = dst_x | src_x
2789 .. opcode:: ATOMXOR - Atomic bitwise Xor
2791 Syntax: ``ATOMXOR dst, resource, offset, src``
2793 Example: ``ATOMXOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2795 The following operation is performed atomically:
2799 dst_x = resource[offset]
2801 resource[offset] = dst_x \oplus src_x
2804 .. opcode:: ATOMUMIN - Atomic unsigned minimum
2806 Syntax: ``ATOMUMIN dst, resource, offset, src``
2808 Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2810 The following operation is performed atomically:
2814 dst_x = resource[offset]
2816 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2819 .. opcode:: ATOMUMAX - Atomic unsigned maximum
2821 Syntax: ``ATOMUMAX dst, resource, offset, src``
2823 Example: ``ATOMUMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2825 The following operation is performed atomically:
2829 dst_x = resource[offset]
2831 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2834 .. opcode:: ATOMIMIN - Atomic signed minimum
2836 Syntax: ``ATOMIMIN dst, resource, offset, src``
2838 Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2840 The following operation is performed atomically:
2844 dst_x = resource[offset]
2846 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2849 .. opcode:: ATOMIMAX - Atomic signed maximum
2851 Syntax: ``ATOMIMAX dst, resource, offset, src``
2853 Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2855 The following operation is performed atomically:
2859 dst_x = resource[offset]
2861 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2864 .. _interlaneopcodes:
2869 These opcodes reduce the given value across the shader invocations
2870 running in the current SIMD group. Every thread in the subgroup will receive
2871 the same result. The BALLOT operations accept a single-channel argument that
2872 is treated as a boolean and produce a 64-bit value.
2874 .. opcode:: VOTE_ANY - Value is set in any of the active invocations
2876 Syntax: ``VOTE_ANY dst, value``
2878 Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
2881 .. opcode:: VOTE_ALL - Value is set in all of the active invocations
2883 Syntax: ``VOTE_ALL dst, value``
2885 Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
2888 .. opcode:: VOTE_EQ - Value is the same in all of the active invocations
2890 Syntax: ``VOTE_EQ dst, value``
2892 Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
2895 .. opcode:: BALLOT - Lanemask of whether the value is set in each active
2898 Syntax: ``BALLOT dst, value``
2900 Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
2902 When the argument is a constant true, this produces a bitmask of active
2903 invocations. In fragment shaders, this can include helper invocations
2904 (invocations whose outputs and writes to memory are discarded, but which
2905 are used to compute derivatives).
2908 .. opcode:: READ_FIRST - Broadcast the value from the first active
2909 invocation to all active lanes
2911 Syntax: ``READ_FIRST dst, value``
2913 Example: ``READ_FIRST TEMP[0], TEMP[1]``
2916 .. opcode:: READ_INVOC - Retrieve the value from the given invocation
2917 (need not be uniform)
2919 Syntax: ``READ_INVOC dst, value, invocation``
2921 Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
2923 invocation.x controls the invocation number to read from for all channels.
2924 The invocation number must be the same across all active invocations in a
2925 sub-group; otherwise, the results are undefined.
2928 Explanation of symbols used
2929 ------------------------------
2936 :math:`|x|` Absolute value of `x`.
2938 :math:`\lceil x \rceil` Ceiling of `x`.
2940 clamp(x,y,z) Clamp x between y and z.
2941 (x < y) ? y : (x > z) ? z : x
2943 :math:`\lfloor x\rfloor` Floor of `x`.
2945 :math:`\log_2{x}` Logarithm of `x`, base 2.
2947 max(x,y) Maximum of x and y.
2950 min(x,y) Minimum of x and y.
2953 partialx(x) Derivative of x relative to fragment's X.
2955 partialy(x) Derivative of x relative to fragment's Y.
2957 pop() Pop from stack.
2959 :math:`x^y` `x` to the power `y`.
2961 push(x) Push x on stack.
2965 trunc(x) Truncate x, i.e. drop the fraction bits.
2972 discard Discard fragment.
2976 target Label of target instruction.
2987 Declares a register that is will be referenced as an operand in Instruction
2990 File field contains register file that is being declared and is one
2993 UsageMask field specifies which of the register components can be accessed
2994 and is one of TGSI_WRITEMASK.
2996 The Local flag specifies that a given value isn't intended for
2997 subroutine parameter passing and, as a result, the implementation
2998 isn't required to give any guarantees of it being preserved across
2999 subroutine boundaries. As it's merely a compiler hint, the
3000 implementation is free to ignore it.
3002 If Dimension flag is set to 1, a Declaration Dimension token follows.
3004 If Semantic flag is set to 1, a Declaration Semantic token follows.
3006 If Interpolate flag is set to 1, a Declaration Interpolate token follows.
3008 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
3010 If Array flag is set to 1, a Declaration Array token follows.
3013 ^^^^^^^^^^^^^^^^^^^^^^^^
3015 Declarations can optional have an ArrayID attribute which can be referred by
3016 indirect addressing operands. An ArrayID of zero is reserved and treated as
3017 if no ArrayID is specified.
3019 If an indirect addressing operand refers to a specific declaration by using
3020 an ArrayID only the registers in this declaration are guaranteed to be
3021 accessed, accessing any register outside this declaration results in undefined
3022 behavior. Note that for compatibility the effective index is zero-based and
3023 not relative to the specified declaration
3025 If no ArrayID is specified with an indirect addressing operand the whole
3026 register file might be accessed by this operand. This is strongly discouraged
3027 and will prevent packing of scalar/vec2 arrays and effective alias analysis.
3028 This is only legal for TEMP and CONST register files.
3030 Declaration Semantic
3031 ^^^^^^^^^^^^^^^^^^^^^^^^
3033 Vertex and fragment shader input and output registers may be labeled
3034 with semantic information consisting of a name and index.
3036 Follows Declaration token if Semantic bit is set.
3038 Since its purpose is to link a shader with other stages of the pipeline,
3039 it is valid to follow only those Declaration tokens that declare a register
3040 either in INPUT or OUTPUT file.
3042 SemanticName field contains the semantic name of the register being declared.
3043 There is no default value.
3045 SemanticIndex is an optional subscript that can be used to distinguish
3046 different register declarations with the same semantic name. The default value
3049 The meanings of the individual semantic names are explained in the following
3052 TGSI_SEMANTIC_POSITION
3053 """"""""""""""""""""""
3055 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
3056 output register which contains the homogeneous vertex position in the clip
3057 space coordinate system. After clipping, the X, Y and Z components of the
3058 vertex will be divided by the W value to get normalized device coordinates.
3060 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
3061 fragment shader input (or system value, depending on which one is
3062 supported by the driver) contains the fragment's window position. The X
3063 component starts at zero and always increases from left to right.
3064 The Y component starts at zero and always increases but Y=0 may either
3065 indicate the top of the window or the bottom depending on the fragment
3066 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
3067 The Z coordinate ranges from 0 to 1 to represent depth from the front
3068 to the back of the Z buffer. The W component contains the interpolated
3069 reciprocal of the vertex position W component (corresponding to gl_Fragcoord,
3070 but unlike d3d10 which interpolates the same 1/w but then gives back
3071 the reciprocal of the interpolated value).
3073 Fragment shaders may also declare an output register with
3074 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
3075 the fragment shader to change the fragment's Z position.
3082 For vertex shader outputs or fragment shader inputs/outputs, this
3083 label indicates that the register contains an R,G,B,A color.
3085 Several shader inputs/outputs may contain colors so the semantic index
3086 is used to distinguish them. For example, color[0] may be the diffuse
3087 color while color[1] may be the specular color.
3089 This label is needed so that the flat/smooth shading can be applied
3090 to the right interpolants during rasterization.
3094 TGSI_SEMANTIC_BCOLOR
3095 """"""""""""""""""""
3097 Back-facing colors are only used for back-facing polygons, and are only valid
3098 in vertex shader outputs. After rasterization, all polygons are front-facing
3099 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
3100 so all BCOLORs effectively become regular COLORs in the fragment shader.
3106 Vertex shader inputs and outputs and fragment shader inputs may be
3107 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
3108 a fog coordinate. Typically, the fragment shader will use the fog coordinate
3109 to compute a fog blend factor which is used to blend the normal fragment color
3110 with a constant fog color. But fog coord really is just an ordinary vec4
3111 register like regular semantics.
3117 Vertex shader input and output registers may be labeled with
3118 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
3119 in the form (S, 0, 0, 1). The point size controls the width or diameter
3120 of points for rasterization. This label cannot be used in fragment
3123 When using this semantic, be sure to set the appropriate state in the
3124 :ref:`rasterizer` first.
3127 TGSI_SEMANTIC_TEXCOORD
3128 """"""""""""""""""""""
3130 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3132 Vertex shader outputs and fragment shader inputs may be labeled with
3133 this semantic to make them replaceable by sprite coordinates via the
3134 sprite_coord_enable state in the :ref:`rasterizer`.
3135 The semantic index permitted with this semantic is limited to <= 7.
3137 If the driver does not support TEXCOORD, sprite coordinate replacement
3138 applies to inputs with the GENERIC semantic instead.
3140 The intended use case for this semantic is gl_TexCoord.
3143 TGSI_SEMANTIC_PCOORD
3144 """"""""""""""""""""
3146 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3148 Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
3149 that the register contains sprite coordinates in the form (x, y, 0, 1), if
3150 the current primitive is a point and point sprites are enabled. Otherwise,
3151 the contents of the register are undefined.
3153 The intended use case for this semantic is gl_PointCoord.
3156 TGSI_SEMANTIC_GENERIC
3157 """""""""""""""""""""
3159 All vertex/fragment shader inputs/outputs not labeled with any other
3160 semantic label can be considered to be generic attributes. Typical
3161 uses of generic inputs/outputs are texcoords and user-defined values.
3164 TGSI_SEMANTIC_NORMAL
3165 """"""""""""""""""""
3167 Indicates that a vertex shader input is a normal vector. This is
3168 typically only used for legacy graphics APIs.
3174 This label applies to fragment shader inputs (or system values,
3175 depending on which one is supported by the driver) and indicates that
3176 the register contains front/back-face information.
3178 If it is an input, it will be a floating-point vector in the form (F, 0, 0, 1),
3179 where F will be positive when the fragment belongs to a front-facing polygon,
3180 and negative when the fragment belongs to a back-facing polygon.
3182 If it is a system value, it will be an integer vector in the form (F, 0, 0, 1),
3183 where F is 0xffffffff when the fragment belongs to a front-facing polygon and
3184 0 when the fragment belongs to a back-facing polygon.
3187 TGSI_SEMANTIC_EDGEFLAG
3188 """"""""""""""""""""""
3190 For vertex shaders, this sematic label indicates that an input or
3191 output is a boolean edge flag. The register layout is [F, x, x, x]
3192 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
3193 simply copies the edge flag input to the edgeflag output.
3195 Edge flags are used to control which lines or points are actually
3196 drawn when the polygon mode converts triangles/quads/polygons into
3200 TGSI_SEMANTIC_STENCIL
3201 """""""""""""""""""""
3203 For fragment shaders, this semantic label indicates that an output
3204 is a writable stencil reference value. Only the Y component is writable.
3205 This allows the fragment shader to change the fragments stencilref value.
3208 TGSI_SEMANTIC_VIEWPORT_INDEX
3209 """"""""""""""""""""""""""""
3211 For geometry shaders, this semantic label indicates that an output
3212 contains the index of the viewport (and scissor) to use.
3213 This is an integer value, and only the X component is used.
3215 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3216 supported, then this semantic label can also be used in vertex or
3217 tessellation evaluation shaders, respectively. Only the value written in the
3218 last vertex processing stage is used.
3224 For geometry shaders, this semantic label indicates that an output
3225 contains the layer value to use for the color and depth/stencil surfaces.
3226 This is an integer value, and only the X component is used.
3227 (Also known as rendertarget array index.)
3229 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3230 supported, then this semantic label can also be used in vertex or
3231 tessellation evaluation shaders, respectively. Only the value written in the
3232 last vertex processing stage is used.
3235 TGSI_SEMANTIC_CULLDIST
3236 """"""""""""""""""""""
3238 Used as distance to plane for performing application-defined culling
3239 of individual primitives against a plane. When components of vertex
3240 elements are given this label, these values are assumed to be a
3241 float32 signed distance to a plane. Primitives will be completely
3242 discarded if the plane distance for all of the vertices in the
3243 primitive are < 0. If a vertex has a cull distance of NaN, that
3244 vertex counts as "out" (as if its < 0);
3245 The limits on both clip and cull distances are bound
3246 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3247 the maximum number of components that can be used to hold the
3248 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3249 which specifies the maximum number of registers which can be
3250 annotated with those semantics.
3253 TGSI_SEMANTIC_CLIPDIST
3254 """"""""""""""""""""""
3256 Note this covers clipping and culling distances.
3258 When components of vertex elements are identified this way, these
3259 values are each assumed to be a float32 signed distance to a plane.
3262 Primitive setup only invokes rasterization on pixels for which
3263 the interpolated plane distances are >= 0.
3266 Primitives will be completely discarded if the plane distance
3267 for all of the vertices in the primitive are < 0.
3268 If a vertex has a cull distance of NaN, that vertex counts as "out"
3271 Multiple clip/cull planes can be implemented simultaneously, by
3272 annotating multiple components of one or more vertex elements with
3273 the above specified semantic.
3274 The limits on both clip and cull distances are bound
3275 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3276 the maximum number of components that can be used to hold the
3277 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3278 which specifies the maximum number of registers which can be
3279 annotated with those semantics.
3280 The properties NUM_CLIPDIST_ENABLED and NUM_CULLDIST_ENABLED
3281 are used to divide up the 2 x vec4 space between clipping and culling.
3283 TGSI_SEMANTIC_SAMPLEID
3284 """"""""""""""""""""""
3286 For fragment shaders, this semantic label indicates that a system value
3287 contains the current sample id (i.e. gl_SampleID).
3288 This is an integer value, and only the X component is used.
3290 TGSI_SEMANTIC_SAMPLEPOS
3291 """""""""""""""""""""""
3293 For fragment shaders, this semantic label indicates that a system value
3294 contains the current sample's position (i.e. gl_SamplePosition). Only the X
3295 and Y values are used.
3297 TGSI_SEMANTIC_SAMPLEMASK
3298 """"""""""""""""""""""""
3300 For fragment shaders, this semantic label indicates that an output contains
3301 the sample mask used to disable further sample processing. The output's
3302 type is uint[4] but only the X component is used (i.e. gl_SampleMask[0]).
3303 Each bit corresponds to one sample position (up to 32x MSAA is supported).
3305 TGSI_SEMANTIC_INVOCATIONID
3306 """"""""""""""""""""""""""
3308 For geometry shaders, this semantic label indicates that a system value
3309 contains the current invocation id (i.e. gl_InvocationID).
3310 This is an integer value, and only the X component is used.
3312 TGSI_SEMANTIC_INSTANCEID
3313 """"""""""""""""""""""""
3315 For vertex shaders, this semantic label indicates that a system value contains
3316 the current instance id (i.e. gl_InstanceID). It does not include the base
3317 instance. This is an integer value, and only the X component is used.
3319 TGSI_SEMANTIC_VERTEXID
3320 """"""""""""""""""""""
3322 For vertex shaders, this semantic label indicates that a system value contains
3323 the current vertex id (i.e. gl_VertexID). It does (unlike in d3d10) include the
3324 base vertex. This is an integer value, and only the X component is used.
3326 TGSI_SEMANTIC_VERTEXID_NOBASE
3327 """""""""""""""""""""""""""""""
3329 For vertex shaders, this semantic label indicates that a system value contains
3330 the current vertex id without including the base vertex (this corresponds to
3331 d3d10 vertex id, so TGSI_SEMANTIC_VERTEXID_NOBASE + TGSI_SEMANTIC_BASEVERTEX
3332 == TGSI_SEMANTIC_VERTEXID). This is an integer value, and only the X component
3335 TGSI_SEMANTIC_BASEVERTEX
3336 """"""""""""""""""""""""
3338 For vertex shaders, this semantic label indicates that a system value contains
3339 the base vertex (i.e. gl_BaseVertex). Note that for non-indexed draw calls,
3340 this contains the first (or start) value instead.
3341 This is an integer value, and only the X component is used.
3343 TGSI_SEMANTIC_PRIMID
3344 """"""""""""""""""""
3346 For geometry and fragment shaders, this semantic label indicates the value
3347 contains the primitive id (i.e. gl_PrimitiveID). This is an integer value,
3348 and only the X component is used.
3349 FIXME: This right now can be either a ordinary input or a system value...
3355 For tessellation evaluation/control shaders, this semantic label indicates a
3356 generic per-patch attribute. Such semantics will not implicitly be per-vertex
3359 TGSI_SEMANTIC_TESSCOORD
3360 """""""""""""""""""""""
3362 For tessellation evaluation shaders, this semantic label indicates the
3363 coordinates of the vertex being processed. This is available in XYZ; W is
3366 TGSI_SEMANTIC_TESSOUTER
3367 """""""""""""""""""""""
3369 For tessellation evaluation/control shaders, this semantic label indicates the
3370 outer tessellation levels of the patch. Isoline tessellation will only have XY
3371 defined, triangle will have XYZ and quads will have XYZW defined. This
3372 corresponds to gl_TessLevelOuter.
3374 TGSI_SEMANTIC_TESSINNER
3375 """""""""""""""""""""""
3377 For tessellation evaluation/control shaders, this semantic label indicates the
3378 inner tessellation levels of the patch. The X value is only defined for
3379 triangle tessellation, while quads will have XY defined. This is entirely
3380 undefined for isoline tessellation.
3382 TGSI_SEMANTIC_VERTICESIN
3383 """"""""""""""""""""""""
3385 For tessellation evaluation/control shaders, this semantic label indicates the
3386 number of vertices provided in the input patch. Only the X value is defined.
3388 TGSI_SEMANTIC_HELPER_INVOCATION
3389 """""""""""""""""""""""""""""""
3391 For fragment shaders, this semantic indicates whether the current
3392 invocation is covered or not. Helper invocations are created in order
3393 to properly compute derivatives, however it may be desirable to skip
3394 some of the logic in those cases. See ``gl_HelperInvocation`` documentation.
3396 TGSI_SEMANTIC_BASEINSTANCE
3397 """"""""""""""""""""""""""
3399 For vertex shaders, the base instance argument supplied for this
3400 draw. This is an integer value, and only the X component is used.
3402 TGSI_SEMANTIC_DRAWID
3403 """"""""""""""""""""
3405 For vertex shaders, the zero-based index of the current draw in a
3406 ``glMultiDraw*`` invocation. This is an integer value, and only the X
3410 TGSI_SEMANTIC_WORK_DIM
3411 """"""""""""""""""""""
3413 For compute shaders started via opencl this retrieves the work_dim
3414 parameter to the clEnqueueNDRangeKernel call with which the shader
3418 TGSI_SEMANTIC_GRID_SIZE
3419 """""""""""""""""""""""
3421 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3422 of a grid of thread blocks.
3425 TGSI_SEMANTIC_BLOCK_ID
3426 """"""""""""""""""""""
3428 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3429 current block inside of the grid.
3432 TGSI_SEMANTIC_BLOCK_SIZE
3433 """"""""""""""""""""""""
3435 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3436 of a block in threads.
3439 TGSI_SEMANTIC_THREAD_ID
3440 """""""""""""""""""""""
3442 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3443 current thread inside of the block.
3446 TGSI_SEMANTIC_SUBGROUP_SIZE
3447 """""""""""""""""""""""""""
3449 This semantic indicates the subgroup size for the current invocation. This is
3450 an integer of at most 64, as it indicates the width of lanemasks. It does not
3451 depend on the number of invocations that are active.
3454 TGSI_SEMANTIC_SUBGROUP_INVOCATION
3455 """""""""""""""""""""""""""""""""
3457 The index of the current invocation within its subgroup.
3460 TGSI_SEMANTIC_SUBGROUP_EQ_MASK
3461 """"""""""""""""""""""""""""""
3463 A bit mask of ``bit index == TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3464 ``1 << subgroup_invocation`` in arbitrary precision arithmetic.
3467 TGSI_SEMANTIC_SUBGROUP_GE_MASK
3468 """"""""""""""""""""""""""""""
3470 A bit mask of ``bit index >= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3471 ``((1 << (subgroup_size - subgroup_invocation)) - 1) << subgroup_invocation``
3472 in arbitrary precision arithmetic.
3475 TGSI_SEMANTIC_SUBGROUP_GT_MASK
3476 """"""""""""""""""""""""""""""
3478 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3479 ``((1 << (subgroup_size - subgroup_invocation - 1)) - 1) << (subgroup_invocation + 1)``
3480 in arbitrary precision arithmetic.
3483 TGSI_SEMANTIC_SUBGROUP_LE_MASK
3484 """"""""""""""""""""""""""""""
3486 A bit mask of ``bit index <= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3487 ``(1 << (subgroup_invocation + 1)) - 1`` in arbitrary precision arithmetic.
3490 TGSI_SEMANTIC_SUBGROUP_LT_MASK
3491 """"""""""""""""""""""""""""""
3493 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3494 ``(1 << subgroup_invocation) - 1`` in arbitrary precision arithmetic.
3497 Declaration Interpolate
3498 ^^^^^^^^^^^^^^^^^^^^^^^
3500 This token is only valid for fragment shader INPUT declarations.
3502 The Interpolate field specifes the way input is being interpolated by
3503 the rasteriser and is one of TGSI_INTERPOLATE_*.
3505 The Location field specifies the location inside the pixel that the
3506 interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. Note that
3507 when per-sample shading is enabled, the implementation may choose to
3508 interpolate at the sample irrespective of the Location field.
3510 The CylindricalWrap bitfield specifies which register components
3511 should be subject to cylindrical wrapping when interpolating by the
3512 rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
3513 should be interpolated according to cylindrical wrapping rules.
3516 Declaration Sampler View
3517 ^^^^^^^^^^^^^^^^^^^^^^^^
3519 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
3521 DCL SVIEW[#], resource, type(s)
3523 Declares a shader input sampler view and assigns it to a SVIEW[#]
3526 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
3528 type must be 1 or 4 entries (if specifying on a per-component
3529 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
3531 For TEX\* style texture sample opcodes (as opposed to SAMPLE\* opcodes
3532 which take an explicit SVIEW[#] source register), there may be optionally
3533 SVIEW[#] declarations. In this case, the SVIEW index is implied by the
3534 SAMP index, and there must be a corresponding SVIEW[#] declaration for
3535 each SAMP[#] declaration. Drivers are free to ignore this if they wish.
3536 But note in particular that some drivers need to know the sampler type
3537 (float/int/unsigned) in order to generate the correct code, so cases
3538 where integer textures are sampled, SVIEW[#] declarations should be
3541 NOTE: It is NOT legal to mix SAMPLE\* style opcodes and TEX\* opcodes
3544 Declaration Resource
3545 ^^^^^^^^^^^^^^^^^^^^
3547 Follows Declaration token if file is TGSI_FILE_RESOURCE.
3549 DCL RES[#], resource [, WR] [, RAW]
3551 Declares a shader input resource and assigns it to a RES[#]
3554 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
3557 If the RAW keyword is not specified, the texture data will be
3558 subject to conversion, swizzling and scaling as required to yield
3559 the specified data type from the physical data format of the bound
3562 If the RAW keyword is specified, no channel conversion will be
3563 performed: the values read for each of the channels (X,Y,Z,W) will
3564 correspond to consecutive words in the same order and format
3565 they're found in memory. No element-to-address conversion will be
3566 performed either: the value of the provided X coordinate will be
3567 interpreted in byte units instead of texel units. The result of
3568 accessing a misaligned address is undefined.
3570 Usage of the STORE opcode is only allowed if the WR (writable) flag
3575 ^^^^^^^^^^^^^^^^^^^^^^^^
3577 Properties are general directives that apply to the whole TGSI program.
3582 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
3583 The default value is UPPER_LEFT.
3585 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
3586 increase downward and rightward.
3587 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
3588 increase upward and rightward.
3590 OpenGL defaults to LOWER_LEFT, and is configurable with the
3591 GL_ARB_fragment_coord_conventions extension.
3593 DirectX 9/10 use UPPER_LEFT.
3595 FS_COORD_PIXEL_CENTER
3596 """""""""""""""""""""
3598 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
3599 The default value is HALF_INTEGER.
3601 If HALF_INTEGER, the fractionary part of the position will be 0.5
3602 If INTEGER, the fractionary part of the position will be 0.0
3604 Note that this does not affect the set of fragments generated by
3605 rasterization, which is instead controlled by half_pixel_center in the
3608 OpenGL defaults to HALF_INTEGER, and is configurable with the
3609 GL_ARB_fragment_coord_conventions extension.
3611 DirectX 9 uses INTEGER.
3612 DirectX 10 uses HALF_INTEGER.
3614 FS_COLOR0_WRITES_ALL_CBUFS
3615 """"""""""""""""""""""""""
3616 Specifies that writes to the fragment shader color 0 are replicated to all
3617 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
3618 fragData is directed to a single color buffer, but fragColor is broadcast.
3621 """"""""""""""""""""""""""
3622 If this property is set on the program bound to the shader stage before the
3623 fragment shader, user clip planes should have no effect (be disabled) even if
3624 that shader does not write to any clip distance outputs and the rasterizer's
3625 clip_plane_enable is non-zero.
3626 This property is only supported by drivers that also support shader clip
3628 This is useful for APIs that don't have UCPs and where clip distances written
3629 by a shader cannot be disabled.
3634 Specifies the number of times a geometry shader should be executed for each
3635 input primitive. Each invocation will have a different
3636 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
3639 VS_WINDOW_SPACE_POSITION
3640 """"""""""""""""""""""""""
3641 If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
3642 is assumed to contain window space coordinates.
3643 Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
3644 directly taken from the 4-th component of the shader output.
3645 Naturally, clipping is not performed on window coordinates either.
3646 The effect of this property is undefined if a geometry or tessellation shader
3652 The number of vertices written by the tessellation control shader. This
3653 effectively defines the patch input size of the tessellation evaluation shader
3659 This sets the tessellation primitive mode, one of ``PIPE_PRIM_TRIANGLES``,
3660 ``PIPE_PRIM_QUADS``, or ``PIPE_PRIM_LINES``. (Unlike in GL, there is no
3661 separate isolines settings, the regular lines is assumed to mean isolines.)
3666 This sets the spacing mode of the tessellation generator, one of
3667 ``PIPE_TESS_SPACING_*``.
3672 This sets the vertex order to be clockwise if the value is 1, or
3673 counter-clockwise if set to 0.
3678 If set to a non-zero value, this turns on point mode for the tessellator,
3679 which means that points will be generated instead of primitives.
3681 NUM_CLIPDIST_ENABLED
3682 """"""""""""""""""""
3684 How many clip distance scalar outputs are enabled.
3686 NUM_CULLDIST_ENABLED
3687 """"""""""""""""""""
3689 How many cull distance scalar outputs are enabled.
3691 FS_EARLY_DEPTH_STENCIL
3692 """"""""""""""""""""""
3694 Whether depth test, stencil test, and occlusion query should run before
3695 the fragment shader (regardless of fragment shader side effects). Corresponds
3696 to GLSL early_fragment_tests.
3701 Which shader stage will MOST LIKELY follow after this shader when the shader
3702 is bound. This is only a hint to the driver and doesn't have to be precise.
3703 Only set for VS and TES.
3705 CS_FIXED_BLOCK_WIDTH / HEIGHT / DEPTH
3706 """""""""""""""""""""""""""""""""""""
3708 Threads per block in each dimension, if known at compile time. If the block size
3709 is known all three should be at least 1. If it is unknown they should all be set
3715 The MUL TGSI operation (FP32 multiplication) will return 0 if either
3716 of the operands are equal to 0. That means that 0 * Inf = 0. This
3717 should be set the same way for an entire pipeline. Note that this
3718 applies not only to the literal MUL TGSI opcode, but all FP32
3719 multiplications implied by other operations, such as MAD, FMA, DP2,
3720 DP3, DP4, DPH, DST, LOG, LRP, XPD, and possibly others. If there is a
3721 mismatch between shaders, then it is unspecified whether this behavior
3724 FS_POST_DEPTH_COVERAGE
3725 """"""""""""""""""""""
3727 When enabled, the input for TGSI_SEMANTIC_SAMPLEMASK will exclude samples
3728 that have failed the depth/stencil tests. This is only valid when
3729 FS_EARLY_DEPTH_STENCIL is also specified.
3732 Texture Sampling and Texture Formats
3733 ------------------------------------
3735 This table shows how texture image components are returned as (x,y,z,w) tuples
3736 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
3737 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
3740 +--------------------+--------------+--------------------+--------------+
3741 | Texture Components | Gallium | OpenGL | Direct3D 9 |
3742 +====================+==============+====================+==============+
3743 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
3744 +--------------------+--------------+--------------------+--------------+
3745 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
3746 +--------------------+--------------+--------------------+--------------+
3747 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
3748 +--------------------+--------------+--------------------+--------------+
3749 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
3750 +--------------------+--------------+--------------------+--------------+
3751 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
3752 +--------------------+--------------+--------------------+--------------+
3753 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
3754 +--------------------+--------------+--------------------+--------------+
3755 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
3756 +--------------------+--------------+--------------------+--------------+
3757 | I | (i, i, i, i) | (i, i, i, i) | N/A |
3758 +--------------------+--------------+--------------------+--------------+
3759 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
3760 | | | [#envmap-bumpmap]_ | |
3761 +--------------------+--------------+--------------------+--------------+
3762 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
3763 | | | [#depth-tex-mode]_ | |
3764 +--------------------+--------------+--------------------+--------------+
3765 | S | (s, s, s, s) | unknown | unknown |
3766 +--------------------+--------------+--------------------+--------------+
3768 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
3769 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
3770 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.