Merge branch 'gallium-nopointsizeminmax'
[mesa.git] / src / gallium / docs / source / tgsi.rst
index 1df0e98a411f83352fb16d9ecbc93db9d32e431b..c292cd37d5c21f8c940f1d7bf22caa56fcf37075 100644 (file)
@@ -1,29 +1,49 @@
 TGSI
 ====
 
-TGSI, Tungsten Graphics Shader Instructions, is an intermediate language
+TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language
 for describing shaders. Since Gallium is inherently shaderful, shaders are
 an important part of the API. TGSI is the only intermediate representation
 used by all drivers.
 
+Basics
+------
+
+All TGSI instructions, known as *opcodes*, operate on arbitrary-precision
+floating-point four-component vectors. An opcode may have up to one
+destination register, known as *dst*, and between zero and three source
+registers, called *src0* through *src2*, or simply *src* if there is only
+one.
+
+Some instructions, like :opcode:`I2F`, permit re-interpretation of vector
+components as integers. Other instructions permit using registers as
+two-component vectors with double precision; see :ref:`Double Opcodes`.
+
+When an instruction has a scalar result, the result is usually copied into
+each of the components of *dst*. When this happens, the result is said to be
+*replicated* to *dst*. :opcode:`RCP` is one such instruction.
+
+Instruction Set
+---------------
+
 From GL_NV_vertex_program
--------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
-ARL - Address Register Load
+.. opcode:: ARL - Address Register Load
 
 .. math::
 
-  dst.x = floor(src.x)
+  dst.x = \lfloor src.x\rfloor
 
-  dst.y = floor(src.y)
+  dst.y = \lfloor src.y\rfloor
 
-  dst.z = floor(src.z)
+  dst.z = \lfloor src.z\rfloor
 
-  dst.w = floor(src.w)
+  dst.w = \lfloor src.w\rfloor
 
 
-MOV - Move
+.. opcode:: MOV - Move
 
 .. math::
 
@@ -36,85 +56,77 @@ MOV - Move
   dst.w = src.w
 
 
-LIT - Light Coefficients
+.. opcode:: LIT - Light Coefficients
 
 .. math::
 
-  dst.x = 1.0
-
-  dst.y = max(src.x, 0.0)
+  dst.x = 1
 
-  dst.z = (src.x > 0.0) ? pow(max(src.y, 0.0), clamp(src.w, -128.0, 128.0)) : 0.0
+  dst.y = max(src.x, 0)
 
-  dst.w = 1.0
+  dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
 
+  dst.w = 1
 
-RCP - Reciprocal
 
-.. math::
+.. opcode:: RCP - Reciprocal
 
-  dst.x = 1.0 / src.x
+This instruction replicates its result.
 
-  dst.y = 1.0 / src.x
+.. math::
 
-  dst.z = 1.0 / src.x
+  dst = \frac{1}{src.x}
 
-  dst.w = 1.0 / src.x
 
+.. opcode:: RSQ - Reciprocal Square Root
 
-RSQ - Reciprocal Square Root
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = 1.0 / sqrt(abs(src.x))
-
-  dst.y = 1.0 / sqrt(abs(src.x))
-
-  dst.z = 1.0 / sqrt(abs(src.x))
-
-  dst.w = 1.0 / sqrt(abs(src.x))
+  dst = \frac{1}{\sqrt{|src.x|}}
 
 
-EXP - Approximate Exponential Base 2
+.. opcode:: EXP - Approximate Exponential Base 2
 
 .. math::
 
-  dst.x = pow(2.0, floor(src.x))
+  dst.x = 2^{\lfloor src.x\rfloor}
 
-  dst.y = src.x - floor(src.x)
+  dst.y = src.x - \lfloor src.x\rfloor
 
-  dst.z = pow(2.0, src.x)
+  dst.z = 2^{src.x}
 
-  dst.w = 1.0
+  dst.w = 1
 
 
-LOG - Approximate Logarithm Base 2
+.. opcode:: LOG - Approximate Logarithm Base 2
 
 .. math::
 
-  dst.x = floor(lg2(abs(src.x)))
+  dst.x = \lfloor\log_2{|src.x|}\rfloor
 
-  dst.y = abs(src.x) / pow(2.0, floor(lg2(abs(src.x))))
+  dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
 
-  dst.z = lg2(abs(src.x))
+  dst.z = \log_2{|src.x|}
 
-  dst.w = 1.0
+  dst.w = 1
 
 
-MUL - Multiply
+.. opcode:: MUL - Multiply
 
 .. math::
 
-  dst.x = src0.x * src1.x
+  dst.x = src0.x \times src1.x
 
-  dst.y = src0.y * src1.y
+  dst.y = src0.y \times src1.y
 
-  dst.z = src0.z * src1.z
+  dst.z = src0.z \times src1.z
 
-  dst.w = src0.w * src1.w
+  dst.w = src0.w \times src1.w
 
 
-ADD - Add
+.. opcode:: ADD - Add
 
 .. math::
 
@@ -127,46 +139,38 @@ ADD - Add
   dst.w = src0.w + src1.w
 
 
-DP3 - 3-component Dot Product
+.. opcode:: DP3 - 3-component Dot Product
 
-.. math::
-
-  dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+This instruction replicates its result.
 
-  dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+.. math::
 
-  dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
+  dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
 
-  dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z
 
+.. opcode:: DP4 - 4-component Dot Product
 
-DP4 - 4-component Dot Product
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
-
-  dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
+  dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
 
-  dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
 
-  dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src0.w * src1.w
-
-
-DST - Distance Vector
+.. opcode:: DST - Distance Vector
 
 .. math::
 
-  dst.x = 1.0
+  dst.x = 1
 
-  dst.y = src0.y * src1.y
+  dst.y = src0.y \times src1.y
 
   dst.z = src0.z
 
   dst.w = src1.w
 
 
-MIN - Minimum
+.. opcode:: MIN - Minimum
 
 .. math::
 
@@ -179,7 +183,7 @@ MIN - Minimum
   dst.w = min(src0.w, src1.w)
 
 
-MAX - Maximum
+.. opcode:: MAX - Maximum
 
 .. math::
 
@@ -192,46 +196,46 @@ MAX - Maximum
   dst.w = max(src0.w, src1.w)
 
 
-SLT - Set On Less Than
+.. opcode:: SLT - Set On Less Than
 
 .. math::
 
-  dst.x = (src0.x < src1.x) ? 1.0 : 0.0
+  dst.x = (src0.x < src1.x) ? 1 : 0
 
-  dst.y = (src0.y < src1.y) ? 1.0 : 0.0
+  dst.y = (src0.y < src1.y) ? 1 : 0
 
-  dst.z = (src0.z < src1.z) ? 1.0 : 0.0
+  dst.z = (src0.z < src1.z) ? 1 : 0
 
-  dst.w = (src0.w < src1.w) ? 1.0 : 0.0
+  dst.w = (src0.w < src1.w) ? 1 : 0
 
 
-SGE - Set On Greater Equal Than
+.. opcode:: SGE - Set On Greater Equal Than
 
 .. math::
 
-  dst.x = (src0.x >= src1.x) ? 1.0 : 0.0
+  dst.x = (src0.x >= src1.x) ? 1 : 0
 
-  dst.y = (src0.y >= src1.y) ? 1.0 : 0.0
+  dst.y = (src0.y >= src1.y) ? 1 : 0
 
-  dst.z = (src0.z >= src1.z) ? 1.0 : 0.0
+  dst.z = (src0.z >= src1.z) ? 1 : 0
 
-  dst.w = (src0.w >= src1.w) ? 1.0 : 0.0
+  dst.w = (src0.w >= src1.w) ? 1 : 0
 
 
-MAD - Multiply And Add
+.. opcode:: MAD - Multiply And Add
 
 .. math::
 
-  dst.x = src0.x * src1.x + src2.x
+  dst.x = src0.x \times src1.x + src2.x
 
-  dst.y = src0.y * src1.y + src2.y
+  dst.y = src0.y \times src1.y + src2.y
 
-  dst.z = src0.z * src1.z + src2.z
+  dst.z = src0.z \times src1.z + src2.z
 
-  dst.w = src0.w * src1.w + src2.w
+  dst.w = src0.w \times src1.w + src2.w
 
 
-SUB - Subtract
+.. opcode:: SUB - Subtract
 
 .. math::
 
@@ -244,20 +248,20 @@ SUB - Subtract
   dst.w = src0.w - src1.w
 
 
-LRP - Linear Interpolate
+.. opcode:: LRP - Linear Interpolate
 
 .. math::
 
-  dst.x = src0.x * (src1.x - src2.x) + src2.x
+  dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
 
-  dst.y = src0.y * (src1.y - src2.y) + src2.y
+  dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
 
-  dst.z = src0.z * (src1.z - src2.z) + src2.z
+  dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
 
-  dst.w = src0.w * (src1.w - src2.w) + src2.w
+  dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
 
 
-CND - Condition
+.. opcode:: CND - Condition
 
 .. math::
 
@@ -270,451 +274,519 @@ CND - Condition
   dst.w = (src2.w > 0.5) ? src0.w : src1.w
 
 
-DP2A - 2-component Dot Product And Add
+.. opcode:: DP2A - 2-component Dot Product And Add
 
 .. math::
 
-  dst.x = src0.x * src1.x + src0.y * src1.y + src2.x
+  dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
 
-  dst.y = src0.x * src1.x + src0.y * src1.y + src2.x
+  dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
 
-  dst.z = src0.x * src1.x + src0.y * src1.y + src2.x
+  dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
 
-  dst.w = src0.x * src1.x + src0.y * src1.y + src2.x
+  dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
 
 
-FRAC - Fraction
+.. opcode:: FRAC - Fraction
 
 .. math::
 
-  dst.x = src.x - floor(src.x)
+  dst.x = src.x - \lfloor src.x\rfloor
 
-  dst.y = src.y - floor(src.y)
+  dst.y = src.y - \lfloor src.y\rfloor
 
-  dst.z = src.z - floor(src.z)
+  dst.z = src.z - \lfloor src.z\rfloor
 
-  dst.w = src.w - floor(src.w)
+  dst.w = src.w - \lfloor src.w\rfloor
 
 
-CLAMP - Clamp
+.. opcode:: CLAMP - Clamp
 
 .. math::
 
   dst.x = clamp(src0.x, src1.x, src2.x)
+
   dst.y = clamp(src0.y, src1.y, src2.y)
+
   dst.z = clamp(src0.z, src1.z, src2.z)
+
   dst.w = clamp(src0.w, src1.w, src2.w)
 
 
-1.3.8  FLR - Floor
+.. opcode:: FLR - Floor
+
+This is identical to :opcode:`ARL`.
 
 .. math::
 
-  dst.x = floor(src.x)
-  dst.y = floor(src.y)
-  dst.z = floor(src.z)
-  dst.w = floor(src.w)
+  dst.x = \lfloor src.x\rfloor
 
+  dst.y = \lfloor src.y\rfloor
 
-1.3.9  ROUND - Round
+  dst.z = \lfloor src.z\rfloor
+
+  dst.w = \lfloor src.w\rfloor
+
+
+.. opcode:: ROUND - Round
 
 .. math::
 
   dst.x = round(src.x)
+
   dst.y = round(src.y)
+
   dst.z = round(src.z)
+
   dst.w = round(src.w)
 
 
-1.3.10  EX2 - Exponential Base 2
+.. opcode:: EX2 - Exponential Base 2
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = pow(2.0, src.x)
-  dst.y = pow(2.0, src.x)
-  dst.z = pow(2.0, src.x)
-  dst.w = pow(2.0, src.x)
+  dst = 2^{src.x}
+
 
+.. opcode:: LG2 - Logarithm Base 2
 
-1.3.11  LG2 - Logarithm Base 2
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = lg2(src.x)
-  dst.y = lg2(src.x)
-  dst.z = lg2(src.x)
-  dst.w = lg2(src.x)
+  dst = \log_2{src.x}
 
 
-1.3.12  POW - Power
+.. opcode:: POW - Power
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = pow(src0.x, src1.x)
-  dst.y = pow(src0.x, src1.x)
-  dst.z = pow(src0.x, src1.x)
-  dst.w = pow(src0.x, src1.x)
+  dst = src0.x^{src1.x}
 
-1.3.15  XPD - Cross Product
+.. opcode:: XPD - Cross Product
 
 .. math::
 
-  dst.x = src0.y * src1.z - src1.y * src0.z
-  dst.y = src0.z * src1.x - src1.z * src0.x
-  dst.z = src0.x * src1.y - src1.x * src0.y
-  dst.w = 1.0
+  dst.x = src0.y \times src1.z - src1.y \times src0.z
+
+  dst.y = src0.z \times src1.x - src1.z \times src0.x
+
+  dst.z = src0.x \times src1.y - src1.x \times src0.y
 
+  dst.w = 1
 
-1.4.1  ABS - Absolute
+
+.. opcode:: ABS - Absolute
 
 .. math::
 
-  dst.x = abs(src.x)
-  dst.y = abs(src.y)
-  dst.z = abs(src.z)
-  dst.w = abs(src.w)
+  dst.x = |src.x|
+
+  dst.y = |src.y|
+
+  dst.z = |src.z|
+
+  dst.w = |src.w|
+
+
+.. opcode:: RCC - Reciprocal Clamped
 
+This instruction replicates its result.
 
-1.4.2  RCC - Reciprocal Clamped
+XXX cleanup on aisle three
 
 .. math::
 
-  dst.x = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
-  dst.y = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
-  dst.z = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
-  dst.w = (1.0 / src.x) > 0.0 ? clamp(1.0 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1.0 / src.x, -1.884467e+019, -5.42101e-020)
+  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)
 
 
-1.4.3  DPH - Homogeneous Dot Product
+.. opcode:: DPH - Homogeneous Dot Product
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
-  dst.y = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
-  dst.z = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
-  dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w
+  dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
+
 
+.. opcode:: COS - Cosine
 
-1.5.1  COS - Cosine
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = cos(src.x)
-  dst.y = cos(src.x)
-  dst.z = cos(src.x)
-  dst.w = cos(src.w)
+  dst = \cos{src.x}
 
 
-1.5.2  DDX - Derivative Relative To X
+.. opcode:: DDX - Derivative Relative To X
 
 .. math::
 
   dst.x = partialx(src.x)
+
   dst.y = partialx(src.y)
+
   dst.z = partialx(src.z)
+
   dst.w = partialx(src.w)
 
 
-1.5.3  DDY - Derivative Relative To Y
+.. opcode:: DDY - Derivative Relative To Y
 
 .. math::
 
   dst.x = partialy(src.x)
+
   dst.y = partialy(src.y)
+
   dst.z = partialy(src.z)
-  dst.w = partialy(src.w)
 
+  dst.w = partialy(src.w)
 
-1.5.7  KILP - Predicated Discard
 
-.. math::
+.. opcode:: KILP - Predicated Discard
 
   discard
 
 
-1.5.10  PK2H - Pack Two 16-bit Floats
+.. opcode:: PK2H - Pack Two 16-bit Floats
 
   TBD
 
 
-1.5.11  PK2US - Pack Two Unsigned 16-bit Scalars
+.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
 
   TBD
 
 
-1.5.12  PK4B - Pack Four Signed 8-bit Scalars
+.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
 
   TBD
 
 
-1.5.13  PK4UB - Pack Four Unsigned 8-bit Scalars
+.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
 
   TBD
 
 
-1.5.15  RFL - Reflection Vector
+.. opcode:: RFL - Reflection Vector
 
 .. math::
 
-  dst.x = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.x - src1.x
-  dst.y = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.y - src1.y
-  dst.z = 2.0 * (src0.x * src1.x + src0.y * src1.y + src0.z * src1.z) / (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z) * src0.z - src1.z
-  dst.w = 1.0
+  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
+
+  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
+
+  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
+
+  dst.w = 1
 
-Considered for removal.
+.. note::
 
+   Considered for removal.
 
-1.5.16  SEQ - Set On Equal
+
+.. opcode:: SEQ - Set On Equal
 
 .. math::
 
-  dst.x = (src0.x == src1.x) ? 1.0 : 0.0
-  dst.y = (src0.y == src1.y) ? 1.0 : 0.0
-  dst.z = (src0.z == src1.z) ? 1.0 : 0.0
-  dst.w = (src0.w == src1.w) ? 1.0 : 0.0
+  dst.x = (src0.x == src1.x) ? 1 : 0
+
+  dst.y = (src0.y == src1.y) ? 1 : 0
+
+  dst.z = (src0.z == src1.z) ? 1 : 0
+
+  dst.w = (src0.w == src1.w) ? 1 : 0
 
 
-1.5.17  SFL - Set On False
+.. opcode:: SFL - Set On False
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = 0.0
-  dst.y = 0.0
-  dst.z = 0.0
-  dst.w = 0.0
+  dst = 0
+
+.. note::
 
-Considered for removal.
+   Considered for removal.
 
-1.5.18  SGT - Set On Greater Than
+
+.. opcode:: SGT - Set On Greater Than
 
 .. math::
 
-  dst.x = (src0.x > src1.x) ? 1.0 : 0.0
-  dst.y = (src0.y > src1.y) ? 1.0 : 0.0
-  dst.z = (src0.z > src1.z) ? 1.0 : 0.0
-  dst.w = (src0.w > src1.w) ? 1.0 : 0.0
+  dst.x = (src0.x > src1.x) ? 1 : 0
+
+  dst.y = (src0.y > src1.y) ? 1 : 0
 
+  dst.z = (src0.z > src1.z) ? 1 : 0
 
-1.5.19  SIN - Sine
+  dst.w = (src0.w > src1.w) ? 1 : 0
+
+
+.. opcode:: SIN - Sine
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = sin(src.x)
-  dst.y = sin(src.x)
-  dst.z = sin(src.x)
-  dst.w = sin(src.w)
+  dst = \sin{src.x}
 
 
-1.5.20  SLE - Set On Less Equal Than
+.. opcode:: SLE - Set On Less Equal Than
 
 .. math::
 
-  dst.x = (src0.x <= src1.x) ? 1.0 : 0.0
-  dst.y = (src0.y <= src1.y) ? 1.0 : 0.0
-  dst.z = (src0.z <= src1.z) ? 1.0 : 0.0
-  dst.w = (src0.w <= src1.w) ? 1.0 : 0.0
+  dst.x = (src0.x <= src1.x) ? 1 : 0
+
+  dst.y = (src0.y <= src1.y) ? 1 : 0
 
+  dst.z = (src0.z <= src1.z) ? 1 : 0
 
-1.5.21  SNE - Set On Not Equal
+  dst.w = (src0.w <= src1.w) ? 1 : 0
+
+
+.. opcode:: SNE - Set On Not Equal
 
 .. math::
 
-  dst.x = (src0.x != src1.x) ? 1.0 : 0.0
-  dst.y = (src0.y != src1.y) ? 1.0 : 0.0
-  dst.z = (src0.z != src1.z) ? 1.0 : 0.0
-  dst.w = (src0.w != src1.w) ? 1.0 : 0.0
+  dst.x = (src0.x != src1.x) ? 1 : 0
+
+  dst.y = (src0.y != src1.y) ? 1 : 0
+
+  dst.z = (src0.z != src1.z) ? 1 : 0
+
+  dst.w = (src0.w != src1.w) ? 1 : 0
 
 
-1.5.22  STR - Set On True
+.. opcode:: STR - Set On True
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = 1.0
-  dst.y = 1.0
-  dst.z = 1.0
-  dst.w = 1.0
+  dst = 1
 
 
-1.5.23  TEX - Texture Lookup
+.. opcode:: TEX - Texture Lookup
 
   TBD
 
 
-1.5.24  TXD - Texture Lookup with Derivatives
+.. opcode:: TXD - Texture Lookup with Derivatives
 
   TBD
 
 
-1.5.25  TXP - Projective Texture Lookup
+.. opcode:: TXP - Projective Texture Lookup
 
   TBD
 
 
-1.5.26  UP2H - Unpack Two 16-Bit Floats
+.. opcode:: UP2H - Unpack Two 16-Bit Floats
 
   TBD
 
-  Considered for removal.
+.. note::
+
+   Considered for removal.
 
-1.5.27  UP2US - Unpack Two Unsigned 16-Bit Scalars
+.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
 
   TBD
 
-  Considered for removal.
+.. note::
 
-1.5.28  UP4B - Unpack Four Signed 8-Bit Values
+   Considered for removal.
+
+.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
 
   TBD
 
-  Considered for removal.
+.. note::
+
+   Considered for removal.
 
-1.5.29  UP4UB - Unpack Four Unsigned 8-Bit Scalars
+.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
 
   TBD
 
-  Considered for removal.
+.. note::
 
-1.5.30  X2D - 2D Coordinate Transformation
+   Considered for removal.
+
+.. opcode:: X2D - 2D Coordinate Transformation
 
 .. math::
 
-  dst.x = src0.x + src1.x * src2.x + src1.y * src2.y
-  dst.y = src0.y + src1.x * src2.z + src1.y * src2.w
-  dst.z = src0.x + src1.x * src2.x + src1.y * src2.y
-  dst.w = src0.y + src1.x * src2.z + src1.y * src2.w
+  dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
+
+  dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
+
+  dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
+
+  dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
 
-Considered for removal.
+.. note::
 
+   Considered for removal.
 
-1.6  GL_NV_vertex_program2
---------------------------
 
+From GL_NV_vertex_program2
+^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-1.6.1  ARA - Address Register Add
+
+.. opcode:: ARA - Address Register Add
 
   TBD
 
-  Considered for removal.
+.. note::
+
+   Considered for removal.
 
-1.6.2  ARR - Address Register Load With Round
+.. opcode:: ARR - Address Register Load With Round
 
 .. math::
 
   dst.x = round(src.x)
+
   dst.y = round(src.y)
+
   dst.z = round(src.z)
+
   dst.w = round(src.w)
 
 
-1.6.3  BRA - Branch
+.. opcode:: BRA - Branch
 
   pc = target
 
-  Considered for removal.
+.. note::
+
+   Considered for removal.
 
-1.6.4  CAL - Subroutine Call
+.. opcode:: CAL - Subroutine Call
 
   push(pc)
   pc = target
 
 
-1.6.5  RET - Subroutine Call Return
+.. opcode:: RET - Subroutine Call Return
 
   pc = pop()
 
   Potential restrictions:  
   * Only occurs at end of function.
 
-1.6.6  SSG - Set Sign
+.. opcode:: SSG - Set Sign
 
 .. math::
 
-  dst.x = (src.x > 0.0) ? 1.0 : (src.x < 0.0) ? -1.0 : 0.0
-  dst.y = (src.y > 0.0) ? 1.0 : (src.y < 0.0) ? -1.0 : 0.0
-  dst.z = (src.z > 0.0) ? 1.0 : (src.z < 0.0) ? -1.0 : 0.0
-  dst.w = (src.w > 0.0) ? 1.0 : (src.w < 0.0) ? -1.0 : 0.0
+  dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
+
+  dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
+
+  dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
+
+  dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
 
 
-1.8.1  CMP - Compare
+.. opcode:: CMP - Compare
 
 .. math::
 
-  dst.x = (src0.x < 0.0) ? src1.x : src2.x
-  dst.y = (src0.y < 0.0) ? src1.y : src2.y
-  dst.z = (src0.z < 0.0) ? src1.z : src2.z
-  dst.w = (src0.w < 0.0) ? src1.w : src2.w
+  dst.x = (src0.x < 0) ? src1.x : src2.x
 
+  dst.y = (src0.y < 0) ? src1.y : src2.y
 
-1.8.2  KIL - Conditional Discard
+  dst.z = (src0.z < 0) ? src1.z : src2.z
+
+  dst.w = (src0.w < 0) ? src1.w : src2.w
+
+
+.. opcode:: KIL - Conditional Discard
 
 .. math::
 
-  if (src.x < 0.0 || src.y < 0.0 || src.z < 0.0 || src.w < 0.0)
+  if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
     discard
   endif
 
 
-1.8.3  SCS - Sine Cosine
+.. opcode:: SCS - Sine Cosine
 
 .. math::
 
-  dst.x = cos(src.x)
-  dst.y = sin(src.x)
-  dst.z = 0.0
-  dst.y = 1.0
+  dst.x = \cos{src.x}
+
+  dst.y = \sin{src.x}
 
+  dst.z = 0
 
-1.8.4  TXB - Texture Lookup With Bias
+  dst.y = 1
+
+
+.. opcode:: TXB - Texture Lookup With Bias
 
   TBD
 
 
-1.9.1  NRM - 3-component Vector Normalise
+.. opcode:: NRM - 3-component Vector Normalise
 
 .. math::
 
-  dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z)
-  dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z)
-  dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z)
-  dst.w = 1.0
+  dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
+
+  dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
+
+  dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
 
+  dst.w = 1
 
-1.9.2  DIV - Divide
+
+.. opcode:: DIV - Divide
 
 .. math::
 
-  dst.x = src0.x / src1.x
-  dst.y = src0.y / src1.y
-  dst.z = src0.z / src1.z
-  dst.w = src0.w / src1.w
+  dst.x = \frac{src0.x}{src1.x}
+
+  dst.y = \frac{src0.y}{src1.y}
+
+  dst.z = \frac{src0.z}{src1.z}
+
+  dst.w = \frac{src0.w}{src1.w}
 
 
-1.9.3  DP2 - 2-component Dot Product
+.. opcode:: DP2 - 2-component Dot Product
+
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = src0.x * src1.x + src0.y * src1.y
-  dst.y = src0.x * src1.x + src0.y * src1.y
-  dst.z = src0.x * src1.x + src0.y * src1.y
-  dst.w = src0.x * src1.x + src0.y * src1.y
+  dst = src0.x \times src1.x + src0.y \times src1.y
 
 
-1.9.5  TXL - Texture Lookup With LOD
+.. opcode:: TXL - Texture Lookup With LOD
 
   TBD
 
 
-1.9.6  BRK - Break
+.. opcode:: BRK - Break
 
   TBD
 
 
-1.9.7  IF - If
+.. opcode:: IF - If
 
   TBD
 
 
-1.9.8  BGNFOR - Begin a For-Loop
+.. opcode:: BGNFOR - Begin a For-Loop
 
   dst.x = floor(src.x)
   dst.y = floor(src.y)
@@ -727,25 +799,31 @@ Considered for removal.
   Note: The destination must be a loop register.
         The source must be a constant register.
 
-  Considered for cleanup / removal.
+.. note::
+
+   Considered for cleanup.
+
+.. note::
 
+   Considered for removal.
 
-1.9.9  REP - Repeat
+
+.. opcode:: REP - Repeat
 
   TBD
 
 
-1.9.10  ELSE - Else
+.. opcode:: ELSE - Else
 
   TBD
 
 
-1.9.11  ENDIF - End If
+.. opcode:: ENDIF - End If
 
   TBD
 
 
-1.9.12  ENDFOR - End a For-Loop
+.. opcode:: ENDFOR - End a For-Loop
 
   dst.x = dst.x + dst.z
   dst.y = dst.y - 1.0
@@ -756,257 +834,415 @@ Considered for removal.
 
   Note: The destination must be a loop register.
 
-  Considered for cleanup / removal.
+.. note::
+
+   Considered for cleanup.
 
-1.9.13  ENDREP - End Repeat
+.. note::
+
+   Considered for removal.
+
+.. opcode:: ENDREP - End Repeat
 
   TBD
 
 
-1.10.1  PUSHA - Push Address Register On Stack
+.. opcode:: PUSHA - Push Address Register On Stack
 
   push(src.x)
   push(src.y)
   push(src.z)
   push(src.w)
 
-  Considered for cleanup / removal.
+.. note::
+
+   Considered for cleanup.
+
+.. note::
 
-1.10.2  POPA - Pop Address Register From Stack
+   Considered for removal.
+
+.. opcode:: POPA - Pop Address Register From Stack
 
   dst.w = pop()
   dst.z = pop()
   dst.y = pop()
   dst.x = pop()
 
-  Considered for cleanup / removal.
+.. note::
+
+   Considered for cleanup.
+
+.. note::
+
+   Considered for removal.
 
 
-1.11  GL_NV_gpu_program4
-------------------------
+From GL_NV_gpu_program4
+^^^^^^^^^^^^^^^^^^^^^^^^
 
 Support for these opcodes indicated by a special pipe capability bit (TBD).
 
-1.11.1  CEIL - Ceiling
+.. opcode:: CEIL - Ceiling
 
 .. math::
 
-  dst.x = ceil(src.x)
-  dst.y = ceil(src.y)
-  dst.z = ceil(src.z)
-  dst.w = ceil(src.w)
+  dst.x = \lceil src.x\rceil
 
+  dst.y = \lceil src.y\rceil
 
-1.11.2  I2F - Integer To Float
+  dst.z = \lceil src.z\rceil
+
+  dst.w = \lceil src.w\rceil
+
+
+.. opcode:: I2F - Integer To Float
 
 .. math::
 
   dst.x = (float) src.x
+
   dst.y = (float) src.y
+
   dst.z = (float) src.z
+
   dst.w = (float) src.w
 
 
-1.11.3  NOT - Bitwise Not
+.. opcode:: NOT - Bitwise Not
 
 .. math::
 
   dst.x = ~src.x
+
   dst.y = ~src.y
+
   dst.z = ~src.z
+
   dst.w = ~src.w
 
 
-1.11.4  TRUNC - Truncate
+.. opcode:: TRUNC - Truncate
 
 .. math::
 
   dst.x = trunc(src.x)
+
   dst.y = trunc(src.y)
+
   dst.z = trunc(src.z)
+
   dst.w = trunc(src.w)
 
 
-1.11.5  SHL - Shift Left
+.. opcode:: SHL - Shift Left
 
 .. math::
 
   dst.x = src0.x << src1.x
+
   dst.y = src0.y << src1.x
+
   dst.z = src0.z << src1.x
+
   dst.w = src0.w << src1.x
 
 
-1.11.6  SHR - Shift Right
+.. opcode:: SHR - Shift Right
 
 .. math::
 
   dst.x = src0.x >> src1.x
+
   dst.y = src0.y >> src1.x
+
   dst.z = src0.z >> src1.x
+
   dst.w = src0.w >> src1.x
 
 
-1.11.7  AND - Bitwise And
+.. opcode:: AND - Bitwise And
 
 .. math::
 
   dst.x = src0.x & src1.x
+
   dst.y = src0.y & src1.y
+
   dst.z = src0.z & src1.z
+
   dst.w = src0.w & src1.w
 
 
-1.11.8  OR - Bitwise Or
+.. opcode:: OR - Bitwise Or
 
 .. math::
 
   dst.x = src0.x | src1.x
+
   dst.y = src0.y | src1.y
+
   dst.z = src0.z | src1.z
+
   dst.w = src0.w | src1.w
 
 
-1.11.9  MOD - Modulus
+.. opcode:: MOD - Modulus
 
 .. math::
 
-  dst.x = src0.x % src1.x
-  dst.y = src0.y % src1.y
-  dst.z = src0.z % src1.z
-  dst.w = src0.w % src1.w
+  dst.x = src0.x \bmod src1.x
+
+  dst.y = src0.y \bmod src1.y
+
+  dst.z = src0.z \bmod src1.z
 
+  dst.w = src0.w \bmod src1.w
 
-1.11.10  XOR - Bitwise Xor
+
+.. opcode:: XOR - Bitwise Xor
 
 .. math::
 
-  dst.x = src0.x ^ src1.x
-  dst.y = src0.y ^ src1.y
-  dst.z = src0.z ^ src1.z
-  dst.w = src0.w ^ src1.w
+  dst.x = src0.x \oplus src1.x
+
+  dst.y = src0.y \oplus src1.y
+
+  dst.z = src0.z \oplus src1.z
+
+  dst.w = src0.w \oplus src1.w
 
 
-1.11.11  SAD - Sum Of Absolute Differences
+.. opcode:: SAD - Sum Of Absolute Differences
 
 .. math::
 
-  dst.x = abs(src0.x - src1.x) + src2.x
-  dst.y = abs(src0.y - src1.y) + src2.y
-  dst.z = abs(src0.z - src1.z) + src2.z
-  dst.w = abs(src0.w - src1.w) + src2.w
+  dst.x = |src0.x - src1.x| + src2.x
 
+  dst.y = |src0.y - src1.y| + src2.y
 
-1.11.12  TXF - Texel Fetch
+  dst.z = |src0.z - src1.z| + src2.z
+
+  dst.w = |src0.w - src1.w| + src2.w
+
+
+.. opcode:: TXF - Texel Fetch
 
   TBD
 
 
-1.11.13  TXQ - Texture Size Query
+.. opcode:: TXQ - Texture Size Query
 
   TBD
 
 
-1.11.14  CONT - Continue
+.. opcode:: CONT - Continue
 
   TBD
 
 
-1.12  GL_NV_geometry_program4
------------------------------
+From GL_NV_geometry_program4
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
-1.12.1  EMIT - Emit
+.. opcode:: EMIT - Emit
 
   TBD
 
 
-1.12.2  ENDPRIM - End Primitive
+.. opcode:: ENDPRIM - End Primitive
 
   TBD
 
 
-1.13  GLSL
-----------
+From GLSL
+^^^^^^^^^^
 
 
-1.13.1  BGNLOOP - Begin a Loop
+.. opcode:: BGNLOOP - Begin a Loop
 
   TBD
 
 
-1.13.2  BGNSUB - Begin Subroutine
+.. opcode:: BGNSUB - Begin Subroutine
 
   TBD
 
 
-1.13.3  ENDLOOP - End a Loop
+.. opcode:: ENDLOOP - End a Loop
 
   TBD
 
 
-1.13.4  ENDSUB - End Subroutine
+.. opcode:: ENDSUB - End Subroutine
 
   TBD
 
 
-
-1.13.10  NOP - No Operation
+.. opcode:: NOP - No Operation
 
   Do nothing.
 
 
+.. opcode:: NRM4 - 4-component Vector Normalise
 
-1.16.7  NRM4 - 4-component Vector Normalise
+This instruction replicates its result.
 
 .. math::
 
-  dst.x = src.x / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
-  dst.y = src.y / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
-  dst.z = src.z / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
-  dst.w = src.w / (src.x * src.x + src.y * src.y + src.z * src.z + src.w * src.w)
+  dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
 
 
-1.17  ps_2_x
-------------
+ps_2_x
+^^^^^^^^^^^^
 
 
-1.17.2  CALLNZ - Subroutine Call If Not Zero
+.. opcode:: CALLNZ - Subroutine Call If Not Zero
 
   TBD
 
 
-1.17.3  IFC - If
+.. opcode:: IFC - If
 
   TBD
 
 
-1.17.5  BREAKC - Break Conditional
+.. opcode:: BREAKC - Break Conditional
 
   TBD
 
+.. _doubleopcodes:
+
+Double Opcodes
+^^^^^^^^^^^^^^^
+
+.. opcode:: DADD - Add Double
+
+.. math::
+
+  dst.xy = src0.xy + src1.xy
+
+  dst.zw = src0.zw + src1.zw
+
+
+.. opcode:: DDIV - Divide Double
+
+.. math::
+
+  dst.xy = src0.xy / src1.xy
+
+  dst.zw = src0.zw / src1.zw
+
+.. opcode:: DSEQ - Set Double on Equal
+
+.. math::
+
+  dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
+
+  dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
+
+.. opcode:: DSLT - Set Double on Less than
+
+.. math::
+
+  dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
+
+  dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
+
+.. opcode:: DFRAC - Double Fraction
+
+.. math::
+
+  dst.xy = src.xy - \lfloor src.xy\rfloor
+
+  dst.zw = src.zw - \lfloor src.zw\rfloor
+
+
+.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
+
+.. math::
+
+  dst0.xy = frexp(src.xy, dst1.xy)
+
+  dst0.zw = frexp(src.zw, dst1.zw)
+
+.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
+
+.. math::
+
+  dst.xy = ldexp(src0.xy, src1.xy)
+
+  dst.zw = ldexp(src0.zw, src1.zw)
+
+.. opcode:: DMIN - Minimum Double
+
+.. math::
+
+  dst.xy = min(src0.xy, src1.xy)
+
+  dst.zw = min(src0.zw, src1.zw)
+
+.. opcode:: DMAX - Maximum Double
+
+.. math::
+
+  dst.xy = max(src0.xy, src1.xy)
+
+  dst.zw = max(src0.zw, src1.zw)
+
+.. opcode:: DMUL - Multiply Double
+
+.. math::
+
+  dst.xy = src0.xy \times src1.xy
+
+  dst.zw = src0.zw \times src1.zw
+
+
+.. opcode:: DMAD - Multiply And Add Doubles
 
-2  Explanation of symbols used
-==============================
+.. math::
+
+  dst.xy = src0.xy \times src1.xy + src2.xy
+
+  dst.zw = src0.zw \times src1.zw + src2.zw
 
 
-2.1  Functions
---------------
+.. opcode:: DRCP - Reciprocal Double
+
+.. math::
 
+   dst.xy = \frac{1}{src.xy}
+
+   dst.zw = \frac{1}{src.zw}
+
+.. opcode:: DSQRT - Square root double
+
+.. math::
 
-  abs(x)            Absolute value of x.
-                    (x < 0.0) ? -x : x
+   dst.xy = \sqrt{src.xy}
 
-  ceil(x)           Ceiling of x.
+   dst.zw = \sqrt{src.zw}
+
+
+Explanation of symbols used
+------------------------------
+
+
+Functions
+^^^^^^^^^^^^^^
+
+
+  :math:`|x|`       Absolute value of `x`.
+
+  :math:`\lceil x \rceil` Ceiling of `x`.
 
   clamp(x,y,z)      Clamp x between y and z.
                     (x < y) ? y : (x > z) ? z : x
 
-  cos(x)            Cosine of x.
-
-  floor(x)          Floor of x.
+  :math:`\lfloor x\rfloor` Floor of `x`.
 
-  lg2(x)            Logarithm base 2 of x.
+  :math:`\log_2{x}` Logarithm of `x`, base 2.
 
   max(x,y)          Maximum of x and y.
                     (x > y) ? x : y
@@ -1020,48 +1256,60 @@ Support for these opcodes indicated by a special pipe capability bit (TBD).
 
   pop()             Pop from stack.
 
-  pow(x,y)          Raise x to power of y.
+  :math:`x^y`       `x` to the power `y`.
 
   push(x)           Push x on stack.
 
   round(x)          Round x.
 
-  sin(x)            Sine of x.
+  trunc(x)          Truncate x, i.e. drop the fraction bits.
 
-  sqrt(x)           Square root of x.
 
-  trunc(x)          Truncate x.
+Keywords
+^^^^^^^^^^^^^
 
 
-2.2  Keywords
--------------
+  discard           Discard fragment.
 
+  pc                Program counter.
 
-  discard           Discard fragment.
+  target            Label of target instruction.
 
-  dst               First destination register.
 
-  dst0              First destination register.
+Other tokens
+---------------
 
-  pc                Program counter.
 
-  src               First source register.
+Declaration
+^^^^^^^^^^^
 
-  src0              First source register.
 
-  src1              Second source register.
+Declares a register that is will be referenced as an operand in Instruction
+tokens.
 
-  src2              Third source register.
+File field contains register file that is being declared and is one
+of TGSI_FILE.
 
-  target            Label of target instruction.
+UsageMask field specifies which of the register components can be accessed
+and is one of TGSI_WRITEMASK.
+
+Interpolate field is only valid for fragment shader INPUT register files.
+It specifes the way input is being interpolated by the rasteriser and is one
+of TGSI_INTERPOLATE.
 
+If Dimension flag is set to 1, a Declaration Dimension token follows.
 
-3  Other tokens
-===============
+If Semantic flag is set to 1, a Declaration Semantic token follows.
 
+CylindricalWrap bitfield is only valid for fragment shader INPUT register
+files. It specifies which register components should be subject to cylindrical
+wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
+is set to 1, the X component should be interpolated according to cylindrical
+wrapping rules.
 
-3.1  Declaration Semantic
--------------------------
+
+Declaration Semantic
+^^^^^^^^^^^^^^^^^^^^^^^^
 
 
   Follows Declaration token if Semantic bit is set.
@@ -1080,10 +1328,172 @@ Support for these opcodes indicated by a special pipe capability bit (TBD).
   The meanings of the individual semantic names are explained in the following
   sections.
 
+TGSI_SEMANTIC_POSITION
+""""""""""""""""""""""
+
+Position, sometimes known as HPOS or WPOS for historical reasons, is the
+location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
+are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
+for the perspective divide, if enabled.
+
+As a vertex shader output, position should be scaled to the viewport. When
+used in fragment shaders, position will be in window coordinates. The convention
+used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
+
+XXX additionally, is there a way to configure the perspective divide? it's
+accelerated on most chipsets AFAIK...
+
+Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
+be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
+
+XXX usually? can we solidify that?
+
+TGSI_SEMANTIC_COLOR
+"""""""""""""""""""
+
+Colors are used to, well, color the primitives. Colors are always in
+``(r, g, b, a)`` format.
+
+If alpha is not specified, it defaults to 1.
+
+TGSI_SEMANTIC_BCOLOR
+""""""""""""""""""""
+
+Back-facing colors are only used for back-facing polygons, and are only valid
+in vertex shader outputs. After rasterization, all polygons are front-facing
+and COLOR and BCOLOR end up occupying the same slots in the fragment, so
+all BCOLORs effectively become regular COLORs in the fragment shader.
+
+TGSI_SEMANTIC_FOG
+"""""""""""""""""
+
+The fog coordinate historically has been used to replace the depth coordinate
+for generation of fog in dedicated fog blocks. Gallium, however, does not use
+dedicated fog acceleration, placing it entirely in the fragment shader
+instead.
+
+The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
+component matters when writing from the vertex shader; the driver will ensure
+that the coordinate is in this format when used as a fragment shader input.
+
+TGSI_SEMANTIC_PSIZE
+"""""""""""""""""""
+
+PSIZE, or point size, is used to specify point sizes per-vertex. It should
+be in ``(s, 0, 0, 1)`` format, where ``s`` is the (possibly clamped) point size.
+Only the first component matters when writing from the vertex shader.
+
+When using this semantic, be sure to set the appropriate state in the
+:ref:`rasterizer` first.
+
+TGSI_SEMANTIC_GENERIC
+"""""""""""""""""""""
+
+Generic semantics are nearly always used for texture coordinate attributes,
+in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
+of lookups, and ``q`` is the level-of-detail bias for biased sampling.
+
+These attributes are called "generic" because they may be used for anything
+else, including parameters, texture generation information, or anything that
+can be stored inside a four-component vector.
+
+TGSI_SEMANTIC_NORMAL
+""""""""""""""""""""
+
+Vertex normal; could be used to implement per-pixel lighting for legacy APIs
+that allow mixing fixed-function and programmable stages.
+
+TGSI_SEMANTIC_FACE
+""""""""""""""""""
+
+FACE is the facing bit, to store the facing information for the fragment
+shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
+when the fragment is front-facing, and negative when the component is
+back-facing.
+
+TGSI_SEMANTIC_EDGEFLAG
+""""""""""""""""""""""
+
+XXX no clue
+
+
+Properties
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+  Properties are general directives that apply to the whole TGSI program.
+
+FS_COORD_ORIGIN
+"""""""""""""""
+
+Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
+The default value is UPPER_LEFT.
+
+If UPPER_LEFT, the position will be (0,0) at the upper left corner and
+increase downward and rightward.
+If LOWER_LEFT, the position will be (0,0) at the lower left corner and
+increase upward and rightward.
+
+OpenGL defaults to LOWER_LEFT, and is configurable with the
+GL_ARB_fragment_coord_conventions extension.
+
+DirectX 9/10 use UPPER_LEFT.
+
+FS_COORD_PIXEL_CENTER
+"""""""""""""""""""""
+
+Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
+The default value is HALF_INTEGER.
+
+If HALF_INTEGER, the fractionary part of the position will be 0.5
+If INTEGER, the fractionary part of the position will be 0.0
+
+Note that this does not affect the set of fragments generated by
+rasterization, which is instead controlled by gl_rasterization_rules in the
+rasterizer.
+
+OpenGL defaults to HALF_INTEGER, and is configurable with the
+GL_ARB_fragment_coord_conventions extension.
+
+DirectX 9 uses INTEGER.
+DirectX 10 uses HALF_INTEGER.
+
+
+
+Texture Sampling and Texture Formats
+------------------------------------
 
-3.1.1  FACE
+This table shows how texture image components are returned as (x,y,z,w) tuples
+by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
+:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
+well.
 
-  Valid only in a fragment shader INPUT declaration.
++--------------------+--------------+--------------------+--------------+
+| Texture Components | Gallium      | OpenGL             | Direct3D 9   |
++====================+==============+====================+==============+
+| R                  | XXX TBD      | (r, 0, 0, 1)       | (r, 1, 1, 1) |
++--------------------+--------------+--------------------+--------------+
+| RG                 | XXX TBD      | (r, g, 0, 1)       | (r, g, 1, 1) |
++--------------------+--------------+--------------------+--------------+
+| RGB                | (r, g, b, 1) | (r, g, b, 1)       | (r, g, b, 1) |
++--------------------+--------------+--------------------+--------------+
+| RGBA               | (r, g, b, a) | (r, g, b, a)       | (r, g, b, a) |
++--------------------+--------------+--------------------+--------------+
+| A                  | (0, 0, 0, a) | (0, 0, 0, a)       | (0, 0, 0, a) |
++--------------------+--------------+--------------------+--------------+
+| L                  | (l, l, l, 1) | (l, l, l, 1)       | (l, l, l, 1) |
++--------------------+--------------+--------------------+--------------+
+| LA                 | (l, l, l, a) | (l, l, l, a)       | (l, l, l, a) |
++--------------------+--------------+--------------------+--------------+
+| I                  | (i, i, i, i) | (i, i, i, i)       | N/A          |
++--------------------+--------------+--------------------+--------------+
+| UV                 | XXX TBD      | (0, 0, 0, 1)       | (u, v, 1, 1) |
+|                    |              | [#envmap-bumpmap]_ |              |
++--------------------+--------------+--------------------+--------------+
+| Z                  | XXX TBD      | (z, z, z, 1)       | (0, z, 0, 1) |
+|                    |              | [#depth-tex-mode]_ |              |
++--------------------+--------------+--------------------+--------------+
 
-  FACE.x is negative when the primitive is back facing. FACE.x is positive
-  when the primitive is front facing.
+.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
+.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
+   or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.