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 and precise modifier
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
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
43 For inputs which have signed or unsigned type only the negate modifier is
50 ^^^^^^^^^^^^^^^^^^^^^^^^^
52 These opcodes are guaranteed to be available regardless of the driver being
55 .. opcode:: ARL - Address Register Load
59 dst.x = (int) \lfloor src.x\rfloor
61 dst.y = (int) \lfloor src.y\rfloor
63 dst.z = (int) \lfloor src.z\rfloor
65 dst.w = (int) \lfloor src.w\rfloor
68 .. opcode:: MOV - Move
81 .. opcode:: LIT - Light Coefficients
86 dst.y &= max(src.x, 0) \\
87 dst.z &= (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 \\
91 .. opcode:: RCP - Reciprocal
93 This instruction replicates its result.
100 .. opcode:: RSQ - Reciprocal Square Root
102 This instruction replicates its result. The results are undefined for src <= 0.
106 dst = \frac{1}{\sqrt{src.x}}
109 .. opcode:: SQRT - Square Root
111 This instruction replicates its result. The results are undefined for src < 0.
118 .. opcode:: EXP - Approximate Exponential Base 2
122 dst.x &= 2^{\lfloor src.x\rfloor} \\
123 dst.y &= src.x - \lfloor src.x\rfloor \\
124 dst.z &= 2^{src.x} \\
128 .. opcode:: LOG - Approximate Logarithm Base 2
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|} \\
138 .. opcode:: MUL - Multiply
142 dst.x = src0.x \times src1.x
144 dst.y = src0.y \times src1.y
146 dst.z = src0.z \times src1.z
148 dst.w = src0.w \times src1.w
151 .. opcode:: ADD - Add
155 dst.x = src0.x + src1.x
157 dst.y = src0.y + src1.y
159 dst.z = src0.z + src1.z
161 dst.w = src0.w + src1.w
164 .. opcode:: DP3 - 3-component Dot Product
166 This instruction replicates its result.
170 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
173 .. opcode:: DP4 - 4-component Dot Product
175 This instruction replicates its result.
179 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
182 .. opcode:: DST - Distance Vector
187 dst.y &= src0.y \times src1.y\\
192 .. opcode:: MIN - Minimum
196 dst.x = min(src0.x, src1.x)
198 dst.y = min(src0.y, src1.y)
200 dst.z = min(src0.z, src1.z)
202 dst.w = min(src0.w, src1.w)
205 .. opcode:: MAX - Maximum
209 dst.x = max(src0.x, src1.x)
211 dst.y = max(src0.y, src1.y)
213 dst.z = max(src0.z, src1.z)
215 dst.w = max(src0.w, src1.w)
218 .. opcode:: SLT - Set On Less Than
222 dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
224 dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
226 dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
228 dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
231 .. opcode:: SGE - Set On Greater Equal Than
235 dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
237 dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
239 dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
241 dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
244 .. opcode:: MAD - Multiply And Add
246 Perform a * b + c. The implementation is free to decide whether there is an
247 intermediate rounding step or not.
251 dst.x = src0.x \times src1.x + src2.x
253 dst.y = src0.y \times src1.y + src2.y
255 dst.z = src0.z \times src1.z + src2.z
257 dst.w = src0.w \times src1.w + src2.w
260 .. opcode:: LRP - Linear Interpolate
264 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
266 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
268 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
270 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
273 .. opcode:: FMA - Fused Multiply-Add
275 Perform a * b + c with no intermediate rounding step.
279 dst.x = src0.x \times src1.x + src2.x
281 dst.y = src0.y \times src1.y + src2.y
283 dst.z = src0.z \times src1.z + src2.z
285 dst.w = src0.w \times src1.w + src2.w
288 .. opcode:: FRC - Fraction
292 dst.x = src.x - \lfloor src.x\rfloor
294 dst.y = src.y - \lfloor src.y\rfloor
296 dst.z = src.z - \lfloor src.z\rfloor
298 dst.w = src.w - \lfloor src.w\rfloor
301 .. opcode:: FLR - Floor
305 dst.x = \lfloor src.x\rfloor
307 dst.y = \lfloor src.y\rfloor
309 dst.z = \lfloor src.z\rfloor
311 dst.w = \lfloor src.w\rfloor
314 .. opcode:: ROUND - Round
327 .. opcode:: EX2 - Exponential Base 2
329 This instruction replicates its result.
336 .. opcode:: LG2 - Logarithm Base 2
338 This instruction replicates its result.
345 .. opcode:: POW - Power
347 This instruction replicates its result.
351 dst = src0.x^{src1.x}
354 .. opcode:: LDEXP - Multiply Number by Integral Power of 2
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}
366 .. opcode:: COS - Cosine
368 This instruction replicates its result.
375 .. opcode:: DDX, DDX_FINE - Derivative Relative To X
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.
383 dst.x = partialx(src.x)
385 dst.y = partialx(src.y)
387 dst.z = partialx(src.z)
389 dst.w = partialx(src.w)
392 .. opcode:: DDY, DDY_FINE - Derivative Relative To Y
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.
400 dst.x = partialy(src.x)
402 dst.y = partialy(src.y)
404 dst.z = partialy(src.z)
406 dst.w = partialy(src.w)
409 .. opcode:: PK2H - Pack Two 16-bit Floats
411 This instruction replicates its result.
415 dst = f32\_to\_f16(src.x) | f32\_to\_f16(src.y) << 16
418 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
420 This instruction replicates its result.
424 dst = f32\_to\_unorm16(src.x) | f32\_to\_unorm16(src.y) << 16
427 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
429 This instruction replicates its result.
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)
439 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
441 This instruction replicates its result.
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)
451 .. opcode:: SEQ - Set On Equal
455 dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
457 dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
459 dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
461 dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
464 .. opcode:: SGT - Set On Greater Than
468 dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
470 dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
472 dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
474 dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
477 .. opcode:: SIN - Sine
479 This instruction replicates its result.
486 .. opcode:: SLE - Set On Less Equal Than
490 dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
492 dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
494 dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
496 dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
499 .. opcode:: SNE - Set On Not Equal
503 dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
505 dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
507 dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
509 dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
512 .. opcode:: TEX - Texture Lookup
514 for array textures src0.y contains the slice for 1D,
515 and src0.z contain the slice for 2D.
517 for shadow textures with no arrays (and not cube map),
518 src0.z contains the reference value.
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.
524 for cube map array shadow textures, the reference value
525 cannot be passed in src0.w, and TEX2 must be used instead.
531 shadow_ref = src0.z or src0.w (optional)
535 dst = texture\_sample(unit, coord, shadow_ref)
538 .. opcode:: TEX2 - Texture Lookup (for shadow cube map arrays only)
540 this is the same as TEX, but uses another reg to encode the
551 dst = texture\_sample(unit, coord, shadow_ref)
556 .. opcode:: TXD - Texture Lookup with Derivatives
568 dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
571 .. opcode:: TXP - Projective Texture Lookup
575 coord.x = src0.x / src0.w
577 coord.y = src0.y / src0.w
579 coord.z = src0.z / src0.w
585 dst = texture\_sample(unit, coord)
588 .. opcode:: UP2H - Unpack Two 16-Bit Floats
592 dst.x = f16\_to\_f32(src0.x \& 0xffff)
594 dst.y = f16\_to\_f32(src0.x >> 16)
596 dst.z = f16\_to\_f32(src0.x \& 0xffff)
598 dst.w = f16\_to\_f32(src0.x >> 16)
602 Considered for removal.
604 .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
610 Considered for removal.
612 .. opcode:: UP4B - Unpack Four Signed 8-Bit Values
618 Considered for removal.
620 .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
626 Considered for removal.
629 .. opcode:: ARR - Address Register Load With Round
633 dst.x = (int) round(src.x)
635 dst.y = (int) round(src.y)
637 dst.z = (int) round(src.z)
639 dst.w = (int) round(src.w)
642 .. opcode:: SSG - Set Sign
646 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
648 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
650 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
652 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
655 .. opcode:: CMP - Compare
659 dst.x = (src0.x < 0) ? src1.x : src2.x
661 dst.y = (src0.y < 0) ? src1.y : src2.y
663 dst.z = (src0.z < 0) ? src1.z : src2.z
665 dst.w = (src0.w < 0) ? src1.w : src2.w
668 .. opcode:: KILL_IF - Conditional Discard
670 Conditional discard. Allowed in fragment shaders only.
674 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
679 .. opcode:: KILL - Discard
681 Unconditional discard. Allowed in fragment shaders only.
684 .. opcode:: TXB - Texture Lookup With Bias
686 for cube map array textures and shadow cube maps, the bias value
687 cannot be passed in src0.w, and TXB2 must be used instead.
689 if the target is a shadow texture, the reference value is always
690 in src.z (this prevents shadow 3d and shadow 2d arrays from
691 using this instruction, but this is not needed).
707 dst = texture\_sample(unit, coord, bias)
710 .. opcode:: TXB2 - Texture Lookup With Bias (some cube maps only)
712 this is the same as TXB, but uses another reg to encode the
713 lod bias value for cube map arrays and shadow cube maps.
714 Presumably shadow 2d arrays and shadow 3d targets could use
715 this encoding too, but this is not legal.
717 shadow cube map arrays are neither possible nor required.
727 dst = texture\_sample(unit, coord, bias)
730 .. opcode:: DIV - Divide
734 dst.x = \frac{src0.x}{src1.x}
736 dst.y = \frac{src0.y}{src1.y}
738 dst.z = \frac{src0.z}{src1.z}
740 dst.w = \frac{src0.w}{src1.w}
743 .. opcode:: DP2 - 2-component Dot Product
745 This instruction replicates its result.
749 dst = src0.x \times src1.x + src0.y \times src1.y
752 .. opcode:: TEX_LZ - Texture Lookup With LOD = 0
754 This is the same as TXL with LOD = 0. Like every texture opcode, it obeys
755 pipe_sampler_view::u.tex.first_level and pipe_sampler_state::min_lod.
756 There is no way to override those two in shaders.
772 dst = texture\_sample(unit, coord, lod)
775 .. opcode:: TXL - Texture Lookup With explicit LOD
777 for cube map array textures, the explicit lod value
778 cannot be passed in src0.w, and TXL2 must be used instead.
780 if the target is a shadow texture, the reference value is always
781 in src.z (this prevents shadow 3d / 2d array / cube targets from
782 using this instruction, but this is not needed).
798 dst = texture\_sample(unit, coord, lod)
801 .. opcode:: TXL2 - Texture Lookup With explicit LOD (for cube map arrays only)
803 this is the same as TXL, but uses another reg to encode the
805 Presumably shadow 3d / 2d array / cube targets could use
806 this encoding too, but this is not legal.
808 shadow cube map arrays are neither possible nor required.
818 dst = texture\_sample(unit, coord, lod)
822 ^^^^^^^^^^^^^^^^^^^^^^^^
824 These opcodes are primarily provided for special-use computational shaders.
825 Support for these opcodes indicated by a special pipe capability bit (TBD).
827 XXX doesn't look like most of the opcodes really belong here.
829 .. opcode:: CEIL - Ceiling
833 dst.x = \lceil src.x\rceil
835 dst.y = \lceil src.y\rceil
837 dst.z = \lceil src.z\rceil
839 dst.w = \lceil src.w\rceil
842 .. opcode:: TRUNC - Truncate
855 .. opcode:: MOD - Modulus
859 dst.x = src0.x \bmod src1.x
861 dst.y = src0.y \bmod src1.y
863 dst.z = src0.z \bmod src1.z
865 dst.w = src0.w \bmod src1.w
868 .. opcode:: UARL - Integer Address Register Load
870 Moves the contents of the source register, assumed to be an integer, into the
871 destination register, which is assumed to be an address (ADDR) register.
874 .. opcode:: TXF - Texel Fetch
876 As per NV_gpu_shader4, extract a single texel from a specified texture
877 image or PIPE_BUFFER resource. The source sampler may not be a CUBE or
879 four-component signed integer vector used to identify the single texel
880 accessed. 3 components + level. If the texture is multisampled, then
881 the fourth component indicates the sample, not the mipmap level.
882 Just like texture instructions, an optional
883 offset vector is provided, which is subject to various driver restrictions
884 (regarding range, source of offsets). This instruction ignores the sampler
887 TXF(uint_vec coord, int_vec offset).
890 .. opcode:: TXQ - Texture Size Query
892 As per NV_gpu_program4, retrieve the dimensions of the texture depending on
893 the target. For 1D (width), 2D/RECT/CUBE (width, height), 3D (width, height,
894 depth), 1D array (width, layers), 2D array (width, height, layers).
895 Also return the number of accessible levels (last_level - first_level + 1)
898 For components which don't return a resource dimension, their value
905 dst.x = texture\_width(unit, lod)
907 dst.y = texture\_height(unit, lod)
909 dst.z = texture\_depth(unit, lod)
911 dst.w = texture\_levels(unit)
914 .. opcode:: TXQS - Texture Samples Query
916 This retrieves the number of samples in the texture, and stores it
917 into the x component as an unsigned integer. The other components are
918 undefined. If the texture is not multisampled, this function returns
919 (1, undef, undef, undef).
923 dst.x = texture\_samples(unit)
926 .. opcode:: TG4 - Texture Gather
928 As per ARB_texture_gather, gathers the four texels to be used in a bi-linear
929 filtering operation and packs them into a single register. Only works with
930 2D, 2D array, cubemaps, and cubemaps arrays. For 2D textures, only the
931 addressing modes of the sampler and the top level of any mip pyramid are
932 used. Set W to zero. It behaves like the TEX instruction, but a filtered
933 sample is not generated. The four samples that contribute to filtering are
934 placed into xyzw in clockwise order, starting with the (u,v) texture
935 coordinate delta at the following locations (-, +), (+, +), (+, -), (-, -),
936 where the magnitude of the deltas are half a texel.
938 PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
939 depth compares, single component selection, and a non-constant offset. It
940 doesn't allow support for the GL independent offset to get i0,j0. This would
941 require another CAP is hw can do it natively. For now we lower that before
950 dst = texture\_gather4 (unit, coord, component)
952 (with SM5 - cube array shadow)
960 dst = texture\_gather (uint, coord, compare)
962 .. opcode:: LODQ - level of detail query
964 Compute the LOD information that the texture pipe would use to access the
965 texture. The Y component contains the computed LOD lambda_prime. The X
966 component contains the LOD that will be accessed, based on min/max lod's
973 dst.xy = lodq(uint, coord);
975 .. opcode:: CLOCK - retrieve the current shader time
977 Invoking this instruction multiple times in the same shader should
978 cause monotonically increasing values to be returned. The values
979 are implicitly 64-bit, so if fewer than 64 bits of precision are
980 available, to provide expected wraparound semantics, the value
981 should be shifted up so that the most significant bit of the time
982 is the most significant bit of the 64-bit value.
990 ^^^^^^^^^^^^^^^^^^^^^^^^
991 These opcodes are used for integer operations.
992 Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
995 .. opcode:: I2F - Signed Integer To Float
997 Rounding is unspecified (round to nearest even suggested).
1001 dst.x = (float) src.x
1003 dst.y = (float) src.y
1005 dst.z = (float) src.z
1007 dst.w = (float) src.w
1010 .. opcode:: U2F - Unsigned Integer To Float
1012 Rounding is unspecified (round to nearest even suggested).
1016 dst.x = (float) src.x
1018 dst.y = (float) src.y
1020 dst.z = (float) src.z
1022 dst.w = (float) src.w
1025 .. opcode:: F2I - Float to Signed Integer
1027 Rounding is towards zero (truncate).
1028 Values outside signed range (including NaNs) produce undefined results.
1041 .. opcode:: F2U - Float to Unsigned Integer
1043 Rounding is towards zero (truncate).
1044 Values outside unsigned range (including NaNs) produce undefined results.
1048 dst.x = (unsigned) src.x
1050 dst.y = (unsigned) src.y
1052 dst.z = (unsigned) src.z
1054 dst.w = (unsigned) src.w
1057 .. opcode:: UADD - Integer Add
1059 This instruction works the same for signed and unsigned integers.
1060 The low 32bit of the result is returned.
1064 dst.x = src0.x + src1.x
1066 dst.y = src0.y + src1.y
1068 dst.z = src0.z + src1.z
1070 dst.w = src0.w + src1.w
1073 .. opcode:: UMAD - Integer Multiply And Add
1075 This instruction works the same for signed and unsigned integers.
1076 The multiplication returns the low 32bit (as does the result itself).
1080 dst.x = src0.x \times src1.x + src2.x
1082 dst.y = src0.y \times src1.y + src2.y
1084 dst.z = src0.z \times src1.z + src2.z
1086 dst.w = src0.w \times src1.w + src2.w
1089 .. opcode:: UMUL - Integer Multiply
1091 This instruction works the same for signed and unsigned integers.
1092 The low 32bit of the result is returned.
1096 dst.x = src0.x \times src1.x
1098 dst.y = src0.y \times src1.y
1100 dst.z = src0.z \times src1.z
1102 dst.w = src0.w \times src1.w
1105 .. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1107 The high 32bits of the multiplication of 2 signed integers are returned.
1111 dst.x = (src0.x \times src1.x) >> 32
1113 dst.y = (src0.y \times src1.y) >> 32
1115 dst.z = (src0.z \times src1.z) >> 32
1117 dst.w = (src0.w \times src1.w) >> 32
1120 .. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1122 The high 32bits of the multiplication of 2 unsigned integers are returned.
1126 dst.x = (src0.x \times src1.x) >> 32
1128 dst.y = (src0.y \times src1.y) >> 32
1130 dst.z = (src0.z \times src1.z) >> 32
1132 dst.w = (src0.w \times src1.w) >> 32
1135 .. opcode:: IDIV - Signed Integer Division
1137 TBD: behavior for division by zero.
1141 dst.x = \frac{src0.x}{src1.x}
1143 dst.y = \frac{src0.y}{src1.y}
1145 dst.z = \frac{src0.z}{src1.z}
1147 dst.w = \frac{src0.w}{src1.w}
1150 .. opcode:: UDIV - Unsigned Integer Division
1152 For division by zero, 0xffffffff is returned.
1156 dst.x = \frac{src0.x}{src1.x}
1158 dst.y = \frac{src0.y}{src1.y}
1160 dst.z = \frac{src0.z}{src1.z}
1162 dst.w = \frac{src0.w}{src1.w}
1165 .. opcode:: UMOD - Unsigned Integer Remainder
1167 If second arg is zero, 0xffffffff is returned.
1171 dst.x = src0.x \bmod src1.x
1173 dst.y = src0.y \bmod src1.y
1175 dst.z = src0.z \bmod src1.z
1177 dst.w = src0.w \bmod src1.w
1180 .. opcode:: NOT - Bitwise Not
1193 .. opcode:: AND - Bitwise And
1197 dst.x = src0.x \& src1.x
1199 dst.y = src0.y \& src1.y
1201 dst.z = src0.z \& src1.z
1203 dst.w = src0.w \& src1.w
1206 .. opcode:: OR - Bitwise Or
1210 dst.x = src0.x | src1.x
1212 dst.y = src0.y | src1.y
1214 dst.z = src0.z | src1.z
1216 dst.w = src0.w | src1.w
1219 .. opcode:: XOR - Bitwise Xor
1223 dst.x = src0.x \oplus src1.x
1225 dst.y = src0.y \oplus src1.y
1227 dst.z = src0.z \oplus src1.z
1229 dst.w = src0.w \oplus src1.w
1232 .. opcode:: IMAX - Maximum of Signed Integers
1236 dst.x = max(src0.x, src1.x)
1238 dst.y = max(src0.y, src1.y)
1240 dst.z = max(src0.z, src1.z)
1242 dst.w = max(src0.w, src1.w)
1245 .. opcode:: UMAX - Maximum of Unsigned Integers
1249 dst.x = max(src0.x, src1.x)
1251 dst.y = max(src0.y, src1.y)
1253 dst.z = max(src0.z, src1.z)
1255 dst.w = max(src0.w, src1.w)
1258 .. opcode:: IMIN - Minimum of Signed Integers
1262 dst.x = min(src0.x, src1.x)
1264 dst.y = min(src0.y, src1.y)
1266 dst.z = min(src0.z, src1.z)
1268 dst.w = min(src0.w, src1.w)
1271 .. opcode:: UMIN - Minimum of Unsigned Integers
1275 dst.x = min(src0.x, src1.x)
1277 dst.y = min(src0.y, src1.y)
1279 dst.z = min(src0.z, src1.z)
1281 dst.w = min(src0.w, src1.w)
1284 .. opcode:: SHL - Shift Left
1286 The shift count is masked with 0x1f before the shift is applied.
1290 dst.x = src0.x << (0x1f \& src1.x)
1292 dst.y = src0.y << (0x1f \& src1.y)
1294 dst.z = src0.z << (0x1f \& src1.z)
1296 dst.w = src0.w << (0x1f \& src1.w)
1299 .. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1301 The shift count is masked with 0x1f before the shift is applied.
1305 dst.x = src0.x >> (0x1f \& src1.x)
1307 dst.y = src0.y >> (0x1f \& src1.y)
1309 dst.z = src0.z >> (0x1f \& src1.z)
1311 dst.w = src0.w >> (0x1f \& src1.w)
1314 .. opcode:: USHR - Logical Shift Right
1316 The shift count is masked with 0x1f before the shift is applied.
1320 dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1322 dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1324 dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1326 dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
1329 .. opcode:: UCMP - Integer Conditional Move
1333 dst.x = src0.x ? src1.x : src2.x
1335 dst.y = src0.y ? src1.y : src2.y
1337 dst.z = src0.z ? src1.z : src2.z
1339 dst.w = src0.w ? src1.w : src2.w
1343 .. opcode:: ISSG - Integer Set Sign
1347 dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1349 dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1351 dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1353 dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1357 .. opcode:: FSLT - Float Set On Less Than (ordered)
1359 Same comparison as SLT but returns integer instead of 1.0/0.0 float
1363 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1365 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1367 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1369 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1372 .. opcode:: ISLT - Signed Integer Set On Less Than
1376 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1378 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1380 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1382 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1385 .. opcode:: USLT - Unsigned Integer Set On Less Than
1389 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1391 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1393 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1395 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1398 .. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1400 Same comparison as SGE but returns integer instead of 1.0/0.0 float
1404 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1406 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1408 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1410 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1413 .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1417 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1419 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1421 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1423 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1426 .. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1430 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1432 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1434 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1436 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1439 .. opcode:: FSEQ - Float Set On Equal (ordered)
1441 Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1445 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1447 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1449 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1451 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1454 .. opcode:: USEQ - Integer Set On Equal
1458 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1460 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1462 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1464 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1467 .. opcode:: FSNE - Float Set On Not Equal (unordered)
1469 Same comparison as SNE but returns integer instead of 1.0/0.0 float
1473 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1475 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1477 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1479 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1482 .. opcode:: USNE - Integer Set On Not Equal
1486 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1488 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1490 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1492 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1495 .. opcode:: INEG - Integer Negate
1510 .. opcode:: IABS - Integer Absolute Value
1524 These opcodes are used for bit-level manipulation of integers.
1526 .. opcode:: IBFE - Signed Bitfield Extract
1528 Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
1529 sign-extends them if the high bit of the extracted window is set.
1533 def ibfe(value, offset, bits):
1534 if offset < 0 or bits < 0 or offset + bits > 32:
1536 if bits == 0: return 0
1537 # Note: >> sign-extends
1538 return (value << (32 - offset - bits)) >> (32 - bits)
1540 .. opcode:: UBFE - Unsigned Bitfield Extract
1542 Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
1547 def ubfe(value, offset, bits):
1548 if offset < 0 or bits < 0 or offset + bits > 32:
1550 if bits == 0: return 0
1551 # Note: >> does not sign-extend
1552 return (value << (32 - offset - bits)) >> (32 - bits)
1554 .. opcode:: BFI - Bitfield Insert
1556 Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
1561 def bfi(base, insert, offset, bits):
1562 if offset < 0 or bits < 0 or offset + bits > 32:
1564 # << defined such that mask == ~0 when bits == 32, offset == 0
1565 mask = ((1 << bits) - 1) << offset
1566 return ((insert << offset) & mask) | (base & ~mask)
1568 .. opcode:: BREV - Bitfield Reverse
1570 See SM5 instruction BFREV. Reverses the bits of the argument.
1572 .. opcode:: POPC - Population Count
1574 See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1576 .. opcode:: LSB - Index of lowest set bit
1578 See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1579 bit of the argument. Returns -1 if none are set.
1581 .. opcode:: IMSB - Index of highest non-sign bit
1583 See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1584 non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1585 highest 1 bit for positive numbers). Returns -1 if all bits are the same
1586 (i.e. for inputs 0 and -1).
1588 .. opcode:: UMSB - Index of highest set bit
1590 See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1591 set bit of the argument. Returns -1 if none are set.
1594 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1596 These opcodes are only supported in geometry shaders; they have no meaning
1597 in any other type of shader.
1599 .. opcode:: EMIT - Emit
1601 Generate a new vertex for the current primitive into the specified vertex
1602 stream using the values in the output registers.
1605 .. opcode:: ENDPRIM - End Primitive
1607 Complete the current primitive in the specified vertex stream (consisting of
1608 the emitted vertices), and start a new one.
1614 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1615 opcodes is determined by a special capability bit, ``GLSL``.
1616 Some require glsl version 1.30 (UIF/SWITCH/CASE/DEFAULT/ENDSWITCH).
1618 .. opcode:: CAL - Subroutine Call
1624 .. opcode:: RET - Subroutine Call Return
1629 .. opcode:: CONT - Continue
1631 Unconditionally moves the point of execution to the instruction after the
1632 last bgnloop. The instruction must appear within a bgnloop/endloop.
1636 Support for CONT is determined by a special capability bit,
1637 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1640 .. opcode:: BGNLOOP - Begin a Loop
1642 Start a loop. Must have a matching endloop.
1645 .. opcode:: BGNSUB - Begin Subroutine
1647 Starts definition of a subroutine. Must have a matching endsub.
1650 .. opcode:: ENDLOOP - End a Loop
1652 End a loop started with bgnloop.
1655 .. opcode:: ENDSUB - End Subroutine
1657 Ends definition of a subroutine.
1660 .. opcode:: NOP - No Operation
1665 .. opcode:: BRK - Break
1667 Unconditionally moves the point of execution to the instruction after the
1668 next endloop or endswitch. The instruction must appear within a loop/endloop
1669 or switch/endswitch.
1672 .. opcode:: IF - Float If
1674 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
1678 where src0.x is interpreted as a floating point register.
1681 .. opcode:: UIF - Bitwise If
1683 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1687 where src0.x is interpreted as an integer register.
1690 .. opcode:: ELSE - Else
1692 Starts an else block, after an IF or UIF statement.
1695 .. opcode:: ENDIF - End If
1697 Ends an IF or UIF block.
1700 .. opcode:: SWITCH - Switch
1702 Starts a C-style switch expression. The switch consists of one or multiple
1703 CASE statements, and at most one DEFAULT statement. Execution of a statement
1704 ends when a BRK is hit, but just like in C falling through to other cases
1705 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
1706 just as last statement, and fallthrough is allowed into/from it.
1707 CASE src arguments are evaluated at bit level against the SWITCH src argument.
1713 (some instructions here)
1716 (some instructions here)
1719 (some instructions here)
1724 .. opcode:: CASE - Switch case
1726 This represents a switch case label. The src arg must be an integer immediate.
1729 .. opcode:: DEFAULT - Switch default
1731 This represents the default case in the switch, which is taken if no other
1735 .. opcode:: ENDSWITCH - End of switch
1737 Ends a switch expression.
1743 The interpolation instructions allow an input to be interpolated in a
1744 different way than its declaration. This corresponds to the GLSL 4.00
1745 interpolateAt* functions. The first argument of each of these must come from
1746 ``TGSI_FILE_INPUT``.
1748 .. opcode:: INTERP_CENTROID - Interpolate at the centroid
1750 Interpolates the varying specified by src0 at the centroid
1752 .. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
1754 Interpolates the varying specified by src0 at the sample id specified by
1755 src1.x (interpreted as an integer)
1757 .. opcode:: INTERP_OFFSET - Interpolate at the specified offset
1759 Interpolates the varying specified by src0 at the offset src1.xy from the
1760 pixel center (interpreted as floats)
1768 The double-precision opcodes reinterpret four-component vectors into
1769 two-component vectors with doubled precision in each component.
1771 .. opcode:: DABS - Absolute
1779 .. opcode:: DADD - Add
1783 dst.xy = src0.xy + src1.xy
1785 dst.zw = src0.zw + src1.zw
1787 .. opcode:: DSEQ - Set on Equal
1791 dst.x = src0.xy == src1.xy ? \sim 0 : 0
1793 dst.z = src0.zw == src1.zw ? \sim 0 : 0
1795 .. opcode:: DSNE - Set on Not Equal
1799 dst.x = src0.xy != src1.xy ? \sim 0 : 0
1801 dst.z = src0.zw != src1.zw ? \sim 0 : 0
1803 .. opcode:: DSLT - Set on Less than
1807 dst.x = src0.xy < src1.xy ? \sim 0 : 0
1809 dst.z = src0.zw < src1.zw ? \sim 0 : 0
1811 .. opcode:: DSGE - Set on Greater equal
1815 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
1817 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
1819 .. opcode:: DFRAC - Fraction
1823 dst.xy = src.xy - \lfloor src.xy\rfloor
1825 dst.zw = src.zw - \lfloor src.zw\rfloor
1827 .. opcode:: DTRUNC - Truncate
1831 dst.xy = trunc(src.xy)
1833 dst.zw = trunc(src.zw)
1835 .. opcode:: DCEIL - Ceiling
1839 dst.xy = \lceil src.xy\rceil
1841 dst.zw = \lceil src.zw\rceil
1843 .. opcode:: DFLR - Floor
1847 dst.xy = \lfloor src.xy\rfloor
1849 dst.zw = \lfloor src.zw\rfloor
1851 .. opcode:: DROUND - Fraction
1855 dst.xy = round(src.xy)
1857 dst.zw = round(src.zw)
1859 .. opcode:: DSSG - Set Sign
1863 dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
1865 dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
1867 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1869 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1870 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1871 :math:`dst1 \times 2^{dst0} = src` . The results are replicated across
1876 dst0.xy = dst.zw = frac(src.xy)
1881 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1883 This opcode is the inverse of :opcode:`DFRACEXP`. The second
1884 source is an integer.
1888 dst.xy = src0.xy \times 2^{src1.x}
1890 dst.zw = src0.zw \times 2^{src1.z}
1892 .. opcode:: DMIN - Minimum
1896 dst.xy = min(src0.xy, src1.xy)
1898 dst.zw = min(src0.zw, src1.zw)
1900 .. opcode:: DMAX - Maximum
1904 dst.xy = max(src0.xy, src1.xy)
1906 dst.zw = max(src0.zw, src1.zw)
1908 .. opcode:: DMUL - Multiply
1912 dst.xy = src0.xy \times src1.xy
1914 dst.zw = src0.zw \times src1.zw
1917 .. opcode:: DMAD - Multiply And Add
1921 dst.xy = src0.xy \times src1.xy + src2.xy
1923 dst.zw = src0.zw \times src1.zw + src2.zw
1926 .. opcode:: DFMA - Fused Multiply-Add
1928 Perform a * b + c with no intermediate rounding step.
1932 dst.xy = src0.xy \times src1.xy + src2.xy
1934 dst.zw = src0.zw \times src1.zw + src2.zw
1937 .. opcode:: DDIV - Divide
1941 dst.xy = \frac{src0.xy}{src1.xy}
1943 dst.zw = \frac{src0.zw}{src1.zw}
1946 .. opcode:: DRCP - Reciprocal
1950 dst.xy = \frac{1}{src.xy}
1952 dst.zw = \frac{1}{src.zw}
1954 .. opcode:: DSQRT - Square Root
1958 dst.xy = \sqrt{src.xy}
1960 dst.zw = \sqrt{src.zw}
1962 .. opcode:: DRSQ - Reciprocal Square Root
1966 dst.xy = \frac{1}{\sqrt{src.xy}}
1968 dst.zw = \frac{1}{\sqrt{src.zw}}
1970 .. opcode:: F2D - Float to Double
1974 dst.xy = double(src0.x)
1976 dst.zw = double(src0.y)
1978 .. opcode:: D2F - Double to Float
1982 dst.x = float(src0.xy)
1984 dst.y = float(src0.zw)
1986 .. opcode:: I2D - Int to Double
1990 dst.xy = double(src0.x)
1992 dst.zw = double(src0.y)
1994 .. opcode:: D2I - Double to Int
1998 dst.x = int(src0.xy)
2000 dst.y = int(src0.zw)
2002 .. opcode:: U2D - Unsigned Int to Double
2006 dst.xy = double(src0.x)
2008 dst.zw = double(src0.y)
2010 .. opcode:: D2U - Double to Unsigned Int
2014 dst.x = unsigned(src0.xy)
2016 dst.y = unsigned(src0.zw)
2021 The 64-bit integer opcodes reinterpret four-component vectors into
2022 two-component vectors with 64-bits in each component.
2024 .. opcode:: I64ABS - 64-bit Integer Absolute Value
2032 .. opcode:: I64NEG - 64-bit Integer Negate
2042 .. opcode:: I64SSG - 64-bit Integer Set Sign
2046 dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
2048 dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
2050 .. opcode:: U64ADD - 64-bit Integer Add
2054 dst.xy = src0.xy + src1.xy
2056 dst.zw = src0.zw + src1.zw
2058 .. opcode:: U64MUL - 64-bit Integer Multiply
2062 dst.xy = src0.xy * src1.xy
2064 dst.zw = src0.zw * src1.zw
2066 .. opcode:: U64SEQ - 64-bit Integer Set on Equal
2070 dst.x = src0.xy == src1.xy ? \sim 0 : 0
2072 dst.z = src0.zw == src1.zw ? \sim 0 : 0
2074 .. opcode:: U64SNE - 64-bit Integer Set on Not Equal
2078 dst.x = src0.xy != src1.xy ? \sim 0 : 0
2080 dst.z = src0.zw != src1.zw ? \sim 0 : 0
2082 .. opcode:: U64SLT - 64-bit Unsigned Integer Set on Less Than
2086 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2088 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2090 .. opcode:: U64SGE - 64-bit Unsigned Integer Set on Greater Equal
2094 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2096 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2098 .. opcode:: I64SLT - 64-bit Signed Integer Set on Less Than
2102 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2104 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2106 .. opcode:: I64SGE - 64-bit Signed Integer Set on Greater Equal
2110 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2112 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2114 .. opcode:: I64MIN - Minimum of 64-bit Signed Integers
2118 dst.xy = min(src0.xy, src1.xy)
2120 dst.zw = min(src0.zw, src1.zw)
2122 .. opcode:: U64MIN - Minimum of 64-bit Unsigned Integers
2126 dst.xy = min(src0.xy, src1.xy)
2128 dst.zw = min(src0.zw, src1.zw)
2130 .. opcode:: I64MAX - Maximum of 64-bit Signed Integers
2134 dst.xy = max(src0.xy, src1.xy)
2136 dst.zw = max(src0.zw, src1.zw)
2138 .. opcode:: U64MAX - Maximum of 64-bit Unsigned Integers
2142 dst.xy = max(src0.xy, src1.xy)
2144 dst.zw = max(src0.zw, src1.zw)
2146 .. opcode:: U64SHL - Shift Left 64-bit Unsigned Integer
2148 The shift count is masked with 0x3f before the shift is applied.
2152 dst.xy = src0.xy << (0x3f \& src1.x)
2154 dst.zw = src0.zw << (0x3f \& src1.y)
2156 .. opcode:: I64SHR - Arithmetic Shift Right (of 64-bit Signed Integer)
2158 The shift count is masked with 0x3f before the shift is applied.
2162 dst.xy = src0.xy >> (0x3f \& src1.x)
2164 dst.zw = src0.zw >> (0x3f \& src1.y)
2166 .. opcode:: U64SHR - Logical Shift Right (of 64-bit Unsigned Integer)
2168 The shift count is masked with 0x3f before the shift is applied.
2172 dst.xy = src0.xy >> (unsigned) (0x3f \& src1.x)
2174 dst.zw = src0.zw >> (unsigned) (0x3f \& src1.y)
2176 .. opcode:: I64DIV - 64-bit Signed Integer Division
2180 dst.xy = \frac{src0.xy}{src1.xy}
2182 dst.zw = \frac{src0.zw}{src1.zw}
2184 .. opcode:: U64DIV - 64-bit Unsigned Integer Division
2188 dst.xy = \frac{src0.xy}{src1.xy}
2190 dst.zw = \frac{src0.zw}{src1.zw}
2192 .. opcode:: U64MOD - 64-bit Unsigned Integer Remainder
2196 dst.xy = src0.xy \bmod src1.xy
2198 dst.zw = src0.zw \bmod src1.zw
2200 .. opcode:: I64MOD - 64-bit Signed Integer Remainder
2204 dst.xy = src0.xy \bmod src1.xy
2206 dst.zw = src0.zw \bmod src1.zw
2208 .. opcode:: F2U64 - Float to 64-bit Unsigned Int
2212 dst.xy = (uint64_t) src0.x
2214 dst.zw = (uint64_t) src0.y
2216 .. opcode:: F2I64 - Float to 64-bit Int
2220 dst.xy = (int64_t) src0.x
2222 dst.zw = (int64_t) src0.y
2224 .. opcode:: U2I64 - Unsigned Integer to 64-bit Integer
2226 This is a zero extension.
2230 dst.xy = (int64_t) src0.x
2232 dst.zw = (int64_t) src0.y
2234 .. opcode:: I2I64 - Signed Integer to 64-bit Integer
2236 This is a sign extension.
2240 dst.xy = (int64_t) src0.x
2242 dst.zw = (int64_t) src0.y
2244 .. opcode:: D2U64 - Double to 64-bit Unsigned Int
2248 dst.xy = (uint64_t) src0.xy
2250 dst.zw = (uint64_t) src0.zw
2252 .. opcode:: D2I64 - Double to 64-bit Int
2256 dst.xy = (int64_t) src0.xy
2258 dst.zw = (int64_t) src0.zw
2260 .. opcode:: U642F - 64-bit unsigned integer to float
2264 dst.x = (float) src0.xy
2266 dst.y = (float) src0.zw
2268 .. opcode:: I642F - 64-bit Int to Float
2272 dst.x = (float) src0.xy
2274 dst.y = (float) src0.zw
2276 .. opcode:: U642D - 64-bit unsigned integer to double
2280 dst.xy = (double) src0.xy
2282 dst.zw = (double) src0.zw
2284 .. opcode:: I642D - 64-bit Int to double
2288 dst.xy = (double) src0.xy
2290 dst.zw = (double) src0.zw
2292 .. _samplingopcodes:
2294 Resource Sampling Opcodes
2295 ^^^^^^^^^^^^^^^^^^^^^^^^^
2297 Those opcodes follow very closely semantics of the respective Direct3D
2298 instructions. If in doubt double check Direct3D documentation.
2299 Note that the swizzle on SVIEW (src1) determines texel swizzling
2304 Using provided address, sample data from the specified texture using the
2305 filtering mode identified by the given sampler. The source data may come from
2306 any resource type other than buffers.
2308 Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2310 Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2312 .. opcode:: SAMPLE_I
2314 Simplified alternative to the SAMPLE instruction. Using the provided
2315 integer address, SAMPLE_I fetches data from the specified sampler view
2316 without any filtering. The source data may come from any resource type
2319 Syntax: ``SAMPLE_I dst, address, sampler_view``
2321 Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2323 The 'address' is specified as unsigned integers. If the 'address' is out of
2324 range [0...(# texels - 1)] the result of the fetch is always 0 in all
2325 components. As such the instruction doesn't honor address wrap modes, in
2326 cases where that behavior is desirable 'SAMPLE' instruction should be used.
2327 address.w always provides an unsigned integer mipmap level. If the value is
2328 out of the range then the instruction always returns 0 in all components.
2329 address.yz are ignored for buffers and 1d textures. address.z is ignored
2330 for 1d texture arrays and 2d textures.
2332 For 1D texture arrays address.y provides the array index (also as unsigned
2333 integer). If the value is out of the range of available array indices
2334 [0... (array size - 1)] then the opcode always returns 0 in all components.
2335 For 2D texture arrays address.z provides the array index, otherwise it
2336 exhibits the same behavior as in the case for 1D texture arrays. The exact
2337 semantics of the source address are presented in the table below:
2339 +---------------------------+----+-----+-----+---------+
2340 | resource type | X | Y | Z | W |
2341 +===========================+====+=====+=====+=========+
2342 | ``PIPE_BUFFER`` | x | | | ignored |
2343 +---------------------------+----+-----+-----+---------+
2344 | ``PIPE_TEXTURE_1D`` | x | | | mpl |
2345 +---------------------------+----+-----+-----+---------+
2346 | ``PIPE_TEXTURE_2D`` | x | y | | mpl |
2347 +---------------------------+----+-----+-----+---------+
2348 | ``PIPE_TEXTURE_3D`` | x | y | z | mpl |
2349 +---------------------------+----+-----+-----+---------+
2350 | ``PIPE_TEXTURE_RECT`` | x | y | | mpl |
2351 +---------------------------+----+-----+-----+---------+
2352 | ``PIPE_TEXTURE_CUBE`` | not allowed as source |
2353 +---------------------------+----+-----+-----+---------+
2354 | ``PIPE_TEXTURE_1D_ARRAY`` | x | idx | | mpl |
2355 +---------------------------+----+-----+-----+---------+
2356 | ``PIPE_TEXTURE_2D_ARRAY`` | x | y | idx | mpl |
2357 +---------------------------+----+-----+-----+---------+
2359 Where 'mpl' is a mipmap level and 'idx' is the array index.
2361 .. opcode:: SAMPLE_I_MS
2363 Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2365 Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2367 .. opcode:: SAMPLE_B
2369 Just like the SAMPLE instruction with the exception that an additional bias
2370 is applied to the level of detail computed as part of the instruction
2373 Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2375 Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2377 .. opcode:: SAMPLE_C
2379 Similar to the SAMPLE instruction but it performs a comparison filter. The
2380 operands to SAMPLE_C are identical to SAMPLE, except that there is an
2381 additional float32 operand, reference value, which must be a register with
2382 single-component, or a scalar literal. SAMPLE_C makes the hardware use the
2383 current samplers compare_func (in pipe_sampler_state) to compare reference
2384 value against the red component value for the surce resource at each texel
2385 that the currently configured texture filter covers based on the provided
2388 Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2390 Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2392 .. opcode:: SAMPLE_C_LZ
2394 Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2397 Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2399 Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2402 .. opcode:: SAMPLE_D
2404 SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2405 the source address in the x direction and the y direction are provided by
2408 Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2410 Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2412 .. opcode:: SAMPLE_L
2414 SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2415 directly as a scalar value, representing no anisotropy.
2417 Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2419 Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2423 Gathers the four texels to be used in a bi-linear filtering operation and
2424 packs them into a single register. Only works with 2D, 2D array, cubemaps,
2425 and cubemaps arrays. For 2D textures, only the addressing modes of the
2426 sampler and the top level of any mip pyramid are used. Set W to zero. It
2427 behaves like the SAMPLE instruction, but a filtered sample is not
2428 generated. The four samples that contribute to filtering are placed into
2429 xyzw in counter-clockwise order, starting with the (u,v) texture coordinate
2430 delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2431 magnitude of the deltas are half a texel.
2434 .. opcode:: SVIEWINFO
2436 Query the dimensions of a given sampler view. dst receives width, height,
2437 depth or array size and number of mipmap levels as int4. The dst can have a
2438 writemask which will specify what info is the caller interested in.
2440 Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2442 Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2444 src_mip_level is an unsigned integer scalar. If it's out of range then
2445 returns 0 for width, height and depth/array size but the total number of
2446 mipmap is still returned correctly for the given sampler view. The returned
2447 width, height and depth values are for the mipmap level selected by the
2448 src_mip_level and are in the number of texels. For 1d texture array width
2449 is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2450 still in dst.w. In contrast to d3d10 resinfo, there's no way in the tgsi
2451 instruction encoding to specify the return type (float/rcpfloat/uint), hence
2452 always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2453 resinfo allowing swizzling dst values is ignored (due to the interaction
2454 with rcpfloat modifier which requires some swizzle handling in the state
2457 .. opcode:: SAMPLE_POS
2459 Query the position of a sample in the given resource or render target
2460 when per-sample fragment shading is in effect.
2462 Syntax: ``SAMPLE_POS dst, source, sample_index``
2464 dst receives float4 (x, y, undef, undef) indicated where the sample is
2465 located. Sample locations are in the range [0, 1] where 0.5 is the center
2468 source is either a sampler view (to indicate a shader resource) or temp
2469 register (to indicate the render target). The source register may have
2470 an optional swizzle to apply to the returned result
2472 sample_index is an integer scalar indicating which sample position is to
2475 If per-sample shading is not in effect or the source resource or render
2476 target is not multisampled, the result is (0.5, 0.5, undef, undef).
2478 NOTE: no driver has implemented this opcode yet (and no state tracker
2479 emits it). This information is subject to change.
2481 .. opcode:: SAMPLE_INFO
2483 Query the number of samples in a multisampled resource or render target.
2485 Syntax: ``SAMPLE_INFO dst, source``
2487 dst receives int4 (n, 0, 0, 0) where n is the number of samples in a
2488 resource or the render target.
2490 source is either a sampler view (to indicate a shader resource) or temp
2491 register (to indicate the render target). The source register may have
2492 an optional swizzle to apply to the returned result
2494 If per-sample shading is not in effect or the source resource or render
2495 target is not multisampled, the result is (1, 0, 0, 0).
2497 NOTE: no driver has implemented this opcode yet (and no state tracker
2498 emits it). This information is subject to change.
2500 .. opcode:: LOD - level of detail
2502 Same syntax as the SAMPLE opcode but instead of performing an actual
2503 texture lookup/filter, return the computed LOD information that the
2504 texture pipe would use to access the texture. The Y component contains
2505 the computed LOD lambda_prime. The X component contains the LOD that will
2506 be accessed, based on min/max lod's and mipmap filters.
2507 The Z and W components are set to 0.
2509 Syntax: ``LOD dst, address, sampler_view, sampler``
2512 .. _resourceopcodes:
2514 Resource Access Opcodes
2515 ^^^^^^^^^^^^^^^^^^^^^^^
2517 For these opcodes, the resource can be a BUFFER, IMAGE, or MEMORY.
2519 .. opcode:: LOAD - Fetch data from a shader buffer or image
2521 Syntax: ``LOAD dst, resource, address``
2523 Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
2525 Using the provided integer address, LOAD fetches data
2526 from the specified buffer or texture without any
2529 The 'address' is specified as a vector of unsigned
2530 integers. If the 'address' is out of range the result
2533 Only the first mipmap level of a resource can be read
2534 from using this instruction.
2536 For 1D or 2D texture arrays, the array index is
2537 provided as an unsigned integer in address.y or
2538 address.z, respectively. address.yz are ignored for
2539 buffers and 1D textures. address.z is ignored for 1D
2540 texture arrays and 2D textures. address.w is always
2543 A swizzle suffix may be added to the resource argument
2544 this will cause the resource data to be swizzled accordingly.
2546 .. opcode:: STORE - Write data to a shader resource
2548 Syntax: ``STORE resource, address, src``
2550 Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
2552 Using the provided integer address, STORE writes data
2553 to the specified buffer or texture.
2555 The 'address' is specified as a vector of unsigned
2556 integers. If the 'address' is out of range the result
2559 Only the first mipmap level of a resource can be
2560 written to using this instruction.
2562 For 1D or 2D texture arrays, the array index is
2563 provided as an unsigned integer in address.y or
2564 address.z, respectively. address.yz are ignored for
2565 buffers and 1D textures. address.z is ignored for 1D
2566 texture arrays and 2D textures. address.w is always
2569 .. opcode:: RESQ - Query information about a resource
2571 Syntax: ``RESQ dst, resource``
2573 Example: ``RESQ TEMP[0], BUFFER[0]``
2575 Returns information about the buffer or image resource. For buffer
2576 resources, the size (in bytes) is returned in the x component. For
2577 image resources, .xyz will contain the width/height/layers of the
2578 image, while .w will contain the number of samples for multi-sampled
2581 .. opcode:: FBFETCH - Load data from framebuffer
2583 Syntax: ``FBFETCH dst, output``
2585 Example: ``FBFETCH TEMP[0], OUT[0]``
2587 This is only valid on ``COLOR`` semantic outputs. Returns the color
2588 of the current position in the framebuffer from before this fragment
2589 shader invocation. May return the same value from multiple calls for
2590 a particular output within a single invocation. Note that result may
2591 be undefined if a fragment is drawn multiple times without a blend
2595 .. _bindlessopcodes:
2600 These opcodes are for working with bindless sampler or image handles and
2601 require PIPE_CAP_BINDLESS_TEXTURE.
2603 .. opcode:: IMG2HND - Get a bindless handle for a image
2605 Syntax: ``IMG2HND dst, image``
2607 Example: ``IMG2HND TEMP[0], IMAGE[0]``
2609 Sets 'dst' to a bindless handle for 'image'.
2611 .. opcode:: SAMP2HND - Get a bindless handle for a sampler
2613 Syntax: ``SAMP2HND dst, sampler``
2615 Example: ``SAMP2HND TEMP[0], SAMP[0]``
2617 Sets 'dst' to a bindless handle for 'sampler'.
2620 .. _threadsyncopcodes:
2622 Inter-thread synchronization opcodes
2623 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2625 These opcodes are intended for communication between threads running
2626 within the same compute grid. For now they're only valid in compute
2629 .. opcode:: BARRIER - Thread group barrier
2633 This opcode suspends the execution of the current thread until all
2634 the remaining threads in the working group reach the same point of
2635 the program. Results are unspecified if any of the remaining
2636 threads terminates or never reaches an executed BARRIER instruction.
2638 .. opcode:: MEMBAR - Memory barrier
2642 This opcode waits for the completion of all memory accesses based on
2643 the type passed in. The type is an immediate bitfield with the following
2646 Bit 0: Shader storage buffers
2647 Bit 1: Atomic buffers
2649 Bit 3: Shared memory
2652 These may be passed in in any combination. An implementation is free to not
2653 distinguish between these as it sees fit. However these map to all the
2654 possibilities made available by GLSL.
2661 These opcodes provide atomic variants of some common arithmetic and
2662 logical operations. In this context atomicity means that another
2663 concurrent memory access operation that affects the same memory
2664 location is guaranteed to be performed strictly before or after the
2665 entire execution of the atomic operation. The resource may be a BUFFER,
2666 IMAGE, HWATOMIC, or MEMORY. In the case of an image, the offset works
2667 the same as for ``LOAD`` and ``STORE``, specified above. For atomic
2668 counters, the offset is an immediate index to the base hw atomic
2669 counter for this operation.
2670 These atomic operations may only be used with 32-bit integer image formats.
2672 .. opcode:: ATOMUADD - Atomic integer addition
2674 Syntax: ``ATOMUADD dst, resource, offset, src``
2676 Example: ``ATOMUADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2678 The following operation is performed atomically:
2682 dst_x = resource[offset]
2684 resource[offset] = dst_x + src_x
2687 .. opcode:: ATOMFADD - Atomic floating point addition
2689 Syntax: ``ATOMFADD dst, resource, offset, src``
2691 Example: ``ATOMFADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2693 The following operation is performed atomically:
2697 dst_x = resource[offset]
2699 resource[offset] = dst_x + src_x
2702 .. opcode:: ATOMXCHG - Atomic exchange
2704 Syntax: ``ATOMXCHG dst, resource, offset, src``
2706 Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2708 The following operation is performed atomically:
2712 dst_x = resource[offset]
2714 resource[offset] = src_x
2717 .. opcode:: ATOMCAS - Atomic compare-and-exchange
2719 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2721 Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
2723 The following operation is performed atomically:
2727 dst_x = resource[offset]
2729 resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
2732 .. opcode:: ATOMAND - Atomic bitwise And
2734 Syntax: ``ATOMAND dst, resource, offset, src``
2736 Example: ``ATOMAND TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2738 The following operation is performed atomically:
2742 dst_x = resource[offset]
2744 resource[offset] = dst_x \& src_x
2747 .. opcode:: ATOMOR - Atomic bitwise Or
2749 Syntax: ``ATOMOR dst, resource, offset, src``
2751 Example: ``ATOMOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2753 The following operation is performed atomically:
2757 dst_x = resource[offset]
2759 resource[offset] = dst_x | src_x
2762 .. opcode:: ATOMXOR - Atomic bitwise Xor
2764 Syntax: ``ATOMXOR dst, resource, offset, src``
2766 Example: ``ATOMXOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2768 The following operation is performed atomically:
2772 dst_x = resource[offset]
2774 resource[offset] = dst_x \oplus src_x
2777 .. opcode:: ATOMUMIN - Atomic unsigned minimum
2779 Syntax: ``ATOMUMIN dst, resource, offset, src``
2781 Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2783 The following operation is performed atomically:
2787 dst_x = resource[offset]
2789 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2792 .. opcode:: ATOMUMAX - Atomic unsigned maximum
2794 Syntax: ``ATOMUMAX dst, resource, offset, src``
2796 Example: ``ATOMUMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2798 The following operation is performed atomically:
2802 dst_x = resource[offset]
2804 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2807 .. opcode:: ATOMIMIN - Atomic signed minimum
2809 Syntax: ``ATOMIMIN dst, resource, offset, src``
2811 Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2813 The following operation is performed atomically:
2817 dst_x = resource[offset]
2819 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2822 .. opcode:: ATOMIMAX - Atomic signed maximum
2824 Syntax: ``ATOMIMAX dst, resource, offset, src``
2826 Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2828 The following operation is performed atomically:
2832 dst_x = resource[offset]
2834 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2837 .. opcode:: ATOMINC_WRAP - Atomic increment + wrap around
2839 Syntax: ``ATOMINC_WRAP dst, resource, offset, src``
2841 Example: ``ATOMINC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2843 The following operation is performed atomically:
2847 dst_x = resource[offset] + 1
2849 resource[offset] = dst_x <= src_x ? dst_x : 0
2852 .. opcode:: ATOMDEC_WRAP - Atomic decrement + wrap around
2854 Syntax: ``ATOMDEC_WRAP dst, resource, offset, src``
2856 Example: ``ATOMDEC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2858 The following operation is performed atomically:
2862 dst_x = resource[offset]
2864 resource[offset] = (dst_x > 0 && dst_x < src_x) ? dst_x - 1 : 0
2867 .. _interlaneopcodes:
2872 These opcodes reduce the given value across the shader invocations
2873 running in the current SIMD group. Every thread in the subgroup will receive
2874 the same result. The BALLOT operations accept a single-channel argument that
2875 is treated as a boolean and produce a 64-bit value.
2877 .. opcode:: VOTE_ANY - Value is set in any of the active invocations
2879 Syntax: ``VOTE_ANY dst, value``
2881 Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
2884 .. opcode:: VOTE_ALL - Value is set in all of the active invocations
2886 Syntax: ``VOTE_ALL dst, value``
2888 Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
2891 .. opcode:: VOTE_EQ - Value is the same in all of the active invocations
2893 Syntax: ``VOTE_EQ dst, value``
2895 Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
2898 .. opcode:: BALLOT - Lanemask of whether the value is set in each active
2901 Syntax: ``BALLOT dst, value``
2903 Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
2905 When the argument is a constant true, this produces a bitmask of active
2906 invocations. In fragment shaders, this can include helper invocations
2907 (invocations whose outputs and writes to memory are discarded, but which
2908 are used to compute derivatives).
2911 .. opcode:: READ_FIRST - Broadcast the value from the first active
2912 invocation to all active lanes
2914 Syntax: ``READ_FIRST dst, value``
2916 Example: ``READ_FIRST TEMP[0], TEMP[1]``
2919 .. opcode:: READ_INVOC - Retrieve the value from the given invocation
2920 (need not be uniform)
2922 Syntax: ``READ_INVOC dst, value, invocation``
2924 Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
2926 invocation.x controls the invocation number to read from for all channels.
2927 The invocation number must be the same across all active invocations in a
2928 sub-group; otherwise, the results are undefined.
2931 Explanation of symbols used
2932 ------------------------------
2939 :math:`|x|` Absolute value of `x`.
2941 :math:`\lceil x \rceil` Ceiling of `x`.
2943 clamp(x,y,z) Clamp x between y and z.
2944 (x < y) ? y : (x > z) ? z : x
2946 :math:`\lfloor x\rfloor` Floor of `x`.
2948 :math:`\log_2{x}` Logarithm of `x`, base 2.
2950 max(x,y) Maximum of x and y.
2953 min(x,y) Minimum of x and y.
2956 partialx(x) Derivative of x relative to fragment's X.
2958 partialy(x) Derivative of x relative to fragment's Y.
2960 pop() Pop from stack.
2962 :math:`x^y` `x` to the power `y`.
2964 push(x) Push x on stack.
2968 trunc(x) Truncate x, i.e. drop the fraction bits.
2975 discard Discard fragment.
2979 target Label of target instruction.
2990 Declares a register that is will be referenced as an operand in Instruction
2993 File field contains register file that is being declared and is one
2996 UsageMask field specifies which of the register components can be accessed
2997 and is one of TGSI_WRITEMASK.
2999 The Local flag specifies that a given value isn't intended for
3000 subroutine parameter passing and, as a result, the implementation
3001 isn't required to give any guarantees of it being preserved across
3002 subroutine boundaries. As it's merely a compiler hint, the
3003 implementation is free to ignore it.
3005 If Dimension flag is set to 1, a Declaration Dimension token follows.
3007 If Semantic flag is set to 1, a Declaration Semantic token follows.
3009 If Interpolate flag is set to 1, a Declaration Interpolate token follows.
3011 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
3013 If Array flag is set to 1, a Declaration Array token follows.
3016 ^^^^^^^^^^^^^^^^^^^^^^^^
3018 Declarations can optional have an ArrayID attribute which can be referred by
3019 indirect addressing operands. An ArrayID of zero is reserved and treated as
3020 if no ArrayID is specified.
3022 If an indirect addressing operand refers to a specific declaration by using
3023 an ArrayID only the registers in this declaration are guaranteed to be
3024 accessed, accessing any register outside this declaration results in undefined
3025 behavior. Note that for compatibility the effective index is zero-based and
3026 not relative to the specified declaration
3028 If no ArrayID is specified with an indirect addressing operand the whole
3029 register file might be accessed by this operand. This is strongly discouraged
3030 and will prevent packing of scalar/vec2 arrays and effective alias analysis.
3031 This is only legal for TEMP and CONST register files.
3033 Declaration Semantic
3034 ^^^^^^^^^^^^^^^^^^^^^^^^
3036 Vertex and fragment shader input and output registers may be labeled
3037 with semantic information consisting of a name and index.
3039 Follows Declaration token if Semantic bit is set.
3041 Since its purpose is to link a shader with other stages of the pipeline,
3042 it is valid to follow only those Declaration tokens that declare a register
3043 either in INPUT or OUTPUT file.
3045 SemanticName field contains the semantic name of the register being declared.
3046 There is no default value.
3048 SemanticIndex is an optional subscript that can be used to distinguish
3049 different register declarations with the same semantic name. The default value
3052 The meanings of the individual semantic names are explained in the following
3055 TGSI_SEMANTIC_POSITION
3056 """"""""""""""""""""""
3058 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
3059 output register which contains the homogeneous vertex position in the clip
3060 space coordinate system. After clipping, the X, Y and Z components of the
3061 vertex will be divided by the W value to get normalized device coordinates.
3063 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
3064 fragment shader input (or system value, depending on which one is
3065 supported by the driver) contains the fragment's window position. The X
3066 component starts at zero and always increases from left to right.
3067 The Y component starts at zero and always increases but Y=0 may either
3068 indicate the top of the window or the bottom depending on the fragment
3069 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
3070 The Z coordinate ranges from 0 to 1 to represent depth from the front
3071 to the back of the Z buffer. The W component contains the interpolated
3072 reciprocal of the vertex position W component (corresponding to gl_Fragcoord,
3073 but unlike d3d10 which interpolates the same 1/w but then gives back
3074 the reciprocal of the interpolated value).
3076 Fragment shaders may also declare an output register with
3077 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
3078 the fragment shader to change the fragment's Z position.
3085 For vertex shader outputs or fragment shader inputs/outputs, this
3086 label indicates that the register contains an R,G,B,A color.
3088 Several shader inputs/outputs may contain colors so the semantic index
3089 is used to distinguish them. For example, color[0] may be the diffuse
3090 color while color[1] may be the specular color.
3092 This label is needed so that the flat/smooth shading can be applied
3093 to the right interpolants during rasterization.
3097 TGSI_SEMANTIC_BCOLOR
3098 """"""""""""""""""""
3100 Back-facing colors are only used for back-facing polygons, and are only valid
3101 in vertex shader outputs. After rasterization, all polygons are front-facing
3102 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
3103 so all BCOLORs effectively become regular COLORs in the fragment shader.
3109 Vertex shader inputs and outputs and fragment shader inputs may be
3110 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
3111 a fog coordinate. Typically, the fragment shader will use the fog coordinate
3112 to compute a fog blend factor which is used to blend the normal fragment color
3113 with a constant fog color. But fog coord really is just an ordinary vec4
3114 register like regular semantics.
3120 Vertex shader input and output registers may be labeled with
3121 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
3122 in the form (S, 0, 0, 1). The point size controls the width or diameter
3123 of points for rasterization. This label cannot be used in fragment
3126 When using this semantic, be sure to set the appropriate state in the
3127 :ref:`rasterizer` first.
3130 TGSI_SEMANTIC_TEXCOORD
3131 """"""""""""""""""""""
3133 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3135 Vertex shader outputs and fragment shader inputs may be labeled with
3136 this semantic to make them replaceable by sprite coordinates via the
3137 sprite_coord_enable state in the :ref:`rasterizer`.
3138 The semantic index permitted with this semantic is limited to <= 7.
3140 If the driver does not support TEXCOORD, sprite coordinate replacement
3141 applies to inputs with the GENERIC semantic instead.
3143 The intended use case for this semantic is gl_TexCoord.
3146 TGSI_SEMANTIC_PCOORD
3147 """"""""""""""""""""
3149 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3151 Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
3152 that the register contains sprite coordinates in the form (x, y, 0, 1), if
3153 the current primitive is a point and point sprites are enabled. Otherwise,
3154 the contents of the register are undefined.
3156 The intended use case for this semantic is gl_PointCoord.
3159 TGSI_SEMANTIC_GENERIC
3160 """""""""""""""""""""
3162 All vertex/fragment shader inputs/outputs not labeled with any other
3163 semantic label can be considered to be generic attributes. Typical
3164 uses of generic inputs/outputs are texcoords and user-defined values.
3167 TGSI_SEMANTIC_NORMAL
3168 """"""""""""""""""""
3170 Indicates that a vertex shader input is a normal vector. This is
3171 typically only used for legacy graphics APIs.
3177 This label applies to fragment shader inputs (or system values,
3178 depending on which one is supported by the driver) and indicates that
3179 the register contains front/back-face information.
3181 If it is an input, it will be a floating-point vector in the form (F, 0, 0, 1),
3182 where F will be positive when the fragment belongs to a front-facing polygon,
3183 and negative when the fragment belongs to a back-facing polygon.
3185 If it is a system value, it will be an integer vector in the form (F, 0, 0, 1),
3186 where F is 0xffffffff when the fragment belongs to a front-facing polygon and
3187 0 when the fragment belongs to a back-facing polygon.
3190 TGSI_SEMANTIC_EDGEFLAG
3191 """"""""""""""""""""""
3193 For vertex shaders, this sematic label indicates that an input or
3194 output is a boolean edge flag. The register layout is [F, x, x, x]
3195 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
3196 simply copies the edge flag input to the edgeflag output.
3198 Edge flags are used to control which lines or points are actually
3199 drawn when the polygon mode converts triangles/quads/polygons into
3203 TGSI_SEMANTIC_STENCIL
3204 """""""""""""""""""""
3206 For fragment shaders, this semantic label indicates that an output
3207 is a writable stencil reference value. Only the Y component is writable.
3208 This allows the fragment shader to change the fragments stencilref value.
3211 TGSI_SEMANTIC_VIEWPORT_INDEX
3212 """"""""""""""""""""""""""""
3214 For geometry shaders, this semantic label indicates that an output
3215 contains the index of the viewport (and scissor) to use.
3216 This is an integer value, and only the X component is used.
3218 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3219 supported, then this semantic label can also be used in vertex or
3220 tessellation evaluation shaders, respectively. Only the value written in the
3221 last vertex processing stage is used.
3227 For geometry shaders, this semantic label indicates that an output
3228 contains the layer value to use for the color and depth/stencil surfaces.
3229 This is an integer value, and only the X component is used.
3230 (Also known as rendertarget array index.)
3232 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3233 supported, then this semantic label can also be used in vertex or
3234 tessellation evaluation shaders, respectively. Only the value written in the
3235 last vertex processing stage is used.
3238 TGSI_SEMANTIC_CLIPDIST
3239 """"""""""""""""""""""
3241 Note this covers clipping and culling distances.
3243 When components of vertex elements are identified this way, these
3244 values are each assumed to be a float32 signed distance to a plane.
3247 Primitive setup only invokes rasterization on pixels for which
3248 the interpolated plane distances are >= 0.
3251 Primitives will be completely discarded if the plane distance
3252 for all of the vertices in the primitive are < 0.
3253 If a vertex has a cull distance of NaN, that vertex counts as "out"
3256 Multiple clip/cull planes can be implemented simultaneously, by
3257 annotating multiple components of one or more vertex elements with
3258 the above specified semantic.
3259 The limits on both clip and cull distances are bound
3260 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3261 the maximum number of components that can be used to hold the
3262 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3263 which specifies the maximum number of registers which can be
3264 annotated with those semantics.
3265 The properties NUM_CLIPDIST_ENABLED and NUM_CULLDIST_ENABLED
3266 are used to divide up the 2 x vec4 space between clipping and culling.
3268 TGSI_SEMANTIC_SAMPLEID
3269 """"""""""""""""""""""
3271 For fragment shaders, this semantic label indicates that a system value
3272 contains the current sample id (i.e. gl_SampleID) as an unsigned int.
3273 Only the X component is used. If per-sample shading is not enabled,
3274 the result is (0, undef, undef, undef).
3276 Note that if the fragment shader uses this system value, the fragment
3277 shader is automatically executed at per sample frequency.
3279 TGSI_SEMANTIC_SAMPLEPOS
3280 """""""""""""""""""""""
3282 For fragment shaders, this semantic label indicates that a system
3283 value contains the current sample's position as float4(x, y, undef, undef)
3284 in the render target (i.e. gl_SamplePosition) when per-fragment shading
3285 is in effect. Position values are in the range [0, 1] where 0.5 is
3286 the center of the fragment.
3288 Note that if the fragment shader uses this system value, the fragment
3289 shader is automatically executed at per sample frequency.
3291 TGSI_SEMANTIC_SAMPLEMASK
3292 """"""""""""""""""""""""
3294 For fragment shaders, this semantic label can be applied to either a
3295 shader system value input or output.
3297 For a system value, the sample mask indicates the set of samples covered by
3298 the current primitive. If MSAA is not enabled, the value is (1, 0, 0, 0).
3300 For an output, the sample mask is used to disable further sample processing.
3302 For both, the register type is uint[4] but only the X component is used
3303 (i.e. gl_SampleMask[0]). Each bit corresponds to one sample position (up
3304 to 32x MSAA is supported).
3306 TGSI_SEMANTIC_INVOCATIONID
3307 """"""""""""""""""""""""""
3309 For geometry shaders, this semantic label indicates that a system value
3310 contains the current invocation id (i.e. gl_InvocationID).
3311 This is an integer value, and only the X component is used.
3313 TGSI_SEMANTIC_INSTANCEID
3314 """"""""""""""""""""""""
3316 For vertex shaders, this semantic label indicates that a system value contains
3317 the current instance id (i.e. gl_InstanceID). It does not include the base
3318 instance. This is an integer value, and only the X component is used.
3320 TGSI_SEMANTIC_VERTEXID
3321 """"""""""""""""""""""
3323 For vertex shaders, this semantic label indicates that a system value contains
3324 the current vertex id (i.e. gl_VertexID). It does (unlike in d3d10) include the
3325 base vertex. This is an integer value, and only the X component is used.
3327 TGSI_SEMANTIC_VERTEXID_NOBASE
3328 """""""""""""""""""""""""""""""
3330 For vertex shaders, this semantic label indicates that a system value contains
3331 the current vertex id without including the base vertex (this corresponds to
3332 d3d10 vertex id, so TGSI_SEMANTIC_VERTEXID_NOBASE + TGSI_SEMANTIC_BASEVERTEX
3333 == TGSI_SEMANTIC_VERTEXID). This is an integer value, and only the X component
3336 TGSI_SEMANTIC_BASEVERTEX
3337 """"""""""""""""""""""""
3339 For vertex shaders, this semantic label indicates that a system value contains
3340 the base vertex (i.e. gl_BaseVertex). Note that for non-indexed draw calls,
3341 this contains the first (or start) value instead.
3342 This is an integer value, and only the X component is used.
3344 TGSI_SEMANTIC_PRIMID
3345 """"""""""""""""""""
3347 For geometry and fragment shaders, this semantic label indicates the value
3348 contains the primitive id (i.e. gl_PrimitiveID). This is an integer value,
3349 and only the X component is used.
3350 FIXME: This right now can be either a ordinary input or a system value...
3356 For tessellation evaluation/control shaders, this semantic label indicates a
3357 generic per-patch attribute. Such semantics will not implicitly be per-vertex
3360 TGSI_SEMANTIC_TESSCOORD
3361 """""""""""""""""""""""
3363 For tessellation evaluation shaders, this semantic label indicates the
3364 coordinates of the vertex being processed. This is available in XYZ; W is
3367 TGSI_SEMANTIC_TESSOUTER
3368 """""""""""""""""""""""
3370 For tessellation evaluation/control shaders, this semantic label indicates the
3371 outer tessellation levels of the patch. Isoline tessellation will only have XY
3372 defined, triangle will have XYZ and quads will have XYZW defined. This
3373 corresponds to gl_TessLevelOuter.
3375 TGSI_SEMANTIC_TESSINNER
3376 """""""""""""""""""""""
3378 For tessellation evaluation/control shaders, this semantic label indicates the
3379 inner tessellation levels of the patch. The X value is only defined for
3380 triangle tessellation, while quads will have XY defined. This is entirely
3381 undefined for isoline tessellation.
3383 TGSI_SEMANTIC_VERTICESIN
3384 """"""""""""""""""""""""
3386 For tessellation evaluation/control shaders, this semantic label indicates the
3387 number of vertices provided in the input patch. Only the X value is defined.
3389 TGSI_SEMANTIC_HELPER_INVOCATION
3390 """""""""""""""""""""""""""""""
3392 For fragment shaders, this semantic indicates whether the current
3393 invocation is covered or not. Helper invocations are created in order
3394 to properly compute derivatives, however it may be desirable to skip
3395 some of the logic in those cases. See ``gl_HelperInvocation`` documentation.
3397 TGSI_SEMANTIC_BASEINSTANCE
3398 """"""""""""""""""""""""""
3400 For vertex shaders, the base instance argument supplied for this
3401 draw. This is an integer value, and only the X component is used.
3403 TGSI_SEMANTIC_DRAWID
3404 """"""""""""""""""""
3406 For vertex shaders, the zero-based index of the current draw in a
3407 ``glMultiDraw*`` invocation. This is an integer value, and only the X
3411 TGSI_SEMANTIC_WORK_DIM
3412 """"""""""""""""""""""
3414 For compute shaders started via opencl this retrieves the work_dim
3415 parameter to the clEnqueueNDRangeKernel call with which the shader
3419 TGSI_SEMANTIC_GRID_SIZE
3420 """""""""""""""""""""""
3422 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3423 of a grid of thread blocks.
3426 TGSI_SEMANTIC_BLOCK_ID
3427 """"""""""""""""""""""
3429 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3430 current block inside of the grid.
3433 TGSI_SEMANTIC_BLOCK_SIZE
3434 """"""""""""""""""""""""
3436 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3437 of a block in threads.
3440 TGSI_SEMANTIC_THREAD_ID
3441 """""""""""""""""""""""
3443 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3444 current thread inside of the block.
3447 TGSI_SEMANTIC_SUBGROUP_SIZE
3448 """""""""""""""""""""""""""
3450 This semantic indicates the subgroup size for the current invocation. This is
3451 an integer of at most 64, as it indicates the width of lanemasks. It does not
3452 depend on the number of invocations that are active.
3455 TGSI_SEMANTIC_SUBGROUP_INVOCATION
3456 """""""""""""""""""""""""""""""""
3458 The index of the current invocation within its subgroup.
3461 TGSI_SEMANTIC_SUBGROUP_EQ_MASK
3462 """"""""""""""""""""""""""""""
3464 A bit mask of ``bit index == TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3465 ``1 << subgroup_invocation`` in arbitrary precision arithmetic.
3468 TGSI_SEMANTIC_SUBGROUP_GE_MASK
3469 """"""""""""""""""""""""""""""
3471 A bit mask of ``bit index >= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3472 ``((1 << (subgroup_size - subgroup_invocation)) - 1) << subgroup_invocation``
3473 in arbitrary precision arithmetic.
3476 TGSI_SEMANTIC_SUBGROUP_GT_MASK
3477 """"""""""""""""""""""""""""""
3479 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3480 ``((1 << (subgroup_size - subgroup_invocation - 1)) - 1) << (subgroup_invocation + 1)``
3481 in arbitrary precision arithmetic.
3484 TGSI_SEMANTIC_SUBGROUP_LE_MASK
3485 """"""""""""""""""""""""""""""
3487 A bit mask of ``bit index <= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3488 ``(1 << (subgroup_invocation + 1)) - 1`` in arbitrary precision arithmetic.
3491 TGSI_SEMANTIC_SUBGROUP_LT_MASK
3492 """"""""""""""""""""""""""""""
3494 A bit mask of ``bit index < TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3495 ``(1 << subgroup_invocation) - 1`` in arbitrary precision arithmetic.
3498 Declaration Interpolate
3499 ^^^^^^^^^^^^^^^^^^^^^^^
3501 This token is only valid for fragment shader INPUT declarations.
3503 The Interpolate field specifes the way input is being interpolated by
3504 the rasteriser and is one of TGSI_INTERPOLATE_*.
3506 The Location field specifies the location inside the pixel that the
3507 interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. Note that
3508 when per-sample shading is enabled, the implementation may choose to
3509 interpolate at the sample irrespective of the Location field.
3511 The CylindricalWrap bitfield specifies which register components
3512 should be subject to cylindrical wrapping when interpolating by the
3513 rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
3514 should be interpolated according to cylindrical wrapping rules.
3517 Declaration Sampler View
3518 ^^^^^^^^^^^^^^^^^^^^^^^^
3520 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
3522 DCL SVIEW[#], resource, type(s)
3524 Declares a shader input sampler view and assigns it to a SVIEW[#]
3527 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
3529 type must be 1 or 4 entries (if specifying on a per-component
3530 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
3532 For TEX\* style texture sample opcodes (as opposed to SAMPLE\* opcodes
3533 which take an explicit SVIEW[#] source register), there may be optionally
3534 SVIEW[#] declarations. In this case, the SVIEW index is implied by the
3535 SAMP index, and there must be a corresponding SVIEW[#] declaration for
3536 each SAMP[#] declaration. Drivers are free to ignore this if they wish.
3537 But note in particular that some drivers need to know the sampler type
3538 (float/int/unsigned) in order to generate the correct code, so cases
3539 where integer textures are sampled, SVIEW[#] declarations should be
3542 NOTE: It is NOT legal to mix SAMPLE\* style opcodes and TEX\* opcodes
3545 Declaration Resource
3546 ^^^^^^^^^^^^^^^^^^^^
3548 Follows Declaration token if file is TGSI_FILE_RESOURCE.
3550 DCL RES[#], resource [, WR] [, RAW]
3552 Declares a shader input resource and assigns it to a RES[#]
3555 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
3558 If the RAW keyword is not specified, the texture data will be
3559 subject to conversion, swizzling and scaling as required to yield
3560 the specified data type from the physical data format of the bound
3563 If the RAW keyword is specified, no channel conversion will be
3564 performed: the values read for each of the channels (X,Y,Z,W) will
3565 correspond to consecutive words in the same order and format
3566 they're found in memory. No element-to-address conversion will be
3567 performed either: the value of the provided X coordinate will be
3568 interpreted in byte units instead of texel units. The result of
3569 accessing a misaligned address is undefined.
3571 Usage of the STORE opcode is only allowed if the WR (writable) flag
3574 Hardware Atomic Register File
3575 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3577 Hardware atomics are declared as a 2D array with an optional array id.
3579 The first member of the dimension is the buffer resource the atomic
3581 The second member is a range into the buffer resource, either for
3582 one or multiple counters. If this is an array, the declaration will have
3585 Each counter is 4 bytes in size, and index and ranges are in counters not bytes.
3589 This declares two atomics, one at the start of the buffer and one in the
3594 DCL HWATOMIC[1][1..3], ARRAY(1)
3596 This declares 5 atomics, one in buffer 0 at 0,
3597 one in buffer 1 at 0, and an array of 3 atomics in
3598 the buffer 1, starting at 1.
3601 ^^^^^^^^^^^^^^^^^^^^^^^^
3603 Properties are general directives that apply to the whole TGSI program.
3608 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
3609 The default value is UPPER_LEFT.
3611 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
3612 increase downward and rightward.
3613 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
3614 increase upward and rightward.
3616 OpenGL defaults to LOWER_LEFT, and is configurable with the
3617 GL_ARB_fragment_coord_conventions extension.
3619 DirectX 9/10 use UPPER_LEFT.
3621 FS_COORD_PIXEL_CENTER
3622 """""""""""""""""""""
3624 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
3625 The default value is HALF_INTEGER.
3627 If HALF_INTEGER, the fractionary part of the position will be 0.5
3628 If INTEGER, the fractionary part of the position will be 0.0
3630 Note that this does not affect the set of fragments generated by
3631 rasterization, which is instead controlled by half_pixel_center in the
3634 OpenGL defaults to HALF_INTEGER, and is configurable with the
3635 GL_ARB_fragment_coord_conventions extension.
3637 DirectX 9 uses INTEGER.
3638 DirectX 10 uses HALF_INTEGER.
3640 FS_COLOR0_WRITES_ALL_CBUFS
3641 """"""""""""""""""""""""""
3642 Specifies that writes to the fragment shader color 0 are replicated to all
3643 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
3644 fragData is directed to a single color buffer, but fragColor is broadcast.
3647 """"""""""""""""""""""""""
3648 If this property is set on the program bound to the shader stage before the
3649 fragment shader, user clip planes should have no effect (be disabled) even if
3650 that shader does not write to any clip distance outputs and the rasterizer's
3651 clip_plane_enable is non-zero.
3652 This property is only supported by drivers that also support shader clip
3654 This is useful for APIs that don't have UCPs and where clip distances written
3655 by a shader cannot be disabled.
3660 Specifies the number of times a geometry shader should be executed for each
3661 input primitive. Each invocation will have a different
3662 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
3665 VS_WINDOW_SPACE_POSITION
3666 """"""""""""""""""""""""""
3667 If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
3668 is assumed to contain window space coordinates.
3669 Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
3670 directly taken from the 4-th component of the shader output.
3671 Naturally, clipping is not performed on window coordinates either.
3672 The effect of this property is undefined if a geometry or tessellation shader
3678 The number of vertices written by the tessellation control shader. This
3679 effectively defines the patch input size of the tessellation evaluation shader
3685 This sets the tessellation primitive mode, one of ``PIPE_PRIM_TRIANGLES``,
3686 ``PIPE_PRIM_QUADS``, or ``PIPE_PRIM_LINES``. (Unlike in GL, there is no
3687 separate isolines settings, the regular lines is assumed to mean isolines.)
3692 This sets the spacing mode of the tessellation generator, one of
3693 ``PIPE_TESS_SPACING_*``.
3698 This sets the vertex order to be clockwise if the value is 1, or
3699 counter-clockwise if set to 0.
3704 If set to a non-zero value, this turns on point mode for the tessellator,
3705 which means that points will be generated instead of primitives.
3707 NUM_CLIPDIST_ENABLED
3708 """"""""""""""""""""
3710 How many clip distance scalar outputs are enabled.
3712 NUM_CULLDIST_ENABLED
3713 """"""""""""""""""""
3715 How many cull distance scalar outputs are enabled.
3717 FS_EARLY_DEPTH_STENCIL
3718 """"""""""""""""""""""
3720 Whether depth test, stencil test, and occlusion query should run before
3721 the fragment shader (regardless of fragment shader side effects). Corresponds
3722 to GLSL early_fragment_tests.
3727 Which shader stage will MOST LIKELY follow after this shader when the shader
3728 is bound. This is only a hint to the driver and doesn't have to be precise.
3729 Only set for VS and TES.
3731 CS_FIXED_BLOCK_WIDTH / HEIGHT / DEPTH
3732 """""""""""""""""""""""""""""""""""""
3734 Threads per block in each dimension, if known at compile time. If the block size
3735 is known all three should be at least 1. If it is unknown they should all be set
3741 The MUL TGSI operation (FP32 multiplication) will return 0 if either
3742 of the operands are equal to 0. That means that 0 * Inf = 0. This
3743 should be set the same way for an entire pipeline. Note that this
3744 applies not only to the literal MUL TGSI opcode, but all FP32
3745 multiplications implied by other operations, such as MAD, FMA, DP2,
3746 DP3, DP4, DST, LOG, LRP, and possibly others. If there is a
3747 mismatch between shaders, then it is unspecified whether this behavior
3750 FS_POST_DEPTH_COVERAGE
3751 """"""""""""""""""""""
3753 When enabled, the input for TGSI_SEMANTIC_SAMPLEMASK will exclude samples
3754 that have failed the depth/stencil tests. This is only valid when
3755 FS_EARLY_DEPTH_STENCIL is also specified.
3758 Texture Sampling and Texture Formats
3759 ------------------------------------
3761 This table shows how texture image components are returned as (x,y,z,w) tuples
3762 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
3763 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
3766 +--------------------+--------------+--------------------+--------------+
3767 | Texture Components | Gallium | OpenGL | Direct3D 9 |
3768 +====================+==============+====================+==============+
3769 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
3770 +--------------------+--------------+--------------------+--------------+
3771 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
3772 +--------------------+--------------+--------------------+--------------+
3773 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
3774 +--------------------+--------------+--------------------+--------------+
3775 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
3776 +--------------------+--------------+--------------------+--------------+
3777 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
3778 +--------------------+--------------+--------------------+--------------+
3779 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
3780 +--------------------+--------------+--------------------+--------------+
3781 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
3782 +--------------------+--------------+--------------------+--------------+
3783 | I | (i, i, i, i) | (i, i, i, i) | N/A |
3784 +--------------------+--------------+--------------------+--------------+
3785 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
3786 | | | [#envmap-bumpmap]_ | |
3787 +--------------------+--------------+--------------------+--------------+
3788 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
3789 | | | [#depth-tex-mode]_ | |
3790 +--------------------+--------------+--------------------+--------------+
3791 | S | (s, s, s, s) | unknown | unknown |
3792 +--------------------+--------------+--------------------+--------------+
3794 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
3795 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
3796 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.