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 negation
32 modifiers are supported (with absolute value being applied first).
33 TGSI_OPCODE_MOV is considered to have float input type for applying modifiers.
35 For inputs which have signed or unsigned type only the negate modifier is
42 ^^^^^^^^^^^^^^^^^^^^^^^^^
44 These opcodes are guaranteed to be available regardless of the driver being
47 .. opcode:: ARL - Address Register Load
51 dst.x = \lfloor src.x\rfloor
53 dst.y = \lfloor src.y\rfloor
55 dst.z = \lfloor src.z\rfloor
57 dst.w = \lfloor src.w\rfloor
60 .. opcode:: MOV - Move
73 .. opcode:: LIT - Light Coefficients
78 dst.y &= max(src.x, 0) \\
79 dst.z &= (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 \\
83 .. opcode:: RCP - Reciprocal
85 This instruction replicates its result.
92 .. opcode:: RSQ - Reciprocal Square Root
94 This instruction replicates its result. The results are undefined for src <= 0.
98 dst = \frac{1}{\sqrt{src.x}}
101 .. opcode:: SQRT - Square Root
103 This instruction replicates its result. The results are undefined for src < 0.
110 .. opcode:: EXP - Approximate Exponential Base 2
114 dst.x &= 2^{\lfloor src.x\rfloor} \\
115 dst.y &= src.x - \lfloor src.x\rfloor \\
116 dst.z &= 2^{src.x} \\
120 .. opcode:: LOG - Approximate Logarithm Base 2
124 dst.x &= \lfloor\log_2{|src.x|}\rfloor \\
125 dst.y &= \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} \\
126 dst.z &= \log_2{|src.x|} \\
130 .. opcode:: MUL - Multiply
134 dst.x = src0.x \times src1.x
136 dst.y = src0.y \times src1.y
138 dst.z = src0.z \times src1.z
140 dst.w = src0.w \times src1.w
143 .. opcode:: ADD - Add
147 dst.x = src0.x + src1.x
149 dst.y = src0.y + src1.y
151 dst.z = src0.z + src1.z
153 dst.w = src0.w + src1.w
156 .. opcode:: DP3 - 3-component Dot Product
158 This instruction replicates its result.
162 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
165 .. opcode:: DP4 - 4-component Dot Product
167 This instruction replicates its result.
171 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
174 .. opcode:: DST - Distance Vector
179 dst.y &= src0.y \times src1.y\\
184 .. opcode:: MIN - Minimum
188 dst.x = min(src0.x, src1.x)
190 dst.y = min(src0.y, src1.y)
192 dst.z = min(src0.z, src1.z)
194 dst.w = min(src0.w, src1.w)
197 .. opcode:: MAX - Maximum
201 dst.x = max(src0.x, src1.x)
203 dst.y = max(src0.y, src1.y)
205 dst.z = max(src0.z, src1.z)
207 dst.w = max(src0.w, src1.w)
210 .. opcode:: SLT - Set On Less Than
214 dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
216 dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
218 dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
220 dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
223 .. opcode:: SGE - Set On Greater Equal Than
227 dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
229 dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
231 dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
233 dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
236 .. opcode:: MAD - Multiply And Add
240 dst.x = src0.x \times src1.x + src2.x
242 dst.y = src0.y \times src1.y + src2.y
244 dst.z = src0.z \times src1.z + src2.z
246 dst.w = src0.w \times src1.w + src2.w
249 .. opcode:: SUB - Subtract
253 dst.x = src0.x - src1.x
255 dst.y = src0.y - src1.y
257 dst.z = src0.z - src1.z
259 dst.w = src0.w - src1.w
262 .. opcode:: LRP - Linear Interpolate
266 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
268 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
270 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
272 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
275 .. opcode:: CND - Condition
279 dst.x = (src2.x > 0.5) ? src0.x : src1.x
281 dst.y = (src2.y > 0.5) ? src0.y : src1.y
283 dst.z = (src2.z > 0.5) ? src0.z : src1.z
285 dst.w = (src2.w > 0.5) ? src0.w : src1.w
288 .. opcode:: DP2A - 2-component Dot Product And Add
292 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
294 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
296 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
298 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
301 .. opcode:: FRC - Fraction
305 dst.x = src.x - \lfloor src.x\rfloor
307 dst.y = src.y - \lfloor src.y\rfloor
309 dst.z = src.z - \lfloor src.z\rfloor
311 dst.w = src.w - \lfloor src.w\rfloor
314 .. opcode:: CLAMP - Clamp
318 dst.x = clamp(src0.x, src1.x, src2.x)
320 dst.y = clamp(src0.y, src1.y, src2.y)
322 dst.z = clamp(src0.z, src1.z, src2.z)
324 dst.w = clamp(src0.w, src1.w, src2.w)
327 .. opcode:: FLR - Floor
329 This is identical to :opcode:`ARL`.
333 dst.x = \lfloor src.x\rfloor
335 dst.y = \lfloor src.y\rfloor
337 dst.z = \lfloor src.z\rfloor
339 dst.w = \lfloor src.w\rfloor
342 .. opcode:: ROUND - Round
355 .. opcode:: EX2 - Exponential Base 2
357 This instruction replicates its result.
364 .. opcode:: LG2 - Logarithm Base 2
366 This instruction replicates its result.
373 .. opcode:: POW - Power
375 This instruction replicates its result.
379 dst = src0.x^{src1.x}
381 .. opcode:: XPD - Cross Product
385 dst.x = src0.y \times src1.z - src1.y \times src0.z
387 dst.y = src0.z \times src1.x - src1.z \times src0.x
389 dst.z = src0.x \times src1.y - src1.x \times src0.y
394 .. opcode:: ABS - Absolute
407 .. opcode:: DPH - Homogeneous Dot Product
409 This instruction replicates its result.
413 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
416 .. opcode:: COS - Cosine
418 This instruction replicates its result.
425 .. opcode:: DDX, DDX_FINE - Derivative Relative To X
427 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
428 advertised. When it is, the fine version guarantees one derivative per row
429 while DDX is allowed to be the same for the entire 2x2 quad.
433 dst.x = partialx(src.x)
435 dst.y = partialx(src.y)
437 dst.z = partialx(src.z)
439 dst.w = partialx(src.w)
442 .. opcode:: DDY, DDY_FINE - Derivative Relative To Y
444 The fine variant is only used when ``PIPE_CAP_TGSI_FS_FINE_DERIVATIVE`` is
445 advertised. When it is, the fine version guarantees one derivative per column
446 while DDY is allowed to be the same for the entire 2x2 quad.
450 dst.x = partialy(src.x)
452 dst.y = partialy(src.y)
454 dst.z = partialy(src.z)
456 dst.w = partialy(src.w)
459 .. opcode:: PK2H - Pack Two 16-bit Floats
464 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
469 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
474 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
479 .. opcode:: RFL - Reflection Vector
483 dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x
485 dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
487 dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
493 Considered for removal.
496 .. opcode:: SEQ - Set On Equal
500 dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
502 dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
504 dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
506 dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
509 .. opcode:: SFL - Set On False
511 This instruction replicates its result.
519 Considered for removal.
522 .. opcode:: SGT - Set On Greater Than
526 dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
528 dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
530 dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
532 dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
535 .. opcode:: SIN - Sine
537 This instruction replicates its result.
544 .. opcode:: SLE - Set On Less Equal Than
548 dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
550 dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
552 dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
554 dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
557 .. opcode:: SNE - Set On Not Equal
561 dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
563 dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
565 dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
567 dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
570 .. opcode:: STR - Set On True
572 This instruction replicates its result.
579 .. opcode:: TEX - Texture Lookup
581 for array textures src0.y contains the slice for 1D,
582 and src0.z contain the slice for 2D.
584 for shadow textures with no arrays (and not cube map),
585 src0.z contains the reference value.
587 for shadow textures with arrays, src0.z contains
588 the reference value for 1D arrays, and src0.w contains
589 the reference value for 2D arrays and cube maps.
591 for cube map array shadow textures, the reference value
592 cannot be passed in src0.w, and TEX2 must be used instead.
598 shadow_ref = src0.z or src0.w (optional)
602 dst = texture\_sample(unit, coord, shadow_ref)
605 .. opcode:: TEX2 - Texture Lookup (for shadow cube map arrays only)
607 this is the same as TEX, but uses another reg to encode the
618 dst = texture\_sample(unit, coord, shadow_ref)
623 .. opcode:: TXD - Texture Lookup with Derivatives
635 dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
638 .. opcode:: TXP - Projective Texture Lookup
642 coord.x = src0.x / src0.w
644 coord.y = src0.y / src0.w
646 coord.z = src0.z / src0.w
652 dst = texture\_sample(unit, coord)
655 .. opcode:: UP2H - Unpack Two 16-Bit Floats
661 Considered for removal.
663 .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
669 Considered for removal.
671 .. opcode:: UP4B - Unpack Four Signed 8-Bit Values
677 Considered for removal.
679 .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
685 Considered for removal.
687 .. opcode:: X2D - 2D Coordinate Transformation
691 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
693 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
695 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
697 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
701 Considered for removal.
704 .. opcode:: ARR - Address Register Load With Round
717 .. opcode:: SSG - Set Sign
721 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
723 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
725 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
727 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
730 .. opcode:: CMP - Compare
734 dst.x = (src0.x < 0) ? src1.x : src2.x
736 dst.y = (src0.y < 0) ? src1.y : src2.y
738 dst.z = (src0.z < 0) ? src1.z : src2.z
740 dst.w = (src0.w < 0) ? src1.w : src2.w
743 .. opcode:: KILL_IF - Conditional Discard
745 Conditional discard. Allowed in fragment shaders only.
749 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
754 .. opcode:: KILL - Discard
756 Unconditional discard. Allowed in fragment shaders only.
759 .. opcode:: SCS - Sine Cosine
772 .. opcode:: TXB - Texture Lookup With Bias
774 for cube map array textures and shadow cube maps, the bias value
775 cannot be passed in src0.w, and TXB2 must be used instead.
777 if the target is a shadow texture, the reference value is always
778 in src.z (this prevents shadow 3d and shadow 2d arrays from
779 using this instruction, but this is not needed).
795 dst = texture\_sample(unit, coord, bias)
798 .. opcode:: TXB2 - Texture Lookup With Bias (some cube maps only)
800 this is the same as TXB, but uses another reg to encode the
801 lod bias value for cube map arrays and shadow cube maps.
802 Presumably shadow 2d arrays and shadow 3d targets could use
803 this encoding too, but this is not legal.
805 shadow cube map arrays are neither possible nor required.
815 dst = texture\_sample(unit, coord, bias)
818 .. opcode:: DIV - Divide
822 dst.x = \frac{src0.x}{src1.x}
824 dst.y = \frac{src0.y}{src1.y}
826 dst.z = \frac{src0.z}{src1.z}
828 dst.w = \frac{src0.w}{src1.w}
831 .. opcode:: DP2 - 2-component Dot Product
833 This instruction replicates its result.
837 dst = src0.x \times src1.x + src0.y \times src1.y
840 .. opcode:: TXL - Texture Lookup With explicit LOD
842 for cube map array textures, the explicit lod value
843 cannot be passed in src0.w, and TXL2 must be used instead.
845 if the target is a shadow texture, the reference value is always
846 in src.z (this prevents shadow 3d / 2d array / cube targets from
847 using this instruction, but this is not needed).
863 dst = texture\_sample(unit, coord, lod)
866 .. opcode:: TXL2 - Texture Lookup With explicit LOD (for cube map arrays only)
868 this is the same as TXL, but uses another reg to encode the
870 Presumably shadow 3d / 2d array / cube targets could use
871 this encoding too, but this is not legal.
873 shadow cube map arrays are neither possible nor required.
883 dst = texture\_sample(unit, coord, lod)
886 .. opcode:: PUSHA - Push Address Register On Stack
895 Considered for cleanup.
899 Considered for removal.
901 .. opcode:: POPA - Pop Address Register From Stack
910 Considered for cleanup.
914 Considered for removal.
917 .. opcode:: BRA - Branch
923 Considered for removal.
926 .. opcode:: CALLNZ - Subroutine Call If Not Zero
932 Considered for cleanup.
936 Considered for removal.
940 ^^^^^^^^^^^^^^^^^^^^^^^^
942 These opcodes are primarily provided for special-use computational shaders.
943 Support for these opcodes indicated by a special pipe capability bit (TBD).
945 XXX doesn't look like most of the opcodes really belong here.
947 .. opcode:: CEIL - Ceiling
951 dst.x = \lceil src.x\rceil
953 dst.y = \lceil src.y\rceil
955 dst.z = \lceil src.z\rceil
957 dst.w = \lceil src.w\rceil
960 .. opcode:: TRUNC - Truncate
973 .. opcode:: MOD - Modulus
977 dst.x = src0.x \bmod src1.x
979 dst.y = src0.y \bmod src1.y
981 dst.z = src0.z \bmod src1.z
983 dst.w = src0.w \bmod src1.w
986 .. opcode:: UARL - Integer Address Register Load
988 Moves the contents of the source register, assumed to be an integer, into the
989 destination register, which is assumed to be an address (ADDR) register.
992 .. opcode:: SAD - Sum Of Absolute Differences
996 dst.x = |src0.x - src1.x| + src2.x
998 dst.y = |src0.y - src1.y| + src2.y
1000 dst.z = |src0.z - src1.z| + src2.z
1002 dst.w = |src0.w - src1.w| + src2.w
1005 .. opcode:: TXF - Texel Fetch
1007 As per NV_gpu_shader4, extract a single texel from a specified texture
1008 image. The source sampler may not be a CUBE or SHADOW. src 0 is a
1009 four-component signed integer vector used to identify the single texel
1010 accessed. 3 components + level. Just like texture instructions, an optional
1011 offset vector is provided, which is subject to various driver restrictions
1012 (regarding range, source of offsets).
1013 TXF(uint_vec coord, int_vec offset).
1016 .. opcode:: TXQ - Texture Size Query
1018 As per NV_gpu_program4, retrieve the dimensions of the texture depending on
1019 the target. For 1D (width), 2D/RECT/CUBE (width, height), 3D (width, height,
1020 depth), 1D array (width, layers), 2D array (width, height, layers).
1021 Also return the number of accessible levels (last_level - first_level + 1)
1024 For components which don't return a resource dimension, their value
1032 dst.x = texture\_width(unit, lod)
1034 dst.y = texture\_height(unit, lod)
1036 dst.z = texture\_depth(unit, lod)
1038 dst.w = texture\_levels(unit)
1040 .. opcode:: TG4 - Texture Gather
1042 As per ARB_texture_gather, gathers the four texels to be used in a bi-linear
1043 filtering operation and packs them into a single register. Only works with
1044 2D, 2D array, cubemaps, and cubemaps arrays. For 2D textures, only the
1045 addressing modes of the sampler and the top level of any mip pyramid are
1046 used. Set W to zero. It behaves like the TEX instruction, but a filtered
1047 sample is not generated. The four samples that contribute to filtering are
1048 placed into xyzw in clockwise order, starting with the (u,v) texture
1049 coordinate delta at the following locations (-, +), (+, +), (+, -), (-, -),
1050 where the magnitude of the deltas are half a texel.
1052 PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
1053 depth compares, single component selection, and a non-constant offset. It
1054 doesn't allow support for the GL independent offset to get i0,j0. This would
1055 require another CAP is hw can do it natively. For now we lower that before
1064 dst = texture\_gather4 (unit, coord, component)
1066 (with SM5 - cube array shadow)
1074 dst = texture\_gather (uint, coord, compare)
1076 .. opcode:: LODQ - level of detail query
1078 Compute the LOD information that the texture pipe would use to access the
1079 texture. The Y component contains the computed LOD lambda_prime. The X
1080 component contains the LOD that will be accessed, based on min/max lod's
1087 dst.xy = lodq(uint, coord);
1090 ^^^^^^^^^^^^^^^^^^^^^^^^
1091 These opcodes are used for integer operations.
1092 Support for these opcodes indicated by PIPE_SHADER_CAP_INTEGERS (all of them?)
1095 .. opcode:: I2F - Signed Integer To Float
1097 Rounding is unspecified (round to nearest even suggested).
1101 dst.x = (float) src.x
1103 dst.y = (float) src.y
1105 dst.z = (float) src.z
1107 dst.w = (float) src.w
1110 .. opcode:: U2F - Unsigned Integer To Float
1112 Rounding is unspecified (round to nearest even suggested).
1116 dst.x = (float) src.x
1118 dst.y = (float) src.y
1120 dst.z = (float) src.z
1122 dst.w = (float) src.w
1125 .. opcode:: F2I - Float to Signed Integer
1127 Rounding is towards zero (truncate).
1128 Values outside signed range (including NaNs) produce undefined results.
1141 .. opcode:: F2U - Float to Unsigned Integer
1143 Rounding is towards zero (truncate).
1144 Values outside unsigned range (including NaNs) produce undefined results.
1148 dst.x = (unsigned) src.x
1150 dst.y = (unsigned) src.y
1152 dst.z = (unsigned) src.z
1154 dst.w = (unsigned) src.w
1157 .. opcode:: UADD - Integer Add
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 + src1.x
1166 dst.y = src0.y + src1.y
1168 dst.z = src0.z + src1.z
1170 dst.w = src0.w + src1.w
1173 .. opcode:: UMAD - Integer Multiply And Add
1175 This instruction works the same for signed and unsigned integers.
1176 The multiplication returns the low 32bit (as does the result itself).
1180 dst.x = src0.x \times src1.x + src2.x
1182 dst.y = src0.y \times src1.y + src2.y
1184 dst.z = src0.z \times src1.z + src2.z
1186 dst.w = src0.w \times src1.w + src2.w
1189 .. opcode:: UMUL - Integer Multiply
1191 This instruction works the same for signed and unsigned integers.
1192 The low 32bit of the result is returned.
1196 dst.x = src0.x \times src1.x
1198 dst.y = src0.y \times src1.y
1200 dst.z = src0.z \times src1.z
1202 dst.w = src0.w \times src1.w
1205 .. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1207 The high 32bits of the multiplication of 2 signed integers are returned.
1211 dst.x = (src0.x \times src1.x) >> 32
1213 dst.y = (src0.y \times src1.y) >> 32
1215 dst.z = (src0.z \times src1.z) >> 32
1217 dst.w = (src0.w \times src1.w) >> 32
1220 .. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1222 The high 32bits of the multiplication of 2 unsigned integers are returned.
1226 dst.x = (src0.x \times src1.x) >> 32
1228 dst.y = (src0.y \times src1.y) >> 32
1230 dst.z = (src0.z \times src1.z) >> 32
1232 dst.w = (src0.w \times src1.w) >> 32
1235 .. opcode:: IDIV - Signed Integer Division
1237 TBD: behavior for division by zero.
1241 dst.x = src0.x \ src1.x
1243 dst.y = src0.y \ src1.y
1245 dst.z = src0.z \ src1.z
1247 dst.w = src0.w \ src1.w
1250 .. opcode:: UDIV - Unsigned Integer Division
1252 For division by zero, 0xffffffff is returned.
1256 dst.x = src0.x \ src1.x
1258 dst.y = src0.y \ src1.y
1260 dst.z = src0.z \ src1.z
1262 dst.w = src0.w \ src1.w
1265 .. opcode:: UMOD - Unsigned Integer Remainder
1267 If second arg is zero, 0xffffffff is returned.
1271 dst.x = src0.x \ src1.x
1273 dst.y = src0.y \ src1.y
1275 dst.z = src0.z \ src1.z
1277 dst.w = src0.w \ src1.w
1280 .. opcode:: NOT - Bitwise Not
1293 .. opcode:: AND - Bitwise And
1297 dst.x = src0.x \& src1.x
1299 dst.y = src0.y \& src1.y
1301 dst.z = src0.z \& src1.z
1303 dst.w = src0.w \& src1.w
1306 .. opcode:: OR - Bitwise Or
1310 dst.x = src0.x | src1.x
1312 dst.y = src0.y | src1.y
1314 dst.z = src0.z | src1.z
1316 dst.w = src0.w | src1.w
1319 .. opcode:: XOR - Bitwise Xor
1323 dst.x = src0.x \oplus src1.x
1325 dst.y = src0.y \oplus src1.y
1327 dst.z = src0.z \oplus src1.z
1329 dst.w = src0.w \oplus src1.w
1332 .. opcode:: IMAX - Maximum of Signed Integers
1336 dst.x = max(src0.x, src1.x)
1338 dst.y = max(src0.y, src1.y)
1340 dst.z = max(src0.z, src1.z)
1342 dst.w = max(src0.w, src1.w)
1345 .. opcode:: UMAX - Maximum of Unsigned Integers
1349 dst.x = max(src0.x, src1.x)
1351 dst.y = max(src0.y, src1.y)
1353 dst.z = max(src0.z, src1.z)
1355 dst.w = max(src0.w, src1.w)
1358 .. opcode:: IMIN - Minimum of Signed Integers
1362 dst.x = min(src0.x, src1.x)
1364 dst.y = min(src0.y, src1.y)
1366 dst.z = min(src0.z, src1.z)
1368 dst.w = min(src0.w, src1.w)
1371 .. opcode:: UMIN - Minimum of Unsigned Integers
1375 dst.x = min(src0.x, src1.x)
1377 dst.y = min(src0.y, src1.y)
1379 dst.z = min(src0.z, src1.z)
1381 dst.w = min(src0.w, src1.w)
1384 .. opcode:: SHL - Shift Left
1386 The shift count is masked with 0x1f before the shift is applied.
1390 dst.x = src0.x << (0x1f \& src1.x)
1392 dst.y = src0.y << (0x1f \& src1.y)
1394 dst.z = src0.z << (0x1f \& src1.z)
1396 dst.w = src0.w << (0x1f \& src1.w)
1399 .. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1401 The shift count is masked with 0x1f before the shift is applied.
1405 dst.x = src0.x >> (0x1f \& src1.x)
1407 dst.y = src0.y >> (0x1f \& src1.y)
1409 dst.z = src0.z >> (0x1f \& src1.z)
1411 dst.w = src0.w >> (0x1f \& src1.w)
1414 .. opcode:: USHR - Logical Shift Right
1416 The shift count is masked with 0x1f before the shift is applied.
1420 dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1422 dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1424 dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1426 dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
1429 .. opcode:: UCMP - Integer Conditional Move
1433 dst.x = src0.x ? src1.x : src2.x
1435 dst.y = src0.y ? src1.y : src2.y
1437 dst.z = src0.z ? src1.z : src2.z
1439 dst.w = src0.w ? src1.w : src2.w
1443 .. opcode:: ISSG - Integer Set Sign
1447 dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1449 dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1451 dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1453 dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1457 .. opcode:: FSLT - Float Set On Less Than (ordered)
1459 Same comparison as SLT but returns integer instead of 1.0/0.0 float
1463 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1465 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1467 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1469 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1472 .. opcode:: ISLT - Signed Integer Set On Less Than
1476 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1478 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1480 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1482 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1485 .. opcode:: USLT - Unsigned Integer Set On Less Than
1489 dst.x = (src0.x < src1.x) ? \sim 0 : 0
1491 dst.y = (src0.y < src1.y) ? \sim 0 : 0
1493 dst.z = (src0.z < src1.z) ? \sim 0 : 0
1495 dst.w = (src0.w < src1.w) ? \sim 0 : 0
1498 .. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1500 Same comparison as SGE but returns integer instead of 1.0/0.0 float
1504 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1506 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1508 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1510 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1513 .. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1517 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1519 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1521 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1523 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1526 .. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1530 dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1532 dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1534 dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1536 dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1539 .. opcode:: FSEQ - Float Set On Equal (ordered)
1541 Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1545 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1547 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1549 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1551 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1554 .. opcode:: USEQ - Integer Set On Equal
1558 dst.x = (src0.x == src1.x) ? \sim 0 : 0
1560 dst.y = (src0.y == src1.y) ? \sim 0 : 0
1562 dst.z = (src0.z == src1.z) ? \sim 0 : 0
1564 dst.w = (src0.w == src1.w) ? \sim 0 : 0
1567 .. opcode:: FSNE - Float Set On Not Equal (unordered)
1569 Same comparison as SNE but returns integer instead of 1.0/0.0 float
1573 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1575 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1577 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1579 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1582 .. opcode:: USNE - Integer Set On Not Equal
1586 dst.x = (src0.x != src1.x) ? \sim 0 : 0
1588 dst.y = (src0.y != src1.y) ? \sim 0 : 0
1590 dst.z = (src0.z != src1.z) ? \sim 0 : 0
1592 dst.w = (src0.w != src1.w) ? \sim 0 : 0
1595 .. opcode:: INEG - Integer Negate
1610 .. opcode:: IABS - Integer Absolute Value
1624 These opcodes are used for bit-level manipulation of integers.
1626 .. opcode:: IBFE - Signed Bitfield Extract
1628 See SM5 instruction of the same name. Extracts a set of bits from the input,
1629 and sign-extends them if the high bit of the extracted window is set.
1633 def ibfe(value, offset, bits):
1634 offset = offset & 0x1f
1636 if bits == 0: return 0
1637 # Note: >> sign-extends
1638 if width + offset < 32:
1639 return (value << (32 - offset - bits)) >> (32 - bits)
1641 return value >> offset
1643 .. opcode:: UBFE - Unsigned Bitfield Extract
1645 See SM5 instruction of the same name. Extracts a set of bits from the input,
1646 without any sign-extension.
1650 def ubfe(value, offset, bits):
1651 offset = offset & 0x1f
1653 if bits == 0: return 0
1654 # Note: >> does not sign-extend
1655 if width + offset < 32:
1656 return (value << (32 - offset - bits)) >> (32 - bits)
1658 return value >> offset
1660 .. opcode:: BFI - Bitfield Insert
1662 See SM5 instruction of the same name. Replaces a bit region of 'base' with
1663 the low bits of 'insert'.
1667 def bfi(base, insert, offset, bits):
1668 offset = offset & 0x1f
1670 mask = ((1 << bits) - 1) << offset
1671 return ((insert << offset) & mask) | (base & ~mask)
1673 .. opcode:: BREV - Bitfield Reverse
1675 See SM5 instruction BFREV. Reverses the bits of the argument.
1677 .. opcode:: POPC - Population Count
1679 See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1681 .. opcode:: LSB - Index of lowest set bit
1683 See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1684 bit of the argument. Returns -1 if none are set.
1686 .. opcode:: IMSB - Index of highest non-sign bit
1688 See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1689 non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1690 highest 1 bit for positive numbers). Returns -1 if all bits are the same
1691 (i.e. for inputs 0 and -1).
1693 .. opcode:: UMSB - Index of highest set bit
1695 See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1696 set bit of the argument. Returns -1 if none are set.
1699 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1701 These opcodes are only supported in geometry shaders; they have no meaning
1702 in any other type of shader.
1704 .. opcode:: EMIT - Emit
1706 Generate a new vertex for the current primitive into the specified vertex
1707 stream using the values in the output registers.
1710 .. opcode:: ENDPRIM - End Primitive
1712 Complete the current primitive in the specified vertex stream (consisting of
1713 the emitted vertices), and start a new one.
1719 These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1720 opcodes is determined by a special capability bit, ``GLSL``.
1721 Some require glsl version 1.30 (UIF/BREAKC/SWITCH/CASE/DEFAULT/ENDSWITCH).
1723 .. opcode:: CAL - Subroutine Call
1729 .. opcode:: RET - Subroutine Call Return
1734 .. opcode:: CONT - Continue
1736 Unconditionally moves the point of execution to the instruction after the
1737 last bgnloop. The instruction must appear within a bgnloop/endloop.
1741 Support for CONT is determined by a special capability bit,
1742 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1745 .. opcode:: BGNLOOP - Begin a Loop
1747 Start a loop. Must have a matching endloop.
1750 .. opcode:: BGNSUB - Begin Subroutine
1752 Starts definition of a subroutine. Must have a matching endsub.
1755 .. opcode:: ENDLOOP - End a Loop
1757 End a loop started with bgnloop.
1760 .. opcode:: ENDSUB - End Subroutine
1762 Ends definition of a subroutine.
1765 .. opcode:: NOP - No Operation
1770 .. opcode:: BRK - Break
1772 Unconditionally moves the point of execution to the instruction after the
1773 next endloop or endswitch. The instruction must appear within a loop/endloop
1774 or switch/endswitch.
1777 .. opcode:: BREAKC - Break Conditional
1779 Conditionally moves the point of execution to the instruction after the
1780 next endloop or endswitch. The instruction must appear within a loop/endloop
1781 or switch/endswitch.
1782 Condition evaluates to true if src0.x != 0 where src0.x is interpreted
1783 as an integer register.
1787 Considered for removal as it's quite inconsistent wrt other opcodes
1788 (could emulate with UIF/BRK/ENDIF).
1791 .. opcode:: IF - Float If
1793 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
1797 where src0.x is interpreted as a floating point register.
1800 .. opcode:: UIF - Bitwise If
1802 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1806 where src0.x is interpreted as an integer register.
1809 .. opcode:: ELSE - Else
1811 Starts an else block, after an IF or UIF statement.
1814 .. opcode:: ENDIF - End If
1816 Ends an IF or UIF block.
1819 .. opcode:: SWITCH - Switch
1821 Starts a C-style switch expression. The switch consists of one or multiple
1822 CASE statements, and at most one DEFAULT statement. Execution of a statement
1823 ends when a BRK is hit, but just like in C falling through to other cases
1824 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
1825 just as last statement, and fallthrough is allowed into/from it.
1826 CASE src arguments are evaluated at bit level against the SWITCH src argument.
1832 (some instructions here)
1835 (some instructions here)
1838 (some instructions here)
1843 .. opcode:: CASE - Switch case
1845 This represents a switch case label. The src arg must be an integer immediate.
1848 .. opcode:: DEFAULT - Switch default
1850 This represents the default case in the switch, which is taken if no other
1854 .. opcode:: ENDSWITCH - End of switch
1856 Ends a switch expression.
1862 The interpolation instructions allow an input to be interpolated in a
1863 different way than its declaration. This corresponds to the GLSL 4.00
1864 interpolateAt* functions. The first argument of each of these must come from
1865 ``TGSI_FILE_INPUT``.
1867 .. opcode:: INTERP_CENTROID - Interpolate at the centroid
1869 Interpolates the varying specified by src0 at the centroid
1871 .. opcode:: INTERP_SAMPLE - Interpolate at the specified sample
1873 Interpolates the varying specified by src0 at the sample id specified by
1874 src1.x (interpreted as an integer)
1876 .. opcode:: INTERP_OFFSET - Interpolate at the specified offset
1878 Interpolates the varying specified by src0 at the offset src1.xy from the
1879 pixel center (interpreted as floats)
1887 The double-precision opcodes reinterpret four-component vectors into
1888 two-component vectors with doubled precision in each component.
1890 Support for these opcodes is XXX undecided. :T
1892 .. opcode:: DADD - Add
1896 dst.xy = src0.xy + src1.xy
1898 dst.zw = src0.zw + src1.zw
1901 .. opcode:: DDIV - Divide
1905 dst.xy = src0.xy / src1.xy
1907 dst.zw = src0.zw / src1.zw
1909 .. opcode:: DSEQ - Set on Equal
1913 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1915 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1917 .. opcode:: DSLT - Set on Less than
1921 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1923 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1925 .. opcode:: DFRAC - Fraction
1929 dst.xy = src.xy - \lfloor src.xy\rfloor
1931 dst.zw = src.zw - \lfloor src.zw\rfloor
1934 .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
1936 Like the ``frexp()`` routine in many math libraries, this opcode stores the
1937 exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1938 :math:`dst1 \times 2^{dst0} = src` .
1942 dst0.xy = exp(src.xy)
1944 dst1.xy = frac(src.xy)
1946 dst0.zw = exp(src.zw)
1948 dst1.zw = frac(src.zw)
1950 .. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1952 This opcode is the inverse of :opcode:`DFRACEXP`.
1956 dst.xy = src0.xy \times 2^{src1.xy}
1958 dst.zw = src0.zw \times 2^{src1.zw}
1960 .. opcode:: DMIN - Minimum
1964 dst.xy = min(src0.xy, src1.xy)
1966 dst.zw = min(src0.zw, src1.zw)
1968 .. opcode:: DMAX - Maximum
1972 dst.xy = max(src0.xy, src1.xy)
1974 dst.zw = max(src0.zw, src1.zw)
1976 .. opcode:: DMUL - Multiply
1980 dst.xy = src0.xy \times src1.xy
1982 dst.zw = src0.zw \times src1.zw
1985 .. opcode:: DMAD - Multiply And Add
1989 dst.xy = src0.xy \times src1.xy + src2.xy
1991 dst.zw = src0.zw \times src1.zw + src2.zw
1994 .. opcode:: DRCP - Reciprocal
1998 dst.xy = \frac{1}{src.xy}
2000 dst.zw = \frac{1}{src.zw}
2002 .. opcode:: DSQRT - Square Root
2006 dst.xy = \sqrt{src.xy}
2008 dst.zw = \sqrt{src.zw}
2011 .. _samplingopcodes:
2013 Resource Sampling Opcodes
2014 ^^^^^^^^^^^^^^^^^^^^^^^^^
2016 Those opcodes follow very closely semantics of the respective Direct3D
2017 instructions. If in doubt double check Direct3D documentation.
2018 Note that the swizzle on SVIEW (src1) determines texel swizzling
2023 Using provided address, sample data from the specified texture using the
2024 filtering mode identified by the gven sampler. The source data may come from
2025 any resource type other than buffers.
2027 Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2029 Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2031 .. opcode:: SAMPLE_I
2033 Simplified alternative to the SAMPLE instruction. Using the provided
2034 integer address, SAMPLE_I fetches data from the specified sampler view
2035 without any filtering. The source data may come from any resource type
2038 Syntax: ``SAMPLE_I dst, address, sampler_view``
2040 Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2042 The 'address' is specified as unsigned integers. If the 'address' is out of
2043 range [0...(# texels - 1)] the result of the fetch is always 0 in all
2044 components. As such the instruction doesn't honor address wrap modes, in
2045 cases where that behavior is desirable 'SAMPLE' instruction should be used.
2046 address.w always provides an unsigned integer mipmap level. If the value is
2047 out of the range then the instruction always returns 0 in all components.
2048 address.yz are ignored for buffers and 1d textures. address.z is ignored
2049 for 1d texture arrays and 2d textures.
2051 For 1D texture arrays address.y provides the array index (also as unsigned
2052 integer). If the value is out of the range of available array indices
2053 [0... (array size - 1)] then the opcode always returns 0 in all components.
2054 For 2D texture arrays address.z provides the array index, otherwise it
2055 exhibits the same behavior as in the case for 1D texture arrays. The exact
2056 semantics of the source address are presented in the table below:
2058 +---------------------------+----+-----+-----+---------+
2059 | resource type | X | Y | Z | W |
2060 +===========================+====+=====+=====+=========+
2061 | ``PIPE_BUFFER`` | x | | | ignored |
2062 +---------------------------+----+-----+-----+---------+
2063 | ``PIPE_TEXTURE_1D`` | x | | | mpl |
2064 +---------------------------+----+-----+-----+---------+
2065 | ``PIPE_TEXTURE_2D`` | x | y | | mpl |
2066 +---------------------------+----+-----+-----+---------+
2067 | ``PIPE_TEXTURE_3D`` | x | y | z | mpl |
2068 +---------------------------+----+-----+-----+---------+
2069 | ``PIPE_TEXTURE_RECT`` | x | y | | mpl |
2070 +---------------------------+----+-----+-----+---------+
2071 | ``PIPE_TEXTURE_CUBE`` | not allowed as source |
2072 +---------------------------+----+-----+-----+---------+
2073 | ``PIPE_TEXTURE_1D_ARRAY`` | x | idx | | mpl |
2074 +---------------------------+----+-----+-----+---------+
2075 | ``PIPE_TEXTURE_2D_ARRAY`` | x | y | idx | mpl |
2076 +---------------------------+----+-----+-----+---------+
2078 Where 'mpl' is a mipmap level and 'idx' is the array index.
2080 .. opcode:: SAMPLE_I_MS
2082 Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2084 Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2086 .. opcode:: SAMPLE_B
2088 Just like the SAMPLE instruction with the exception that an additional bias
2089 is applied to the level of detail computed as part of the instruction
2092 Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2094 Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2096 .. opcode:: SAMPLE_C
2098 Similar to the SAMPLE instruction but it performs a comparison filter. The
2099 operands to SAMPLE_C are identical to SAMPLE, except that there is an
2100 additional float32 operand, reference value, which must be a register with
2101 single-component, or a scalar literal. SAMPLE_C makes the hardware use the
2102 current samplers compare_func (in pipe_sampler_state) to compare reference
2103 value against the red component value for the surce resource at each texel
2104 that the currently configured texture filter covers based on the provided
2107 Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2109 Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2111 .. opcode:: SAMPLE_C_LZ
2113 Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2116 Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2118 Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2121 .. opcode:: SAMPLE_D
2123 SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2124 the source address in the x direction and the y direction are provided by
2127 Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2129 Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2131 .. opcode:: SAMPLE_L
2133 SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2134 directly as a scalar value, representing no anisotropy.
2136 Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2138 Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2142 Gathers the four texels to be used in a bi-linear filtering operation and
2143 packs them into a single register. Only works with 2D, 2D array, cubemaps,
2144 and cubemaps arrays. For 2D textures, only the addressing modes of the
2145 sampler and the top level of any mip pyramid are used. Set W to zero. It
2146 behaves like the SAMPLE instruction, but a filtered sample is not
2147 generated. The four samples that contribute to filtering are placed into
2148 xyzw in counter-clockwise order, starting with the (u,v) texture coordinate
2149 delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2150 magnitude of the deltas are half a texel.
2153 .. opcode:: SVIEWINFO
2155 Query the dimensions of a given sampler view. dst receives width, height,
2156 depth or array size and number of mipmap levels as int4. The dst can have a
2157 writemask which will specify what info is the caller interested in.
2159 Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2161 Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2163 src_mip_level is an unsigned integer scalar. If it's out of range then
2164 returns 0 for width, height and depth/array size but the total number of
2165 mipmap is still returned correctly for the given sampler view. The returned
2166 width, height and depth values are for the mipmap level selected by the
2167 src_mip_level and are in the number of texels. For 1d texture array width
2168 is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2169 still in dst.w. In contrast to d3d10 resinfo, there's no way in the tgsi
2170 instruction encoding to specify the return type (float/rcpfloat/uint), hence
2171 always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2172 resinfo allowing swizzling dst values is ignored (due to the interaction
2173 with rcpfloat modifier which requires some swizzle handling in the state
2176 .. opcode:: SAMPLE_POS
2178 Query the position of a given sample. dst receives float4 (x, y, 0, 0)
2179 indicated where the sample is located. If the resource is not a multi-sample
2180 resource and not a render target, the result is 0.
2182 .. opcode:: SAMPLE_INFO
2184 dst receives number of samples in x. If the resource is not a multi-sample
2185 resource and not a render target, the result is 0.
2188 .. _resourceopcodes:
2190 Resource Access Opcodes
2191 ^^^^^^^^^^^^^^^^^^^^^^^
2193 .. opcode:: LOAD - Fetch data from a shader resource
2195 Syntax: ``LOAD dst, resource, address``
2197 Example: ``LOAD TEMP[0], RES[0], TEMP[1]``
2199 Using the provided integer address, LOAD fetches data
2200 from the specified buffer or texture without any
2203 The 'address' is specified as a vector of unsigned
2204 integers. If the 'address' is out of range the result
2207 Only the first mipmap level of a resource can be read
2208 from using this instruction.
2210 For 1D or 2D texture arrays, the array index is
2211 provided as an unsigned integer in address.y or
2212 address.z, respectively. address.yz are ignored for
2213 buffers and 1D textures. address.z is ignored for 1D
2214 texture arrays and 2D textures. address.w is always
2217 .. opcode:: STORE - Write data to a shader resource
2219 Syntax: ``STORE resource, address, src``
2221 Example: ``STORE RES[0], TEMP[0], TEMP[1]``
2223 Using the provided integer address, STORE writes data
2224 to the specified buffer or texture.
2226 The 'address' is specified as a vector of unsigned
2227 integers. If the 'address' is out of range the result
2230 Only the first mipmap level of a resource can be
2231 written to using this instruction.
2233 For 1D or 2D texture arrays, the array index is
2234 provided as an unsigned integer in address.y or
2235 address.z, respectively. address.yz are ignored for
2236 buffers and 1D textures. address.z is ignored for 1D
2237 texture arrays and 2D textures. address.w is always
2241 .. _threadsyncopcodes:
2243 Inter-thread synchronization opcodes
2244 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2246 These opcodes are intended for communication between threads running
2247 within the same compute grid. For now they're only valid in compute
2250 .. opcode:: MFENCE - Memory fence
2252 Syntax: ``MFENCE resource``
2254 Example: ``MFENCE RES[0]``
2256 This opcode forces strong ordering between any memory access
2257 operations that affect the specified resource. This means that
2258 previous loads and stores (and only those) will be performed and
2259 visible to other threads before the program execution continues.
2262 .. opcode:: LFENCE - Load memory fence
2264 Syntax: ``LFENCE resource``
2266 Example: ``LFENCE RES[0]``
2268 Similar to MFENCE, but it only affects the ordering of memory loads.
2271 .. opcode:: SFENCE - Store memory fence
2273 Syntax: ``SFENCE resource``
2275 Example: ``SFENCE RES[0]``
2277 Similar to MFENCE, but it only affects the ordering of memory stores.
2280 .. opcode:: BARRIER - Thread group barrier
2284 This opcode suspends the execution of the current thread until all
2285 the remaining threads in the working group reach the same point of
2286 the program. Results are unspecified if any of the remaining
2287 threads terminates or never reaches an executed BARRIER instruction.
2295 These opcodes provide atomic variants of some common arithmetic and
2296 logical operations. In this context atomicity means that another
2297 concurrent memory access operation that affects the same memory
2298 location is guaranteed to be performed strictly before or after the
2299 entire execution of the atomic operation.
2301 For the moment they're only valid in compute programs.
2303 .. opcode:: ATOMUADD - Atomic integer addition
2305 Syntax: ``ATOMUADD dst, resource, offset, src``
2307 Example: ``ATOMUADD TEMP[0], RES[0], TEMP[1], TEMP[2]``
2309 The following operation is performed atomically on each component:
2313 dst_i = resource[offset]_i
2315 resource[offset]_i = dst_i + src_i
2318 .. opcode:: ATOMXCHG - Atomic exchange
2320 Syntax: ``ATOMXCHG dst, resource, offset, src``
2322 Example: ``ATOMXCHG TEMP[0], RES[0], TEMP[1], TEMP[2]``
2324 The following operation is performed atomically on each component:
2328 dst_i = resource[offset]_i
2330 resource[offset]_i = src_i
2333 .. opcode:: ATOMCAS - Atomic compare-and-exchange
2335 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2337 Example: ``ATOMCAS TEMP[0], RES[0], TEMP[1], TEMP[2], TEMP[3]``
2339 The following operation is performed atomically on each component:
2343 dst_i = resource[offset]_i
2345 resource[offset]_i = (dst_i == cmp_i ? src_i : dst_i)
2348 .. opcode:: ATOMAND - Atomic bitwise And
2350 Syntax: ``ATOMAND dst, resource, offset, src``
2352 Example: ``ATOMAND TEMP[0], RES[0], TEMP[1], TEMP[2]``
2354 The following operation is performed atomically on each component:
2358 dst_i = resource[offset]_i
2360 resource[offset]_i = dst_i \& src_i
2363 .. opcode:: ATOMOR - Atomic bitwise Or
2365 Syntax: ``ATOMOR dst, resource, offset, src``
2367 Example: ``ATOMOR TEMP[0], RES[0], TEMP[1], TEMP[2]``
2369 The following operation is performed atomically on each component:
2373 dst_i = resource[offset]_i
2375 resource[offset]_i = dst_i | src_i
2378 .. opcode:: ATOMXOR - Atomic bitwise Xor
2380 Syntax: ``ATOMXOR dst, resource, offset, src``
2382 Example: ``ATOMXOR TEMP[0], RES[0], TEMP[1], TEMP[2]``
2384 The following operation is performed atomically on each component:
2388 dst_i = resource[offset]_i
2390 resource[offset]_i = dst_i \oplus src_i
2393 .. opcode:: ATOMUMIN - Atomic unsigned minimum
2395 Syntax: ``ATOMUMIN dst, resource, offset, src``
2397 Example: ``ATOMUMIN TEMP[0], RES[0], TEMP[1], TEMP[2]``
2399 The following operation is performed atomically on each component:
2403 dst_i = resource[offset]_i
2405 resource[offset]_i = (dst_i < src_i ? dst_i : src_i)
2408 .. opcode:: ATOMUMAX - Atomic unsigned maximum
2410 Syntax: ``ATOMUMAX dst, resource, offset, src``
2412 Example: ``ATOMUMAX TEMP[0], RES[0], TEMP[1], TEMP[2]``
2414 The following operation is performed atomically on each component:
2418 dst_i = resource[offset]_i
2420 resource[offset]_i = (dst_i > src_i ? dst_i : src_i)
2423 .. opcode:: ATOMIMIN - Atomic signed minimum
2425 Syntax: ``ATOMIMIN dst, resource, offset, src``
2427 Example: ``ATOMIMIN TEMP[0], RES[0], TEMP[1], TEMP[2]``
2429 The following operation is performed atomically on each component:
2433 dst_i = resource[offset]_i
2435 resource[offset]_i = (dst_i < src_i ? dst_i : src_i)
2438 .. opcode:: ATOMIMAX - Atomic signed maximum
2440 Syntax: ``ATOMIMAX dst, resource, offset, src``
2442 Example: ``ATOMIMAX TEMP[0], RES[0], TEMP[1], TEMP[2]``
2444 The following operation is performed atomically on each component:
2448 dst_i = resource[offset]_i
2450 resource[offset]_i = (dst_i > src_i ? dst_i : src_i)
2454 Explanation of symbols used
2455 ------------------------------
2462 :math:`|x|` Absolute value of `x`.
2464 :math:`\lceil x \rceil` Ceiling of `x`.
2466 clamp(x,y,z) Clamp x between y and z.
2467 (x < y) ? y : (x > z) ? z : x
2469 :math:`\lfloor x\rfloor` Floor of `x`.
2471 :math:`\log_2{x}` Logarithm of `x`, base 2.
2473 max(x,y) Maximum of x and y.
2476 min(x,y) Minimum of x and y.
2479 partialx(x) Derivative of x relative to fragment's X.
2481 partialy(x) Derivative of x relative to fragment's Y.
2483 pop() Pop from stack.
2485 :math:`x^y` `x` to the power `y`.
2487 push(x) Push x on stack.
2491 trunc(x) Truncate x, i.e. drop the fraction bits.
2498 discard Discard fragment.
2502 target Label of target instruction.
2513 Declares a register that is will be referenced as an operand in Instruction
2516 File field contains register file that is being declared and is one
2519 UsageMask field specifies which of the register components can be accessed
2520 and is one of TGSI_WRITEMASK.
2522 The Local flag specifies that a given value isn't intended for
2523 subroutine parameter passing and, as a result, the implementation
2524 isn't required to give any guarantees of it being preserved across
2525 subroutine boundaries. As it's merely a compiler hint, the
2526 implementation is free to ignore it.
2528 If Dimension flag is set to 1, a Declaration Dimension token follows.
2530 If Semantic flag is set to 1, a Declaration Semantic token follows.
2532 If Interpolate flag is set to 1, a Declaration Interpolate token follows.
2534 If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
2536 If Array flag is set to 1, a Declaration Array token follows.
2539 ^^^^^^^^^^^^^^^^^^^^^^^^
2541 Declarations can optional have an ArrayID attribute which can be referred by
2542 indirect addressing operands. An ArrayID of zero is reserved and treaded as
2543 if no ArrayID is specified.
2545 If an indirect addressing operand refers to a specific declaration by using
2546 an ArrayID only the registers in this declaration are guaranteed to be
2547 accessed, accessing any register outside this declaration results in undefined
2548 behavior. Note that for compatibility the effective index is zero-based and
2549 not relative to the specified declaration
2551 If no ArrayID is specified with an indirect addressing operand the whole
2552 register file might be accessed by this operand. This is strongly discouraged
2553 and will prevent packing of scalar/vec2 arrays and effective alias analysis.
2555 Declaration Semantic
2556 ^^^^^^^^^^^^^^^^^^^^^^^^
2558 Vertex and fragment shader input and output registers may be labeled
2559 with semantic information consisting of a name and index.
2561 Follows Declaration token if Semantic bit is set.
2563 Since its purpose is to link a shader with other stages of the pipeline,
2564 it is valid to follow only those Declaration tokens that declare a register
2565 either in INPUT or OUTPUT file.
2567 SemanticName field contains the semantic name of the register being declared.
2568 There is no default value.
2570 SemanticIndex is an optional subscript that can be used to distinguish
2571 different register declarations with the same semantic name. The default value
2574 The meanings of the individual semantic names are explained in the following
2577 TGSI_SEMANTIC_POSITION
2578 """"""""""""""""""""""
2580 For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
2581 output register which contains the homogeneous vertex position in the clip
2582 space coordinate system. After clipping, the X, Y and Z components of the
2583 vertex will be divided by the W value to get normalized device coordinates.
2585 For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
2586 fragment shader input contains the fragment's window position. The X
2587 component starts at zero and always increases from left to right.
2588 The Y component starts at zero and always increases but Y=0 may either
2589 indicate the top of the window or the bottom depending on the fragment
2590 coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
2591 The Z coordinate ranges from 0 to 1 to represent depth from the front
2592 to the back of the Z buffer. The W component contains the reciprocol
2593 of the interpolated vertex position W component.
2595 Fragment shaders may also declare an output register with
2596 TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
2597 the fragment shader to change the fragment's Z position.
2604 For vertex shader outputs or fragment shader inputs/outputs, this
2605 label indicates that the resister contains an R,G,B,A color.
2607 Several shader inputs/outputs may contain colors so the semantic index
2608 is used to distinguish them. For example, color[0] may be the diffuse
2609 color while color[1] may be the specular color.
2611 This label is needed so that the flat/smooth shading can be applied
2612 to the right interpolants during rasterization.
2616 TGSI_SEMANTIC_BCOLOR
2617 """"""""""""""""""""
2619 Back-facing colors are only used for back-facing polygons, and are only valid
2620 in vertex shader outputs. After rasterization, all polygons are front-facing
2621 and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
2622 so all BCOLORs effectively become regular COLORs in the fragment shader.
2628 Vertex shader inputs and outputs and fragment shader inputs may be
2629 labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
2630 a fog coordinate. Typically, the fragment shader will use the fog coordinate
2631 to compute a fog blend factor which is used to blend the normal fragment color
2632 with a constant fog color. But fog coord really is just an ordinary vec4
2633 register like regular semantics.
2639 Vertex shader input and output registers may be labeled with
2640 TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
2641 in the form (S, 0, 0, 1). The point size controls the width or diameter
2642 of points for rasterization. This label cannot be used in fragment
2645 When using this semantic, be sure to set the appropriate state in the
2646 :ref:`rasterizer` first.
2649 TGSI_SEMANTIC_TEXCOORD
2650 """"""""""""""""""""""
2652 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
2654 Vertex shader outputs and fragment shader inputs may be labeled with
2655 this semantic to make them replaceable by sprite coordinates via the
2656 sprite_coord_enable state in the :ref:`rasterizer`.
2657 The semantic index permitted with this semantic is limited to <= 7.
2659 If the driver does not support TEXCOORD, sprite coordinate replacement
2660 applies to inputs with the GENERIC semantic instead.
2662 The intended use case for this semantic is gl_TexCoord.
2665 TGSI_SEMANTIC_PCOORD
2666 """"""""""""""""""""
2668 Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
2670 Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
2671 that the register contains sprite coordinates in the form (x, y, 0, 1), if
2672 the current primitive is a point and point sprites are enabled. Otherwise,
2673 the contents of the register are undefined.
2675 The intended use case for this semantic is gl_PointCoord.
2678 TGSI_SEMANTIC_GENERIC
2679 """""""""""""""""""""
2681 All vertex/fragment shader inputs/outputs not labeled with any other
2682 semantic label can be considered to be generic attributes. Typical
2683 uses of generic inputs/outputs are texcoords and user-defined values.
2686 TGSI_SEMANTIC_NORMAL
2687 """"""""""""""""""""
2689 Indicates that a vertex shader input is a normal vector. This is
2690 typically only used for legacy graphics APIs.
2696 This label applies to fragment shader inputs only and indicates that
2697 the register contains front/back-face information of the form (F, 0,
2698 0, 1). The first component will be positive when the fragment belongs
2699 to a front-facing polygon, and negative when the fragment belongs to a
2700 back-facing polygon.
2703 TGSI_SEMANTIC_EDGEFLAG
2704 """"""""""""""""""""""
2706 For vertex shaders, this sematic label indicates that an input or
2707 output is a boolean edge flag. The register layout is [F, x, x, x]
2708 where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
2709 simply copies the edge flag input to the edgeflag output.
2711 Edge flags are used to control which lines or points are actually
2712 drawn when the polygon mode converts triangles/quads/polygons into
2716 TGSI_SEMANTIC_STENCIL
2717 """""""""""""""""""""
2719 For fragment shaders, this semantic label indicates that an output
2720 is a writable stencil reference value. Only the Y component is writable.
2721 This allows the fragment shader to change the fragments stencilref value.
2724 TGSI_SEMANTIC_VIEWPORT_INDEX
2725 """"""""""""""""""""""""""""
2727 For geometry shaders, this semantic label indicates that an output
2728 contains the index of the viewport (and scissor) to use.
2729 Only the X value is used.
2735 For geometry shaders, this semantic label indicates that an output
2736 contains the layer value to use for the color and depth/stencil surfaces.
2737 Only the X value is used. (Also known as rendertarget array index.)
2740 TGSI_SEMANTIC_CULLDIST
2741 """"""""""""""""""""""
2743 Used as distance to plane for performing application-defined culling
2744 of individual primitives against a plane. When components of vertex
2745 elements are given this label, these values are assumed to be a
2746 float32 signed distance to a plane. Primitives will be completely
2747 discarded if the plane distance for all of the vertices in the
2748 primitive are < 0. If a vertex has a cull distance of NaN, that
2749 vertex counts as "out" (as if its < 0);
2750 The limits on both clip and cull distances are bound
2751 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
2752 the maximum number of components that can be used to hold the
2753 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
2754 which specifies the maximum number of registers which can be
2755 annotated with those semantics.
2758 TGSI_SEMANTIC_CLIPDIST
2759 """"""""""""""""""""""
2761 When components of vertex elements are identified this way, these
2762 values are each assumed to be a float32 signed distance to a plane.
2763 Primitive setup only invokes rasterization on pixels for which
2764 the interpolated plane distances are >= 0. Multiple clip planes
2765 can be implemented simultaneously, by annotating multiple
2766 components of one or more vertex elements with the above specified
2767 semantic. The limits on both clip and cull distances are bound
2768 by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT define which defines
2769 the maximum number of components that can be used to hold the
2770 distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
2771 which specifies the maximum number of registers which can be
2772 annotated with those semantics.
2774 TGSI_SEMANTIC_SAMPLEID
2775 """"""""""""""""""""""
2777 For fragment shaders, this semantic label indicates that a system value
2778 contains the current sample id (i.e. gl_SampleID). Only the X value is used.
2780 TGSI_SEMANTIC_SAMPLEPOS
2781 """""""""""""""""""""""
2783 For fragment shaders, this semantic label indicates that a system value
2784 contains the current sample's position (i.e. gl_SamplePosition). Only the X
2785 and Y values are used.
2787 TGSI_SEMANTIC_SAMPLEMASK
2788 """"""""""""""""""""""""
2790 For fragment shaders, this semantic label indicates that an output contains
2791 the sample mask used to disable further sample processing
2792 (i.e. gl_SampleMask). Only the X value is used, up to 32x MS.
2794 TGSI_SEMANTIC_INVOCATIONID
2795 """"""""""""""""""""""""""
2797 For geometry shaders, this semantic label indicates that a system value
2798 contains the current invocation id (i.e. gl_InvocationID). Only the X value is
2801 Declaration Interpolate
2802 ^^^^^^^^^^^^^^^^^^^^^^^
2804 This token is only valid for fragment shader INPUT declarations.
2806 The Interpolate field specifes the way input is being interpolated by
2807 the rasteriser and is one of TGSI_INTERPOLATE_*.
2809 The Location field specifies the location inside the pixel that the
2810 interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. Note that
2811 when per-sample shading is enabled, the implementation may choose to
2812 interpolate at the sample irrespective of the Location field.
2814 The CylindricalWrap bitfield specifies which register components
2815 should be subject to cylindrical wrapping when interpolating by the
2816 rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
2817 should be interpolated according to cylindrical wrapping rules.
2820 Declaration Sampler View
2821 ^^^^^^^^^^^^^^^^^^^^^^^^
2823 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
2825 DCL SVIEW[#], resource, type(s)
2827 Declares a shader input sampler view and assigns it to a SVIEW[#]
2830 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
2832 type must be 1 or 4 entries (if specifying on a per-component
2833 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
2836 Declaration Resource
2837 ^^^^^^^^^^^^^^^^^^^^
2839 Follows Declaration token if file is TGSI_FILE_RESOURCE.
2841 DCL RES[#], resource [, WR] [, RAW]
2843 Declares a shader input resource and assigns it to a RES[#]
2846 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
2849 If the RAW keyword is not specified, the texture data will be
2850 subject to conversion, swizzling and scaling as required to yield
2851 the specified data type from the physical data format of the bound
2854 If the RAW keyword is specified, no channel conversion will be
2855 performed: the values read for each of the channels (X,Y,Z,W) will
2856 correspond to consecutive words in the same order and format
2857 they're found in memory. No element-to-address conversion will be
2858 performed either: the value of the provided X coordinate will be
2859 interpreted in byte units instead of texel units. The result of
2860 accessing a misaligned address is undefined.
2862 Usage of the STORE opcode is only allowed if the WR (writable) flag
2867 ^^^^^^^^^^^^^^^^^^^^^^^^
2869 Properties are general directives that apply to the whole TGSI program.
2874 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
2875 The default value is UPPER_LEFT.
2877 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
2878 increase downward and rightward.
2879 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
2880 increase upward and rightward.
2882 OpenGL defaults to LOWER_LEFT, and is configurable with the
2883 GL_ARB_fragment_coord_conventions extension.
2885 DirectX 9/10 use UPPER_LEFT.
2887 FS_COORD_PIXEL_CENTER
2888 """""""""""""""""""""
2890 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
2891 The default value is HALF_INTEGER.
2893 If HALF_INTEGER, the fractionary part of the position will be 0.5
2894 If INTEGER, the fractionary part of the position will be 0.0
2896 Note that this does not affect the set of fragments generated by
2897 rasterization, which is instead controlled by half_pixel_center in the
2900 OpenGL defaults to HALF_INTEGER, and is configurable with the
2901 GL_ARB_fragment_coord_conventions extension.
2903 DirectX 9 uses INTEGER.
2904 DirectX 10 uses HALF_INTEGER.
2906 FS_COLOR0_WRITES_ALL_CBUFS
2907 """"""""""""""""""""""""""
2908 Specifies that writes to the fragment shader color 0 are replicated to all
2909 bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
2910 fragData is directed to a single color buffer, but fragColor is broadcast.
2913 """"""""""""""""""""""""""
2914 If this property is set on the program bound to the shader stage before the
2915 fragment shader, user clip planes should have no effect (be disabled) even if
2916 that shader does not write to any clip distance outputs and the rasterizer's
2917 clip_plane_enable is non-zero.
2918 This property is only supported by drivers that also support shader clip
2920 This is useful for APIs that don't have UCPs and where clip distances written
2921 by a shader cannot be disabled.
2926 Specifies the number of times a geometry shader should be executed for each
2927 input primitive. Each invocation will have a different
2928 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
2931 VS_WINDOW_SPACE_POSITION
2932 """"""""""""""""""""""""""
2933 If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
2934 is assumed to contain window space coordinates.
2935 Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
2936 directly taken from the 4-th component of the shader output.
2937 Naturally, clipping is not performed on window coordinates either.
2938 The effect of this property is undefined if a geometry or tessellation shader
2941 Texture Sampling and Texture Formats
2942 ------------------------------------
2944 This table shows how texture image components are returned as (x,y,z,w) tuples
2945 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
2946 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
2949 +--------------------+--------------+--------------------+--------------+
2950 | Texture Components | Gallium | OpenGL | Direct3D 9 |
2951 +====================+==============+====================+==============+
2952 | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
2953 +--------------------+--------------+--------------------+--------------+
2954 | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
2955 +--------------------+--------------+--------------------+--------------+
2956 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
2957 +--------------------+--------------+--------------------+--------------+
2958 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
2959 +--------------------+--------------+--------------------+--------------+
2960 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
2961 +--------------------+--------------+--------------------+--------------+
2962 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
2963 +--------------------+--------------+--------------------+--------------+
2964 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
2965 +--------------------+--------------+--------------------+--------------+
2966 | I | (i, i, i, i) | (i, i, i, i) | N/A |
2967 +--------------------+--------------+--------------------+--------------+
2968 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
2969 | | | [#envmap-bumpmap]_ | |
2970 +--------------------+--------------+--------------------+--------------+
2971 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
2972 | | | [#depth-tex-mode]_ | |
2973 +--------------------+--------------+--------------------+--------------+
2974 | S | (s, s, s, s) | unknown | unknown |
2975 +--------------------+--------------+--------------------+--------------+
2977 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
2978 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
2979 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.