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:`Double Opcodes`.
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 From GL_NV_vertex_program
30 ^^^^^^^^^^^^^^^^^^^^^^^^^
33 .. opcode:: ARL - Address Register Load
37 dst.x = \lfloor src.x\rfloor
39 dst.y = \lfloor src.y\rfloor
41 dst.z = \lfloor src.z\rfloor
43 dst.w = \lfloor src.w\rfloor
46 .. opcode:: MOV - Move
59 .. opcode:: LIT - Light Coefficients
67 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
72 .. opcode:: RCP - Reciprocal
74 This instruction replicates its result.
81 .. opcode:: RSQ - Reciprocal Square Root
83 This instruction replicates its result.
87 dst = \frac{1}{\sqrt{|src.x|}}
90 .. opcode:: EXP - Approximate Exponential Base 2
94 dst.x = 2^{\lfloor src.x\rfloor}
96 dst.y = src.x - \lfloor src.x\rfloor
103 .. opcode:: LOG - Approximate Logarithm Base 2
107 dst.x = \lfloor\log_2{|src.x|}\rfloor
109 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
111 dst.z = \log_2{|src.x|}
116 .. opcode:: MUL - Multiply
120 dst.x = src0.x \times src1.x
122 dst.y = src0.y \times src1.y
124 dst.z = src0.z \times src1.z
126 dst.w = src0.w \times src1.w
129 .. opcode:: ADD - Add
133 dst.x = src0.x + src1.x
135 dst.y = src0.y + src1.y
137 dst.z = src0.z + src1.z
139 dst.w = src0.w + src1.w
142 .. opcode:: DP3 - 3-component Dot Product
144 This instruction replicates its result.
148 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
151 .. opcode:: DP4 - 4-component Dot Product
153 This instruction replicates its result.
157 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
160 .. opcode:: DST - Distance Vector
166 dst.y = src0.y \times src1.y
173 .. opcode:: MIN - Minimum
177 dst.x = min(src0.x, src1.x)
179 dst.y = min(src0.y, src1.y)
181 dst.z = min(src0.z, src1.z)
183 dst.w = min(src0.w, src1.w)
186 .. opcode:: MAX - Maximum
190 dst.x = max(src0.x, src1.x)
192 dst.y = max(src0.y, src1.y)
194 dst.z = max(src0.z, src1.z)
196 dst.w = max(src0.w, src1.w)
199 .. opcode:: SLT - Set On Less Than
203 dst.x = (src0.x < src1.x) ? 1 : 0
205 dst.y = (src0.y < src1.y) ? 1 : 0
207 dst.z = (src0.z < src1.z) ? 1 : 0
209 dst.w = (src0.w < src1.w) ? 1 : 0
212 .. opcode:: SGE - Set On Greater Equal Than
216 dst.x = (src0.x >= src1.x) ? 1 : 0
218 dst.y = (src0.y >= src1.y) ? 1 : 0
220 dst.z = (src0.z >= src1.z) ? 1 : 0
222 dst.w = (src0.w >= src1.w) ? 1 : 0
225 .. opcode:: MAD - Multiply And Add
229 dst.x = src0.x \times src1.x + src2.x
231 dst.y = src0.y \times src1.y + src2.y
233 dst.z = src0.z \times src1.z + src2.z
235 dst.w = src0.w \times src1.w + src2.w
238 .. opcode:: SUB - Subtract
242 dst.x = src0.x - src1.x
244 dst.y = src0.y - src1.y
246 dst.z = src0.z - src1.z
248 dst.w = src0.w - src1.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:: CND - Condition
268 dst.x = (src2.x > 0.5) ? src0.x : src1.x
270 dst.y = (src2.y > 0.5) ? src0.y : src1.y
272 dst.z = (src2.z > 0.5) ? src0.z : src1.z
274 dst.w = (src2.w > 0.5) ? src0.w : src1.w
277 .. opcode:: DP2A - 2-component Dot Product And Add
281 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
283 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
285 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
287 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
290 .. opcode:: FRAC - Fraction
294 dst.x = src.x - \lfloor src.x\rfloor
296 dst.y = src.y - \lfloor src.y\rfloor
298 dst.z = src.z - \lfloor src.z\rfloor
300 dst.w = src.w - \lfloor src.w\rfloor
303 .. opcode:: CLAMP - Clamp
307 dst.x = clamp(src0.x, src1.x, src2.x)
309 dst.y = clamp(src0.y, src1.y, src2.y)
311 dst.z = clamp(src0.z, src1.z, src2.z)
313 dst.w = clamp(src0.w, src1.w, src2.w)
316 .. opcode:: FLR - Floor
318 This is identical to :opcode:`ARL`.
322 dst.x = \lfloor src.x\rfloor
324 dst.y = \lfloor src.y\rfloor
326 dst.z = \lfloor src.z\rfloor
328 dst.w = \lfloor src.w\rfloor
331 .. opcode:: ROUND - Round
344 .. opcode:: EX2 - Exponential Base 2
346 This instruction replicates its result.
353 .. opcode:: LG2 - Logarithm Base 2
355 This instruction replicates its result.
362 .. opcode:: POW - Power
364 This instruction replicates its result.
368 dst = src0.x^{src1.x}
370 .. opcode:: XPD - Cross Product
374 dst.x = src0.y \times src1.z - src1.y \times src0.z
376 dst.y = src0.z \times src1.x - src1.z \times src0.x
378 dst.z = src0.x \times src1.y - src1.x \times src0.y
383 .. opcode:: ABS - Absolute
396 .. opcode:: RCC - Reciprocal Clamped
398 This instruction replicates its result.
400 XXX cleanup on aisle three
404 dst = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
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 - Derivative Relative To X
429 dst.x = partialx(src.x)
431 dst.y = partialx(src.y)
433 dst.z = partialx(src.z)
435 dst.w = partialx(src.w)
438 .. opcode:: DDY - Derivative Relative To Y
442 dst.x = partialy(src.x)
444 dst.y = partialy(src.y)
446 dst.z = partialy(src.z)
448 dst.w = partialy(src.w)
451 .. opcode:: KILP - Predicated Discard
456 .. opcode:: PK2H - Pack Two 16-bit Floats
461 .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
466 .. opcode:: PK4B - Pack Four Signed 8-bit Scalars
471 .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
476 .. opcode:: RFL - Reflection Vector
480 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
482 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
484 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
490 Considered for removal.
493 .. opcode:: SEQ - Set On Equal
497 dst.x = (src0.x == src1.x) ? 1 : 0
499 dst.y = (src0.y == src1.y) ? 1 : 0
501 dst.z = (src0.z == src1.z) ? 1 : 0
503 dst.w = (src0.w == src1.w) ? 1 : 0
506 .. opcode:: SFL - Set On False
508 This instruction replicates its result.
516 Considered for removal.
519 .. opcode:: SGT - Set On Greater Than
523 dst.x = (src0.x > src1.x) ? 1 : 0
525 dst.y = (src0.y > src1.y) ? 1 : 0
527 dst.z = (src0.z > src1.z) ? 1 : 0
529 dst.w = (src0.w > src1.w) ? 1 : 0
532 .. opcode:: SIN - Sine
534 This instruction replicates its result.
541 .. opcode:: SLE - Set On Less Equal Than
545 dst.x = (src0.x <= src1.x) ? 1 : 0
547 dst.y = (src0.y <= src1.y) ? 1 : 0
549 dst.z = (src0.z <= src1.z) ? 1 : 0
551 dst.w = (src0.w <= src1.w) ? 1 : 0
554 .. opcode:: SNE - Set On Not Equal
558 dst.x = (src0.x != src1.x) ? 1 : 0
560 dst.y = (src0.y != src1.y) ? 1 : 0
562 dst.z = (src0.z != src1.z) ? 1 : 0
564 dst.w = (src0.w != src1.w) ? 1 : 0
567 .. opcode:: STR - Set On True
569 This instruction replicates its result.
576 .. opcode:: TEX - Texture Lookup
581 .. opcode:: TXD - Texture Lookup with Derivatives
586 .. opcode:: TXP - Projective Texture Lookup
591 .. opcode:: UP2H - Unpack Two 16-Bit Floats
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.
623 .. opcode:: X2D - 2D Coordinate Transformation
627 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
629 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
631 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
633 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
637 Considered for removal.
640 From GL_NV_vertex_program2
641 ^^^^^^^^^^^^^^^^^^^^^^^^^^
644 .. opcode:: ARA - Address Register Add
650 Considered for removal.
652 .. opcode:: ARR - Address Register Load With Round
665 .. opcode:: BRA - Branch
671 Considered for removal.
673 .. opcode:: CAL - Subroutine Call
679 .. opcode:: RET - Subroutine Call Return
683 Potential restrictions:
684 * Only occurs at end of function.
686 .. opcode:: SSG - Set Sign
690 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
692 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
694 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
696 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
699 .. opcode:: CMP - Compare
703 dst.x = (src0.x < 0) ? src1.x : src2.x
705 dst.y = (src0.y < 0) ? src1.y : src2.y
707 dst.z = (src0.z < 0) ? src1.z : src2.z
709 dst.w = (src0.w < 0) ? src1.w : src2.w
712 .. opcode:: KIL - Conditional Discard
716 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
721 .. opcode:: SCS - Sine Cosine
734 .. opcode:: TXB - Texture Lookup With Bias
739 .. opcode:: NRM - 3-component Vector Normalise
743 dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
745 dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
747 dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
752 .. opcode:: DIV - Divide
756 dst.x = \frac{src0.x}{src1.x}
758 dst.y = \frac{src0.y}{src1.y}
760 dst.z = \frac{src0.z}{src1.z}
762 dst.w = \frac{src0.w}{src1.w}
765 .. opcode:: DP2 - 2-component Dot Product
767 This instruction replicates its result.
771 dst = src0.x \times src1.x + src0.y \times src1.y
774 .. opcode:: TXL - Texture Lookup With LOD
779 .. opcode:: BRK - Break
789 .. opcode:: BGNFOR - Begin a For-Loop
796 pc = [matching ENDFOR] + 1
799 Note: The destination must be a loop register.
800 The source must be a constant register.
804 Considered for cleanup.
808 Considered for removal.
811 .. opcode:: REP - Repeat
816 .. opcode:: ELSE - Else
821 .. opcode:: ENDIF - End If
826 .. opcode:: ENDFOR - End a For-Loop
828 dst.x = dst.x + dst.z
832 pc = [matching BGNFOR instruction] + 1
835 Note: The destination must be a loop register.
839 Considered for cleanup.
843 Considered for removal.
845 .. opcode:: ENDREP - End Repeat
850 .. opcode:: PUSHA - Push Address Register On Stack
859 Considered for cleanup.
863 Considered for removal.
865 .. opcode:: POPA - Pop Address Register From Stack
874 Considered for cleanup.
878 Considered for removal.
881 From GL_NV_gpu_program4
882 ^^^^^^^^^^^^^^^^^^^^^^^^
884 Support for these opcodes indicated by a special pipe capability bit (TBD).
886 .. opcode:: CEIL - Ceiling
890 dst.x = \lceil src.x\rceil
892 dst.y = \lceil src.y\rceil
894 dst.z = \lceil src.z\rceil
896 dst.w = \lceil src.w\rceil
899 .. opcode:: I2F - Integer To Float
903 dst.x = (float) src.x
905 dst.y = (float) src.y
907 dst.z = (float) src.z
909 dst.w = (float) src.w
912 .. opcode:: NOT - Bitwise Not
925 .. opcode:: TRUNC - Truncate
938 .. opcode:: SHL - Shift Left
942 dst.x = src0.x << src1.x
944 dst.y = src0.y << src1.x
946 dst.z = src0.z << src1.x
948 dst.w = src0.w << src1.x
951 .. opcode:: SHR - Shift Right
955 dst.x = src0.x >> src1.x
957 dst.y = src0.y >> src1.x
959 dst.z = src0.z >> src1.x
961 dst.w = src0.w >> src1.x
964 .. opcode:: AND - Bitwise And
968 dst.x = src0.x & src1.x
970 dst.y = src0.y & src1.y
972 dst.z = src0.z & src1.z
974 dst.w = src0.w & src1.w
977 .. opcode:: OR - Bitwise Or
981 dst.x = src0.x | src1.x
983 dst.y = src0.y | src1.y
985 dst.z = src0.z | src1.z
987 dst.w = src0.w | src1.w
990 .. opcode:: MOD - Modulus
994 dst.x = src0.x \bmod src1.x
996 dst.y = src0.y \bmod src1.y
998 dst.z = src0.z \bmod src1.z
1000 dst.w = src0.w \bmod src1.w
1003 .. opcode:: XOR - Bitwise Xor
1007 dst.x = src0.x \oplus src1.x
1009 dst.y = src0.y \oplus src1.y
1011 dst.z = src0.z \oplus src1.z
1013 dst.w = src0.w \oplus src1.w
1016 .. opcode:: SAD - Sum Of Absolute Differences
1020 dst.x = |src0.x - src1.x| + src2.x
1022 dst.y = |src0.y - src1.y| + src2.y
1024 dst.z = |src0.z - src1.z| + src2.z
1026 dst.w = |src0.w - src1.w| + src2.w
1029 .. opcode:: TXF - Texel Fetch
1034 .. opcode:: TXQ - Texture Size Query
1039 .. opcode:: CONT - Continue
1044 From GL_NV_geometry_program4
1045 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1048 .. opcode:: EMIT - Emit
1053 .. opcode:: ENDPRIM - End Primitive
1062 .. opcode:: BGNLOOP - Begin a Loop
1067 .. opcode:: BGNSUB - Begin Subroutine
1072 .. opcode:: ENDLOOP - End a Loop
1077 .. opcode:: ENDSUB - End Subroutine
1082 .. opcode:: NOP - No Operation
1087 .. opcode:: NRM4 - 4-component Vector Normalise
1089 This instruction replicates its result.
1093 dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
1100 .. opcode:: CALLNZ - Subroutine Call If Not Zero
1105 .. opcode:: IFC - If
1110 .. opcode:: BREAKC - Break Conditional
1119 .. opcode:: DADD - Add Double
1123 dst.xy = src0.xy + src1.xy
1125 dst.zw = src0.zw + src1.zw
1128 .. opcode:: DDIV - Divide Double
1132 dst.xy = src0.xy / src1.xy
1134 dst.zw = src0.zw / src1.zw
1136 .. opcode:: DSEQ - Set Double on Equal
1140 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1142 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1144 .. opcode:: DSLT - Set Double on Less than
1148 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1150 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1152 .. opcode:: DFRAC - Double Fraction
1156 dst.xy = src.xy - \lfloor src.xy\rfloor
1158 dst.zw = src.zw - \lfloor src.zw\rfloor
1161 .. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
1165 dst0.xy = frexp(src.xy, dst1.xy)
1167 dst0.zw = frexp(src.zw, dst1.zw)
1169 .. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
1173 dst.xy = ldexp(src0.xy, src1.xy)
1175 dst.zw = ldexp(src0.zw, src1.zw)
1177 .. opcode:: DMIN - Minimum Double
1181 dst.xy = min(src0.xy, src1.xy)
1183 dst.zw = min(src0.zw, src1.zw)
1185 .. opcode:: DMAX - Maximum Double
1189 dst.xy = max(src0.xy, src1.xy)
1191 dst.zw = max(src0.zw, src1.zw)
1193 .. opcode:: DMUL - Multiply Double
1197 dst.xy = src0.xy \times src1.xy
1199 dst.zw = src0.zw \times src1.zw
1202 .. opcode:: DMAD - Multiply And Add Doubles
1206 dst.xy = src0.xy \times src1.xy + src2.xy
1208 dst.zw = src0.zw \times src1.zw + src2.zw
1211 .. opcode:: DRCP - Reciprocal Double
1215 dst.xy = \frac{1}{src.xy}
1217 dst.zw = \frac{1}{src.zw}
1219 .. opcode:: DSQRT - Square root double
1223 dst.xy = \sqrt{src.xy}
1225 dst.zw = \sqrt{src.zw}
1228 Explanation of symbols used
1229 ------------------------------
1236 :math:`|x|` Absolute value of `x`.
1238 :math:`\lceil x \rceil` Ceiling of `x`.
1240 clamp(x,y,z) Clamp x between y and z.
1241 (x < y) ? y : (x > z) ? z : x
1243 :math:`\lfloor x\rfloor` Floor of `x`.
1245 :math:`\log_2{x}` Logarithm of `x`, base 2.
1247 max(x,y) Maximum of x and y.
1250 min(x,y) Minimum of x and y.
1253 partialx(x) Derivative of x relative to fragment's X.
1255 partialy(x) Derivative of x relative to fragment's Y.
1257 pop() Pop from stack.
1259 :math:`x^y` `x` to the power `y`.
1261 push(x) Push x on stack.
1265 trunc(x) Truncate x, i.e. drop the fraction bits.
1272 discard Discard fragment.
1276 target Label of target instruction.
1287 Declares a register that is will be referenced as an operand in Instruction
1290 File field contains register file that is being declared and is one
1293 UsageMask field specifies which of the register components can be accessed
1294 and is one of TGSI_WRITEMASK.
1296 Interpolate field is only valid for fragment shader INPUT register files.
1297 It specifes the way input is being interpolated by the rasteriser and is one
1298 of TGSI_INTERPOLATE.
1300 If Dimension flag is set to 1, a Declaration Dimension token follows.
1302 If Semantic flag is set to 1, a Declaration Semantic token follows.
1304 CylindricalWrap bitfield is only valid for fragment shader INPUT register
1305 files. It specifies which register components should be subject to cylindrical
1306 wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1307 is set to 1, the X component should be interpolated according to cylindrical
1311 Declaration Semantic
1312 ^^^^^^^^^^^^^^^^^^^^^^^^
1315 Follows Declaration token if Semantic bit is set.
1317 Since its purpose is to link a shader with other stages of the pipeline,
1318 it is valid to follow only those Declaration tokens that declare a register
1319 either in INPUT or OUTPUT file.
1321 SemanticName field contains the semantic name of the register being declared.
1322 There is no default value.
1324 SemanticIndex is an optional subscript that can be used to distinguish
1325 different register declarations with the same semantic name. The default value
1328 The meanings of the individual semantic names are explained in the following
1331 TGSI_SEMANTIC_POSITION
1332 """"""""""""""""""""""
1334 Position, sometimes known as HPOS or WPOS for historical reasons, is the
1335 location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1336 are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1337 for the perspective divide, if enabled.
1339 As a vertex shader output, position should be scaled to the viewport. When
1340 used in fragment shaders, position will be in window coordinates. The convention
1341 used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
1343 XXX additionally, is there a way to configure the perspective divide? it's
1344 accelerated on most chipsets AFAIK...
1346 Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1347 be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1349 XXX usually? can we solidify that?
1354 Colors are used to, well, color the primitives. Colors are always in
1355 ``(r, g, b, a)`` format.
1357 If alpha is not specified, it defaults to 1.
1359 TGSI_SEMANTIC_BCOLOR
1360 """"""""""""""""""""
1362 Back-facing colors are only used for back-facing polygons, and are only valid
1363 in vertex shader outputs. After rasterization, all polygons are front-facing
1364 and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1365 all BCOLORs effectively become regular COLORs in the fragment shader.
1370 The fog coordinate historically has been used to replace the depth coordinate
1371 for generation of fog in dedicated fog blocks. Gallium, however, does not use
1372 dedicated fog acceleration, placing it entirely in the fragment shader
1375 The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1376 component matters when writing from the vertex shader; the driver will ensure
1377 that the coordinate is in this format when used as a fragment shader input.
1382 PSIZE, or point size, is used to specify point sizes per-vertex. It should
1383 be in ``(s, 0, 0, 1)`` format, where ``s`` is the (possibly clamped) point size.
1384 Only the first component matters when writing from the vertex shader.
1386 When using this semantic, be sure to set the appropriate state in the
1387 :ref:`rasterizer` first.
1389 TGSI_SEMANTIC_GENERIC
1390 """""""""""""""""""""
1392 Generic semantics are nearly always used for texture coordinate attributes,
1393 in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1394 of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1396 These attributes are called "generic" because they may be used for anything
1397 else, including parameters, texture generation information, or anything that
1398 can be stored inside a four-component vector.
1403 FACE is the facing bit, to store the facing information for the fragment
1404 shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1405 when the fragment is front-facing, and negative when the component is
1408 TGSI_SEMANTIC_EDGEFLAG
1409 """"""""""""""""""""""
1415 ^^^^^^^^^^^^^^^^^^^^^^^^
1418 Properties are general directives that apply to the whole TGSI program.
1423 Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1424 The default value is UPPER_LEFT.
1426 If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1427 increase downward and rightward.
1428 If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1429 increase upward and rightward.
1431 OpenGL defaults to LOWER_LEFT, and is configurable with the
1432 GL_ARB_fragment_coord_conventions extension.
1434 DirectX 9/10 use UPPER_LEFT.
1436 FS_COORD_PIXEL_CENTER
1437 """""""""""""""""""""
1439 Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1440 The default value is HALF_INTEGER.
1442 If HALF_INTEGER, the fractionary part of the position will be 0.5
1443 If INTEGER, the fractionary part of the position will be 0.0
1445 Note that this does not affect the set of fragments generated by
1446 rasterization, which is instead controlled by gl_rasterization_rules in the
1449 OpenGL defaults to HALF_INTEGER, and is configurable with the
1450 GL_ARB_fragment_coord_conventions extension.
1452 DirectX 9 uses INTEGER.
1453 DirectX 10 uses HALF_INTEGER.
1457 Texture Sampling and Texture Formats
1458 ------------------------------------
1460 This table shows how texture image components are returned as (x,y,z,w) tuples
1461 by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1462 :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1465 +--------------------+--------------+--------------------+--------------+
1466 | Texture Components | Gallium | OpenGL | Direct3D 9 |
1467 +====================+==============+====================+==============+
1468 | R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1469 +--------------------+--------------+--------------------+--------------+
1470 | RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1471 +--------------------+--------------+--------------------+--------------+
1472 | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1473 +--------------------+--------------+--------------------+--------------+
1474 | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1475 +--------------------+--------------+--------------------+--------------+
1476 | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1477 +--------------------+--------------+--------------------+--------------+
1478 | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1479 +--------------------+--------------+--------------------+--------------+
1480 | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1481 +--------------------+--------------+--------------------+--------------+
1482 | I | (i, i, i, i) | (i, i, i, i) | N/A |
1483 +--------------------+--------------+--------------------+--------------+
1484 | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1485 | | | [#envmap-bumpmap]_ | |
1486 +--------------------+--------------+--------------------+--------------+
1487 | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
1488 | | | [#depth-tex-mode]_ | |
1489 +--------------------+--------------+--------------------+--------------+
1491 .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
1492 .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
1493 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.