blob: ecab7cb8097bba02831174a295918f804157915f [file] [log] [blame]
Corbin Simpsonc686e172009-12-20 15:00:40 -08001TGSI
2====
3
Michal Krolb6659682010-01-04 12:52:43 +01004TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language
Corbin Simpsonc686e172009-12-20 15:00:40 -08005for describing shaders. Since Gallium is inherently shaderful, shaders are
6an important part of the API. TGSI is the only intermediate representation
7used by all drivers.
Keith Whitwella62aaa72009-12-21 23:25:15 +00008
Corbin Simpson62ca7b82010-02-02 16:36:34 -08009Basics
10------
11
12All TGSI instructions, known as *opcodes*, operate on arbitrary-precision
13floating-point four-component vectors. An opcode may have up to one
14destination register, known as *dst*, and between zero and three source
15registers, called *src0* through *src2*, or simply *src* if there is only
16one.
17
18Some instructions, like :opcode:`I2F`, permit re-interpretation of vector
19components as integers. Other instructions permit using registers as
20two-component vectors with double precision; see :ref:`Double Opcodes`.
21
Corbin Simpson17c2a442010-02-02 17:02:28 -080022When an instruction has a scalar result, the result is usually copied into
23each of the components of *dst*. When this happens, the result is said to be
24*replicated* to *dst*. :opcode:`RCP` is one such instruction.
25
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080026Instruction Set
27---------------
28
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070029Core ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080030^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000031
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070032These opcodes are guaranteed to be available regardless of the driver being
33used.
Keith Whitwella62aaa72009-12-21 23:25:15 +000034
Corbin Simpson85805222010-02-02 16:20:12 -080035.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080036
37.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000038
Corbin Simpsond92a6852009-12-21 19:30:29 -080039 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080040
Corbin Simpsond92a6852009-12-21 19:30:29 -080041 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080042
Corbin Simpsond92a6852009-12-21 19:30:29 -080043 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080044
Corbin Simpsond92a6852009-12-21 19:30:29 -080045 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000046
47
Corbin Simpson85805222010-02-02 16:20:12 -080048.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080049
50.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000051
52 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080053
Keith Whitwella62aaa72009-12-21 23:25:15 +000054 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080055
Keith Whitwella62aaa72009-12-21 23:25:15 +000056 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080057
Keith Whitwella62aaa72009-12-21 23:25:15 +000058 dst.w = src.w
59
60
Corbin Simpson85805222010-02-02 16:20:12 -080061.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080062
63.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000064
Corbin Simpsonda65ac62009-12-21 20:32:46 -080065 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080066
Corbin Simpsonda65ac62009-12-21 20:32:46 -080067 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080068
Corbin Simpsonda65ac62009-12-21 20:32:46 -080069 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080070
Corbin Simpsonda65ac62009-12-21 20:32:46 -080071 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000072
73
Corbin Simpson85805222010-02-02 16:20:12 -080074.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080075
Corbin Simpson17c2a442010-02-02 17:02:28 -080076This instruction replicates its result.
77
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080078.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000079
Corbin Simpson17c2a442010-02-02 17:02:28 -080080 dst = \frac{1}{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +000081
82
Corbin Simpson85805222010-02-02 16:20:12 -080083.. opcode:: RSQ - Reciprocal Square Root
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080084
Corbin Simpson17c2a442010-02-02 17:02:28 -080085This instruction replicates its result.
86
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080087.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000088
Corbin Simpson17c2a442010-02-02 17:02:28 -080089 dst = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +000090
91
Corbin Simpson85805222010-02-02 16:20:12 -080092.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080093
94.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000095
Corbin Simpsondd801e52009-12-21 19:41:09 -080096 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080097
Corbin Simpsond92a6852009-12-21 19:30:29 -080098 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099
Corbin Simpsondd801e52009-12-21 19:41:09 -0800100 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800101
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800102 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000103
104
Corbin Simpson85805222010-02-02 16:20:12 -0800105.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800106
107.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000108
Corbin Simpson14743ac2009-12-21 19:57:56 -0800109 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800110
Corbin Simpson14743ac2009-12-21 19:57:56 -0800111 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800112
Corbin Simpson14743ac2009-12-21 19:57:56 -0800113 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800114
Corbin Simpson14743ac2009-12-21 19:57:56 -0800115 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000116
117
Corbin Simpson85805222010-02-02 16:20:12 -0800118.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800119
120.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000121
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800122 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800123
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800124 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800125
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800126 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800127
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800128 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000129
130
Corbin Simpson85805222010-02-02 16:20:12 -0800131.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800132
133.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000134
135 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800136
Keith Whitwella62aaa72009-12-21 23:25:15 +0000137 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800138
Keith Whitwella62aaa72009-12-21 23:25:15 +0000139 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800140
Keith Whitwella62aaa72009-12-21 23:25:15 +0000141 dst.w = src0.w + src1.w
142
143
Corbin Simpson85805222010-02-02 16:20:12 -0800144.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800145
Corbin Simpson17c2a442010-02-02 17:02:28 -0800146This instruction replicates its result.
147
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800148.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000149
Corbin Simpson17c2a442010-02-02 17:02:28 -0800150 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000151
152
Corbin Simpson85805222010-02-02 16:20:12 -0800153.. opcode:: DP4 - 4-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800154
Corbin Simpson17c2a442010-02-02 17:02:28 -0800155This instruction replicates its result.
156
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800157.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000158
Corbin Simpson17c2a442010-02-02 17:02:28 -0800159 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000160
161
Corbin Simpson85805222010-02-02 16:20:12 -0800162.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800163
164.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000165
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800166 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800167
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800168 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800169
Keith Whitwella62aaa72009-12-21 23:25:15 +0000170 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800171
Keith Whitwella62aaa72009-12-21 23:25:15 +0000172 dst.w = src1.w
173
174
Corbin Simpson85805222010-02-02 16:20:12 -0800175.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800176
177.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000178
179 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800180
Keith Whitwella62aaa72009-12-21 23:25:15 +0000181 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800182
Keith Whitwella62aaa72009-12-21 23:25:15 +0000183 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800184
Keith Whitwella62aaa72009-12-21 23:25:15 +0000185 dst.w = min(src0.w, src1.w)
186
187
Corbin Simpson85805222010-02-02 16:20:12 -0800188.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800189
190.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000191
192 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800193
Keith Whitwella62aaa72009-12-21 23:25:15 +0000194 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800195
Keith Whitwella62aaa72009-12-21 23:25:15 +0000196 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800197
Keith Whitwella62aaa72009-12-21 23:25:15 +0000198 dst.w = max(src0.w, src1.w)
199
200
Corbin Simpson85805222010-02-02 16:20:12 -0800201.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800202
203.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000204
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800205 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800206
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800207 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800208
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800209 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800210
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800211 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000212
213
Corbin Simpson85805222010-02-02 16:20:12 -0800214.. opcode:: SGE - Set On Greater Equal Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800215
216.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000217
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800218 dst.x = (src0.x >= src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800219
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800220 dst.y = (src0.y >= src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800221
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800222 dst.z = (src0.z >= src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800223
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800224 dst.w = (src0.w >= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000225
226
Corbin Simpson85805222010-02-02 16:20:12 -0800227.. opcode:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800228
229.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000230
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800231 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800232
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800233 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800234
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800235 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800236
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800237 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000238
239
Corbin Simpson85805222010-02-02 16:20:12 -0800240.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800241
242.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000243
244 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800245
Keith Whitwella62aaa72009-12-21 23:25:15 +0000246 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800247
Keith Whitwella62aaa72009-12-21 23:25:15 +0000248 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800249
Keith Whitwella62aaa72009-12-21 23:25:15 +0000250 dst.w = src0.w - src1.w
251
252
Corbin Simpson85805222010-02-02 16:20:12 -0800253.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800254
255.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000256
Michal Krolb3567fc2010-01-04 12:59:17 +0100257 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800258
Michal Krolb3567fc2010-01-04 12:59:17 +0100259 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800260
Michal Krolb3567fc2010-01-04 12:59:17 +0100261 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800262
Michal Krolb3567fc2010-01-04 12:59:17 +0100263 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000264
265
Corbin Simpson85805222010-02-02 16:20:12 -0800266.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800267
268.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000269
270 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800271
Keith Whitwella62aaa72009-12-21 23:25:15 +0000272 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800273
Keith Whitwella62aaa72009-12-21 23:25:15 +0000274 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800275
Keith Whitwella62aaa72009-12-21 23:25:15 +0000276 dst.w = (src2.w > 0.5) ? src0.w : src1.w
277
278
Corbin Simpson85805222010-02-02 16:20:12 -0800279.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800280
281.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000282
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800283 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800284
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800285 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800286
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800287 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800288
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800289 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000290
291
José Fonsecad9c6ebb2010-06-01 16:25:05 +0100292.. opcode:: FRC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800293
294.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000295
Corbin Simpsond92a6852009-12-21 19:30:29 -0800296 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800297
Corbin Simpsond92a6852009-12-21 19:30:29 -0800298 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800299
Corbin Simpsond92a6852009-12-21 19:30:29 -0800300 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800301
Corbin Simpsond92a6852009-12-21 19:30:29 -0800302 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000303
304
Corbin Simpson85805222010-02-02 16:20:12 -0800305.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800306
307.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000308
309 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800310
Keith Whitwella62aaa72009-12-21 23:25:15 +0000311 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800312
Keith Whitwella62aaa72009-12-21 23:25:15 +0000313 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800314
Keith Whitwella62aaa72009-12-21 23:25:15 +0000315 dst.w = clamp(src0.w, src1.w, src2.w)
316
317
Corbin Simpson85805222010-02-02 16:20:12 -0800318.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800319
Corbin Simpson17c2a442010-02-02 17:02:28 -0800320This is identical to :opcode:`ARL`.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000321
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800322.. math::
323
Corbin Simpsond92a6852009-12-21 19:30:29 -0800324 dst.x = \lfloor src.x\rfloor
325
326 dst.y = \lfloor src.y\rfloor
327
328 dst.z = \lfloor src.z\rfloor
329
330 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000331
332
Corbin Simpson85805222010-02-02 16:20:12 -0800333.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000334
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800335.. math::
336
Keith Whitwella62aaa72009-12-21 23:25:15 +0000337 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800338
Keith Whitwella62aaa72009-12-21 23:25:15 +0000339 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800340
Keith Whitwella62aaa72009-12-21 23:25:15 +0000341 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800342
Keith Whitwella62aaa72009-12-21 23:25:15 +0000343 dst.w = round(src.w)
344
345
Corbin Simpson85805222010-02-02 16:20:12 -0800346.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000347
Corbin Simpson17c2a442010-02-02 17:02:28 -0800348This instruction replicates its result.
349
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800350.. math::
351
Corbin Simpson17c2a442010-02-02 17:02:28 -0800352 dst = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000353
354
Corbin Simpson85805222010-02-02 16:20:12 -0800355.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000356
Corbin Simpson17c2a442010-02-02 17:02:28 -0800357This instruction replicates its result.
358
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800359.. math::
360
Corbin Simpson17c2a442010-02-02 17:02:28 -0800361 dst = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000362
363
Corbin Simpson85805222010-02-02 16:20:12 -0800364.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000365
Corbin Simpson17c2a442010-02-02 17:02:28 -0800366This instruction replicates its result.
367
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800368.. math::
369
Corbin Simpson17c2a442010-02-02 17:02:28 -0800370 dst = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000371
Corbin Simpson85805222010-02-02 16:20:12 -0800372.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000373
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800374.. math::
375
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800376 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800377
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800378 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800379
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800380 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800381
382 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000383
384
Corbin Simpson85805222010-02-02 16:20:12 -0800385.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000386
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800387.. math::
388
Corbin Simpson14743ac2009-12-21 19:57:56 -0800389 dst.x = |src.x|
390
391 dst.y = |src.y|
392
393 dst.z = |src.z|
394
395 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000396
397
Corbin Simpson85805222010-02-02 16:20:12 -0800398.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800399
Corbin Simpson17c2a442010-02-02 17:02:28 -0800400This instruction replicates its result.
401
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800402XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000403
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800404.. math::
405
Corbin Simpson17c2a442010-02-02 17:02:28 -0800406 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)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000407
408
Corbin Simpson85805222010-02-02 16:20:12 -0800409.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000410
Corbin Simpson17c2a442010-02-02 17:02:28 -0800411This instruction replicates its result.
412
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800413.. math::
414
Corbin Simpson17c2a442010-02-02 17:02:28 -0800415 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000416
417
Corbin Simpson85805222010-02-02 16:20:12 -0800418.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000419
Corbin Simpson17c2a442010-02-02 17:02:28 -0800420This instruction replicates its result.
421
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800422.. math::
423
Corbin Simpson17c2a442010-02-02 17:02:28 -0800424 dst = \cos{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000425
426
Corbin Simpson85805222010-02-02 16:20:12 -0800427.. opcode:: DDX - Derivative Relative To X
Keith Whitwella62aaa72009-12-21 23:25:15 +0000428
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800429.. math::
430
Keith Whitwella62aaa72009-12-21 23:25:15 +0000431 dst.x = partialx(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800432
Keith Whitwella62aaa72009-12-21 23:25:15 +0000433 dst.y = partialx(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800434
Keith Whitwella62aaa72009-12-21 23:25:15 +0000435 dst.z = partialx(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800436
Keith Whitwella62aaa72009-12-21 23:25:15 +0000437 dst.w = partialx(src.w)
438
439
Corbin Simpson85805222010-02-02 16:20:12 -0800440.. opcode:: DDY - Derivative Relative To Y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000441
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800442.. math::
443
Keith Whitwella62aaa72009-12-21 23:25:15 +0000444 dst.x = partialy(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800445
Keith Whitwella62aaa72009-12-21 23:25:15 +0000446 dst.y = partialy(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800447
Keith Whitwella62aaa72009-12-21 23:25:15 +0000448 dst.z = partialy(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800449
Keith Whitwella62aaa72009-12-21 23:25:15 +0000450 dst.w = partialy(src.w)
451
452
Corbin Simpson85805222010-02-02 16:20:12 -0800453.. opcode:: KILP - Predicated Discard
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800454
Keith Whitwella62aaa72009-12-21 23:25:15 +0000455 discard
456
457
Corbin Simpson85805222010-02-02 16:20:12 -0800458.. opcode:: PK2H - Pack Two 16-bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000459
460 TBD
461
462
Corbin Simpson85805222010-02-02 16:20:12 -0800463.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000464
465 TBD
466
467
Corbin Simpson85805222010-02-02 16:20:12 -0800468.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000469
470 TBD
471
472
Corbin Simpson85805222010-02-02 16:20:12 -0800473.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000474
475 TBD
476
477
Corbin Simpson85805222010-02-02 16:20:12 -0800478.. opcode:: RFL - Reflection Vector
Keith Whitwella62aaa72009-12-21 23:25:15 +0000479
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800480.. math::
481
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800482 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
483
484 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
485
486 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
487
488 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000489
Corbin Simpson17c2a442010-02-02 17:02:28 -0800490.. note::
491
492 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000493
Keith Whitwella62aaa72009-12-21 23:25:15 +0000494
Corbin Simpson85805222010-02-02 16:20:12 -0800495.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000496
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800497.. math::
498
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800499 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800500
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800501 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800502
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800503 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800504
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800505 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000506
507
Corbin Simpson85805222010-02-02 16:20:12 -0800508.. opcode:: SFL - Set On False
Keith Whitwella62aaa72009-12-21 23:25:15 +0000509
Corbin Simpson17c2a442010-02-02 17:02:28 -0800510This instruction replicates its result.
511
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800512.. math::
513
Corbin Simpson17c2a442010-02-02 17:02:28 -0800514 dst = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800515
Corbin Simpson17c2a442010-02-02 17:02:28 -0800516.. note::
Corbin Simpson04771912010-01-18 17:31:56 -0800517
Corbin Simpson17c2a442010-02-02 17:02:28 -0800518 Considered for removal.
Corbin Simpson04771912010-01-18 17:31:56 -0800519
Keith Whitwella62aaa72009-12-21 23:25:15 +0000520
Corbin Simpson85805222010-02-02 16:20:12 -0800521.. opcode:: SGT - Set On Greater Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000522
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800523.. math::
524
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800525 dst.x = (src0.x > src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800526
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800527 dst.y = (src0.y > src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800528
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800529 dst.z = (src0.z > src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800530
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800531 dst.w = (src0.w > src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000532
533
Corbin Simpson85805222010-02-02 16:20:12 -0800534.. opcode:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000535
Corbin Simpson17c2a442010-02-02 17:02:28 -0800536This instruction replicates its result.
537
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800538.. math::
539
Corbin Simpson17c2a442010-02-02 17:02:28 -0800540 dst = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000541
542
Corbin Simpson85805222010-02-02 16:20:12 -0800543.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000544
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800545.. math::
546
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800547 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800548
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800549 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800550
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800551 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800552
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800553 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000554
555
Corbin Simpson85805222010-02-02 16:20:12 -0800556.. opcode:: SNE - Set On Not Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000557
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800558.. math::
559
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800560 dst.x = (src0.x != src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800561
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800562 dst.y = (src0.y != src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800563
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800564 dst.z = (src0.z != src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800565
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800566 dst.w = (src0.w != src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000567
568
Corbin Simpson85805222010-02-02 16:20:12 -0800569.. opcode:: STR - Set On True
Keith Whitwella62aaa72009-12-21 23:25:15 +0000570
Corbin Simpson17c2a442010-02-02 17:02:28 -0800571This instruction replicates its result.
572
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800573.. math::
574
Corbin Simpson17c2a442010-02-02 17:02:28 -0800575 dst = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000576
577
Corbin Simpson85805222010-02-02 16:20:12 -0800578.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000579
580 TBD
581
582
Corbin Simpson85805222010-02-02 16:20:12 -0800583.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000584
585 TBD
586
587
Corbin Simpson85805222010-02-02 16:20:12 -0800588.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000589
590 TBD
591
592
Corbin Simpson85805222010-02-02 16:20:12 -0800593.. opcode:: UP2H - Unpack Two 16-Bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000594
595 TBD
596
Corbin Simpson17c2a442010-02-02 17:02:28 -0800597.. note::
598
599 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000600
Corbin Simpson85805222010-02-02 16:20:12 -0800601.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000602
603 TBD
604
Corbin Simpson17c2a442010-02-02 17:02:28 -0800605.. note::
606
607 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000608
Corbin Simpson85805222010-02-02 16:20:12 -0800609.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000610
611 TBD
612
Corbin Simpson17c2a442010-02-02 17:02:28 -0800613.. note::
614
615 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000616
Corbin Simpson85805222010-02-02 16:20:12 -0800617.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000618
619 TBD
620
Corbin Simpson17c2a442010-02-02 17:02:28 -0800621.. note::
622
623 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000624
Corbin Simpson85805222010-02-02 16:20:12 -0800625.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000626
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800627.. math::
628
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800629 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800630
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800631 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800632
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800633 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800634
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800635 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000636
Corbin Simpson17c2a442010-02-02 17:02:28 -0800637.. note::
638
639 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000640
Keith Whitwella62aaa72009-12-21 23:25:15 +0000641
Corbin Simpson85805222010-02-02 16:20:12 -0800642.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000643
644 TBD
645
Corbin Simpson17c2a442010-02-02 17:02:28 -0800646.. note::
647
648 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000649
Corbin Simpson85805222010-02-02 16:20:12 -0800650.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000651
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800652.. math::
653
Keith Whitwella62aaa72009-12-21 23:25:15 +0000654 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800655
Keith Whitwella62aaa72009-12-21 23:25:15 +0000656 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800657
Keith Whitwella62aaa72009-12-21 23:25:15 +0000658 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800659
Keith Whitwella62aaa72009-12-21 23:25:15 +0000660 dst.w = round(src.w)
661
662
Corbin Simpson85805222010-02-02 16:20:12 -0800663.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000664
665 pc = target
666
Corbin Simpson17c2a442010-02-02 17:02:28 -0800667.. note::
668
669 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000670
Corbin Simpson85805222010-02-02 16:20:12 -0800671.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000672
673 push(pc)
674 pc = target
675
676
Corbin Simpson85805222010-02-02 16:20:12 -0800677.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000678
679 pc = pop()
680
Keith Whitwell14eacb02009-12-21 23:38:29 +0000681 Potential restrictions:
Michal Krolcef21802010-01-04 13:15:28 +0100682 * Only occurs at end of function.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000683
Corbin Simpson85805222010-02-02 16:20:12 -0800684.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000685
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800686.. math::
687
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800688 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
689
690 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
691
692 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
693
694 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000695
696
Corbin Simpson85805222010-02-02 16:20:12 -0800697.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000698
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800699.. math::
700
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800701 dst.x = (src0.x < 0) ? src1.x : src2.x
702
703 dst.y = (src0.y < 0) ? src1.y : src2.y
704
705 dst.z = (src0.z < 0) ? src1.z : src2.z
706
707 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000708
709
Corbin Simpson85805222010-02-02 16:20:12 -0800710.. opcode:: KIL - Conditional Discard
Keith Whitwella62aaa72009-12-21 23:25:15 +0000711
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800712.. math::
713
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800714 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000715 discard
716 endif
717
718
Corbin Simpson85805222010-02-02 16:20:12 -0800719.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000720
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800721.. math::
722
Corbin Simpsond92a6852009-12-21 19:30:29 -0800723 dst.x = \cos{src.x}
724
725 dst.y = \sin{src.x}
726
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800727 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800728
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800729 dst.y = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000730
731
Corbin Simpson85805222010-02-02 16:20:12 -0800732.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000733
734 TBD
735
736
Corbin Simpson85805222010-02-02 16:20:12 -0800737.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000738
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800739.. math::
740
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800741 dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800742
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800743 dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800744
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800745 dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800746
747 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000748
749
Corbin Simpson85805222010-02-02 16:20:12 -0800750.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000751
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800752.. math::
753
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800754 dst.x = \frac{src0.x}{src1.x}
755
756 dst.y = \frac{src0.y}{src1.y}
757
758 dst.z = \frac{src0.z}{src1.z}
759
760 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000761
762
Corbin Simpson85805222010-02-02 16:20:12 -0800763.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000764
Corbin Simpson17c2a442010-02-02 17:02:28 -0800765This instruction replicates its result.
766
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800767.. math::
768
Corbin Simpson17c2a442010-02-02 17:02:28 -0800769 dst = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000770
771
Corbin Simpson85805222010-02-02 16:20:12 -0800772.. opcode:: TXL - Texture Lookup With LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000773
774 TBD
775
776
Corbin Simpson85805222010-02-02 16:20:12 -0800777.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000778
779 TBD
780
781
Corbin Simpson85805222010-02-02 16:20:12 -0800782.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000783
784 TBD
785
786
Corbin Simpson85805222010-02-02 16:20:12 -0800787.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000788
789 TBD
790
791
Corbin Simpson85805222010-02-02 16:20:12 -0800792.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000793
794 TBD
795
796
Corbin Simpson85805222010-02-02 16:20:12 -0800797.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000798
799 push(src.x)
800 push(src.y)
801 push(src.z)
802 push(src.w)
803
Corbin Simpson17c2a442010-02-02 17:02:28 -0800804.. note::
805
806 Considered for cleanup.
807
808.. note::
809
810 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000811
Corbin Simpson85805222010-02-02 16:20:12 -0800812.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000813
814 dst.w = pop()
815 dst.z = pop()
816 dst.y = pop()
817 dst.x = pop()
818
Corbin Simpson17c2a442010-02-02 17:02:28 -0800819.. note::
820
821 Considered for cleanup.
822
823.. note::
824
825 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000826
Keith Whitwella62aaa72009-12-21 23:25:15 +0000827
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700828Compute ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800829^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000830
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700831These opcodes are primarily provided for special-use computational shaders.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000832Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000833
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700834XXX so let's discuss it, yeah?
835
Corbin Simpson85805222010-02-02 16:20:12 -0800836.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000837
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800838.. math::
839
Corbin Simpson14743ac2009-12-21 19:57:56 -0800840 dst.x = \lceil src.x\rceil
841
842 dst.y = \lceil src.y\rceil
843
844 dst.z = \lceil src.z\rceil
845
846 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000847
848
Corbin Simpson85805222010-02-02 16:20:12 -0800849.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000850
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800851.. math::
852
Keith Whitwella62aaa72009-12-21 23:25:15 +0000853 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800854
Keith Whitwella62aaa72009-12-21 23:25:15 +0000855 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800856
Keith Whitwella62aaa72009-12-21 23:25:15 +0000857 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800858
Keith Whitwella62aaa72009-12-21 23:25:15 +0000859 dst.w = (float) src.w
860
861
Corbin Simpson85805222010-02-02 16:20:12 -0800862.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +0000863
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800864.. math::
865
Keith Whitwella62aaa72009-12-21 23:25:15 +0000866 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800867
Keith Whitwella62aaa72009-12-21 23:25:15 +0000868 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800869
Keith Whitwella62aaa72009-12-21 23:25:15 +0000870 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800871
Keith Whitwella62aaa72009-12-21 23:25:15 +0000872 dst.w = ~src.w
873
874
Corbin Simpson85805222010-02-02 16:20:12 -0800875.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800876
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800877.. math::
878
Keith Whitwella62aaa72009-12-21 23:25:15 +0000879 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800880
Keith Whitwella62aaa72009-12-21 23:25:15 +0000881 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800882
Keith Whitwella62aaa72009-12-21 23:25:15 +0000883 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800884
Keith Whitwella62aaa72009-12-21 23:25:15 +0000885 dst.w = trunc(src.w)
886
887
Corbin Simpson85805222010-02-02 16:20:12 -0800888.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000889
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800890.. math::
891
Keith Whitwella62aaa72009-12-21 23:25:15 +0000892 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800893
Keith Whitwella62aaa72009-12-21 23:25:15 +0000894 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800895
Keith Whitwella62aaa72009-12-21 23:25:15 +0000896 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800897
Keith Whitwella62aaa72009-12-21 23:25:15 +0000898 dst.w = src0.w << src1.x
899
900
Corbin Simpson85805222010-02-02 16:20:12 -0800901.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000902
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800903.. math::
904
Keith Whitwella62aaa72009-12-21 23:25:15 +0000905 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800906
Keith Whitwella62aaa72009-12-21 23:25:15 +0000907 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800908
Keith Whitwella62aaa72009-12-21 23:25:15 +0000909 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800910
Keith Whitwella62aaa72009-12-21 23:25:15 +0000911 dst.w = src0.w >> src1.x
912
913
Corbin Simpson85805222010-02-02 16:20:12 -0800914.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000915
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800916.. math::
917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800919
Keith Whitwella62aaa72009-12-21 23:25:15 +0000920 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800921
Keith Whitwella62aaa72009-12-21 23:25:15 +0000922 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800923
Keith Whitwella62aaa72009-12-21 23:25:15 +0000924 dst.w = src0.w & src1.w
925
926
Corbin Simpson85805222010-02-02 16:20:12 -0800927.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000928
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800929.. math::
930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800932
Keith Whitwella62aaa72009-12-21 23:25:15 +0000933 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800934
Keith Whitwella62aaa72009-12-21 23:25:15 +0000935 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800936
Keith Whitwella62aaa72009-12-21 23:25:15 +0000937 dst.w = src0.w | src1.w
938
939
Corbin Simpson85805222010-02-02 16:20:12 -0800940.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000941
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800942.. math::
943
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800944 dst.x = src0.x \bmod src1.x
945
946 dst.y = src0.y \bmod src1.y
947
948 dst.z = src0.z \bmod src1.z
949
950 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000951
952
Corbin Simpson85805222010-02-02 16:20:12 -0800953.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000954
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800955.. math::
956
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800957 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800958
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800959 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800960
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800961 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800962
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800963 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000964
965
Corbin Simpson85805222010-02-02 16:20:12 -0800966.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +0000967
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800968.. math::
969
Corbin Simpson14743ac2009-12-21 19:57:56 -0800970 dst.x = |src0.x - src1.x| + src2.x
971
972 dst.y = |src0.y - src1.y| + src2.y
973
974 dst.z = |src0.z - src1.z| + src2.z
975
976 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000977
978
Corbin Simpson85805222010-02-02 16:20:12 -0800979.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000980
981 TBD
982
983
Corbin Simpson85805222010-02-02 16:20:12 -0800984.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +0000985
986 TBD
987
988
Corbin Simpson85805222010-02-02 16:20:12 -0800989.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +0000990
991 TBD
992
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700993.. note::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000994
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700995 Support for CONT is determined by a special capability bit,
996 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
997
998
999Geometry ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001001
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001002These opcodes are only supported in geometry shaders; they have no meaning
1003in any other type of shader.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001004
Corbin Simpson85805222010-02-02 16:20:12 -08001005.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001006
1007 TBD
1008
1009
Corbin Simpson85805222010-02-02 16:20:12 -08001010.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001011
1012 TBD
1013
1014
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001015GLSL ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001016^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001017
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001018These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1019opcodes is determined by a special capability bit, ``GLSL``.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001020
Corbin Simpson85805222010-02-02 16:20:12 -08001021.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001022
1023 TBD
1024
1025
Corbin Simpson85805222010-02-02 16:20:12 -08001026.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001027
1028 TBD
1029
1030
Corbin Simpson85805222010-02-02 16:20:12 -08001031.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001032
1033 TBD
1034
1035
Corbin Simpson85805222010-02-02 16:20:12 -08001036.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001037
1038 TBD
1039
1040
Corbin Simpson85805222010-02-02 16:20:12 -08001041.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001042
Michal Krol8ab89d72010-01-04 13:23:41 +01001043 Do nothing.
1044
Keith Whitwella62aaa72009-12-21 23:25:15 +00001045
Corbin Simpson85805222010-02-02 16:20:12 -08001046.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001047
Corbin Simpson17c2a442010-02-02 17:02:28 -08001048This instruction replicates its result.
1049
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001050.. math::
1051
Corbin Simpson17c2a442010-02-02 17:02:28 -08001052 dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +00001053
1054
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001055ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001056^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001057
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001058XXX wait what
Keith Whitwella62aaa72009-12-21 23:25:15 +00001059
Corbin Simpson85805222010-02-02 16:20:12 -08001060.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001061
1062 TBD
1063
1064
Corbin Simpson85805222010-02-02 16:20:12 -08001065.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001066
1067 TBD
1068
1069
Corbin Simpson85805222010-02-02 16:20:12 -08001070.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001071
1072 TBD
1073
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001074.. _doubleopcodes:
1075
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001076Double ISA
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001077^^^^^^^^^^^^^^^
1078
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001079The double-precision opcodes reinterpret four-component vectors into
1080two-component vectors with doubled precision in each component.
1081
1082Support for these opcodes is XXX undecided. :T
1083
1084.. opcode:: DADD - Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001085
1086.. math::
1087
1088 dst.xy = src0.xy + src1.xy
1089
1090 dst.zw = src0.zw + src1.zw
1091
1092
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001093.. opcode:: DDIV - Divide
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001094
1095.. math::
1096
1097 dst.xy = src0.xy / src1.xy
1098
1099 dst.zw = src0.zw / src1.zw
1100
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001101.. opcode:: DSEQ - Set on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001102
1103.. math::
1104
1105 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1106
1107 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1108
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001109.. opcode:: DSLT - Set on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001110
1111.. math::
1112
1113 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1114
1115 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1116
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001117.. opcode:: DFRAC - Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001118
1119.. math::
1120
1121 dst.xy = src.xy - \lfloor src.xy\rfloor
1122
1123 dst.zw = src.zw - \lfloor src.zw\rfloor
1124
1125
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001126.. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001127
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001128Like the ``frexp()`` routine in many math libraries, this opcode stores the
1129exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1130:math:`dst1 \times 2^{dst0} = src` .
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001131
1132.. math::
1133
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001134 dst0.xy = exp(src.xy)
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001135
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001136 dst1.xy = frac(src.xy)
1137
1138 dst0.zw = exp(src.zw)
1139
1140 dst1.zw = frac(src.zw)
1141
1142.. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1143
1144This opcode is the inverse of :opcode:`DFRACEXP`.
1145
1146.. math::
1147
1148 dst.xy = src0.xy \times 2^{src1.xy}
1149
1150 dst.zw = src0.zw \times 2^{src1.zw}
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001151
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001152.. opcode:: DMIN - Minimum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001153
1154.. math::
1155
1156 dst.xy = min(src0.xy, src1.xy)
1157
1158 dst.zw = min(src0.zw, src1.zw)
1159
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001160.. opcode:: DMAX - Maximum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001161
1162.. math::
1163
1164 dst.xy = max(src0.xy, src1.xy)
1165
1166 dst.zw = max(src0.zw, src1.zw)
1167
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001168.. opcode:: DMUL - Multiply
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001169
1170.. math::
1171
1172 dst.xy = src0.xy \times src1.xy
1173
1174 dst.zw = src0.zw \times src1.zw
1175
1176
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001177.. opcode:: DMAD - Multiply And Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001178
1179.. math::
1180
1181 dst.xy = src0.xy \times src1.xy + src2.xy
1182
1183 dst.zw = src0.zw \times src1.zw + src2.zw
1184
1185
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001186.. opcode:: DRCP - Reciprocal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001187
1188.. math::
1189
1190 dst.xy = \frac{1}{src.xy}
1191
1192 dst.zw = \frac{1}{src.zw}
1193
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001194.. opcode:: DSQRT - Square Root
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001195
1196.. math::
1197
1198 dst.xy = \sqrt{src.xy}
1199
1200 dst.zw = \sqrt{src.zw}
1201
Keith Whitwella62aaa72009-12-21 23:25:15 +00001202
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001203Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001204------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001205
1206
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001207Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001208^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001209
1210
Corbin Simpson14743ac2009-12-21 19:57:56 -08001211 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001212
Corbin Simpson14743ac2009-12-21 19:57:56 -08001213 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001214
1215 clamp(x,y,z) Clamp x between y and z.
1216 (x < y) ? y : (x > z) ? z : x
1217
Corbin Simpsondd801e52009-12-21 19:41:09 -08001218 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001219
Corbin Simpson14743ac2009-12-21 19:57:56 -08001220 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001221
1222 max(x,y) Maximum of x and y.
1223 (x > y) ? x : y
1224
1225 min(x,y) Minimum of x and y.
1226 (x < y) ? x : y
1227
1228 partialx(x) Derivative of x relative to fragment's X.
1229
1230 partialy(x) Derivative of x relative to fragment's Y.
1231
1232 pop() Pop from stack.
1233
Corbin Simpsondd801e52009-12-21 19:41:09 -08001234 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001235
1236 push(x) Push x on stack.
1237
1238 round(x) Round x.
1239
Michal Krol07f416c2010-01-04 13:21:32 +01001240 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001241
1242
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001243Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001244^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001245
1246
1247 discard Discard fragment.
1248
Keith Whitwella62aaa72009-12-21 23:25:15 +00001249 pc Program counter.
1250
Keith Whitwella62aaa72009-12-21 23:25:15 +00001251 target Label of target instruction.
1252
1253
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001254Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001255---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001256
1257
Michal Krol63d60972010-02-03 15:45:32 +01001258Declaration
1259^^^^^^^^^^^
1260
1261
1262Declares a register that is will be referenced as an operand in Instruction
1263tokens.
1264
1265File field contains register file that is being declared and is one
1266of TGSI_FILE.
1267
1268UsageMask field specifies which of the register components can be accessed
1269and is one of TGSI_WRITEMASK.
1270
1271Interpolate field is only valid for fragment shader INPUT register files.
1272It specifes the way input is being interpolated by the rasteriser and is one
1273of TGSI_INTERPOLATE.
1274
1275If Dimension flag is set to 1, a Declaration Dimension token follows.
1276
1277If Semantic flag is set to 1, a Declaration Semantic token follows.
1278
1279CylindricalWrap bitfield is only valid for fragment shader INPUT register
1280files. It specifies which register components should be subject to cylindrical
1281wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1282is set to 1, the X component should be interpolated according to cylindrical
1283wrapping rules.
1284
1285
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001286Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001287^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001288
1289
1290 Follows Declaration token if Semantic bit is set.
1291
1292 Since its purpose is to link a shader with other stages of the pipeline,
1293 it is valid to follow only those Declaration tokens that declare a register
1294 either in INPUT or OUTPUT file.
1295
1296 SemanticName field contains the semantic name of the register being declared.
1297 There is no default value.
1298
1299 SemanticIndex is an optional subscript that can be used to distinguish
1300 different register declarations with the same semantic name. The default value
1301 is 0.
1302
1303 The meanings of the individual semantic names are explained in the following
1304 sections.
1305
Corbin Simpson54ddf642009-12-23 23:36:06 -08001306TGSI_SEMANTIC_POSITION
1307""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001308
Corbin Simpson54ddf642009-12-23 23:36:06 -08001309Position, sometimes known as HPOS or WPOS for historical reasons, is the
1310location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1311are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1312for the perspective divide, if enabled.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001313
Corbin Simpson54ddf642009-12-23 23:36:06 -08001314As a vertex shader output, position should be scaled to the viewport. When
Luca Barbieri73317132010-01-21 05:36:14 +01001315used in fragment shaders, position will be in window coordinates. The convention
1316used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001317
1318XXX additionally, is there a way to configure the perspective divide? it's
1319accelerated on most chipsets AFAIK...
1320
1321Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1322be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1323
1324XXX usually? can we solidify that?
1325
1326TGSI_SEMANTIC_COLOR
1327"""""""""""""""""""
1328
1329Colors are used to, well, color the primitives. Colors are always in
1330``(r, g, b, a)`` format.
1331
1332If alpha is not specified, it defaults to 1.
1333
1334TGSI_SEMANTIC_BCOLOR
1335""""""""""""""""""""
1336
1337Back-facing colors are only used for back-facing polygons, and are only valid
1338in vertex shader outputs. After rasterization, all polygons are front-facing
1339and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1340all BCOLORs effectively become regular COLORs in the fragment shader.
1341
1342TGSI_SEMANTIC_FOG
1343"""""""""""""""""
1344
1345The fog coordinate historically has been used to replace the depth coordinate
1346for generation of fog in dedicated fog blocks. Gallium, however, does not use
1347dedicated fog acceleration, placing it entirely in the fragment shader
1348instead.
1349
1350The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1351component matters when writing from the vertex shader; the driver will ensure
1352that the coordinate is in this format when used as a fragment shader input.
1353
1354TGSI_SEMANTIC_PSIZE
1355"""""""""""""""""""
1356
1357PSIZE, or point size, is used to specify point sizes per-vertex. It should
Roland Scheidegger8091e732010-02-03 18:27:32 +01001358be in ``(s, 0, 0, 1)`` format, where ``s`` is the (possibly clamped) point size.
1359Only the first component matters when writing from the vertex shader.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001360
1361When using this semantic, be sure to set the appropriate state in the
1362:ref:`rasterizer` first.
1363
1364TGSI_SEMANTIC_GENERIC
1365"""""""""""""""""""""
1366
1367Generic semantics are nearly always used for texture coordinate attributes,
1368in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1369of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1370
1371These attributes are called "generic" because they may be used for anything
1372else, including parameters, texture generation information, or anything that
1373can be stored inside a four-component vector.
1374
1375TGSI_SEMANTIC_NORMAL
1376""""""""""""""""""""
1377
Michal Krol86b336f2010-01-04 13:38:58 +01001378Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1379that allow mixing fixed-function and programmable stages.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001380
1381TGSI_SEMANTIC_FACE
1382""""""""""""""""""
1383
1384FACE is the facing bit, to store the facing information for the fragment
1385shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1386when the fragment is front-facing, and negative when the component is
1387back-facing.
1388
1389TGSI_SEMANTIC_EDGEFLAG
1390""""""""""""""""""""""
1391
1392XXX no clue
Luca Barbieri73317132010-01-21 05:36:14 +01001393
1394
1395Properties
1396^^^^^^^^^^^^^^^^^^^^^^^^
1397
1398
1399 Properties are general directives that apply to the whole TGSI program.
1400
1401FS_COORD_ORIGIN
1402"""""""""""""""
1403
1404Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1405The default value is UPPER_LEFT.
1406
1407If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1408increase downward and rightward.
1409If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1410increase upward and rightward.
1411
1412OpenGL defaults to LOWER_LEFT, and is configurable with the
1413GL_ARB_fragment_coord_conventions extension.
1414
1415DirectX 9/10 use UPPER_LEFT.
1416
1417FS_COORD_PIXEL_CENTER
1418"""""""""""""""""""""
1419
1420Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1421The default value is HALF_INTEGER.
1422
1423If HALF_INTEGER, the fractionary part of the position will be 0.5
1424If INTEGER, the fractionary part of the position will be 0.0
1425
1426Note that this does not affect the set of fragments generated by
1427rasterization, which is instead controlled by gl_rasterization_rules in the
1428rasterizer.
1429
1430OpenGL defaults to HALF_INTEGER, and is configurable with the
1431GL_ARB_fragment_coord_conventions extension.
1432
1433DirectX 9 uses INTEGER.
1434DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001435
1436
1437
1438Texture Sampling and Texture Formats
1439------------------------------------
1440
Corbin Simpson797dcc02010-02-02 17:07:26 -08001441This table shows how texture image components are returned as (x,y,z,w) tuples
1442by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1443:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1444well.
Brian Paul4778f462010-02-02 08:14:40 -07001445
Corbin Simpson516e7152010-02-02 12:44:22 -08001446+--------------------+--------------+--------------------+--------------+
1447| Texture Components | Gallium | OpenGL | Direct3D 9 |
1448+====================+==============+====================+==============+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001449| R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001450+--------------------+--------------+--------------------+--------------+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001451| RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001452+--------------------+--------------+--------------------+--------------+
1453| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1454+--------------------+--------------+--------------------+--------------+
1455| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1456+--------------------+--------------+--------------------+--------------+
1457| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1458+--------------------+--------------+--------------------+--------------+
1459| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1460+--------------------+--------------+--------------------+--------------+
1461| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1462+--------------------+--------------+--------------------+--------------+
1463| I | (i, i, i, i) | (i, i, i, i) | N/A |
1464+--------------------+--------------+--------------------+--------------+
1465| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1466| | | [#envmap-bumpmap]_ | |
1467+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001468| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001469| | | [#depth-tex-mode]_ | |
1470+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001471
Corbin Simpson516e7152010-02-02 12:44:22 -08001472.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001473.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
Corbin Simpson797dcc02010-02-02 17:07:26 -08001474 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.