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 as an unsigned integer. The other components are
986 undefined. If the texture is not multisampled, this function returns
987 (1, undef, undef, undef).
991 dst.x = texture\_samples(unit)
994 .. opcode:: TG4 - Texture Gather
996 As per ARB_texture_gather, gathers the four texels to be used in a bi-linear
997 filtering operation and packs them into a single register. Only works with
998 2D, 2D array, cubemaps, and cubemaps arrays. For 2D textures, only the
999 addressing modes of the sampler and the top level of any mip pyramid are
1000 used. Set W to zero. It behaves like the TEX instruction, but a filtered
1001 sample is not generated. The four samples that contribute to filtering are
1002 placed into xyzw in clockwise order, starting with the (u,v) texture
1003 coordinate delta at the following locations (-, +), (+, +), (+, -), (-, -),
1004 where the magnitude of the deltas are half a texel.
1006 PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
1007 depth compares, single component selection, and a non-constant offset. It
1008 doesn't allow support for the GL independent offset to get i0,j0. This would
1009 require another CAP is hw can do it natively. For now we lower that before
1018 dst = texture\_gather4 (unit, coord, component)
1020 (with SM5 - cube array shadow)
1028 dst = texture\_gather (uint, coord, compare)
1030 .. opcode:: LODQ - level of detail query
1032 Compute the LOD information that the texture pipe would use to access the
1033 texture. The Y component contains the computed LOD lambda_prime. The X
1034 component contains the LOD that will be accessed, based on min/max lod's
1041 dst.xy = lodq(uint, coord);
1043 .. opcode:: CLOCK - retrieve the current shader time
1045 Invoking this instruction multiple times in the same shader should
1046 cause monotonically increasing values to be returned. The values
1047 are implicitly 64-bit, so if fewer than 64 bits of precision are
1048 available, to provide expected wraparound semantics, the value
1049 should be shifted up so that the most significant bit of the time
1050 is the most significant bit of the 64-bit value.
1058 ^^^^^^^^^^^^^^^^^^^^^^^^
1059 These opcodes are used for integer operations.
1060 Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
1063 .. opcode:: I2F - Signed Integer To Float
1065 Rounding is unspecified (round to nearest even suggested).
1069 dst.x = (float) src.x
1071 dst.y = (float) src.y
1073 dst.z = (float) src.z
1075 dst.w = (float) src.w
1078 .. opcode:: U2F - Unsigned Integer To Float
1080 Rounding is unspecified (round to nearest even suggested).
1084 dst.x = (float) src.x
1086 dst.y = (float) src.y
1088 dst.z = (float) src.z
1090 dst.w = (float) src.w
1093 .. opcode:: F2I - Float to Signed Integer
1095 Rounding is towards zero (truncate).
1096 Values outside signed range (including NaNs) produce undefined results.
1109 .. opcode:: F2U - Float to Unsigned Integer
1111 Rounding is towards zero (truncate).
1112 Values outside unsigned range (including NaNs) produce undefined results.
1116 dst.x = (unsigned) src.x
1118 dst.y = (unsigned) src.y
1120 dst.z = (unsigned) src.z
1122 dst.w = (unsigned) src.w
1125 .. opcode:: UADD - Integer Add
1127 This instruction works the same for signed and unsigned integers.
1128 The low 32bit of the result is returned.
1132 dst.x = src0.x + src1.x
1134 dst.y = src0.y + src1.y
1136 dst.z = src0.z + src1.z
1138 dst.w = src0.w + src1.w
1141 .. opcode:: UMAD - Integer Multiply And Add
1143 This instruction works the same for signed and unsigned integers.
1144 The multiplication returns the low 32bit (as does the result itself).
1148 dst.x = src0.x \times src1.x + src2.x
1150 dst.y = src0.y \times src1.y + src2.y
1152 dst.z = src0.z \times src1.z + src2.z
1154 dst.w = src0.w \times src1.w + src2.w
1157 .. opcode:: UMUL - Integer Multiply
1159 This instruction works the same for signed and unsigned integers.
1160 The low 32bit of the result is returned.
1164 dst.x = src0.x \times src1.x
1166 dst.y = src0.y \times src1.y
1168 dst.z = src0.z \times src1.z
1170 dst.w = src0.w \times src1.w
1173 .. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1175 The high 32bits of the multiplication of 2 signed integers are returned.
1179 dst.x = (src0.x \times src1.x) >> 32
1181 dst.y = (src0.y \times src1.y) >> 32
1183 dst.z = (src0.z \times src1.z) >> 32
1185 dst.w = (src0.w \times src1.w) >> 32
1188 .. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1190 The high 32bits of the multiplication of 2 unsigned integers are returned.
1194 dst.x = (src0.x \times src1.x) >> 32
1196 dst.y = (src0.y \times src1.y) >> 32
1198 dst.z = (src0.z \times src1.z) >> 32
1200 dst.w = (src0.w \times src1.w) >> 32
1203 .. opcode:: IDIV - Signed Integer Division
1205 TBD: behavior for division by zero.
1209 dst.x = \frac{src0.x}{src1.x}
1211 dst.y = \frac{src0.y}{src1.y}
1213 dst.z = \frac{src0.z}{src1.z}
1215 dst.w = \frac{src0.w}{src1.w}
1218 .. opcode:: UDIV - Unsigned Integer Division
1220 For division by zero, 0xffffffff is returned.
1224 dst.x = \frac{src0.x}{src1.x}
1226 dst.y = \frac{src0.y}{src1.y}
1228 dst.z = \frac{src0.z}{src1.z}
1230 dst.w = \frac{src0.w}{src1.w}
1233 .. opcode:: UMOD - Unsigned Integer Remainder
1235 If second arg is zero, 0xffffffff is returned.
1239 dst.x = src0.x \bmod src1.x
1241 dst.y = src0.y \bmod src1.y
1243 dst.z = src0.z \bmod src1.z
1245 dst.w = src0.w \bmod src1.w
1248 .. opcode:: NOT - Bitwise Not
1261 .. opcode:: AND - Bitwise And
1265 dst.x = src0.x \& src1.x
1267 dst.y = src0.y \& src1.y
1269 dst.z = src0.z \& src1.z
1271 dst.w = src0.w \& src1.w
1274 .. opcode:: OR - Bitwise Or
1278 dst.x = src0.x | src1.x
1280 dst.y = src0.y | src1.y
1282 dst.z = src0.z | src1.z
1284 dst.w = src0.w | src1.w
1287 .. opcode:: XOR - Bitwise Xor
1291 dst.x = src0.x \oplus src1.x
1293 dst.y = src0.y \oplus src1.y
1295 dst.z = src0.z \oplus src1.z
1297 dst.w = src0.w \oplus src1.w
1300 .. opcode:: IMAX - Maximum of Signed Integers
1304 dst.x = max(src0.x, src1.x)
1306 dst.y = max(src0.y, src1.y)
1308 dst.z = max(src0.z, src1.z)
1310 dst.w = max(src0.w, src1.w)
1313 .. opcode:: UMAX - Maximum of Unsigned Integers
1317 dst.x = max(src0.x, src1.x)
1319 dst.y = max(src0.y, src1.y)
1321 dst.z = max(src0.z, src1.z)
1323 dst.w = max(src0.w, src1.w)
1326 .. opcode:: IMIN - Minimum of Signed Integers
1330 dst.x = min(src0.x, src1.x)
1332 dst.y = min(src0.y, src1.y)
1334 dst.z = min(src0.z, src1.z)
1336 dst.w = min(src0.w, src1.w)
1339 .. opcode:: UMIN - Minimum of Unsigned Integers
1343 dst.x = min(src0.x, src1.x)
1345 dst.y = min(src0.y, src1.y)
1347 dst.z = min(src0.z, src1.z)
1349 dst.w = min(src0.w, src1.w)
1352 .. opcode:: SHL - Shift Left
1354 The shift count is masked with 0x1f before the shift is applied.
1358 dst.x = src0.x << (0x1f \& src1.x)
1360 dst.y = src0.y << (0x1f \& src1.y)
1362 dst.z = src0.z << (0x1f \& src1.z)
1364 dst.w = src0.w << (0x1f \& src1.w)
1367 .. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1369 The shift count is masked with 0x1f before the shift is applied.
1373 dst.x = src0.x >> (0x1f \& src1.x)
1375 dst.y = src0.y >> (0x1f \& src1.y)
1377 dst.z = src0.z >> (0x1f \& src1.z)
1379 dst.w = src0.w >> (0x1f \& src1.w)
1382 .. opcode:: USHR - Logical Shift Right
1384 The shift count is masked with 0x1f before the shift is applied.
1388 dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1390 dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1392 dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1394 dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
1397 .. opcode:: UCMP - Integer Conditional Move
1401 dst.x = src0.x ? src1.x : src2.x
1403 dst.y = src0.y ? src1.y : src2.y
1405 dst.z = src0.z ? src1.z : src2.z
1407 dst.w = src0.w ? src1.w : src2.w
1411 .. opcode:: ISSG - Integer Set Sign
1415 dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1417 dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1419 dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1421 dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1425 .. opcode:: FSLT - Float Set On Less Than (ordered)
1427 Same comparison as SLT but returns integer instead of 1.0/0.0 float
1431 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1433 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1435 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1437 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1440 .. opcode:: ISLT - Signed Integer Set On Less Than
1444 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1446 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1448 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1450 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1453 .. opcode:: USLT - Unsigned Integer Set On Less Than
1457 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1459 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1461 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1463 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1466 .. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1468 Same comparison as SGE but returns integer instead of 1.0/0.0 float
1472 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1474 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1476 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1478 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1481 .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1485 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1487 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1489 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1491 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1494 .. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1498 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1500 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1502 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1504 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1507 .. opcode:: FSEQ - Float Set On Equal (ordered)
1509 Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1513 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1515 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1517 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1519 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1522 .. opcode:: USEQ - Integer Set On Equal
1526 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1528 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1530 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1532 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1535 .. opcode:: FSNE - Float Set On Not Equal (unordered)
1537 Same comparison as SNE but returns integer instead of 1.0/0.0 float
1541 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1543 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1545 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1547 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1550 .. opcode:: USNE - Integer Set On Not Equal
1554 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1556 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1558 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1560 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1563 .. opcode:: INEG - Integer Negate
1578 .. opcode:: IABS - Integer Absolute Value
1592 These opcodes are used for bit-level manipulation of integers.
1594 .. opcode:: IBFE - Signed Bitfield Extract
1596 Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
1597 sign-extends them if the high bit of the extracted window is set.
1601 def ibfe(value, offset, bits):
1602 if offset < 0 or bits < 0 or offset + bits > 32:
1604 if bits == 0: return 0
1605 # Note: >> sign-extends
1606 return (value << (32 - offset - bits)) >> (32 - bits)
1608 .. opcode:: UBFE - Unsigned Bitfield Extract
1610 Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
1615 def ubfe(value, offset, bits):
1616 if offset < 0 or bits < 0 or offset + bits > 32:
1618 if bits == 0: return 0
1619 # Note: >> does not sign-extend
1620 return (value << (32 - offset - bits)) >> (32 - bits)
1622 .. opcode:: BFI - Bitfield Insert
1624 Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
1629 def bfi(base, insert, offset, bits):
1630 if offset < 0 or bits < 0 or offset + bits > 32:
1632 # << defined such that mask == ~0 when bits == 32, offset == 0
1633 mask = ((1 << bits) - 1) << offset
1634 return ((insert << offset) & mask) | (base & ~mask)
1636 .. opcode:: BREV - Bitfield Reverse
1638 See SM5 instruction BFREV. Reverses the bits of the argument.
1640 .. opcode:: POPC - Population Count
1642 See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1644 .. opcode:: LSB - Index of lowest set bit
1646 See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1647 bit of the argument. Returns -1 if none are set.
1649 .. opcode:: IMSB - Index of highest non-sign bit
1651 See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1652 non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1653 highest 1 bit for positive numbers). Returns -1 if all bits are the same
1654 (i.e. for inputs 0 and -1).
1656 .. opcode:: UMSB - Index of highest set bit
1658 See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1659 set bit of the argument. Returns -1 if none are set.
1662 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1664 These opcodes are only supported in geometry shaders; they have no meaning
1665 in any other type of shader.
1667 .. opcode:: EMIT - Emit
1669 Generate a new vertex for the current primitive into the specified vertex
1670 stream using the values in the output registers.
1673 .. opcode:: ENDPRIM - End Primitive
1675 Complete the current primitive in the specified vertex stream (consisting of
1676 the emitted vertices), and start a new one.
1682 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1683 opcodes is determined by a special capability bit, ``GLSL``.
1684 Some require glsl version 1.30 (UIF/BREAKC/SWITCH/CASE/DEFAULT/ENDSWITCH).
1686 .. opcode:: CAL - Subroutine Call
1692 .. opcode:: RET - Subroutine Call Return
1697 .. opcode:: CONT - Continue
1699 Unconditionally moves the point of execution to the instruction after the
1700 last bgnloop. The instruction must appear within a bgnloop/endloop.
1704 Support for CONT is determined by a special capability bit,
1705 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1708 .. opcode:: BGNLOOP - Begin a Loop
1710 Start a loop. Must have a matching endloop.
1713 .. opcode:: BGNSUB - Begin Subroutine
1715 Starts definition of a subroutine. Must have a matching endsub.
1718 .. opcode:: ENDLOOP - End a Loop
1720 End a loop started with bgnloop.
1723 .. opcode:: ENDSUB - End Subroutine
1725 Ends definition of a subroutine.
1728 .. opcode:: NOP - No Operation
1733 .. opcode:: BRK - Break
1735 Unconditionally moves the point of execution to the instruction after the
1736 next endloop or endswitch. The instruction must appear within a loop/endloop
1737 or switch/endswitch.
1740 .. opcode:: BREAKC - Break Conditional
1742 Conditionally moves the point of execution to the instruction after the
1743 next endloop or endswitch. The instruction must appear within a loop/endloop
1744 or switch/endswitch.
1745 Condition evaluates to true if src0.x != 0 where src0.x is interpreted
1746 as an integer register.
1750 Considered for removal as it's quite inconsistent wrt other opcodes
1751 (could emulate with UIF/BRK/ENDIF).
1754 .. opcode:: IF - Float If
1756 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
1760 where src0.x is interpreted as a floating point register.
1763 .. opcode:: UIF - Bitwise If
1765 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1769 where src0.x is interpreted as an integer register.
1772 .. opcode:: ELSE - Else
1774 Starts an else block, after an IF or UIF statement.
1777 .. opcode:: ENDIF - End If
1779 Ends an IF or UIF block.
1782 .. opcode:: SWITCH - Switch
1784 Starts a C-style switch expression. The switch consists of one or multiple
1785 CASE statements, and at most one DEFAULT statement. Execution of a statement
1786 ends when a BRK is hit, but just like in C falling through to other cases
1787 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
1788 just as last statement, and fallthrough is allowed into/from it.
1789 CASE src arguments are evaluated at bit level against the SWITCH src argument.
1795 (some instructions here)
1798 (some instructions here)
1801 (some instructions here)
1806 .. opcode:: CASE - Switch case
1808 This represents a switch case label. The src arg must be an integer immediate.
1811 .. opcode:: DEFAULT - Switch default
1813 This represents the default case in the switch, which is taken if no other
1817 .. opcode:: ENDSWITCH - End of switch
1819 Ends a switch expression.
1825 The interpolation instructions allow an input to be interpolated in a
1826 different way than its declaration. This corresponds to the GLSL 4.00
1827 interpolateAt* functions. The first argument of each of these must come from
1828 ``TGSI_FILE_INPUT``.
1830 .. opcode:: INTERP_CENTROID - Interpolate at the centroid
1832 Interpolates the varying specified by src0 at the centroid
1834 .. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
1836 Interpolates the varying specified by src0 at the sample id specified by
1837 src1.x (interpreted as an integer)
1839 .. opcode:: INTERP_OFFSET - Interpolate at the specified offset
1841 Interpolates the varying specified by src0 at the offset src1.xy from the
1842 pixel center (interpreted as floats)
1850 The double-precision opcodes reinterpret four-component vectors into
1851 two-component vectors with doubled precision in each component.
1853 .. opcode:: DABS - Absolute
1861 .. opcode:: DADD - Add
1865 dst.xy = src0.xy + src1.xy
1867 dst.zw = src0.zw + src1.zw
1869 .. opcode:: DSEQ - Set on Equal
1873 dst.x = src0.xy == src1.xy ? \sim 0 : 0
1875 dst.z = src0.zw == src1.zw ? \sim 0 : 0
1877 .. opcode:: DSNE - Set on Equal
1881 dst.x = src0.xy != src1.xy ? \sim 0 : 0
1883 dst.z = src0.zw != src1.zw ? \sim 0 : 0
1885 .. opcode:: DSLT - Set on Less than
1889 dst.x = src0.xy < src1.xy ? \sim 0 : 0
1891 dst.z = src0.zw < src1.zw ? \sim 0 : 0
1893 .. opcode:: DSGE - Set on Greater equal
1897 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
1899 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
1901 .. opcode:: DFRAC - Fraction
1905 dst.xy = src.xy - \lfloor src.xy\rfloor
1907 dst.zw = src.zw - \lfloor src.zw\rfloor
1909 .. opcode:: DTRUNC - Truncate
1913 dst.xy = trunc(src.xy)
1915 dst.zw = trunc(src.zw)
1917 .. opcode:: DCEIL - Ceiling
1921 dst.xy = \lceil src.xy\rceil
1923 dst.zw = \lceil src.zw\rceil
1925 .. opcode:: DFLR - Floor
1929 dst.xy = \lfloor src.xy\rfloor
1931 dst.zw = \lfloor src.zw\rfloor
1933 .. opcode:: DROUND - Fraction
1937 dst.xy = round(src.xy)
1939 dst.zw = round(src.zw)
1941 .. opcode:: DSSG - Set Sign
1945 dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
1947 dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
1949 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1951 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1952 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1953 :math:`dst1 \times 2^{dst0} = src` .
1957 dst0.xy = exp(src.xy)
1959 dst1.xy = frac(src.xy)
1961 dst0.zw = exp(src.zw)
1963 dst1.zw = frac(src.zw)
1965 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1967 This opcode is the inverse of :opcode:`DFRACEXP`. The second
1968 source is an integer.
1972 dst.xy = src0.xy \times 2^{src1.x}
1974 dst.zw = src0.zw \times 2^{src1.y}
1976 .. opcode:: DMIN - Minimum
1980 dst.xy = min(src0.xy, src1.xy)
1982 dst.zw = min(src0.zw, src1.zw)
1984 .. opcode:: DMAX - Maximum
1988 dst.xy = max(src0.xy, src1.xy)
1990 dst.zw = max(src0.zw, src1.zw)
1992 .. opcode:: DMUL - Multiply
1996 dst.xy = src0.xy \times src1.xy
1998 dst.zw = src0.zw \times src1.zw
2001 .. opcode:: DMAD - Multiply And Add
2005 dst.xy = src0.xy \times src1.xy + src2.xy
2007 dst.zw = src0.zw \times src1.zw + src2.zw
2010 .. opcode:: DFMA - Fused Multiply-Add
2012 Perform a * b + c with no intermediate rounding step.
2016 dst.xy = src0.xy \times src1.xy + src2.xy
2018 dst.zw = src0.zw \times src1.zw + src2.zw
2021 .. opcode:: DDIV - Divide
2025 dst.xy = \frac{src0.xy}{src1.xy}
2027 dst.zw = \frac{src0.zw}{src1.zw}
2030 .. opcode:: DRCP - Reciprocal
2034 dst.xy = \frac{1}{src.xy}
2036 dst.zw = \frac{1}{src.zw}
2038 .. opcode:: DSQRT - Square Root
2042 dst.xy = \sqrt{src.xy}
2044 dst.zw = \sqrt{src.zw}
2046 .. opcode:: DRSQ - Reciprocal Square Root
2050 dst.xy = \frac{1}{\sqrt{src.xy}}
2052 dst.zw = \frac{1}{\sqrt{src.zw}}
2054 .. opcode:: F2D - Float to Double
2058 dst.xy = double(src0.x)
2060 dst.zw = double(src0.y)
2062 .. opcode:: D2F - Double to Float
2066 dst.x = float(src0.xy)
2068 dst.y = float(src0.zw)
2070 .. opcode:: I2D - Int to Double
2074 dst.xy = double(src0.x)
2076 dst.zw = double(src0.y)
2078 .. opcode:: D2I - Double to Int
2082 dst.x = int(src0.xy)
2084 dst.y = int(src0.zw)
2086 .. opcode:: U2D - Unsigned Int to Double
2090 dst.xy = double(src0.x)
2092 dst.zw = double(src0.y)
2094 .. opcode:: D2U - Double to Unsigned Int
2098 dst.x = unsigned(src0.xy)
2100 dst.y = unsigned(src0.zw)
2105 The 64-bit integer opcodes reinterpret four-component vectors into
2106 two-component vectors with 64-bits in each component.
2108 .. opcode:: I64ABS - 64-bit Integer Absolute Value
2116 .. opcode:: I64NEG - 64-bit Integer Negate
2126 .. opcode:: I64SSG - 64-bit Integer Set Sign
2130 dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
2132 dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
2134 .. opcode:: U64ADD - 64-bit Integer Add
2138 dst.xy = src0.xy + src1.xy
2140 dst.zw = src0.zw + src1.zw
2142 .. opcode:: U64MUL - 64-bit Integer Multiply
2146 dst.xy = src0.xy * src1.xy
2148 dst.zw = src0.zw * src1.zw
2150 .. opcode:: U64SEQ - 64-bit Integer Set on Equal
2154 dst.x = src0.xy == src1.xy ? \sim 0 : 0
2156 dst.z = src0.zw == src1.zw ? \sim 0 : 0
2158 .. opcode:: U64SNE - 64-bit Integer Set on Not Equal
2162 dst.x = src0.xy != src1.xy ? \sim 0 : 0
2164 dst.z = src0.zw != src1.zw ? \sim 0 : 0
2166 .. opcode:: U64SLT - 64-bit Unsigned Integer Set on Less Than
2170 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2172 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2174 .. opcode:: U64SGE - 64-bit Unsigned Integer Set on Greater Equal
2178 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2180 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2182 .. opcode:: I64SLT - 64-bit Signed Integer Set on Less Than
2186 dst.x = src0.xy < src1.xy ? \sim 0 : 0
2188 dst.z = src0.zw < src1.zw ? \sim 0 : 0
2190 .. opcode:: I64SGE - 64-bit Signed Integer Set on Greater Equal
2194 dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2196 dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2198 .. opcode:: I64MIN - Minimum of 64-bit Signed Integers
2202 dst.xy = min(src0.xy, src1.xy)
2204 dst.zw = min(src0.zw, src1.zw)
2206 .. opcode:: U64MIN - Minimum of 64-bit Unsigned Integers
2210 dst.xy = min(src0.xy, src1.xy)
2212 dst.zw = min(src0.zw, src1.zw)
2214 .. opcode:: I64MAX - Maximum of 64-bit Signed Integers
2218 dst.xy = max(src0.xy, src1.xy)
2220 dst.zw = max(src0.zw, src1.zw)
2222 .. opcode:: U64MAX - Maximum of 64-bit Unsigned Integers
2226 dst.xy = max(src0.xy, src1.xy)
2228 dst.zw = max(src0.zw, src1.zw)
2230 .. opcode:: U64SHL - Shift Left 64-bit Unsigned Integer
2232 The shift count is masked with 0x3f before the shift is applied.
2236 dst.xy = src0.xy << (0x3f \& src1.x)
2238 dst.zw = src0.zw << (0x3f \& src1.y)
2240 .. opcode:: I64SHR - Arithmetic Shift Right (of 64-bit Signed Integer)
2242 The shift count is masked with 0x3f before the shift is applied.
2246 dst.xy = src0.xy >> (0x3f \& src1.x)
2248 dst.zw = src0.zw >> (0x3f \& src1.y)
2250 .. opcode:: U64SHR - Logical Shift Right (of 64-bit Unsigned Integer)
2252 The shift count is masked with 0x3f before the shift is applied.
2256 dst.xy = src0.xy >> (unsigned) (0x3f \& src1.x)
2258 dst.zw = src0.zw >> (unsigned) (0x3f \& src1.y)
2260 .. opcode:: I64DIV - 64-bit Signed Integer Division
2264 dst.xy = \frac{src0.xy}{src1.xy}
2266 dst.zw = \frac{src0.zw}{src1.zw}
2268 .. opcode:: U64DIV - 64-bit Unsigned Integer Division
2272 dst.xy = \frac{src0.xy}{src1.xy}
2274 dst.zw = \frac{src0.zw}{src1.zw}
2276 .. opcode:: U64MOD - 64-bit Unsigned Integer Remainder
2280 dst.xy = src0.xy \bmod src1.xy
2282 dst.zw = src0.zw \bmod src1.zw
2284 .. opcode:: I64MOD - 64-bit Signed Integer Remainder
2288 dst.xy = src0.xy \bmod src1.xy
2290 dst.zw = src0.zw \bmod src1.zw
2292 .. opcode:: F2U64 - Float to 64-bit Unsigned Int
2296 dst.xy = (uint64_t) src0.x
2298 dst.zw = (uint64_t) src0.y
2300 .. opcode:: F2I64 - Float to 64-bit Int
2304 dst.xy = (int64_t) src0.x
2306 dst.zw = (int64_t) src0.y
2308 .. opcode:: U2I64 - Unsigned Integer to 64-bit Integer
2310 This is a zero extension.
2314 dst.xy = (uint64_t) src0.x
2316 dst.zw = (uint64_t) src0.y
2318 .. opcode:: I2I64 - Signed Integer to 64-bit Integer
2320 This is a sign extension.
2324 dst.xy = (int64_t) src0.x
2326 dst.zw = (int64_t) src0.y
2328 .. opcode:: D2U64 - Double to 64-bit Unsigned Int
2332 dst.xy = (uint64_t) src0.xy
2334 dst.zw = (uint64_t) src0.zw
2336 .. opcode:: D2I64 - Double to 64-bit Int
2340 dst.xy = (int64_t) src0.xy
2342 dst.zw = (int64_t) src0.zw
2344 .. opcode:: U642F - 64-bit unsigned integer to float
2348 dst.x = (float) src0.xy
2350 dst.y = (float) src0.zw
2352 .. opcode:: I642F - 64-bit Int to Float
2356 dst.x = (float) src0.xy
2358 dst.y = (float) src0.zw
2360 .. opcode:: U642D - 64-bit unsigned integer to double
2364 dst.xy = (double) src0.xy
2366 dst.zw = (double) src0.zw
2368 .. opcode:: I642D - 64-bit Int to double
2372 dst.xy = (double) src0.xy
2374 dst.zw = (double) src0.zw
2376 .. _samplingopcodes:
2378 Resource Sampling Opcodes
2379 ^^^^^^^^^^^^^^^^^^^^^^^^^
2381 Those opcodes follow very closely semantics of the respective Direct3D
2382 instructions. If in doubt double check Direct3D documentation.
2383 Note that the swizzle on SVIEW (src1) determines texel swizzling
2388 Using provided address, sample data from the specified texture using the
2389 filtering mode identified by the given sampler. The source data may come from
2390 any resource type other than buffers.
2392 Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2394 Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2396 .. opcode:: SAMPLE_I
2398 Simplified alternative to the SAMPLE instruction. Using the provided
2399 integer address, SAMPLE_I fetches data from the specified sampler view
2400 without any filtering. The source data may come from any resource type
2403 Syntax: ``SAMPLE_I dst, address, sampler_view``
2405 Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2407 The 'address' is specified as unsigned integers. If the 'address' is out of
2408 range [0...(# texels - 1)] the result of the fetch is always 0 in all
2409 components. As such the instruction doesn't honor address wrap modes, in
2410 cases where that behavior is desirable 'SAMPLE' instruction should be used.
2411 address.w always provides an unsigned integer mipmap level. If the value is
2412 out of the range then the instruction always returns 0 in all components.
2413 address.yz are ignored for buffers and 1d textures. address.z is ignored
2414 for 1d texture arrays and 2d textures.
2416 For 1D texture arrays address.y provides the array index (also as unsigned
2417 integer). If the value is out of the range of available array indices
2418 [0... (array size - 1)] then the opcode always returns 0 in all components.
2419 For 2D texture arrays address.z provides the array index, otherwise it
2420 exhibits the same behavior as in the case for 1D texture arrays. The exact
2421 semantics of the source address are presented in the table below:
2423 +---------------------------+----+-----+-----+---------+
2424 | resource type | X | Y | Z | W |
2425 +===========================+====+=====+=====+=========+
2426 | ``PIPE_BUFFER`` | x | | | ignored |
2427 +---------------------------+----+-----+-----+---------+
2428 | ``PIPE_TEXTURE_1D`` | x | | | mpl |
2429 +---------------------------+----+-----+-----+---------+
2430 | ``PIPE_TEXTURE_2D`` | x | y | | mpl |
2431 +---------------------------+----+-----+-----+---------+
2432 | ``PIPE_TEXTURE_3D`` | x | y | z | mpl |
2433 +---------------------------+----+-----+-----+---------+
2434 | ``PIPE_TEXTURE_RECT`` | x | y | | mpl |
2435 +---------------------------+----+-----+-----+---------+
2436 | ``PIPE_TEXTURE_CUBE`` | not allowed as source |
2437 +---------------------------+----+-----+-----+---------+
2438 | ``PIPE_TEXTURE_1D_ARRAY`` | x | idx | | mpl |
2439 +---------------------------+----+-----+-----+---------+
2440 | ``PIPE_TEXTURE_2D_ARRAY`` | x | y | idx | mpl |
2441 +---------------------------+----+-----+-----+---------+
2443 Where 'mpl' is a mipmap level and 'idx' is the array index.
2445 .. opcode:: SAMPLE_I_MS
2447 Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2449 Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2451 .. opcode:: SAMPLE_B
2453 Just like the SAMPLE instruction with the exception that an additional bias
2454 is applied to the level of detail computed as part of the instruction
2457 Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2459 Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2461 .. opcode:: SAMPLE_C
2463 Similar to the SAMPLE instruction but it performs a comparison filter. The
2464 operands to SAMPLE_C are identical to SAMPLE, except that there is an
2465 additional float32 operand, reference value, which must be a register with
2466 single-component, or a scalar literal. SAMPLE_C makes the hardware use the
2467 current samplers compare_func (in pipe_sampler_state) to compare reference
2468 value against the red component value for the surce resource at each texel
2469 that the currently configured texture filter covers based on the provided
2472 Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2474 Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2476 .. opcode:: SAMPLE_C_LZ
2478 Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2481 Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2483 Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2486 .. opcode:: SAMPLE_D
2488 SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2489 the source address in the x direction and the y direction are provided by
2492 Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2494 Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2496 .. opcode:: SAMPLE_L
2498 SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2499 directly as a scalar value, representing no anisotropy.
2501 Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2503 Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2507 Gathers the four texels to be used in a bi-linear filtering operation and
2508 packs them into a single register. Only works with 2D, 2D array, cubemaps,
2509 and cubemaps arrays. For 2D textures, only the addressing modes of the
2510 sampler and the top level of any mip pyramid are used. Set W to zero. It
2511 behaves like the SAMPLE instruction, but a filtered sample is not
2512 generated. The four samples that contribute to filtering are placed into
2513 xyzw in counter-clockwise order, starting with the (u,v) texture coordinate
2514 delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2515 magnitude of the deltas are half a texel.
2518 .. opcode:: SVIEWINFO
2520 Query the dimensions of a given sampler view. dst receives width, height,
2521 depth or array size and number of mipmap levels as int4. The dst can have a
2522 writemask which will specify what info is the caller interested in.
2524 Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2526 Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2528 src_mip_level is an unsigned integer scalar. If it's out of range then
2529 returns 0 for width, height and depth/array size but the total number of
2530 mipmap is still returned correctly for the given sampler view. The returned
2531 width, height and depth values are for the mipmap level selected by the
2532 src_mip_level and are in the number of texels. For 1d texture array width
2533 is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2534 still in dst.w. In contrast to d3d10 resinfo, there's no way in the tgsi
2535 instruction encoding to specify the return type (float/rcpfloat/uint), hence
2536 always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2537 resinfo allowing swizzling dst values is ignored (due to the interaction
2538 with rcpfloat modifier which requires some swizzle handling in the state
2541 .. opcode:: SAMPLE_POS
2543 Query the position of a sample in the given resource or render target
2544 when per-sample fragment shading is in effect.
2546 Syntax: ``SAMPLE_POS dst, source, sample_index``
2548 dst receives float4 (x, y, undef, undef) indicated where the sample is
2549 located. Sample locations are in the range [0, 1] where 0.5 is the center
2552 source is either a sampler view (to indicate a shader resource) or temp
2553 register (to indicate the render target). The source register may have
2554 an optional swizzle to apply to the returned result
2556 sample_index is an integer scalar indicating which sample position is to
2559 If per-sample shading is not in effect or the source resource or render
2560 target is not multisampled, the result is (0.5, 0.5, undef, undef).
2562 NOTE: no driver has implemented this opcode yet (and no state tracker
2563 emits it). This information is subject to change.
2565 .. opcode:: SAMPLE_INFO
2567 Query the number of samples in a multisampled resource or render target.
2569 Syntax: ``SAMPLE_INFO dst, source``
2571 dst receives int4 (n, 0, 0, 0) where n is the number of samples in a
2572 resource or the render target.
2574 source is either a sampler view (to indicate a shader resource) or temp
2575 register (to indicate the render target). The source register may have
2576 an optional swizzle to apply to the returned result
2578 If per-sample shading is not in effect or the source resource or render
2579 target is not multisampled, the result is (1, 0, 0, 0).
2581 NOTE: no driver has implemented this opcode yet (and no state tracker
2582 emits it). This information is subject to change.
2584 .. _resourceopcodes:
2586 Resource Access Opcodes
2587 ^^^^^^^^^^^^^^^^^^^^^^^
2589 For these opcodes, the resource can be a BUFFER, IMAGE, or MEMORY.
2591 .. opcode:: LOAD - Fetch data from a shader buffer or image
2593 Syntax: ``LOAD dst, resource, address``
2595 Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
2597 Using the provided integer address, LOAD fetches data
2598 from the specified buffer or texture without any
2601 The 'address' is specified as a vector of unsigned
2602 integers. If the 'address' is out of range the result
2605 Only the first mipmap level of a resource can be read
2606 from using this instruction.
2608 For 1D or 2D texture arrays, the array index is
2609 provided as an unsigned integer in address.y or
2610 address.z, respectively. address.yz are ignored for
2611 buffers and 1D textures. address.z is ignored for 1D
2612 texture arrays and 2D textures. address.w is always
2615 A swizzle suffix may be added to the resource argument
2616 this will cause the resource data to be swizzled accordingly.
2618 .. opcode:: STORE - Write data to a shader resource
2620 Syntax: ``STORE resource, address, src``
2622 Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
2624 Using the provided integer address, STORE writes data
2625 to the specified buffer or texture.
2627 The 'address' is specified as a vector of unsigned
2628 integers. If the 'address' is out of range the result
2631 Only the first mipmap level of a resource can be
2632 written to using this instruction.
2634 For 1D or 2D texture arrays, the array index is
2635 provided as an unsigned integer in address.y or
2636 address.z, respectively. address.yz are ignored for
2637 buffers and 1D textures. address.z is ignored for 1D
2638 texture arrays and 2D textures. address.w is always
2641 .. opcode:: RESQ - Query information about a resource
2643 Syntax: ``RESQ dst, resource``
2645 Example: ``RESQ TEMP[0], BUFFER[0]``
2647 Returns information about the buffer or image resource. For buffer
2648 resources, the size (in bytes) is returned in the x component. For
2649 image resources, .xyz will contain the width/height/layers of the
2650 image, while .w will contain the number of samples for multi-sampled
2653 .. opcode:: FBFETCH - Load data from framebuffer
2655 Syntax: ``FBFETCH dst, output``
2657 Example: ``FBFETCH TEMP[0], OUT[0]``
2659 This is only valid on ``COLOR`` semantic outputs. Returns the color
2660 of the current position in the framebuffer from before this fragment
2661 shader invocation. May return the same value from multiple calls for
2662 a particular output within a single invocation. Note that result may
2663 be undefined if a fragment is drawn multiple times without a blend
2667 .. _threadsyncopcodes:
2669 Inter-thread synchronization opcodes
2670 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2672 These opcodes are intended for communication between threads running
2673 within the same compute grid. For now they're only valid in compute
2676 .. opcode:: MFENCE - Memory fence
2678 Syntax: ``MFENCE resource``
2680 Example: ``MFENCE RES[0]``
2682 This opcode forces strong ordering between any memory access
2683 operations that affect the specified resource. This means that
2684 previous loads and stores (and only those) will be performed and
2685 visible to other threads before the program execution continues.
2688 .. opcode:: LFENCE - Load memory fence
2690 Syntax: ``LFENCE resource``
2692 Example: ``LFENCE RES[0]``
2694 Similar to MFENCE, but it only affects the ordering of memory loads.
2697 .. opcode:: SFENCE - Store memory fence
2699 Syntax: ``SFENCE resource``
2701 Example: ``SFENCE RES[0]``
2703 Similar to MFENCE, but it only affects the ordering of memory stores.
2706 .. opcode:: BARRIER - Thread group barrier
2710 This opcode suspends the execution of the current thread until all
2711 the remaining threads in the working group reach the same point of
2712 the program. Results are unspecified if any of the remaining
2713 threads terminates or never reaches an executed BARRIER instruction.
2715 .. opcode:: MEMBAR - Memory barrier
2719 This opcode waits for the completion of all memory accesses based on
2720 the type passed in. The type is an immediate bitfield with the following
2723 Bit 0: Shader storage buffers
2724 Bit 1: Atomic buffers
2726 Bit 3: Shared memory
2729 These may be passed in in any combination. An implementation is free to not
2730 distinguish between these as it sees fit. However these map to all the
2731 possibilities made available by GLSL.
2738 These opcodes provide atomic variants of some common arithmetic and
2739 logical operations. In this context atomicity means that another
2740 concurrent memory access operation that affects the same memory
2741 location is guaranteed to be performed strictly before or after the
2742 entire execution of the atomic operation. The resource may be a BUFFER,
2743 IMAGE, or MEMORY. In the case of an image, the offset works the same as for
2744 ``LOAD`` and ``STORE``, specified above. These atomic operations may
2745 only be used with 32-bit integer image formats.
2747 .. opcode:: ATOMUADD - Atomic integer addition
2749 Syntax: ``ATOMUADD dst, resource, offset, src``
2751 Example: ``ATOMUADD 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:: ATOMXCHG - Atomic exchange
2764 Syntax: ``ATOMXCHG dst, resource, offset, src``
2766 Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2768 The following operation is performed atomically:
2772 dst_x = resource[offset]
2774 resource[offset] = src_x
2777 .. opcode:: ATOMCAS - Atomic compare-and-exchange
2779 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2781 Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
2783 The following operation is performed atomically:
2787 dst_x = resource[offset]
2789 resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
2792 .. opcode:: ATOMAND - Atomic bitwise And
2794 Syntax: ``ATOMAND dst, resource, offset, src``
2796 Example: ``ATOMAND 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
2807 .. opcode:: ATOMOR - Atomic bitwise Or
2809 Syntax: ``ATOMOR dst, resource, offset, src``
2811 Example: ``ATOMOR 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
2822 .. opcode:: ATOMXOR - Atomic bitwise Xor
2824 Syntax: ``ATOMXOR dst, resource, offset, src``
2826 Example: ``ATOMXOR 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 \oplus src_x
2837 .. opcode:: ATOMUMIN - Atomic unsigned minimum
2839 Syntax: ``ATOMUMIN dst, resource, offset, src``
2841 Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2843 The following operation is performed atomically:
2847 dst_x = resource[offset]
2849 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2852 .. opcode:: ATOMUMAX - Atomic unsigned maximum
2854 Syntax: ``ATOMUMAX dst, resource, offset, src``
2856 Example: ``ATOMUMAX 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 > src_x ? dst_x : src_x)
2867 .. opcode:: ATOMIMIN - Atomic signed minimum
2869 Syntax: ``ATOMIMIN dst, resource, offset, src``
2871 Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2873 The following operation is performed atomically:
2877 dst_x = resource[offset]
2879 resource[offset] = (dst_x < src_x ? dst_x : src_x)
2882 .. opcode:: ATOMIMAX - Atomic signed maximum
2884 Syntax: ``ATOMIMAX dst, resource, offset, src``
2886 Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2888 The following operation is performed atomically:
2892 dst_x = resource[offset]
2894 resource[offset] = (dst_x > src_x ? dst_x : src_x)
2897 .. _interlaneopcodes:
2902 These opcodes reduce the given value across the shader invocations
2903 running in the current SIMD group. Every thread in the subgroup will receive
2904 the same result. The BALLOT operations accept a single-channel argument that
2905 is treated as a boolean and produce a 64-bit value.
2907 .. opcode:: VOTE_ANY - Value is set in any of the active invocations
2909 Syntax: ``VOTE_ANY dst, value``
2911 Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
2914 .. opcode:: VOTE_ALL - Value is set in all of the active invocations
2916 Syntax: ``VOTE_ALL dst, value``
2918 Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
2921 .. opcode:: VOTE_EQ - Value is the same in all of the active invocations
2923 Syntax: ``VOTE_EQ dst, value``
2925 Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
2928 .. opcode:: BALLOT - Lanemask of whether the value is set in each active
2931 Syntax: ``BALLOT dst, value``
2933 Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
2935 When the argument is a constant true, this produces a bitmask of active
2936 invocations. In fragment shaders, this can include helper invocations
2937 (invocations whose outputs and writes to memory are discarded, but which
2938 are used to compute derivatives).
2941 .. opcode:: READ_FIRST - Broadcast the value from the first active
2942 invocation to all active lanes
2944 Syntax: ``READ_FIRST dst, value``
2946 Example: ``READ_FIRST TEMP[0], TEMP[1]``
2949 .. opcode:: READ_INVOC - Retrieve the value from the given invocation
2950 (need not be uniform)
2952 Syntax: ``READ_INVOC dst, value, invocation``
2954 Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
2956 invocation.x controls the invocation number to read from for all channels.
2957 The invocation number must be the same across all active invocations in a
2958 sub-group; otherwise, the results are undefined.
2961 Explanation of symbols used
2962 ------------------------------
2969 :math:`|x|` Absolute value of `x`.
2971 :math:`\lceil x \rceil` Ceiling of `x`.
2973 clamp(x,y,z) Clamp x between y and z.
2974 (x < y) ? y : (x > z) ? z : x
2976 :math:`\lfloor x\rfloor` Floor of `x`.
2978 :math:`\log_2{x}` Logarithm of `x`, base 2.
2980 max(x,y) Maximum of x and y.
2983 min(x,y) Minimum of x and y.
2986 partialx(x) Derivative of x relative to fragment's X.
2988 partialy(x) Derivative of x relative to fragment's Y.
2990 pop() Pop from stack.
2992 :math:`x^y` `x` to the power `y`.
2994 push(x) Push x on stack.
2998 trunc(x) Truncate x, i.e. drop the fraction bits.
3005 discard Discard fragment.
3009 target Label of target instruction.
3020 Declares a register that is will be referenced as an operand in Instruction
3023 File field contains register file that is being declared and is one
3026 UsageMask field specifies which of the register components can be accessed
3027 and is one of TGSI_WRITEMASK.
3029 The Local flag specifies that a given value isn't intended for
3030 subroutine parameter passing and, as a result, the implementation
3031 isn't required to give any guarantees of it being preserved across
3032 subroutine boundaries. As it's merely a compiler hint, the
3033 implementation is free to ignore it.
3035 If Dimension flag is set to 1, a Declaration Dimension token follows.
3037 If Semantic flag is set to 1, a Declaration Semantic token follows.
3039 If Interpolate flag is set to 1, a Declaration Interpolate token follows.
3041 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
3043 If Array flag is set to 1, a Declaration Array token follows.
3046 ^^^^^^^^^^^^^^^^^^^^^^^^
3048 Declarations can optional have an ArrayID attribute which can be referred by
3049 indirect addressing operands. An ArrayID of zero is reserved and treated as
3050 if no ArrayID is specified.
3052 If an indirect addressing operand refers to a specific declaration by using
3053 an ArrayID only the registers in this declaration are guaranteed to be
3054 accessed, accessing any register outside this declaration results in undefined
3055 behavior. Note that for compatibility the effective index is zero-based and
3056 not relative to the specified declaration
3058 If no ArrayID is specified with an indirect addressing operand the whole
3059 register file might be accessed by this operand. This is strongly discouraged
3060 and will prevent packing of scalar/vec2 arrays and effective alias analysis.
3061 This is only legal for TEMP and CONST register files.
3063 Declaration Semantic
3064 ^^^^^^^^^^^^^^^^^^^^^^^^
3066 Vertex and fragment shader input and output registers may be labeled
3067 with semantic information consisting of a name and index.
3069 Follows Declaration token if Semantic bit is set.
3071 Since its purpose is to link a shader with other stages of the pipeline,
3072 it is valid to follow only those Declaration tokens that declare a register
3073 either in INPUT or OUTPUT file.
3075 SemanticName field contains the semantic name of the register being declared.
3076 There is no default value.
3078 SemanticIndex is an optional subscript that can be used to distinguish
3079 different register declarations with the same semantic name. The default value
3082 The meanings of the individual semantic names are explained in the following
3085 TGSI_SEMANTIC_POSITION
3086 """"""""""""""""""""""
3088 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
3089 output register which contains the homogeneous vertex position in the clip
3090 space coordinate system. After clipping, the X, Y and Z components of the
3091 vertex will be divided by the W value to get normalized device coordinates.
3093 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
3094 fragment shader input (or system value, depending on which one is
3095 supported by the driver) contains the fragment's window position. The X
3096 component starts at zero and always increases from left to right.
3097 The Y component starts at zero and always increases but Y=0 may either
3098 indicate the top of the window or the bottom depending on the fragment
3099 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
3100 The Z coordinate ranges from 0 to 1 to represent depth from the front
3101 to the back of the Z buffer. The W component contains the interpolated
3102 reciprocal of the vertex position W component (corresponding to gl_Fragcoord,
3103 but unlike d3d10 which interpolates the same 1/w but then gives back
3104 the reciprocal of the interpolated value).
3106 Fragment shaders may also declare an output register with
3107 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
3108 the fragment shader to change the fragment's Z position.
3115 For vertex shader outputs or fragment shader inputs/outputs, this
3116 label indicates that the register contains an R,G,B,A color.
3118 Several shader inputs/outputs may contain colors so the semantic index
3119 is used to distinguish them. For example, color[0] may be the diffuse
3120 color while color[1] may be the specular color.
3122 This label is needed so that the flat/smooth shading can be applied
3123 to the right interpolants during rasterization.
3127 TGSI_SEMANTIC_BCOLOR
3128 """"""""""""""""""""
3130 Back-facing colors are only used for back-facing polygons, and are only valid
3131 in vertex shader outputs. After rasterization, all polygons are front-facing
3132 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
3133 so all BCOLORs effectively become regular COLORs in the fragment shader.
3139 Vertex shader inputs and outputs and fragment shader inputs may be
3140 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
3141 a fog coordinate. Typically, the fragment shader will use the fog coordinate
3142 to compute a fog blend factor which is used to blend the normal fragment color
3143 with a constant fog color. But fog coord really is just an ordinary vec4
3144 register like regular semantics.
3150 Vertex shader input and output registers may be labeled with
3151 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
3152 in the form (S, 0, 0, 1). The point size controls the width or diameter
3153 of points for rasterization. This label cannot be used in fragment
3156 When using this semantic, be sure to set the appropriate state in the
3157 :ref:`rasterizer` first.
3160 TGSI_SEMANTIC_TEXCOORD
3161 """"""""""""""""""""""
3163 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3165 Vertex shader outputs and fragment shader inputs may be labeled with
3166 this semantic to make them replaceable by sprite coordinates via the
3167 sprite_coord_enable state in the :ref:`rasterizer`.
3168 The semantic index permitted with this semantic is limited to <= 7.
3170 If the driver does not support TEXCOORD, sprite coordinate replacement
3171 applies to inputs with the GENERIC semantic instead.
3173 The intended use case for this semantic is gl_TexCoord.
3176 TGSI_SEMANTIC_PCOORD
3177 """"""""""""""""""""
3179 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
3181 Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
3182 that the register contains sprite coordinates in the form (x, y, 0, 1), if
3183 the current primitive is a point and point sprites are enabled. Otherwise,
3184 the contents of the register are undefined.
3186 The intended use case for this semantic is gl_PointCoord.
3189 TGSI_SEMANTIC_GENERIC
3190 """""""""""""""""""""
3192 All vertex/fragment shader inputs/outputs not labeled with any other
3193 semantic label can be considered to be generic attributes. Typical
3194 uses of generic inputs/outputs are texcoords and user-defined values.
3197 TGSI_SEMANTIC_NORMAL
3198 """"""""""""""""""""
3200 Indicates that a vertex shader input is a normal vector. This is
3201 typically only used for legacy graphics APIs.
3207 This label applies to fragment shader inputs (or system values,
3208 depending on which one is supported by the driver) and indicates that
3209 the register contains front/back-face information.
3211 If it is an input, it will be a floating-point vector in the form (F, 0, 0, 1),
3212 where F will be positive when the fragment belongs to a front-facing polygon,
3213 and negative when the fragment belongs to a back-facing polygon.
3215 If it is a system value, it will be an integer vector in the form (F, 0, 0, 1),
3216 where F is 0xffffffff when the fragment belongs to a front-facing polygon and
3217 0 when the fragment belongs to a back-facing polygon.
3220 TGSI_SEMANTIC_EDGEFLAG
3221 """"""""""""""""""""""
3223 For vertex shaders, this sematic label indicates that an input or
3224 output is a boolean edge flag. The register layout is [F, x, x, x]
3225 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
3226 simply copies the edge flag input to the edgeflag output.
3228 Edge flags are used to control which lines or points are actually
3229 drawn when the polygon mode converts triangles/quads/polygons into
3233 TGSI_SEMANTIC_STENCIL
3234 """""""""""""""""""""
3236 For fragment shaders, this semantic label indicates that an output
3237 is a writable stencil reference value. Only the Y component is writable.
3238 This allows the fragment shader to change the fragments stencilref value.
3241 TGSI_SEMANTIC_VIEWPORT_INDEX
3242 """"""""""""""""""""""""""""
3244 For geometry shaders, this semantic label indicates that an output
3245 contains the index of the viewport (and scissor) to use.
3246 This is an integer value, and only the X component is used.
3248 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3249 supported, then this semantic label can also be used in vertex or
3250 tessellation evaluation shaders, respectively. Only the value written in the
3251 last vertex processing stage is used.
3257 For geometry shaders, this semantic label indicates that an output
3258 contains the layer value to use for the color and depth/stencil surfaces.
3259 This is an integer value, and only the X component is used.
3260 (Also known as rendertarget array index.)
3262 If PIPE_CAP_TGSI_VS_LAYER_VIEWPORT or PIPE_CAP_TGSI_TES_LAYER_VIEWPORT is
3263 supported, then this semantic label can also be used in vertex or
3264 tessellation evaluation shaders, respectively. Only the value written in the
3265 last vertex processing stage is used.
3268 TGSI_SEMANTIC_CULLDIST
3269 """"""""""""""""""""""
3271 Used as distance to plane for performing application-defined culling
3272 of individual primitives against a plane. When components of vertex
3273 elements are given this label, these values are assumed to be a
3274 float32 signed distance to a plane. Primitives will be completely
3275 discarded if the plane distance for all of the vertices in the
3276 primitive are < 0. If a vertex has a cull distance of NaN, that
3277 vertex counts as "out" (as if its < 0);
3278 The limits on both clip and cull distances are bound
3279 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3280 the maximum number of components that can be used to hold the
3281 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3282 which specifies the maximum number of registers which can be
3283 annotated with those semantics.
3286 TGSI_SEMANTIC_CLIPDIST
3287 """"""""""""""""""""""
3289 Note this covers clipping and culling distances.
3291 When components of vertex elements are identified this way, these
3292 values are each assumed to be a float32 signed distance to a plane.
3295 Primitive setup only invokes rasterization on pixels for which
3296 the interpolated plane distances are >= 0.
3299 Primitives will be completely discarded if the plane distance
3300 for all of the vertices in the primitive are < 0.
3301 If a vertex has a cull distance of NaN, that vertex counts as "out"
3304 Multiple clip/cull planes can be implemented simultaneously, by
3305 annotating multiple components of one or more vertex elements with
3306 the above specified semantic.
3307 The limits on both clip and cull distances are bound
3308 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
3309 the maximum number of components that can be used to hold the
3310 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
3311 which specifies the maximum number of registers which can be
3312 annotated with those semantics.
3313 The properties NUM_CLIPDIST_ENABLED and NUM_CULLDIST_ENABLED
3314 are used to divide up the 2 x vec4 space between clipping and culling.
3316 TGSI_SEMANTIC_SAMPLEID
3317 """"""""""""""""""""""
3319 For fragment shaders, this semantic label indicates that a system value
3320 contains the current sample id (i.e. gl_SampleID) as an unsigned int.
3321 Only the X component is used. If per-sample shading is not enabled,
3322 the result is (0, undef, undef, undef).
3324 TGSI_SEMANTIC_SAMPLEPOS
3325 """""""""""""""""""""""
3327 For fragment shaders, this semantic label indicates that a system
3328 value contains the current sample's position as float4(x, y, undef, undef)
3329 in the render target (i.e. gl_SamplePosition) when per-fragment shading
3330 is in effect. Position values are in the range [0, 1] where 0.5 is
3331 the center of the fragment.
3333 TGSI_SEMANTIC_SAMPLEMASK
3334 """"""""""""""""""""""""
3336 For fragment shaders, this semantic label can be applied to either a
3337 shader system value input or output.
3339 For a system value, the sample mask indicates the set of samples covered by
3340 the current primitive. If MSAA is not enabled, the value is (1, 0, 0, 0).
3342 For an output, the sample mask is used to disable further sample processing.
3344 For both, the register type is uint[4] but only the X component is used
3345 (i.e. gl_SampleMask[0]). Each bit corresponds to one sample position (up
3346 to 32x MSAA is supported).
3348 TGSI_SEMANTIC_INVOCATIONID
3349 """"""""""""""""""""""""""
3351 For geometry shaders, this semantic label indicates that a system value
3352 contains the current invocation id (i.e. gl_InvocationID).
3353 This is an integer value, and only the X component is used.
3355 TGSI_SEMANTIC_INSTANCEID
3356 """"""""""""""""""""""""
3358 For vertex shaders, this semantic label indicates that a system value contains
3359 the current instance id (i.e. gl_InstanceID). It does not include the base
3360 instance. This is an integer value, and only the X component is used.
3362 TGSI_SEMANTIC_VERTEXID
3363 """"""""""""""""""""""
3365 For vertex shaders, this semantic label indicates that a system value contains
3366 the current vertex id (i.e. gl_VertexID). It does (unlike in d3d10) include the
3367 base vertex. This is an integer value, and only the X component is used.
3369 TGSI_SEMANTIC_VERTEXID_NOBASE
3370 """""""""""""""""""""""""""""""
3372 For vertex shaders, this semantic label indicates that a system value contains
3373 the current vertex id without including the base vertex (this corresponds to
3374 d3d10 vertex id, so TGSI_SEMANTIC_VERTEXID_NOBASE + TGSI_SEMANTIC_BASEVERTEX
3375 == TGSI_SEMANTIC_VERTEXID). This is an integer value, and only the X component
3378 TGSI_SEMANTIC_BASEVERTEX
3379 """"""""""""""""""""""""
3381 For vertex shaders, this semantic label indicates that a system value contains
3382 the base vertex (i.e. gl_BaseVertex). Note that for non-indexed draw calls,
3383 this contains the first (or start) value instead.
3384 This is an integer value, and only the X component is used.
3386 TGSI_SEMANTIC_PRIMID
3387 """"""""""""""""""""
3389 For geometry and fragment shaders, this semantic label indicates the value
3390 contains the primitive id (i.e. gl_PrimitiveID). This is an integer value,
3391 and only the X component is used.
3392 FIXME: This right now can be either a ordinary input or a system value...
3398 For tessellation evaluation/control shaders, this semantic label indicates a
3399 generic per-patch attribute. Such semantics will not implicitly be per-vertex
3402 TGSI_SEMANTIC_TESSCOORD
3403 """""""""""""""""""""""
3405 For tessellation evaluation shaders, this semantic label indicates the
3406 coordinates of the vertex being processed. This is available in XYZ; W is
3409 TGSI_SEMANTIC_TESSOUTER
3410 """""""""""""""""""""""
3412 For tessellation evaluation/control shaders, this semantic label indicates the
3413 outer tessellation levels of the patch. Isoline tessellation will only have XY
3414 defined, triangle will have XYZ and quads will have XYZW defined. This
3415 corresponds to gl_TessLevelOuter.
3417 TGSI_SEMANTIC_TESSINNER
3418 """""""""""""""""""""""
3420 For tessellation evaluation/control shaders, this semantic label indicates the
3421 inner tessellation levels of the patch. The X value is only defined for
3422 triangle tessellation, while quads will have XY defined. This is entirely
3423 undefined for isoline tessellation.
3425 TGSI_SEMANTIC_VERTICESIN
3426 """"""""""""""""""""""""
3428 For tessellation evaluation/control shaders, this semantic label indicates the
3429 number of vertices provided in the input patch. Only the X value is defined.
3431 TGSI_SEMANTIC_HELPER_INVOCATION
3432 """""""""""""""""""""""""""""""
3434 For fragment shaders, this semantic indicates whether the current
3435 invocation is covered or not. Helper invocations are created in order
3436 to properly compute derivatives, however it may be desirable to skip
3437 some of the logic in those cases. See ``gl_HelperInvocation`` documentation.
3439 TGSI_SEMANTIC_BASEINSTANCE
3440 """"""""""""""""""""""""""
3442 For vertex shaders, the base instance argument supplied for this
3443 draw. This is an integer value, and only the X component is used.
3445 TGSI_SEMANTIC_DRAWID
3446 """"""""""""""""""""
3448 For vertex shaders, the zero-based index of the current draw in a
3449 ``glMultiDraw*`` invocation. This is an integer value, and only the X
3453 TGSI_SEMANTIC_WORK_DIM
3454 """"""""""""""""""""""
3456 For compute shaders started via opencl this retrieves the work_dim
3457 parameter to the clEnqueueNDRangeKernel call with which the shader
3461 TGSI_SEMANTIC_GRID_SIZE
3462 """""""""""""""""""""""
3464 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3465 of a grid of thread blocks.
3468 TGSI_SEMANTIC_BLOCK_ID
3469 """"""""""""""""""""""
3471 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3472 current block inside of the grid.
3475 TGSI_SEMANTIC_BLOCK_SIZE
3476 """"""""""""""""""""""""
3478 For compute shaders, this semantic indicates the maximum (x, y, z) dimensions
3479 of a block in threads.
3482 TGSI_SEMANTIC_THREAD_ID
3483 """""""""""""""""""""""
3485 For compute shaders, this semantic indicates the (x, y, z) coordinates of the
3486 current thread inside of the block.
3489 TGSI_SEMANTIC_SUBGROUP_SIZE
3490 """""""""""""""""""""""""""
3492 This semantic indicates the subgroup size for the current invocation. This is
3493 an integer of at most 64, as it indicates the width of lanemasks. It does not
3494 depend on the number of invocations that are active.
3497 TGSI_SEMANTIC_SUBGROUP_INVOCATION
3498 """""""""""""""""""""""""""""""""
3500 The index of the current invocation within its subgroup.
3503 TGSI_SEMANTIC_SUBGROUP_EQ_MASK
3504 """"""""""""""""""""""""""""""
3506 A bit mask of ``bit index == TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3507 ``1 << subgroup_invocation`` in arbitrary precision arithmetic.
3510 TGSI_SEMANTIC_SUBGROUP_GE_MASK
3511 """"""""""""""""""""""""""""""
3513 A bit mask of ``bit index >= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3514 ``((1 << (subgroup_size - subgroup_invocation)) - 1) << subgroup_invocation``
3515 in arbitrary precision arithmetic.
3518 TGSI_SEMANTIC_SUBGROUP_GT_MASK
3519 """"""""""""""""""""""""""""""
3521 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3522 ``((1 << (subgroup_size - subgroup_invocation - 1)) - 1) << (subgroup_invocation + 1)``
3523 in arbitrary precision arithmetic.
3526 TGSI_SEMANTIC_SUBGROUP_LE_MASK
3527 """"""""""""""""""""""""""""""
3529 A bit mask of ``bit index <= TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3530 ``(1 << (subgroup_invocation + 1)) - 1`` in arbitrary precision arithmetic.
3533 TGSI_SEMANTIC_SUBGROUP_LT_MASK
3534 """"""""""""""""""""""""""""""
3536 A bit mask of ``bit index > TGSI_SEMANTIC_SUBGROUP_INVOCATION``, i.e.
3537 ``(1 << subgroup_invocation) - 1`` in arbitrary precision arithmetic.
3540 Declaration Interpolate
3541 ^^^^^^^^^^^^^^^^^^^^^^^
3543 This token is only valid for fragment shader INPUT declarations.
3545 The Interpolate field specifes the way input is being interpolated by
3546 the rasteriser and is one of TGSI_INTERPOLATE_*.
3548 The Location field specifies the location inside the pixel that the
3549 interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. Note that
3550 when per-sample shading is enabled, the implementation may choose to
3551 interpolate at the sample irrespective of the Location field.
3553 The CylindricalWrap bitfield specifies which register components
3554 should be subject to cylindrical wrapping when interpolating by the
3555 rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
3556 should be interpolated according to cylindrical wrapping rules.
3559 Declaration Sampler View
3560 ^^^^^^^^^^^^^^^^^^^^^^^^
3562 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
3564 DCL SVIEW[#], resource, type(s)
3566 Declares a shader input sampler view and assigns it to a SVIEW[#]
3569 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
3571 type must be 1 or 4 entries (if specifying on a per-component
3572 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
3574 For TEX\* style texture sample opcodes (as opposed to SAMPLE\* opcodes
3575 which take an explicit SVIEW[#] source register), there may be optionally
3576 SVIEW[#] declarations. In this case, the SVIEW index is implied by the
3577 SAMP index, and there must be a corresponding SVIEW[#] declaration for
3578 each SAMP[#] declaration. Drivers are free to ignore this if they wish.
3579 But note in particular that some drivers need to know the sampler type
3580 (float/int/unsigned) in order to generate the correct code, so cases
3581 where integer textures are sampled, SVIEW[#] declarations should be
3584 NOTE: It is NOT legal to mix SAMPLE\* style opcodes and TEX\* opcodes
3587 Declaration Resource
3588 ^^^^^^^^^^^^^^^^^^^^
3590 Follows Declaration token if file is TGSI_FILE_RESOURCE.
3592 DCL RES[#], resource [, WR] [, RAW]
3594 Declares a shader input resource and assigns it to a RES[#]
3597 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
3600 If the RAW keyword is not specified, the texture data will be
3601 subject to conversion, swizzling and scaling as required to yield
3602 the specified data type from the physical data format of the bound
3605 If the RAW keyword is specified, no channel conversion will be
3606 performed: the values read for each of the channels (X,Y,Z,W) will
3607 correspond to consecutive words in the same order and format
3608 they're found in memory. No element-to-address conversion will be
3609 performed either: the value of the provided X coordinate will be
3610 interpreted in byte units instead of texel units. The result of
3611 accessing a misaligned address is undefined.
3613 Usage of the STORE opcode is only allowed if the WR (writable) flag
3618 ^^^^^^^^^^^^^^^^^^^^^^^^
3620 Properties are general directives that apply to the whole TGSI program.
3625 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
3626 The default value is UPPER_LEFT.
3628 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
3629 increase downward and rightward.
3630 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
3631 increase upward and rightward.
3633 OpenGL defaults to LOWER_LEFT, and is configurable with the
3634 GL_ARB_fragment_coord_conventions extension.
3636 DirectX 9/10 use UPPER_LEFT.
3638 FS_COORD_PIXEL_CENTER
3639 """""""""""""""""""""
3641 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
3642 The default value is HALF_INTEGER.
3644 If HALF_INTEGER, the fractionary part of the position will be 0.5
3645 If INTEGER, the fractionary part of the position will be 0.0
3647 Note that this does not affect the set of fragments generated by
3648 rasterization, which is instead controlled by half_pixel_center in the
3651 OpenGL defaults to HALF_INTEGER, and is configurable with the
3652 GL_ARB_fragment_coord_conventions extension.
3654 DirectX 9 uses INTEGER.
3655 DirectX 10 uses HALF_INTEGER.
3657 FS_COLOR0_WRITES_ALL_CBUFS
3658 """"""""""""""""""""""""""
3659 Specifies that writes to the fragment shader color 0 are replicated to all
3660 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
3661 fragData is directed to a single color buffer, but fragColor is broadcast.
3664 """"""""""""""""""""""""""
3665 If this property is set on the program bound to the shader stage before the
3666 fragment shader, user clip planes should have no effect (be disabled) even if
3667 that shader does not write to any clip distance outputs and the rasterizer's
3668 clip_plane_enable is non-zero.
3669 This property is only supported by drivers that also support shader clip
3671 This is useful for APIs that don't have UCPs and where clip distances written
3672 by a shader cannot be disabled.
3677 Specifies the number of times a geometry shader should be executed for each
3678 input primitive. Each invocation will have a different
3679 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
3682 VS_WINDOW_SPACE_POSITION
3683 """"""""""""""""""""""""""
3684 If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
3685 is assumed to contain window space coordinates.
3686 Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
3687 directly taken from the 4-th component of the shader output.
3688 Naturally, clipping is not performed on window coordinates either.
3689 The effect of this property is undefined if a geometry or tessellation shader
3695 The number of vertices written by the tessellation control shader. This
3696 effectively defines the patch input size of the tessellation evaluation shader
3702 This sets the tessellation primitive mode, one of ``PIPE_PRIM_TRIANGLES``,
3703 ``PIPE_PRIM_QUADS``, or ``PIPE_PRIM_LINES``. (Unlike in GL, there is no
3704 separate isolines settings, the regular lines is assumed to mean isolines.)
3709 This sets the spacing mode of the tessellation generator, one of
3710 ``PIPE_TESS_SPACING_*``.
3715 This sets the vertex order to be clockwise if the value is 1, or
3716 counter-clockwise if set to 0.
3721 If set to a non-zero value, this turns on point mode for the tessellator,
3722 which means that points will be generated instead of primitives.
3724 NUM_CLIPDIST_ENABLED
3725 """"""""""""""""""""
3727 How many clip distance scalar outputs are enabled.
3729 NUM_CULLDIST_ENABLED
3730 """"""""""""""""""""
3732 How many cull distance scalar outputs are enabled.
3734 FS_EARLY_DEPTH_STENCIL
3735 """"""""""""""""""""""
3737 Whether depth test, stencil test, and occlusion query should run before
3738 the fragment shader (regardless of fragment shader side effects). Corresponds
3739 to GLSL early_fragment_tests.
3744 Which shader stage will MOST LIKELY follow after this shader when the shader
3745 is bound. This is only a hint to the driver and doesn't have to be precise.
3746 Only set for VS and TES.
3748 CS_FIXED_BLOCK_WIDTH / HEIGHT / DEPTH
3749 """""""""""""""""""""""""""""""""""""
3751 Threads per block in each dimension, if known at compile time. If the block size
3752 is known all three should be at least 1. If it is unknown they should all be set
3758 The MUL TGSI operation (FP32 multiplication) will return 0 if either
3759 of the operands are equal to 0. That means that 0 * Inf = 0. This
3760 should be set the same way for an entire pipeline. Note that this
3761 applies not only to the literal MUL TGSI opcode, but all FP32
3762 multiplications implied by other operations, such as MAD, FMA, DP2,
3763 DP3, DP4, DPH, DST, LOG, LRP, XPD, and possibly others. If there is a
3764 mismatch between shaders, then it is unspecified whether this behavior
3767 FS_POST_DEPTH_COVERAGE
3768 """"""""""""""""""""""
3770 When enabled, the input for TGSI_SEMANTIC_SAMPLEMASK will exclude samples
3771 that have failed the depth/stencil tests. This is only valid when
3772 FS_EARLY_DEPTH_STENCIL is also specified.
3775 Texture Sampling and Texture Formats
3776 ------------------------------------
3778 This table shows how texture image components are returned as (x,y,z,w) tuples
3779 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
3780 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
3783 +--------------------+--------------+--------------------+--------------+
3784 | Texture Components | Gallium | OpenGL | Direct3D 9 |
3785 +====================+==============+====================+==============+
3786 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
3787 +--------------------+--------------+--------------------+--------------+
3788 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
3789 +--------------------+--------------+--------------------+--------------+
3790 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
3791 +--------------------+--------------+--------------------+--------------+
3792 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
3793 +--------------------+--------------+--------------------+--------------+
3794 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
3795 +--------------------+--------------+--------------------+--------------+
3796 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
3797 +--------------------+--------------+--------------------+--------------+
3798 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
3799 +--------------------+--------------+--------------------+--------------+
3800 | I | (i, i, i, i) | (i, i, i, i) | N/A |
3801 +--------------------+--------------+--------------------+--------------+
3802 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
3803 | | | [#envmap-bumpmap]_ | |
3804 +--------------------+--------------+--------------------+--------------+
3805 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
3806 | | | [#depth-tex-mode]_ | |
3807 +--------------------+--------------+--------------------+--------------+
3808 | S | (s, s, s, s) | unknown | unknown |
3809 +--------------------+--------------+--------------------+--------------+
3811 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
3812 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
3813 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.