TGSI, Tungsten Graphics Shader Instructions, 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.
ARL - Address Register Load
MOV - Move
LIT - Light Coefficients
RCP - Reciprocal
RSQ - Reciprocal Square Root
EXP - Approximate Exponential Base 2
LOG - Approximate Logarithm Base 2
MUL - Multiply
ADD - Add
DP3 - 3-component Dot Product
DP4 - 4-component Dot Product
DST - Distance Vector
MIN - Minimum
MAX - Maximum
SLT - Set On Less Than
SGE - Set On Greater Equal Than
MAD - Multiply And Add
SUB - Subtract
LRP - Linear Interpolate
CND - Condition
DP2A - 2-component Dot Product And Add
FRAC - Fraction
CLAMP - Clamp
FLR - Floor
This is identical to ARL.
ROUND - Round
EX2 - Exponential Base 2
LG2 - Logarithm Base 2
POW - Power
XPD - Cross Product
ABS - Absolute
RCC - Reciprocal Clamped
XXX cleanup on aisle three
DPH - Homogeneous Dot Product
COS - Cosine
DDX - Derivative Relative To X
DDY - Derivative Relative To Y
KILP - Predicated Discard
discard
PK2H - Pack Two 16-bit Floats
TBD
PK2US - Pack Two Unsigned 16-bit Scalars
TBD
PK4B - Pack Four Signed 8-bit Scalars
TBD
PK4UB - Pack Four Unsigned 8-bit Scalars
TBD
RFL - Reflection Vector
Considered for removal.
SEQ - Set On Equal
SFL - Set On False
Considered for removal.
SGT - Set On Greater Than
SIN - Sine
SLE - Set On Less Equal Than
SNE - Set On Not Equal
STR - Set On True
TEX - Texture Lookup
TBD
TXD - Texture Lookup with Derivatives
TBD
TXP - Projective Texture Lookup
TBD
UP2H - Unpack Two 16-Bit Floats
TBD
Considered for removal.
UP2US - Unpack Two Unsigned 16-Bit Scalars
TBD
Considered for removal.
UP4B - Unpack Four Signed 8-Bit Values
TBD
Considered for removal.
UP4UB - Unpack Four Unsigned 8-Bit Scalars
TBD
Considered for removal.
X2D - 2D Coordinate Transformation
Considered for removal.
ARA - Address Register Add
TBD
Considered for removal.
ARR - Address Register Load With Round
BRA - Branch
pc = target
Considered for removal.
CAL - Subroutine Call
push(pc) pc = target
RET - Subroutine Call Return
pc = pop()
Potential restrictions: times Only occurs at end of function.
SSG - Set Sign
CMP - Compare
KIL - Conditional Discard
SCS - Sine Cosine
TXB - Texture Lookup With Bias
TBD
NRM - 3-component Vector Normalise
DIV - Divide
DP2 - 2-component Dot Product
TXL - Texture Lookup With LOD
TBD
BRK - Break
TBD
IF - If
TBD
BGNFOR - Begin a For-Loop
dst.x = floor(src.x) dst.y = floor(src.y) dst.z = floor(src.z)
- if (dst.y <= 0)
- pc = [matching ENDFOR] + 1
endif
- Note: The destination must be a loop register.
- The source must be a constant register.
Considered for cleanup / removal.
REP - Repeat
TBD
ELSE - Else
TBD
ENDIF - End If
TBD
ENDFOR - End a For-Loop
dst.x = dst.x + dst.z dst.y = dst.y - 1.0
- if (dst.y > 0)
- pc = [matching BGNFOR instruction] + 1
endif
Note: The destination must be a loop register.
Considered for cleanup / removal.
ENDREP - End Repeat
TBD
PUSHA - Push Address Register On Stack
push(src.x) push(src.y) push(src.z) push(src.w)
Considered for cleanup / removal.
POPA - Pop Address Register From Stack
dst.w = pop() dst.z = pop() dst.y = pop() dst.x = pop()
Considered for cleanup / removal.
Support for these opcodes indicated by a special pipe capability bit (TBD).
CEIL - Ceiling
I2F - Integer To Float
NOT - Bitwise Not
TRUNC - Truncate
XXX how is this different from floor?
SHL - Shift Left
SHR - Shift Right
AND - Bitwise And
OR - Bitwise Or
MOD - Modulus
XOR - Bitwise Xor
SAD - Sum Of Absolute Differences
TXF - Texel Fetch
TBD
TXQ - Texture Size Query
TBD
CONT - Continue
TBD
BGNLOOP - Begin a Loop
TBD
BGNSUB - Begin Subroutine
TBD
ENDLOOP - End a Loop
TBD
ENDSUB - End Subroutine
TBD
NOP - No Operation
Do nothing.
NRM4 - 4-component Vector Normalise
Absolute value of x.
Ceiling of x.
- clamp(x,y,z) Clamp x between y and z.
- (x < y) ? y : (x > z) ? z : x
Floor of x.
Logarithm of x, base 2.
- max(x,y) Maximum of x and y.
- (x > y) ? x : y
- min(x,y) Minimum of x and y.
- (x < y) ? x : y
partialx(x) Derivative of x relative to fragment’s X.
partialy(x) Derivative of x relative to fragment’s Y.
pop() Pop from stack.
x to the power y.
push(x) Push x on stack.
round(x) Round x.
trunc(x) Truncate x.
discard Discard fragment.
dst First destination register.
dst0 First destination register.
pc Program counter.
src First source register.
src0 First source register.
src1 Second source register.
src2 Third source register.
target Label of target instruction.
Follows Declaration token if Semantic bit is set.
Since its purpose is to link a shader with other stages of the pipeline, it is valid to follow only those Declaration tokens that declare a register either in INPUT or OUTPUT file.
SemanticName field contains the semantic name of the register being declared. There is no default value.
SemanticIndex is an optional subscript that can be used to distinguish different register declarations with the same semantic name. The default value is 0.
The meanings of the individual semantic names are explained in the following sections.
Valid only in a fragment shader INPUT declaration.
FACE.x is negative when the primitive is back facing. FACE.x is positive when the primitive is front facing.