blob: d99ed7c6d6b24acb10b7b4b8b5c84e682c811450 [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
681
Corbin Simpson85805222010-02-02 16:20:12 -0800682.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000683
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800684.. math::
685
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800686 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
687
688 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
689
690 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
691
692 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000693
694
Corbin Simpson85805222010-02-02 16:20:12 -0800695.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000696
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800697.. math::
698
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800699 dst.x = (src0.x < 0) ? src1.x : src2.x
700
701 dst.y = (src0.y < 0) ? src1.y : src2.y
702
703 dst.z = (src0.z < 0) ? src1.z : src2.z
704
705 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000706
707
Corbin Simpson85805222010-02-02 16:20:12 -0800708.. opcode:: KIL - Conditional Discard
Keith Whitwella62aaa72009-12-21 23:25:15 +0000709
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800710.. math::
711
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800712 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000713 discard
714 endif
715
716
Corbin Simpson85805222010-02-02 16:20:12 -0800717.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000718
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800719.. math::
720
Corbin Simpsond92a6852009-12-21 19:30:29 -0800721 dst.x = \cos{src.x}
722
723 dst.y = \sin{src.x}
724
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800725 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800726
Tilman Sauerbeckd3231182010-09-19 09:03:11 +0200727 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000728
729
Corbin Simpson85805222010-02-02 16:20:12 -0800730.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000731
732 TBD
733
734
Corbin Simpson85805222010-02-02 16:20:12 -0800735.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000736
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800737.. math::
738
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800739 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 -0800740
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800741 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 -0800742
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800743 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 -0800744
745 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000746
747
Corbin Simpson85805222010-02-02 16:20:12 -0800748.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000749
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800750.. math::
751
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800752 dst.x = \frac{src0.x}{src1.x}
753
754 dst.y = \frac{src0.y}{src1.y}
755
756 dst.z = \frac{src0.z}{src1.z}
757
758 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000759
760
Corbin Simpson85805222010-02-02 16:20:12 -0800761.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000762
Corbin Simpson17c2a442010-02-02 17:02:28 -0800763This instruction replicates its result.
764
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800765.. math::
766
Corbin Simpson17c2a442010-02-02 17:02:28 -0800767 dst = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000768
769
Corbin Simpson85805222010-02-02 16:20:12 -0800770.. opcode:: TXL - Texture Lookup With LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000771
772 TBD
773
774
Corbin Simpson85805222010-02-02 16:20:12 -0800775.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000776
777 TBD
778
779
Corbin Simpson85805222010-02-02 16:20:12 -0800780.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000781
782 TBD
783
784
Corbin Simpson85805222010-02-02 16:20:12 -0800785.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000786
787 TBD
788
789
Corbin Simpson85805222010-02-02 16:20:12 -0800790.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000791
792 TBD
793
794
Corbin Simpson85805222010-02-02 16:20:12 -0800795.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000796
797 push(src.x)
798 push(src.y)
799 push(src.z)
800 push(src.w)
801
Corbin Simpson17c2a442010-02-02 17:02:28 -0800802.. note::
803
804 Considered for cleanup.
805
806.. note::
807
808 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000809
Corbin Simpson85805222010-02-02 16:20:12 -0800810.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000811
812 dst.w = pop()
813 dst.z = pop()
814 dst.y = pop()
815 dst.x = pop()
816
Corbin Simpson17c2a442010-02-02 17:02:28 -0800817.. note::
818
819 Considered for cleanup.
820
821.. note::
822
823 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000824
Keith Whitwella62aaa72009-12-21 23:25:15 +0000825
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700826Compute ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800827^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000828
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700829These opcodes are primarily provided for special-use computational shaders.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000830Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000831
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700832XXX so let's discuss it, yeah?
833
Corbin Simpson85805222010-02-02 16:20:12 -0800834.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000835
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800836.. math::
837
Corbin Simpson14743ac2009-12-21 19:57:56 -0800838 dst.x = \lceil src.x\rceil
839
840 dst.y = \lceil src.y\rceil
841
842 dst.z = \lceil src.z\rceil
843
844 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000845
846
Corbin Simpson85805222010-02-02 16:20:12 -0800847.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000848
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800849.. math::
850
Keith Whitwella62aaa72009-12-21 23:25:15 +0000851 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800852
Keith Whitwella62aaa72009-12-21 23:25:15 +0000853 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800854
Keith Whitwella62aaa72009-12-21 23:25:15 +0000855 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800856
Keith Whitwella62aaa72009-12-21 23:25:15 +0000857 dst.w = (float) src.w
858
859
Corbin Simpson85805222010-02-02 16:20:12 -0800860.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +0000861
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800862.. math::
863
Keith Whitwella62aaa72009-12-21 23:25:15 +0000864 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800865
Keith Whitwella62aaa72009-12-21 23:25:15 +0000866 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800867
Keith Whitwella62aaa72009-12-21 23:25:15 +0000868 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800869
Keith Whitwella62aaa72009-12-21 23:25:15 +0000870 dst.w = ~src.w
871
872
Corbin Simpson85805222010-02-02 16:20:12 -0800873.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800874
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800875.. math::
876
Keith Whitwella62aaa72009-12-21 23:25:15 +0000877 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800878
Keith Whitwella62aaa72009-12-21 23:25:15 +0000879 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800880
Keith Whitwella62aaa72009-12-21 23:25:15 +0000881 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800882
Keith Whitwella62aaa72009-12-21 23:25:15 +0000883 dst.w = trunc(src.w)
884
885
Corbin Simpson85805222010-02-02 16:20:12 -0800886.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000887
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800888.. math::
889
Keith Whitwella62aaa72009-12-21 23:25:15 +0000890 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800891
Keith Whitwella62aaa72009-12-21 23:25:15 +0000892 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800893
Keith Whitwella62aaa72009-12-21 23:25:15 +0000894 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800895
Keith Whitwella62aaa72009-12-21 23:25:15 +0000896 dst.w = src0.w << src1.x
897
898
Corbin Simpson85805222010-02-02 16:20:12 -0800899.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000900
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800901.. math::
902
Keith Whitwella62aaa72009-12-21 23:25:15 +0000903 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800904
Keith Whitwella62aaa72009-12-21 23:25:15 +0000905 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800906
Keith Whitwella62aaa72009-12-21 23:25:15 +0000907 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800908
Keith Whitwella62aaa72009-12-21 23:25:15 +0000909 dst.w = src0.w >> src1.x
910
911
Corbin Simpson85805222010-02-02 16:20:12 -0800912.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000913
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800914.. math::
915
Keith Whitwella62aaa72009-12-21 23:25:15 +0000916 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800919
Keith Whitwella62aaa72009-12-21 23:25:15 +0000920 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800921
Keith Whitwella62aaa72009-12-21 23:25:15 +0000922 dst.w = src0.w & src1.w
923
924
Corbin Simpson85805222010-02-02 16:20:12 -0800925.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000926
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800927.. math::
928
Keith Whitwella62aaa72009-12-21 23:25:15 +0000929 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800932
Keith Whitwella62aaa72009-12-21 23:25:15 +0000933 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800934
Keith Whitwella62aaa72009-12-21 23:25:15 +0000935 dst.w = src0.w | src1.w
936
937
Corbin Simpson85805222010-02-02 16:20:12 -0800938.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000939
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800940.. math::
941
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800942 dst.x = src0.x \bmod src1.x
943
944 dst.y = src0.y \bmod src1.y
945
946 dst.z = src0.z \bmod src1.z
947
948 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000949
950
Corbin Simpson85805222010-02-02 16:20:12 -0800951.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000952
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800953.. math::
954
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800955 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800956
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800957 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800958
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800959 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800960
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800961 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000962
963
Corbin Simpson85805222010-02-02 16:20:12 -0800964.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +0000965
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800966.. math::
967
Corbin Simpson14743ac2009-12-21 19:57:56 -0800968 dst.x = |src0.x - src1.x| + src2.x
969
970 dst.y = |src0.y - src1.y| + src2.y
971
972 dst.z = |src0.z - src1.z| + src2.z
973
974 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000975
976
Corbin Simpson85805222010-02-02 16:20:12 -0800977.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000978
979 TBD
980
981
Corbin Simpson85805222010-02-02 16:20:12 -0800982.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +0000983
984 TBD
985
986
Corbin Simpson85805222010-02-02 16:20:12 -0800987.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +0000988
989 TBD
990
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700991.. note::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000992
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700993 Support for CONT is determined by a special capability bit,
994 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
995
996
997Geometry ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800998^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000999
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001000These opcodes are only supported in geometry shaders; they have no meaning
1001in any other type of shader.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001002
Corbin Simpson85805222010-02-02 16:20:12 -08001003.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001004
1005 TBD
1006
1007
Corbin Simpson85805222010-02-02 16:20:12 -08001008.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001009
1010 TBD
1011
1012
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001013GLSL ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001014^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001015
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001016These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1017opcodes is determined by a special capability bit, ``GLSL``.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001018
Corbin Simpson85805222010-02-02 16:20:12 -08001019.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001020
1021 TBD
1022
1023
Corbin Simpson85805222010-02-02 16:20:12 -08001024.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001025
1026 TBD
1027
1028
Corbin Simpson85805222010-02-02 16:20:12 -08001029.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001030
1031 TBD
1032
1033
Corbin Simpson85805222010-02-02 16:20:12 -08001034.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001035
1036 TBD
1037
1038
Corbin Simpson85805222010-02-02 16:20:12 -08001039.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001040
Michal Krol8ab89d72010-01-04 13:23:41 +01001041 Do nothing.
1042
Keith Whitwella62aaa72009-12-21 23:25:15 +00001043
Corbin Simpson85805222010-02-02 16:20:12 -08001044.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001045
Corbin Simpson17c2a442010-02-02 17:02:28 -08001046This instruction replicates its result.
1047
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001048.. math::
1049
Corbin Simpson17c2a442010-02-02 17:02:28 -08001050 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 +00001051
1052
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001053ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001054^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001055
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001056XXX wait what
Keith Whitwella62aaa72009-12-21 23:25:15 +00001057
Corbin Simpson85805222010-02-02 16:20:12 -08001058.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001059
1060 TBD
1061
1062
Corbin Simpson85805222010-02-02 16:20:12 -08001063.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001064
1065 TBD
1066
1067
Corbin Simpson85805222010-02-02 16:20:12 -08001068.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001069
1070 TBD
1071
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001072.. _doubleopcodes:
1073
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001074Double ISA
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001075^^^^^^^^^^^^^^^
1076
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001077The double-precision opcodes reinterpret four-component vectors into
1078two-component vectors with doubled precision in each component.
1079
1080Support for these opcodes is XXX undecided. :T
1081
1082.. opcode:: DADD - Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001083
1084.. math::
1085
1086 dst.xy = src0.xy + src1.xy
1087
1088 dst.zw = src0.zw + src1.zw
1089
1090
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001091.. opcode:: DDIV - Divide
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001092
1093.. math::
1094
1095 dst.xy = src0.xy / src1.xy
1096
1097 dst.zw = src0.zw / src1.zw
1098
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001099.. opcode:: DSEQ - Set on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001100
1101.. math::
1102
1103 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1104
1105 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1106
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001107.. opcode:: DSLT - Set on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001108
1109.. math::
1110
1111 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1112
1113 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1114
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001115.. opcode:: DFRAC - Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001116
1117.. math::
1118
1119 dst.xy = src.xy - \lfloor src.xy\rfloor
1120
1121 dst.zw = src.zw - \lfloor src.zw\rfloor
1122
1123
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001124.. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001125
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001126Like the ``frexp()`` routine in many math libraries, this opcode stores the
1127exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1128:math:`dst1 \times 2^{dst0} = src` .
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001129
1130.. math::
1131
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001132 dst0.xy = exp(src.xy)
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001133
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001134 dst1.xy = frac(src.xy)
1135
1136 dst0.zw = exp(src.zw)
1137
1138 dst1.zw = frac(src.zw)
1139
1140.. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1141
1142This opcode is the inverse of :opcode:`DFRACEXP`.
1143
1144.. math::
1145
1146 dst.xy = src0.xy \times 2^{src1.xy}
1147
1148 dst.zw = src0.zw \times 2^{src1.zw}
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001149
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001150.. opcode:: DMIN - Minimum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001151
1152.. math::
1153
1154 dst.xy = min(src0.xy, src1.xy)
1155
1156 dst.zw = min(src0.zw, src1.zw)
1157
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001158.. opcode:: DMAX - Maximum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001159
1160.. math::
1161
1162 dst.xy = max(src0.xy, src1.xy)
1163
1164 dst.zw = max(src0.zw, src1.zw)
1165
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001166.. opcode:: DMUL - Multiply
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001167
1168.. math::
1169
1170 dst.xy = src0.xy \times src1.xy
1171
1172 dst.zw = src0.zw \times src1.zw
1173
1174
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001175.. opcode:: DMAD - Multiply And Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001176
1177.. math::
1178
1179 dst.xy = src0.xy \times src1.xy + src2.xy
1180
1181 dst.zw = src0.zw \times src1.zw + src2.zw
1182
1183
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001184.. opcode:: DRCP - Reciprocal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001185
1186.. math::
1187
1188 dst.xy = \frac{1}{src.xy}
1189
1190 dst.zw = \frac{1}{src.zw}
1191
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001192.. opcode:: DSQRT - Square Root
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001193
1194.. math::
1195
1196 dst.xy = \sqrt{src.xy}
1197
1198 dst.zw = \sqrt{src.zw}
1199
Keith Whitwella62aaa72009-12-21 23:25:15 +00001200
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001201Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001202------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001203
1204
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001205Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001206^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001207
1208
Corbin Simpson14743ac2009-12-21 19:57:56 -08001209 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001210
Corbin Simpson14743ac2009-12-21 19:57:56 -08001211 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001212
1213 clamp(x,y,z) Clamp x between y and z.
1214 (x < y) ? y : (x > z) ? z : x
1215
Corbin Simpsondd801e52009-12-21 19:41:09 -08001216 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001217
Corbin Simpson14743ac2009-12-21 19:57:56 -08001218 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001219
1220 max(x,y) Maximum of x and y.
1221 (x > y) ? x : y
1222
1223 min(x,y) Minimum of x and y.
1224 (x < y) ? x : y
1225
1226 partialx(x) Derivative of x relative to fragment's X.
1227
1228 partialy(x) Derivative of x relative to fragment's Y.
1229
1230 pop() Pop from stack.
1231
Corbin Simpsondd801e52009-12-21 19:41:09 -08001232 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001233
1234 push(x) Push x on stack.
1235
1236 round(x) Round x.
1237
Michal Krol07f416c2010-01-04 13:21:32 +01001238 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001239
1240
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001241Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001242^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001243
1244
1245 discard Discard fragment.
1246
Keith Whitwella62aaa72009-12-21 23:25:15 +00001247 pc Program counter.
1248
Keith Whitwella62aaa72009-12-21 23:25:15 +00001249 target Label of target instruction.
1250
1251
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001252Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001253---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001254
1255
Michal Krol63d60972010-02-03 15:45:32 +01001256Declaration
1257^^^^^^^^^^^
1258
1259
1260Declares a register that is will be referenced as an operand in Instruction
1261tokens.
1262
1263File field contains register file that is being declared and is one
1264of TGSI_FILE.
1265
1266UsageMask field specifies which of the register components can be accessed
1267and is one of TGSI_WRITEMASK.
1268
1269Interpolate field is only valid for fragment shader INPUT register files.
1270It specifes the way input is being interpolated by the rasteriser and is one
1271of TGSI_INTERPOLATE.
1272
1273If Dimension flag is set to 1, a Declaration Dimension token follows.
1274
1275If Semantic flag is set to 1, a Declaration Semantic token follows.
1276
1277CylindricalWrap bitfield is only valid for fragment shader INPUT register
1278files. It specifies which register components should be subject to cylindrical
1279wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1280is set to 1, the X component should be interpolated according to cylindrical
1281wrapping rules.
1282
1283
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001284Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001285^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001286
Brian Paul05a18f42010-06-24 07:21:15 -06001287 Vertex and fragment shader input and output registers may be labeled
1288 with semantic information consisting of a name and index.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001289
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
Brian Paul50b3f2e2010-06-23 17:00:10 -06001309For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
1310output register which contains the homogeneous vertex position in the clip
1311space coordinate system. After clipping, the X, Y and Z components of the
1312vertex will be divided by the W value to get normalized device coordinates.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001313
Brian Paul50b3f2e2010-06-23 17:00:10 -06001314For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
1315fragment shader input contains the fragment's window position. The X
1316component starts at zero and always increases from left to right.
1317The Y component starts at zero and always increases but Y=0 may either
1318indicate the top of the window or the bottom depending on the fragment
1319coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
1320The Z coordinate ranges from 0 to 1 to represent depth from the front
1321to the back of the Z buffer. The W component contains the reciprocol
1322of the interpolated vertex position W component.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001323
Brian Paul05a18f42010-06-24 07:21:15 -06001324Fragment shaders may also declare an output register with
1325TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
1326the fragment shader to change the fragment's Z position.
1327
Corbin Simpson54ddf642009-12-23 23:36:06 -08001328
Corbin Simpson54ddf642009-12-23 23:36:06 -08001329
1330TGSI_SEMANTIC_COLOR
1331"""""""""""""""""""
1332
Brian Paul50b3f2e2010-06-23 17:00:10 -06001333For vertex shader outputs or fragment shader inputs/outputs, this
1334label indicates that the resister contains an R,G,B,A color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001335
Brian Paul50b3f2e2010-06-23 17:00:10 -06001336Several shader inputs/outputs may contain colors so the semantic index
1337is used to distinguish them. For example, color[0] may be the diffuse
1338color while color[1] may be the specular color.
1339
1340This label is needed so that the flat/smooth shading can be applied
1341to the right interpolants during rasterization.
1342
1343
Corbin Simpson54ddf642009-12-23 23:36:06 -08001344
1345TGSI_SEMANTIC_BCOLOR
1346""""""""""""""""""""
1347
1348Back-facing colors are only used for back-facing polygons, and are only valid
1349in vertex shader outputs. After rasterization, all polygons are front-facing
Brian Paul50b3f2e2010-06-23 17:00:10 -06001350and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
1351so all BCOLORs effectively become regular COLORs in the fragment shader.
1352
Corbin Simpson54ddf642009-12-23 23:36:06 -08001353
1354TGSI_SEMANTIC_FOG
1355"""""""""""""""""
1356
Brian Paul05a18f42010-06-24 07:21:15 -06001357Vertex shader inputs and outputs and fragment shader inputs may be
1358labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
1359a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
1360shader will use the fog coordinate to compute a fog blend factor which
1361is used to blend the normal fragment color with a constant fog color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001362
Brian Paul05a18f42010-06-24 07:21:15 -06001363Only the first component matters when writing from the vertex shader;
1364the driver will ensure that the coordinate is in this format when used
1365as a fragment shader input.
1366
Corbin Simpson54ddf642009-12-23 23:36:06 -08001367
1368TGSI_SEMANTIC_PSIZE
1369"""""""""""""""""""
1370
Brian Paul05a18f42010-06-24 07:21:15 -06001371Vertex shader input and output registers may be labeled with
1372TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
1373in the form (S, 0, 0, 1). The point size controls the width or diameter
1374of points for rasterization. This label cannot be used in fragment
1375shaders.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001376
1377When using this semantic, be sure to set the appropriate state in the
1378:ref:`rasterizer` first.
1379
Brian Paul05a18f42010-06-24 07:21:15 -06001380
Corbin Simpson54ddf642009-12-23 23:36:06 -08001381TGSI_SEMANTIC_GENERIC
1382"""""""""""""""""""""
1383
Brian Paul05a18f42010-06-24 07:21:15 -06001384All vertex/fragment shader inputs/outputs not labeled with any other
1385semantic label can be considered to be generic attributes. Typical
1386uses of generic inputs/outputs are texcoords and user-defined values.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001387
Corbin Simpson54ddf642009-12-23 23:36:06 -08001388
1389TGSI_SEMANTIC_NORMAL
1390""""""""""""""""""""
1391
Brian Paul05a18f42010-06-24 07:21:15 -06001392Indicates that a vertex shader input is a normal vector. This is
1393typically only used for legacy graphics APIs.
1394
Corbin Simpson54ddf642009-12-23 23:36:06 -08001395
1396TGSI_SEMANTIC_FACE
1397""""""""""""""""""
1398
Brian Paul05a18f42010-06-24 07:21:15 -06001399This label applies to fragment shader inputs only and indicates that
1400the register contains front/back-face information of the form (F, 0,
14010, 1). The first component will be positive when the fragment belongs
1402to a front-facing polygon, and negative when the fragment belongs to a
1403back-facing polygon.
1404
Corbin Simpson54ddf642009-12-23 23:36:06 -08001405
1406TGSI_SEMANTIC_EDGEFLAG
1407""""""""""""""""""""""
1408
Brian Paul73153002010-06-23 17:38:58 -06001409For vertex shaders, this sematic label indicates that an input or
1410output is a boolean edge flag. The register layout is [F, x, x, x]
1411where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
1412simply copies the edge flag input to the edgeflag output.
1413
1414Edge flags are used to control which lines or points are actually
1415drawn when the polygon mode converts triangles/quads/polygons into
1416points or lines.
1417
Dave Airlie4ecb2c12010-10-06 09:28:46 +10001418TGSI_SEMANTIC_STENCIL
1419""""""""""""""""""""""
1420
1421For fragment shaders, this semantic label indicates than an output
1422is a writable stencil reference value. Only the Y component is writable.
1423This allows the fragment shader to change the fragments stencilref value.
Luca Barbieri73317132010-01-21 05:36:14 +01001424
1425
1426Properties
1427^^^^^^^^^^^^^^^^^^^^^^^^
1428
1429
1430 Properties are general directives that apply to the whole TGSI program.
1431
1432FS_COORD_ORIGIN
1433"""""""""""""""
1434
1435Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1436The default value is UPPER_LEFT.
1437
1438If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1439increase downward and rightward.
1440If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1441increase upward and rightward.
1442
1443OpenGL defaults to LOWER_LEFT, and is configurable with the
1444GL_ARB_fragment_coord_conventions extension.
1445
1446DirectX 9/10 use UPPER_LEFT.
1447
1448FS_COORD_PIXEL_CENTER
1449"""""""""""""""""""""
1450
1451Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1452The default value is HALF_INTEGER.
1453
1454If HALF_INTEGER, the fractionary part of the position will be 0.5
1455If INTEGER, the fractionary part of the position will be 0.0
1456
1457Note that this does not affect the set of fragments generated by
1458rasterization, which is instead controlled by gl_rasterization_rules in the
1459rasterizer.
1460
1461OpenGL defaults to HALF_INTEGER, and is configurable with the
1462GL_ARB_fragment_coord_conventions extension.
1463
1464DirectX 9 uses INTEGER.
1465DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001466
1467
1468
1469Texture Sampling and Texture Formats
1470------------------------------------
1471
Corbin Simpson797dcc02010-02-02 17:07:26 -08001472This table shows how texture image components are returned as (x,y,z,w) tuples
1473by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1474:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1475well.
Brian Paul4778f462010-02-02 08:14:40 -07001476
Corbin Simpson516e7152010-02-02 12:44:22 -08001477+--------------------+--------------+--------------------+--------------+
1478| Texture Components | Gallium | OpenGL | Direct3D 9 |
1479+====================+==============+====================+==============+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001480| R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001481+--------------------+--------------+--------------------+--------------+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001482| RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001483+--------------------+--------------+--------------------+--------------+
1484| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1485+--------------------+--------------+--------------------+--------------+
1486| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1487+--------------------+--------------+--------------------+--------------+
1488| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1489+--------------------+--------------+--------------------+--------------+
1490| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1491+--------------------+--------------+--------------------+--------------+
1492| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1493+--------------------+--------------+--------------------+--------------+
1494| I | (i, i, i, i) | (i, i, i, i) | N/A |
1495+--------------------+--------------+--------------------+--------------+
1496| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1497| | | [#envmap-bumpmap]_ | |
1498+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001499| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001500| | | [#depth-tex-mode]_ | |
1501+--------------------+--------------+--------------------+--------------+
Dave Airlie66a0d1e2010-10-06 09:30:17 +10001502| S | (s, s, s, s) | unknown | unknown |
1503+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001504
Corbin Simpson516e7152010-02-02 12:44:22 -08001505.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001506.. [#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 -08001507 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.