blob: fc5482d38421ea9bac7740078133879bdde1314a [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 Simpsone8ed3b92009-12-21 19:12:55 -080029From GL_NV_vertex_program
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080030^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000031
32
Corbin Simpson85805222010-02-02 16:20:12 -080033.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080034
35.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000036
Corbin Simpsond92a6852009-12-21 19:30:29 -080037 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080038
Corbin Simpsond92a6852009-12-21 19:30:29 -080039 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080040
Corbin Simpsond92a6852009-12-21 19:30:29 -080041 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080042
Corbin Simpsond92a6852009-12-21 19:30:29 -080043 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000044
45
Corbin Simpson85805222010-02-02 16:20:12 -080046.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080047
48.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000049
50 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080051
Keith Whitwella62aaa72009-12-21 23:25:15 +000052 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080053
Keith Whitwella62aaa72009-12-21 23:25:15 +000054 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080055
Keith Whitwella62aaa72009-12-21 23:25:15 +000056 dst.w = src.w
57
58
Corbin Simpson85805222010-02-02 16:20:12 -080059.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080060
61.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000062
Corbin Simpsonda65ac62009-12-21 20:32:46 -080063 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080064
Corbin Simpsonda65ac62009-12-21 20:32:46 -080065 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080066
Corbin Simpsonda65ac62009-12-21 20:32:46 -080067 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080068
Corbin Simpsonda65ac62009-12-21 20:32:46 -080069 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000070
71
Corbin Simpson85805222010-02-02 16:20:12 -080072.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080073
Corbin Simpson17c2a442010-02-02 17:02:28 -080074This instruction replicates its result.
75
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080076.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000077
Corbin Simpson17c2a442010-02-02 17:02:28 -080078 dst = \frac{1}{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +000079
80
Corbin Simpson85805222010-02-02 16:20:12 -080081.. opcode:: RSQ - Reciprocal Square Root
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080082
Corbin Simpson17c2a442010-02-02 17:02:28 -080083This instruction replicates its result.
84
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080085.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000086
Corbin Simpson17c2a442010-02-02 17:02:28 -080087 dst = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +000088
89
Corbin Simpson85805222010-02-02 16:20:12 -080090.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080091
92.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000093
Corbin Simpsondd801e52009-12-21 19:41:09 -080094 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080095
Corbin Simpsond92a6852009-12-21 19:30:29 -080096 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080097
Corbin Simpsondd801e52009-12-21 19:41:09 -080098 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800100 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000101
102
Corbin Simpson85805222010-02-02 16:20:12 -0800103.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800104
105.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000106
Corbin Simpson14743ac2009-12-21 19:57:56 -0800107 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800108
Corbin Simpson14743ac2009-12-21 19:57:56 -0800109 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800110
Corbin Simpson14743ac2009-12-21 19:57:56 -0800111 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800112
Corbin Simpson14743ac2009-12-21 19:57:56 -0800113 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000114
115
Corbin Simpson85805222010-02-02 16:20:12 -0800116.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800117
118.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000119
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800120 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800121
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800122 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800123
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800124 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800125
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800126 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000127
128
Corbin Simpson85805222010-02-02 16:20:12 -0800129.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800130
131.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000132
133 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800134
Keith Whitwella62aaa72009-12-21 23:25:15 +0000135 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800136
Keith Whitwella62aaa72009-12-21 23:25:15 +0000137 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800138
Keith Whitwella62aaa72009-12-21 23:25:15 +0000139 dst.w = src0.w + src1.w
140
141
Corbin Simpson85805222010-02-02 16:20:12 -0800142.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800143
Corbin Simpson17c2a442010-02-02 17:02:28 -0800144This instruction replicates its result.
145
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800146.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000147
Corbin Simpson17c2a442010-02-02 17:02:28 -0800148 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000149
150
Corbin Simpson85805222010-02-02 16:20:12 -0800151.. opcode:: DP4 - 4-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800152
Corbin Simpson17c2a442010-02-02 17:02:28 -0800153This instruction replicates its result.
154
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800155.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000156
Corbin Simpson17c2a442010-02-02 17:02:28 -0800157 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 +0000158
159
Corbin Simpson85805222010-02-02 16:20:12 -0800160.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800161
162.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000163
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800164 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800165
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800166 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800167
Keith Whitwella62aaa72009-12-21 23:25:15 +0000168 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800169
Keith Whitwella62aaa72009-12-21 23:25:15 +0000170 dst.w = src1.w
171
172
Corbin Simpson85805222010-02-02 16:20:12 -0800173.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800174
175.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000176
177 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800178
Keith Whitwella62aaa72009-12-21 23:25:15 +0000179 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800180
Keith Whitwella62aaa72009-12-21 23:25:15 +0000181 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800182
Keith Whitwella62aaa72009-12-21 23:25:15 +0000183 dst.w = min(src0.w, src1.w)
184
185
Corbin Simpson85805222010-02-02 16:20:12 -0800186.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800187
188.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000189
190 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800191
Keith Whitwella62aaa72009-12-21 23:25:15 +0000192 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800193
Keith Whitwella62aaa72009-12-21 23:25:15 +0000194 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800195
Keith Whitwella62aaa72009-12-21 23:25:15 +0000196 dst.w = max(src0.w, src1.w)
197
198
Corbin Simpson85805222010-02-02 16:20:12 -0800199.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800200
201.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000202
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800203 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800204
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800205 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800206
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800207 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800208
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800209 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000210
211
Corbin Simpson85805222010-02-02 16:20:12 -0800212.. opcode:: SGE - Set On Greater Equal Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800213
214.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000215
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800216 dst.x = (src0.x >= src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800217
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800218 dst.y = (src0.y >= src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800219
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800220 dst.z = (src0.z >= src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800221
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800222 dst.w = (src0.w >= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000223
224
Corbin Simpson85805222010-02-02 16:20:12 -0800225.. opcode:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800226
227.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000228
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800229 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800230
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800231 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800232
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800233 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800234
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800235 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000236
237
Corbin Simpson85805222010-02-02 16:20:12 -0800238.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800239
240.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000241
242 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800243
Keith Whitwella62aaa72009-12-21 23:25:15 +0000244 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800245
Keith Whitwella62aaa72009-12-21 23:25:15 +0000246 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800247
Keith Whitwella62aaa72009-12-21 23:25:15 +0000248 dst.w = src0.w - src1.w
249
250
Corbin Simpson85805222010-02-02 16:20:12 -0800251.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800252
253.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000254
Michal Krolb3567fc2010-01-04 12:59:17 +0100255 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800256
Michal Krolb3567fc2010-01-04 12:59:17 +0100257 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800258
Michal Krolb3567fc2010-01-04 12:59:17 +0100259 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800260
Michal Krolb3567fc2010-01-04 12:59:17 +0100261 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000262
263
Corbin Simpson85805222010-02-02 16:20:12 -0800264.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800265
266.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000267
268 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800269
Keith Whitwella62aaa72009-12-21 23:25:15 +0000270 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800271
Keith Whitwella62aaa72009-12-21 23:25:15 +0000272 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800273
Keith Whitwella62aaa72009-12-21 23:25:15 +0000274 dst.w = (src2.w > 0.5) ? src0.w : src1.w
275
276
Corbin Simpson85805222010-02-02 16:20:12 -0800277.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800278
279.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000280
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800281 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800282
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800283 dst.y = 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.z = 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.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000288
289
Corbin Simpson85805222010-02-02 16:20:12 -0800290.. opcode:: FRAC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800291
292.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000293
Corbin Simpsond92a6852009-12-21 19:30:29 -0800294 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800295
Corbin Simpsond92a6852009-12-21 19:30:29 -0800296 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800297
Corbin Simpsond92a6852009-12-21 19:30:29 -0800298 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800299
Corbin Simpsond92a6852009-12-21 19:30:29 -0800300 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000301
302
Corbin Simpson85805222010-02-02 16:20:12 -0800303.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800304
305.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000306
307 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800308
Keith Whitwella62aaa72009-12-21 23:25:15 +0000309 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800310
Keith Whitwella62aaa72009-12-21 23:25:15 +0000311 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800312
Keith Whitwella62aaa72009-12-21 23:25:15 +0000313 dst.w = clamp(src0.w, src1.w, src2.w)
314
315
Corbin Simpson85805222010-02-02 16:20:12 -0800316.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800317
Corbin Simpson17c2a442010-02-02 17:02:28 -0800318This is identical to :opcode:`ARL`.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000319
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800320.. math::
321
Corbin Simpsond92a6852009-12-21 19:30:29 -0800322 dst.x = \lfloor src.x\rfloor
323
324 dst.y = \lfloor src.y\rfloor
325
326 dst.z = \lfloor src.z\rfloor
327
328 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000329
330
Corbin Simpson85805222010-02-02 16:20:12 -0800331.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000332
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800333.. math::
334
Keith Whitwella62aaa72009-12-21 23:25:15 +0000335 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800336
Keith Whitwella62aaa72009-12-21 23:25:15 +0000337 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800338
Keith Whitwella62aaa72009-12-21 23:25:15 +0000339 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800340
Keith Whitwella62aaa72009-12-21 23:25:15 +0000341 dst.w = round(src.w)
342
343
Corbin Simpson85805222010-02-02 16:20:12 -0800344.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000345
Corbin Simpson17c2a442010-02-02 17:02:28 -0800346This instruction replicates its result.
347
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800348.. math::
349
Corbin Simpson17c2a442010-02-02 17:02:28 -0800350 dst = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000351
352
Corbin Simpson85805222010-02-02 16:20:12 -0800353.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000354
Corbin Simpson17c2a442010-02-02 17:02:28 -0800355This instruction replicates its result.
356
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800357.. math::
358
Corbin Simpson17c2a442010-02-02 17:02:28 -0800359 dst = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000360
361
Corbin Simpson85805222010-02-02 16:20:12 -0800362.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000363
Corbin Simpson17c2a442010-02-02 17:02:28 -0800364This instruction replicates its result.
365
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800366.. math::
367
Corbin Simpson17c2a442010-02-02 17:02:28 -0800368 dst = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000369
Corbin Simpson85805222010-02-02 16:20:12 -0800370.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000371
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800372.. math::
373
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800374 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800375
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800376 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800377
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800378 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800379
380 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000381
382
Corbin Simpson85805222010-02-02 16:20:12 -0800383.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000384
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800385.. math::
386
Corbin Simpson14743ac2009-12-21 19:57:56 -0800387 dst.x = |src.x|
388
389 dst.y = |src.y|
390
391 dst.z = |src.z|
392
393 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000394
395
Corbin Simpson85805222010-02-02 16:20:12 -0800396.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800397
Corbin Simpson17c2a442010-02-02 17:02:28 -0800398This instruction replicates its result.
399
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800400XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000401
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800402.. math::
403
Corbin Simpson17c2a442010-02-02 17:02:28 -0800404 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 +0000405
406
Corbin Simpson85805222010-02-02 16:20:12 -0800407.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000408
Corbin Simpson17c2a442010-02-02 17:02:28 -0800409This instruction replicates its result.
410
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800411.. math::
412
Corbin Simpson17c2a442010-02-02 17:02:28 -0800413 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 +0000414
415
Corbin Simpson85805222010-02-02 16:20:12 -0800416.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000417
Corbin Simpson17c2a442010-02-02 17:02:28 -0800418This instruction replicates its result.
419
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800420.. math::
421
Corbin Simpson17c2a442010-02-02 17:02:28 -0800422 dst = \cos{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000423
424
Corbin Simpson85805222010-02-02 16:20:12 -0800425.. opcode:: DDX - Derivative Relative To X
Keith Whitwella62aaa72009-12-21 23:25:15 +0000426
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800427.. math::
428
Keith Whitwella62aaa72009-12-21 23:25:15 +0000429 dst.x = partialx(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800430
Keith Whitwella62aaa72009-12-21 23:25:15 +0000431 dst.y = partialx(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800432
Keith Whitwella62aaa72009-12-21 23:25:15 +0000433 dst.z = partialx(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800434
Keith Whitwella62aaa72009-12-21 23:25:15 +0000435 dst.w = partialx(src.w)
436
437
Corbin Simpson85805222010-02-02 16:20:12 -0800438.. opcode:: DDY - Derivative Relative To Y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000439
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800440.. math::
441
Keith Whitwella62aaa72009-12-21 23:25:15 +0000442 dst.x = partialy(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800443
Keith Whitwella62aaa72009-12-21 23:25:15 +0000444 dst.y = partialy(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800445
Keith Whitwella62aaa72009-12-21 23:25:15 +0000446 dst.z = partialy(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800447
Keith Whitwella62aaa72009-12-21 23:25:15 +0000448 dst.w = partialy(src.w)
449
450
Corbin Simpson85805222010-02-02 16:20:12 -0800451.. opcode:: KILP - Predicated Discard
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800452
Keith Whitwella62aaa72009-12-21 23:25:15 +0000453 discard
454
455
Corbin Simpson85805222010-02-02 16:20:12 -0800456.. opcode:: PK2H - Pack Two 16-bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000457
458 TBD
459
460
Corbin Simpson85805222010-02-02 16:20:12 -0800461.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000462
463 TBD
464
465
Corbin Simpson85805222010-02-02 16:20:12 -0800466.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000467
468 TBD
469
470
Corbin Simpson85805222010-02-02 16:20:12 -0800471.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000472
473 TBD
474
475
Corbin Simpson85805222010-02-02 16:20:12 -0800476.. opcode:: RFL - Reflection Vector
Keith Whitwella62aaa72009-12-21 23:25:15 +0000477
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800478.. math::
479
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800480 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
481
482 dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
483
484 dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
485
486 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000487
Corbin Simpson17c2a442010-02-02 17:02:28 -0800488.. note::
489
490 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000491
Keith Whitwella62aaa72009-12-21 23:25:15 +0000492
Corbin Simpson85805222010-02-02 16:20:12 -0800493.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000494
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800495.. math::
496
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800497 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800498
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800499 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800500
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800501 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800502
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800503 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000504
505
Corbin Simpson85805222010-02-02 16:20:12 -0800506.. opcode:: SFL - Set On False
Keith Whitwella62aaa72009-12-21 23:25:15 +0000507
Corbin Simpson17c2a442010-02-02 17:02:28 -0800508This instruction replicates its result.
509
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800510.. math::
511
Corbin Simpson17c2a442010-02-02 17:02:28 -0800512 dst = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800513
Corbin Simpson17c2a442010-02-02 17:02:28 -0800514.. note::
Corbin Simpson04771912010-01-18 17:31:56 -0800515
Corbin Simpson17c2a442010-02-02 17:02:28 -0800516 Considered for removal.
Corbin Simpson04771912010-01-18 17:31:56 -0800517
Keith Whitwella62aaa72009-12-21 23:25:15 +0000518
Corbin Simpson85805222010-02-02 16:20:12 -0800519.. opcode:: SGT - Set On Greater Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000520
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800521.. math::
522
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800523 dst.x = (src0.x > src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800524
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800525 dst.y = (src0.y > src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800526
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800527 dst.z = (src0.z > src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800528
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800529 dst.w = (src0.w > src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000530
531
Corbin Simpson85805222010-02-02 16:20:12 -0800532.. opcode:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000533
Corbin Simpson17c2a442010-02-02 17:02:28 -0800534This instruction replicates its result.
535
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800536.. math::
537
Corbin Simpson17c2a442010-02-02 17:02:28 -0800538 dst = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000539
540
Corbin Simpson85805222010-02-02 16:20:12 -0800541.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000542
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800543.. math::
544
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800545 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800546
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800547 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800548
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800549 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800550
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800551 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000552
553
Corbin Simpson85805222010-02-02 16:20:12 -0800554.. opcode:: SNE - Set On Not Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000555
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800556.. math::
557
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800558 dst.x = (src0.x != src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800559
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800560 dst.y = (src0.y != src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800561
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800562 dst.z = (src0.z != src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800563
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800564 dst.w = (src0.w != src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000565
566
Corbin Simpson85805222010-02-02 16:20:12 -0800567.. opcode:: STR - Set On True
Keith Whitwella62aaa72009-12-21 23:25:15 +0000568
Corbin Simpson17c2a442010-02-02 17:02:28 -0800569This instruction replicates its result.
570
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800571.. math::
572
Corbin Simpson17c2a442010-02-02 17:02:28 -0800573 dst = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000574
575
Corbin Simpson85805222010-02-02 16:20:12 -0800576.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000577
578 TBD
579
580
Corbin Simpson85805222010-02-02 16:20:12 -0800581.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000582
583 TBD
584
585
Corbin Simpson85805222010-02-02 16:20:12 -0800586.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000587
588 TBD
589
590
Corbin Simpson85805222010-02-02 16:20:12 -0800591.. opcode:: UP2H - Unpack Two 16-Bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000592
593 TBD
594
Corbin Simpson17c2a442010-02-02 17:02:28 -0800595.. note::
596
597 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000598
Corbin Simpson85805222010-02-02 16:20:12 -0800599.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000600
601 TBD
602
Corbin Simpson17c2a442010-02-02 17:02:28 -0800603.. note::
604
605 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000606
Corbin Simpson85805222010-02-02 16:20:12 -0800607.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000608
609 TBD
610
Corbin Simpson17c2a442010-02-02 17:02:28 -0800611.. note::
612
613 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000614
Corbin Simpson85805222010-02-02 16:20:12 -0800615.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000616
617 TBD
618
Corbin Simpson17c2a442010-02-02 17:02:28 -0800619.. note::
620
621 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000622
Corbin Simpson85805222010-02-02 16:20:12 -0800623.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000624
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800625.. math::
626
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800627 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800628
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800629 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800630
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800631 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800632
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800633 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000634
Corbin Simpson17c2a442010-02-02 17:02:28 -0800635.. note::
636
637 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000638
Keith Whitwella62aaa72009-12-21 23:25:15 +0000639
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800640From GL_NV_vertex_program2
641^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000642
643
Corbin Simpson85805222010-02-02 16:20:12 -0800644.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000645
646 TBD
647
Corbin Simpson17c2a442010-02-02 17:02:28 -0800648.. note::
649
650 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000651
Corbin Simpson85805222010-02-02 16:20:12 -0800652.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000653
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800654.. math::
655
Keith Whitwella62aaa72009-12-21 23:25:15 +0000656 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800657
Keith Whitwella62aaa72009-12-21 23:25:15 +0000658 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800659
Keith Whitwella62aaa72009-12-21 23:25:15 +0000660 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800661
Keith Whitwella62aaa72009-12-21 23:25:15 +0000662 dst.w = round(src.w)
663
664
Corbin Simpson85805222010-02-02 16:20:12 -0800665.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000666
667 pc = target
668
Corbin Simpson17c2a442010-02-02 17:02:28 -0800669.. note::
670
671 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000672
Corbin Simpson85805222010-02-02 16:20:12 -0800673.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000674
675 push(pc)
676 pc = target
677
678
Corbin Simpson85805222010-02-02 16:20:12 -0800679.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000680
681 pc = pop()
682
Keith Whitwell14eacb02009-12-21 23:38:29 +0000683 Potential restrictions:
Michal Krolcef21802010-01-04 13:15:28 +0100684 * Only occurs at end of function.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000685
Corbin Simpson85805222010-02-02 16:20:12 -0800686.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000687
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800688.. math::
689
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800690 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
691
692 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
693
694 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
695
696 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000697
698
Corbin Simpson85805222010-02-02 16:20:12 -0800699.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000700
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800701.. math::
702
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800703 dst.x = (src0.x < 0) ? src1.x : src2.x
704
705 dst.y = (src0.y < 0) ? src1.y : src2.y
706
707 dst.z = (src0.z < 0) ? src1.z : src2.z
708
709 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000710
711
Corbin Simpson85805222010-02-02 16:20:12 -0800712.. opcode:: KIL - Conditional Discard
Keith Whitwella62aaa72009-12-21 23:25:15 +0000713
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800714.. math::
715
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800716 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000717 discard
718 endif
719
720
Corbin Simpson85805222010-02-02 16:20:12 -0800721.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000722
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800723.. math::
724
Corbin Simpsond92a6852009-12-21 19:30:29 -0800725 dst.x = \cos{src.x}
726
727 dst.y = \sin{src.x}
728
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800729 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800730
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800731 dst.y = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000732
733
Corbin Simpson85805222010-02-02 16:20:12 -0800734.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000735
736 TBD
737
738
Corbin Simpson85805222010-02-02 16:20:12 -0800739.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000740
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800741.. math::
742
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800743 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 -0800744
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800745 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 -0800746
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800747 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 -0800748
749 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000750
751
Corbin Simpson85805222010-02-02 16:20:12 -0800752.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000753
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800754.. math::
755
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800756 dst.x = \frac{src0.x}{src1.x}
757
758 dst.y = \frac{src0.y}{src1.y}
759
760 dst.z = \frac{src0.z}{src1.z}
761
762 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000763
764
Corbin Simpson85805222010-02-02 16:20:12 -0800765.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000766
Corbin Simpson17c2a442010-02-02 17:02:28 -0800767This instruction replicates its result.
768
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800769.. math::
770
Corbin Simpson17c2a442010-02-02 17:02:28 -0800771 dst = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000772
773
Corbin Simpson85805222010-02-02 16:20:12 -0800774.. opcode:: TXL - Texture Lookup With LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000775
776 TBD
777
778
Corbin Simpson85805222010-02-02 16:20:12 -0800779.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000780
781 TBD
782
783
Corbin Simpson85805222010-02-02 16:20:12 -0800784.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000785
786 TBD
787
788
Corbin Simpson85805222010-02-02 16:20:12 -0800789.. opcode:: BGNFOR - Begin a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000790
791 dst.x = floor(src.x)
792 dst.y = floor(src.y)
793 dst.z = floor(src.z)
794
795 if (dst.y <= 0)
796 pc = [matching ENDFOR] + 1
797 endif
798
799 Note: The destination must be a loop register.
800 The source must be a constant register.
801
Corbin Simpson17c2a442010-02-02 17:02:28 -0800802.. note::
803
804 Considered for cleanup.
805
806.. note::
807
808 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000809
Keith Whitwella62aaa72009-12-21 23:25:15 +0000810
Corbin Simpson85805222010-02-02 16:20:12 -0800811.. opcode:: REP - Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000812
813 TBD
814
815
Corbin Simpson85805222010-02-02 16:20:12 -0800816.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000817
818 TBD
819
820
Corbin Simpson85805222010-02-02 16:20:12 -0800821.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000822
823 TBD
824
825
Corbin Simpson85805222010-02-02 16:20:12 -0800826.. opcode:: ENDFOR - End a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000827
828 dst.x = dst.x + dst.z
829 dst.y = dst.y - 1.0
830
831 if (dst.y > 0)
832 pc = [matching BGNFOR instruction] + 1
833 endif
834
835 Note: The destination must be a loop register.
836
Corbin Simpson17c2a442010-02-02 17:02:28 -0800837.. note::
838
839 Considered for cleanup.
840
841.. note::
842
843 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000844
Corbin Simpson85805222010-02-02 16:20:12 -0800845.. opcode:: ENDREP - End Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000846
847 TBD
848
849
Corbin Simpson85805222010-02-02 16:20:12 -0800850.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000851
852 push(src.x)
853 push(src.y)
854 push(src.z)
855 push(src.w)
856
Corbin Simpson17c2a442010-02-02 17:02:28 -0800857.. note::
858
859 Considered for cleanup.
860
861.. note::
862
863 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000864
Corbin Simpson85805222010-02-02 16:20:12 -0800865.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000866
867 dst.w = pop()
868 dst.z = pop()
869 dst.y = pop()
870 dst.x = pop()
871
Corbin Simpson17c2a442010-02-02 17:02:28 -0800872.. note::
873
874 Considered for cleanup.
875
876.. note::
877
878 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000879
Keith Whitwella62aaa72009-12-21 23:25:15 +0000880
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800881From GL_NV_gpu_program4
882^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000883
Keith Whitwell14eacb02009-12-21 23:38:29 +0000884Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000885
Corbin Simpson85805222010-02-02 16:20:12 -0800886.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000887
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800888.. math::
889
Corbin Simpson14743ac2009-12-21 19:57:56 -0800890 dst.x = \lceil src.x\rceil
891
892 dst.y = \lceil src.y\rceil
893
894 dst.z = \lceil src.z\rceil
895
896 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000897
898
Corbin Simpson85805222010-02-02 16:20:12 -0800899.. opcode:: I2F - Integer To Float
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 = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800904
Keith Whitwella62aaa72009-12-21 23:25:15 +0000905 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800906
Keith Whitwella62aaa72009-12-21 23:25:15 +0000907 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800908
Keith Whitwella62aaa72009-12-21 23:25:15 +0000909 dst.w = (float) src.w
910
911
Corbin Simpson85805222010-02-02 16:20:12 -0800912.. opcode:: NOT - Bitwise Not
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 = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800919
Keith Whitwella62aaa72009-12-21 23:25:15 +0000920 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800921
Keith Whitwella62aaa72009-12-21 23:25:15 +0000922 dst.w = ~src.w
923
924
Corbin Simpson85805222010-02-02 16:20:12 -0800925.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800926
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800927.. math::
928
Keith Whitwella62aaa72009-12-21 23:25:15 +0000929 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800932
Keith Whitwella62aaa72009-12-21 23:25:15 +0000933 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800934
Keith Whitwella62aaa72009-12-21 23:25:15 +0000935 dst.w = trunc(src.w)
936
937
Corbin Simpson85805222010-02-02 16:20:12 -0800938.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000939
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800940.. math::
941
Keith Whitwella62aaa72009-12-21 23:25:15 +0000942 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800943
Keith Whitwella62aaa72009-12-21 23:25:15 +0000944 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800945
Keith Whitwella62aaa72009-12-21 23:25:15 +0000946 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800947
Keith Whitwella62aaa72009-12-21 23:25:15 +0000948 dst.w = src0.w << src1.x
949
950
Corbin Simpson85805222010-02-02 16:20:12 -0800951.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000952
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800953.. math::
954
Keith Whitwella62aaa72009-12-21 23:25:15 +0000955 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800956
Keith Whitwella62aaa72009-12-21 23:25:15 +0000957 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800958
Keith Whitwella62aaa72009-12-21 23:25:15 +0000959 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800960
Keith Whitwella62aaa72009-12-21 23:25:15 +0000961 dst.w = src0.w >> src1.x
962
963
Corbin Simpson85805222010-02-02 16:20:12 -0800964.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000965
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800966.. math::
967
Keith Whitwella62aaa72009-12-21 23:25:15 +0000968 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800969
Keith Whitwella62aaa72009-12-21 23:25:15 +0000970 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800971
Keith Whitwella62aaa72009-12-21 23:25:15 +0000972 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800973
Keith Whitwella62aaa72009-12-21 23:25:15 +0000974 dst.w = src0.w & src1.w
975
976
Corbin Simpson85805222010-02-02 16:20:12 -0800977.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000978
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800979.. math::
980
Keith Whitwella62aaa72009-12-21 23:25:15 +0000981 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800982
Keith Whitwella62aaa72009-12-21 23:25:15 +0000983 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800984
Keith Whitwella62aaa72009-12-21 23:25:15 +0000985 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800986
Keith Whitwella62aaa72009-12-21 23:25:15 +0000987 dst.w = src0.w | src1.w
988
989
Corbin Simpson85805222010-02-02 16:20:12 -0800990.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000991
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800992.. math::
993
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800994 dst.x = src0.x \bmod src1.x
995
996 dst.y = src0.y \bmod src1.y
997
998 dst.z = src0.z \bmod src1.z
999
1000 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001001
1002
Corbin Simpson85805222010-02-02 16:20:12 -08001003.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +00001004
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001005.. math::
1006
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001007 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001008
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001009 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001010
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001011 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001012
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001013 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001014
1015
Corbin Simpson85805222010-02-02 16:20:12 -08001016.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +00001017
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001018.. math::
1019
Corbin Simpson14743ac2009-12-21 19:57:56 -08001020 dst.x = |src0.x - src1.x| + src2.x
1021
1022 dst.y = |src0.y - src1.y| + src2.y
1023
1024 dst.z = |src0.z - src1.z| + src2.z
1025
1026 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001027
1028
Corbin Simpson85805222010-02-02 16:20:12 -08001029.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +00001030
1031 TBD
1032
1033
Corbin Simpson85805222010-02-02 16:20:12 -08001034.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +00001035
1036 TBD
1037
1038
Corbin Simpson85805222010-02-02 16:20:12 -08001039.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +00001040
1041 TBD
1042
1043
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001044From GL_NV_geometry_program4
1045^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001046
1047
Corbin Simpson85805222010-02-02 16:20:12 -08001048.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001049
1050 TBD
1051
1052
Corbin Simpson85805222010-02-02 16:20:12 -08001053.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001054
1055 TBD
1056
1057
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001058From GLSL
1059^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001060
1061
Corbin Simpson85805222010-02-02 16:20:12 -08001062.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001063
1064 TBD
1065
1066
Corbin Simpson85805222010-02-02 16:20:12 -08001067.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001068
1069 TBD
1070
1071
Corbin Simpson85805222010-02-02 16:20:12 -08001072.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001073
1074 TBD
1075
1076
Corbin Simpson85805222010-02-02 16:20:12 -08001077.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001078
1079 TBD
1080
1081
Corbin Simpson85805222010-02-02 16:20:12 -08001082.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001083
Michal Krol8ab89d72010-01-04 13:23:41 +01001084 Do nothing.
1085
Keith Whitwella62aaa72009-12-21 23:25:15 +00001086
Corbin Simpson85805222010-02-02 16:20:12 -08001087.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001088
Corbin Simpson17c2a442010-02-02 17:02:28 -08001089This instruction replicates its result.
1090
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001091.. math::
1092
Corbin Simpson17c2a442010-02-02 17:02:28 -08001093 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 +00001094
1095
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001096ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001097^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001098
1099
Corbin Simpson85805222010-02-02 16:20:12 -08001100.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001101
1102 TBD
1103
1104
Corbin Simpson85805222010-02-02 16:20:12 -08001105.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001106
1107 TBD
1108
1109
Corbin Simpson85805222010-02-02 16:20:12 -08001110.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001111
1112 TBD
1113
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001114.. _doubleopcodes:
1115
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001116Double Opcodes
1117^^^^^^^^^^^^^^^
1118
Corbin Simpson85805222010-02-02 16:20:12 -08001119.. opcode:: DADD - Add Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001120
1121.. math::
1122
1123 dst.xy = src0.xy + src1.xy
1124
1125 dst.zw = src0.zw + src1.zw
1126
1127
Corbin Simpson85805222010-02-02 16:20:12 -08001128.. opcode:: DDIV - Divide Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001129
1130.. math::
1131
1132 dst.xy = src0.xy / src1.xy
1133
1134 dst.zw = src0.zw / src1.zw
1135
Corbin Simpson85805222010-02-02 16:20:12 -08001136.. opcode:: DSEQ - Set Double on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001137
1138.. math::
1139
1140 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1141
1142 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1143
Corbin Simpson85805222010-02-02 16:20:12 -08001144.. opcode:: DSLT - Set Double on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001145
1146.. math::
1147
1148 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1149
1150 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1151
Corbin Simpson85805222010-02-02 16:20:12 -08001152.. opcode:: DFRAC - Double Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001153
1154.. math::
1155
1156 dst.xy = src.xy - \lfloor src.xy\rfloor
1157
1158 dst.zw = src.zw - \lfloor src.zw\rfloor
1159
1160
Corbin Simpson85805222010-02-02 16:20:12 -08001161.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001162
1163.. math::
1164
1165 dst0.xy = frexp(src.xy, dst1.xy)
1166
1167 dst0.zw = frexp(src.zw, dst1.zw)
1168
Corbin Simpson85805222010-02-02 16:20:12 -08001169.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001170
1171.. math::
1172
1173 dst.xy = ldexp(src0.xy, src1.xy)
1174
1175 dst.zw = ldexp(src0.zw, src1.zw)
1176
Corbin Simpson85805222010-02-02 16:20:12 -08001177.. opcode:: DMIN - Minimum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001178
1179.. math::
1180
1181 dst.xy = min(src0.xy, src1.xy)
1182
1183 dst.zw = min(src0.zw, src1.zw)
1184
Corbin Simpson85805222010-02-02 16:20:12 -08001185.. opcode:: DMAX - Maximum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001186
1187.. math::
1188
1189 dst.xy = max(src0.xy, src1.xy)
1190
1191 dst.zw = max(src0.zw, src1.zw)
1192
Corbin Simpson85805222010-02-02 16:20:12 -08001193.. opcode:: DMUL - Multiply Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001194
1195.. math::
1196
1197 dst.xy = src0.xy \times src1.xy
1198
1199 dst.zw = src0.zw \times src1.zw
1200
1201
Corbin Simpson85805222010-02-02 16:20:12 -08001202.. opcode:: DMAD - Multiply And Add Doubles
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001203
1204.. math::
1205
1206 dst.xy = src0.xy \times src1.xy + src2.xy
1207
1208 dst.zw = src0.zw \times src1.zw + src2.zw
1209
1210
Corbin Simpson85805222010-02-02 16:20:12 -08001211.. opcode:: DRCP - Reciprocal Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001212
1213.. math::
1214
1215 dst.xy = \frac{1}{src.xy}
1216
1217 dst.zw = \frac{1}{src.zw}
1218
Corbin Simpson85805222010-02-02 16:20:12 -08001219.. opcode:: DSQRT - Square root double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001220
1221.. math::
1222
1223 dst.xy = \sqrt{src.xy}
1224
1225 dst.zw = \sqrt{src.zw}
1226
Keith Whitwella62aaa72009-12-21 23:25:15 +00001227
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001228Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001229------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001230
1231
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001232Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001233^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001234
1235
Corbin Simpson14743ac2009-12-21 19:57:56 -08001236 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001237
Corbin Simpson14743ac2009-12-21 19:57:56 -08001238 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001239
1240 clamp(x,y,z) Clamp x between y and z.
1241 (x < y) ? y : (x > z) ? z : x
1242
Corbin Simpsondd801e52009-12-21 19:41:09 -08001243 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001244
Corbin Simpson14743ac2009-12-21 19:57:56 -08001245 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001246
1247 max(x,y) Maximum of x and y.
1248 (x > y) ? x : y
1249
1250 min(x,y) Minimum of x and y.
1251 (x < y) ? x : y
1252
1253 partialx(x) Derivative of x relative to fragment's X.
1254
1255 partialy(x) Derivative of x relative to fragment's Y.
1256
1257 pop() Pop from stack.
1258
Corbin Simpsondd801e52009-12-21 19:41:09 -08001259 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001260
1261 push(x) Push x on stack.
1262
1263 round(x) Round x.
1264
Michal Krol07f416c2010-01-04 13:21:32 +01001265 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001266
1267
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001268Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001269^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001270
1271
1272 discard Discard fragment.
1273
Keith Whitwella62aaa72009-12-21 23:25:15 +00001274 pc Program counter.
1275
Keith Whitwella62aaa72009-12-21 23:25:15 +00001276 target Label of target instruction.
1277
1278
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001279Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001280---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001281
1282
Michal Krol63d60972010-02-03 15:45:32 +01001283Declaration
1284^^^^^^^^^^^
1285
1286
1287Declares a register that is will be referenced as an operand in Instruction
1288tokens.
1289
1290File field contains register file that is being declared and is one
1291of TGSI_FILE.
1292
1293UsageMask field specifies which of the register components can be accessed
1294and is one of TGSI_WRITEMASK.
1295
1296Interpolate field is only valid for fragment shader INPUT register files.
1297It specifes the way input is being interpolated by the rasteriser and is one
1298of TGSI_INTERPOLATE.
1299
1300If Dimension flag is set to 1, a Declaration Dimension token follows.
1301
1302If Semantic flag is set to 1, a Declaration Semantic token follows.
1303
1304CylindricalWrap bitfield is only valid for fragment shader INPUT register
1305files. It specifies which register components should be subject to cylindrical
1306wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1307is set to 1, the X component should be interpolated according to cylindrical
1308wrapping rules.
1309
1310
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001311Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001312^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001313
1314
1315 Follows Declaration token if Semantic bit is set.
1316
1317 Since its purpose is to link a shader with other stages of the pipeline,
1318 it is valid to follow only those Declaration tokens that declare a register
1319 either in INPUT or OUTPUT file.
1320
1321 SemanticName field contains the semantic name of the register being declared.
1322 There is no default value.
1323
1324 SemanticIndex is an optional subscript that can be used to distinguish
1325 different register declarations with the same semantic name. The default value
1326 is 0.
1327
1328 The meanings of the individual semantic names are explained in the following
1329 sections.
1330
Corbin Simpson54ddf642009-12-23 23:36:06 -08001331TGSI_SEMANTIC_POSITION
1332""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001333
Corbin Simpson54ddf642009-12-23 23:36:06 -08001334Position, sometimes known as HPOS or WPOS for historical reasons, is the
1335location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1336are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1337for the perspective divide, if enabled.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001338
Corbin Simpson54ddf642009-12-23 23:36:06 -08001339As a vertex shader output, position should be scaled to the viewport. When
Luca Barbieri73317132010-01-21 05:36:14 +01001340used in fragment shaders, position will be in window coordinates. The convention
1341used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001342
1343XXX additionally, is there a way to configure the perspective divide? it's
1344accelerated on most chipsets AFAIK...
1345
1346Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1347be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1348
1349XXX usually? can we solidify that?
1350
1351TGSI_SEMANTIC_COLOR
1352"""""""""""""""""""
1353
1354Colors are used to, well, color the primitives. Colors are always in
1355``(r, g, b, a)`` format.
1356
1357If alpha is not specified, it defaults to 1.
1358
1359TGSI_SEMANTIC_BCOLOR
1360""""""""""""""""""""
1361
1362Back-facing colors are only used for back-facing polygons, and are only valid
1363in vertex shader outputs. After rasterization, all polygons are front-facing
1364and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1365all BCOLORs effectively become regular COLORs in the fragment shader.
1366
1367TGSI_SEMANTIC_FOG
1368"""""""""""""""""
1369
1370The fog coordinate historically has been used to replace the depth coordinate
1371for generation of fog in dedicated fog blocks. Gallium, however, does not use
1372dedicated fog acceleration, placing it entirely in the fragment shader
1373instead.
1374
1375The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1376component matters when writing from the vertex shader; the driver will ensure
1377that the coordinate is in this format when used as a fragment shader input.
1378
1379TGSI_SEMANTIC_PSIZE
1380"""""""""""""""""""
1381
1382PSIZE, or point size, is used to specify point sizes per-vertex. It should
1383be in ``(p, n, x, f)`` format, where ``p`` is the point size, ``n`` is the minimum
1384size, ``x`` is the maximum size, and ``f`` is the fade threshold.
1385
1386XXX this is arb_vp. is this what we actually do? should double-check...
1387
1388When using this semantic, be sure to set the appropriate state in the
1389:ref:`rasterizer` first.
1390
1391TGSI_SEMANTIC_GENERIC
1392"""""""""""""""""""""
1393
1394Generic semantics are nearly always used for texture coordinate attributes,
1395in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1396of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1397
1398These attributes are called "generic" because they may be used for anything
1399else, including parameters, texture generation information, or anything that
1400can be stored inside a four-component vector.
1401
1402TGSI_SEMANTIC_NORMAL
1403""""""""""""""""""""
1404
Michal Krol86b336f2010-01-04 13:38:58 +01001405Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1406that allow mixing fixed-function and programmable stages.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001407
1408TGSI_SEMANTIC_FACE
1409""""""""""""""""""
1410
1411FACE is the facing bit, to store the facing information for the fragment
1412shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1413when the fragment is front-facing, and negative when the component is
1414back-facing.
1415
1416TGSI_SEMANTIC_EDGEFLAG
1417""""""""""""""""""""""
1418
1419XXX no clue
Luca Barbieri73317132010-01-21 05:36:14 +01001420
1421
1422Properties
1423^^^^^^^^^^^^^^^^^^^^^^^^
1424
1425
1426 Properties are general directives that apply to the whole TGSI program.
1427
1428FS_COORD_ORIGIN
1429"""""""""""""""
1430
1431Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1432The default value is UPPER_LEFT.
1433
1434If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1435increase downward and rightward.
1436If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1437increase upward and rightward.
1438
1439OpenGL defaults to LOWER_LEFT, and is configurable with the
1440GL_ARB_fragment_coord_conventions extension.
1441
1442DirectX 9/10 use UPPER_LEFT.
1443
1444FS_COORD_PIXEL_CENTER
1445"""""""""""""""""""""
1446
1447Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1448The default value is HALF_INTEGER.
1449
1450If HALF_INTEGER, the fractionary part of the position will be 0.5
1451If INTEGER, the fractionary part of the position will be 0.0
1452
1453Note that this does not affect the set of fragments generated by
1454rasterization, which is instead controlled by gl_rasterization_rules in the
1455rasterizer.
1456
1457OpenGL defaults to HALF_INTEGER, and is configurable with the
1458GL_ARB_fragment_coord_conventions extension.
1459
1460DirectX 9 uses INTEGER.
1461DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001462
1463
1464
1465Texture Sampling and Texture Formats
1466------------------------------------
1467
Corbin Simpson797dcc02010-02-02 17:07:26 -08001468This table shows how texture image components are returned as (x,y,z,w) tuples
1469by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1470:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1471well.
Brian Paul4778f462010-02-02 08:14:40 -07001472
Corbin Simpson516e7152010-02-02 12:44:22 -08001473+--------------------+--------------+--------------------+--------------+
1474| Texture Components | Gallium | OpenGL | Direct3D 9 |
1475+====================+==============+====================+==============+
1476| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1477+--------------------+--------------+--------------------+--------------+
1478| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1479+--------------------+--------------+--------------------+--------------+
1480| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1481+--------------------+--------------+--------------------+--------------+
1482| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1483+--------------------+--------------+--------------------+--------------+
1484| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1485+--------------------+--------------+--------------------+--------------+
1486| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1487+--------------------+--------------+--------------------+--------------+
1488| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1489+--------------------+--------------+--------------------+--------------+
1490| I | (i, i, i, i) | (i, i, i, i) | N/A |
1491+--------------------+--------------+--------------------+--------------+
1492| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1493| | | [#envmap-bumpmap]_ | |
1494+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001495| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001496| | | [#depth-tex-mode]_ | |
1497+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001498
Corbin Simpson516e7152010-02-02 12:44:22 -08001499.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001500.. [#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 -08001501 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.