blob: e2c8602da0254832a92ec3aa8524c08d250e8ad7 [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:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000790
791 TBD
792
793
Corbin Simpson85805222010-02-02 16:20:12 -0800794.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000795
796 TBD
797
798
Corbin Simpson85805222010-02-02 16:20:12 -0800799.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000800
801 push(src.x)
802 push(src.y)
803 push(src.z)
804 push(src.w)
805
Corbin Simpson17c2a442010-02-02 17:02:28 -0800806.. note::
807
808 Considered for cleanup.
809
810.. note::
811
812 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000813
Corbin Simpson85805222010-02-02 16:20:12 -0800814.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000815
816 dst.w = pop()
817 dst.z = pop()
818 dst.y = pop()
819 dst.x = pop()
820
Corbin Simpson17c2a442010-02-02 17:02:28 -0800821.. note::
822
823 Considered for cleanup.
824
825.. note::
826
827 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000828
Keith Whitwella62aaa72009-12-21 23:25:15 +0000829
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800830From GL_NV_gpu_program4
831^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000832
Keith Whitwell14eacb02009-12-21 23:38:29 +0000833Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000834
Corbin Simpson85805222010-02-02 16:20:12 -0800835.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000836
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800837.. math::
838
Corbin Simpson14743ac2009-12-21 19:57:56 -0800839 dst.x = \lceil src.x\rceil
840
841 dst.y = \lceil src.y\rceil
842
843 dst.z = \lceil src.z\rceil
844
845 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000846
847
Corbin Simpson85805222010-02-02 16:20:12 -0800848.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000849
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800850.. math::
851
Keith Whitwella62aaa72009-12-21 23:25:15 +0000852 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800853
Keith Whitwella62aaa72009-12-21 23:25:15 +0000854 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800855
Keith Whitwella62aaa72009-12-21 23:25:15 +0000856 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800857
Keith Whitwella62aaa72009-12-21 23:25:15 +0000858 dst.w = (float) src.w
859
860
Corbin Simpson85805222010-02-02 16:20:12 -0800861.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +0000862
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800863.. math::
864
Keith Whitwella62aaa72009-12-21 23:25:15 +0000865 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800866
Keith Whitwella62aaa72009-12-21 23:25:15 +0000867 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800868
Keith Whitwella62aaa72009-12-21 23:25:15 +0000869 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800870
Keith Whitwella62aaa72009-12-21 23:25:15 +0000871 dst.w = ~src.w
872
873
Corbin Simpson85805222010-02-02 16:20:12 -0800874.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800875
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800876.. math::
877
Keith Whitwella62aaa72009-12-21 23:25:15 +0000878 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800879
Keith Whitwella62aaa72009-12-21 23:25:15 +0000880 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800881
Keith Whitwella62aaa72009-12-21 23:25:15 +0000882 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800883
Keith Whitwella62aaa72009-12-21 23:25:15 +0000884 dst.w = trunc(src.w)
885
886
Corbin Simpson85805222010-02-02 16:20:12 -0800887.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000888
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800889.. math::
890
Keith Whitwella62aaa72009-12-21 23:25:15 +0000891 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800892
Keith Whitwella62aaa72009-12-21 23:25:15 +0000893 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800894
Keith Whitwella62aaa72009-12-21 23:25:15 +0000895 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800896
Keith Whitwella62aaa72009-12-21 23:25:15 +0000897 dst.w = src0.w << src1.x
898
899
Corbin Simpson85805222010-02-02 16:20:12 -0800900.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000901
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800902.. math::
903
Keith Whitwella62aaa72009-12-21 23:25:15 +0000904 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800905
Keith Whitwella62aaa72009-12-21 23:25:15 +0000906 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800907
Keith Whitwella62aaa72009-12-21 23:25:15 +0000908 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800909
Keith Whitwella62aaa72009-12-21 23:25:15 +0000910 dst.w = src0.w >> src1.x
911
912
Corbin Simpson85805222010-02-02 16:20:12 -0800913.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000914
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800915.. math::
916
Keith Whitwella62aaa72009-12-21 23:25:15 +0000917 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800918
Keith Whitwella62aaa72009-12-21 23:25:15 +0000919 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800920
Keith Whitwella62aaa72009-12-21 23:25:15 +0000921 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800922
Keith Whitwella62aaa72009-12-21 23:25:15 +0000923 dst.w = src0.w & src1.w
924
925
Corbin Simpson85805222010-02-02 16:20:12 -0800926.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000927
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800928.. math::
929
Keith Whitwella62aaa72009-12-21 23:25:15 +0000930 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800931
Keith Whitwella62aaa72009-12-21 23:25:15 +0000932 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800933
Keith Whitwella62aaa72009-12-21 23:25:15 +0000934 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800935
Keith Whitwella62aaa72009-12-21 23:25:15 +0000936 dst.w = src0.w | src1.w
937
938
Corbin Simpson85805222010-02-02 16:20:12 -0800939.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000940
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800941.. math::
942
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800943 dst.x = src0.x \bmod src1.x
944
945 dst.y = src0.y \bmod src1.y
946
947 dst.z = src0.z \bmod src1.z
948
949 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000950
951
Corbin Simpson85805222010-02-02 16:20:12 -0800952.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000953
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800954.. math::
955
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800956 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800957
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800958 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800959
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800960 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800961
Corbin Simpsonf90733c2010-01-18 17:37:25 -0800962 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000963
964
Corbin Simpson85805222010-02-02 16:20:12 -0800965.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +0000966
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800967.. math::
968
Corbin Simpson14743ac2009-12-21 19:57:56 -0800969 dst.x = |src0.x - src1.x| + src2.x
970
971 dst.y = |src0.y - src1.y| + src2.y
972
973 dst.z = |src0.z - src1.z| + src2.z
974
975 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000976
977
Corbin Simpson85805222010-02-02 16:20:12 -0800978.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000979
980 TBD
981
982
Corbin Simpson85805222010-02-02 16:20:12 -0800983.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +0000984
985 TBD
986
987
Corbin Simpson85805222010-02-02 16:20:12 -0800988.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +0000989
990 TBD
991
992
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800993From GL_NV_geometry_program4
994^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000995
996
Corbin Simpson85805222010-02-02 16:20:12 -0800997.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +0000998
999 TBD
1000
1001
Corbin Simpson85805222010-02-02 16:20:12 -08001002.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001003
1004 TBD
1005
1006
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001007From GLSL
1008^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001009
1010
Corbin Simpson85805222010-02-02 16:20:12 -08001011.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001012
1013 TBD
1014
1015
Corbin Simpson85805222010-02-02 16:20:12 -08001016.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001017
1018 TBD
1019
1020
Corbin Simpson85805222010-02-02 16:20:12 -08001021.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001022
1023 TBD
1024
1025
Corbin Simpson85805222010-02-02 16:20:12 -08001026.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001027
1028 TBD
1029
1030
Corbin Simpson85805222010-02-02 16:20:12 -08001031.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001032
Michal Krol8ab89d72010-01-04 13:23:41 +01001033 Do nothing.
1034
Keith Whitwella62aaa72009-12-21 23:25:15 +00001035
Corbin Simpson85805222010-02-02 16:20:12 -08001036.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001037
Corbin Simpson17c2a442010-02-02 17:02:28 -08001038This instruction replicates its result.
1039
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001040.. math::
1041
Corbin Simpson17c2a442010-02-02 17:02:28 -08001042 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 +00001043
1044
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001045ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001046^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001047
1048
Corbin Simpson85805222010-02-02 16:20:12 -08001049.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001050
1051 TBD
1052
1053
Corbin Simpson85805222010-02-02 16:20:12 -08001054.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001055
1056 TBD
1057
1058
Corbin Simpson85805222010-02-02 16:20:12 -08001059.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001060
1061 TBD
1062
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001063.. _doubleopcodes:
1064
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001065Double Opcodes
1066^^^^^^^^^^^^^^^
1067
Corbin Simpson85805222010-02-02 16:20:12 -08001068.. opcode:: DADD - Add Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001069
1070.. math::
1071
1072 dst.xy = src0.xy + src1.xy
1073
1074 dst.zw = src0.zw + src1.zw
1075
1076
Corbin Simpson85805222010-02-02 16:20:12 -08001077.. opcode:: DDIV - Divide Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001078
1079.. math::
1080
1081 dst.xy = src0.xy / src1.xy
1082
1083 dst.zw = src0.zw / src1.zw
1084
Corbin Simpson85805222010-02-02 16:20:12 -08001085.. opcode:: DSEQ - Set Double on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001086
1087.. math::
1088
1089 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1090
1091 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1092
Corbin Simpson85805222010-02-02 16:20:12 -08001093.. opcode:: DSLT - Set Double on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001094
1095.. math::
1096
1097 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1098
1099 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1100
Corbin Simpson85805222010-02-02 16:20:12 -08001101.. opcode:: DFRAC - Double Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001102
1103.. math::
1104
1105 dst.xy = src.xy - \lfloor src.xy\rfloor
1106
1107 dst.zw = src.zw - \lfloor src.zw\rfloor
1108
1109
Corbin Simpson85805222010-02-02 16:20:12 -08001110.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001111
1112.. math::
1113
1114 dst0.xy = frexp(src.xy, dst1.xy)
1115
1116 dst0.zw = frexp(src.zw, dst1.zw)
1117
Corbin Simpson85805222010-02-02 16:20:12 -08001118.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001119
1120.. math::
1121
1122 dst.xy = ldexp(src0.xy, src1.xy)
1123
1124 dst.zw = ldexp(src0.zw, src1.zw)
1125
Corbin Simpson85805222010-02-02 16:20:12 -08001126.. opcode:: DMIN - Minimum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001127
1128.. math::
1129
1130 dst.xy = min(src0.xy, src1.xy)
1131
1132 dst.zw = min(src0.zw, src1.zw)
1133
Corbin Simpson85805222010-02-02 16:20:12 -08001134.. opcode:: DMAX - Maximum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001135
1136.. math::
1137
1138 dst.xy = max(src0.xy, src1.xy)
1139
1140 dst.zw = max(src0.zw, src1.zw)
1141
Corbin Simpson85805222010-02-02 16:20:12 -08001142.. opcode:: DMUL - Multiply Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001143
1144.. math::
1145
1146 dst.xy = src0.xy \times src1.xy
1147
1148 dst.zw = src0.zw \times src1.zw
1149
1150
Corbin Simpson85805222010-02-02 16:20:12 -08001151.. opcode:: DMAD - Multiply And Add Doubles
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001152
1153.. math::
1154
1155 dst.xy = src0.xy \times src1.xy + src2.xy
1156
1157 dst.zw = src0.zw \times src1.zw + src2.zw
1158
1159
Corbin Simpson85805222010-02-02 16:20:12 -08001160.. opcode:: DRCP - Reciprocal Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001161
1162.. math::
1163
1164 dst.xy = \frac{1}{src.xy}
1165
1166 dst.zw = \frac{1}{src.zw}
1167
Corbin Simpson85805222010-02-02 16:20:12 -08001168.. opcode:: DSQRT - Square root double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001169
1170.. math::
1171
1172 dst.xy = \sqrt{src.xy}
1173
1174 dst.zw = \sqrt{src.zw}
1175
Keith Whitwella62aaa72009-12-21 23:25:15 +00001176
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001177Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001178------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001179
1180
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001181Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001182^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001183
1184
Corbin Simpson14743ac2009-12-21 19:57:56 -08001185 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001186
Corbin Simpson14743ac2009-12-21 19:57:56 -08001187 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001188
1189 clamp(x,y,z) Clamp x between y and z.
1190 (x < y) ? y : (x > z) ? z : x
1191
Corbin Simpsondd801e52009-12-21 19:41:09 -08001192 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001193
Corbin Simpson14743ac2009-12-21 19:57:56 -08001194 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001195
1196 max(x,y) Maximum of x and y.
1197 (x > y) ? x : y
1198
1199 min(x,y) Minimum of x and y.
1200 (x < y) ? x : y
1201
1202 partialx(x) Derivative of x relative to fragment's X.
1203
1204 partialy(x) Derivative of x relative to fragment's Y.
1205
1206 pop() Pop from stack.
1207
Corbin Simpsondd801e52009-12-21 19:41:09 -08001208 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001209
1210 push(x) Push x on stack.
1211
1212 round(x) Round x.
1213
Michal Krol07f416c2010-01-04 13:21:32 +01001214 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001215
1216
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001217Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001218^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001219
1220
1221 discard Discard fragment.
1222
Keith Whitwella62aaa72009-12-21 23:25:15 +00001223 pc Program counter.
1224
Keith Whitwella62aaa72009-12-21 23:25:15 +00001225 target Label of target instruction.
1226
1227
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001228Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001229---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001230
1231
Michal Krol63d60972010-02-03 15:45:32 +01001232Declaration
1233^^^^^^^^^^^
1234
1235
1236Declares a register that is will be referenced as an operand in Instruction
1237tokens.
1238
1239File field contains register file that is being declared and is one
1240of TGSI_FILE.
1241
1242UsageMask field specifies which of the register components can be accessed
1243and is one of TGSI_WRITEMASK.
1244
1245Interpolate field is only valid for fragment shader INPUT register files.
1246It specifes the way input is being interpolated by the rasteriser and is one
1247of TGSI_INTERPOLATE.
1248
1249If Dimension flag is set to 1, a Declaration Dimension token follows.
1250
1251If Semantic flag is set to 1, a Declaration Semantic token follows.
1252
1253CylindricalWrap bitfield is only valid for fragment shader INPUT register
1254files. It specifies which register components should be subject to cylindrical
1255wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1256is set to 1, the X component should be interpolated according to cylindrical
1257wrapping rules.
1258
1259
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001260Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001261^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001262
1263
1264 Follows Declaration token if Semantic bit is set.
1265
1266 Since its purpose is to link a shader with other stages of the pipeline,
1267 it is valid to follow only those Declaration tokens that declare a register
1268 either in INPUT or OUTPUT file.
1269
1270 SemanticName field contains the semantic name of the register being declared.
1271 There is no default value.
1272
1273 SemanticIndex is an optional subscript that can be used to distinguish
1274 different register declarations with the same semantic name. The default value
1275 is 0.
1276
1277 The meanings of the individual semantic names are explained in the following
1278 sections.
1279
Corbin Simpson54ddf642009-12-23 23:36:06 -08001280TGSI_SEMANTIC_POSITION
1281""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001282
Corbin Simpson54ddf642009-12-23 23:36:06 -08001283Position, sometimes known as HPOS or WPOS for historical reasons, is the
1284location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1285are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1286for the perspective divide, if enabled.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001287
Corbin Simpson54ddf642009-12-23 23:36:06 -08001288As a vertex shader output, position should be scaled to the viewport. When
Luca Barbieri73317132010-01-21 05:36:14 +01001289used in fragment shaders, position will be in window coordinates. The convention
1290used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001291
1292XXX additionally, is there a way to configure the perspective divide? it's
1293accelerated on most chipsets AFAIK...
1294
1295Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1296be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1297
1298XXX usually? can we solidify that?
1299
1300TGSI_SEMANTIC_COLOR
1301"""""""""""""""""""
1302
1303Colors are used to, well, color the primitives. Colors are always in
1304``(r, g, b, a)`` format.
1305
1306If alpha is not specified, it defaults to 1.
1307
1308TGSI_SEMANTIC_BCOLOR
1309""""""""""""""""""""
1310
1311Back-facing colors are only used for back-facing polygons, and are only valid
1312in vertex shader outputs. After rasterization, all polygons are front-facing
1313and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1314all BCOLORs effectively become regular COLORs in the fragment shader.
1315
1316TGSI_SEMANTIC_FOG
1317"""""""""""""""""
1318
1319The fog coordinate historically has been used to replace the depth coordinate
1320for generation of fog in dedicated fog blocks. Gallium, however, does not use
1321dedicated fog acceleration, placing it entirely in the fragment shader
1322instead.
1323
1324The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1325component matters when writing from the vertex shader; the driver will ensure
1326that the coordinate is in this format when used as a fragment shader input.
1327
1328TGSI_SEMANTIC_PSIZE
1329"""""""""""""""""""
1330
1331PSIZE, or point size, is used to specify point sizes per-vertex. It should
Roland Scheidegger8091e732010-02-03 18:27:32 +01001332be in ``(s, 0, 0, 1)`` format, where ``s`` is the (possibly clamped) point size.
1333Only the first component matters when writing from the vertex shader.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001334
1335When using this semantic, be sure to set the appropriate state in the
1336:ref:`rasterizer` first.
1337
1338TGSI_SEMANTIC_GENERIC
1339"""""""""""""""""""""
1340
1341Generic semantics are nearly always used for texture coordinate attributes,
1342in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1343of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1344
1345These attributes are called "generic" because they may be used for anything
1346else, including parameters, texture generation information, or anything that
1347can be stored inside a four-component vector.
1348
1349TGSI_SEMANTIC_NORMAL
1350""""""""""""""""""""
1351
Michal Krol86b336f2010-01-04 13:38:58 +01001352Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1353that allow mixing fixed-function and programmable stages.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001354
1355TGSI_SEMANTIC_FACE
1356""""""""""""""""""
1357
1358FACE is the facing bit, to store the facing information for the fragment
1359shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1360when the fragment is front-facing, and negative when the component is
1361back-facing.
1362
1363TGSI_SEMANTIC_EDGEFLAG
1364""""""""""""""""""""""
1365
1366XXX no clue
Luca Barbieri73317132010-01-21 05:36:14 +01001367
1368
1369Properties
1370^^^^^^^^^^^^^^^^^^^^^^^^
1371
1372
1373 Properties are general directives that apply to the whole TGSI program.
1374
1375FS_COORD_ORIGIN
1376"""""""""""""""
1377
1378Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1379The default value is UPPER_LEFT.
1380
1381If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1382increase downward and rightward.
1383If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1384increase upward and rightward.
1385
1386OpenGL defaults to LOWER_LEFT, and is configurable with the
1387GL_ARB_fragment_coord_conventions extension.
1388
1389DirectX 9/10 use UPPER_LEFT.
1390
1391FS_COORD_PIXEL_CENTER
1392"""""""""""""""""""""
1393
1394Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1395The default value is HALF_INTEGER.
1396
1397If HALF_INTEGER, the fractionary part of the position will be 0.5
1398If INTEGER, the fractionary part of the position will be 0.0
1399
1400Note that this does not affect the set of fragments generated by
1401rasterization, which is instead controlled by gl_rasterization_rules in the
1402rasterizer.
1403
1404OpenGL defaults to HALF_INTEGER, and is configurable with the
1405GL_ARB_fragment_coord_conventions extension.
1406
1407DirectX 9 uses INTEGER.
1408DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001409
1410
1411
1412Texture Sampling and Texture Formats
1413------------------------------------
1414
Corbin Simpson797dcc02010-02-02 17:07:26 -08001415This table shows how texture image components are returned as (x,y,z,w) tuples
1416by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1417:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1418well.
Brian Paul4778f462010-02-02 08:14:40 -07001419
Corbin Simpson516e7152010-02-02 12:44:22 -08001420+--------------------+--------------+--------------------+--------------+
1421| Texture Components | Gallium | OpenGL | Direct3D 9 |
1422+====================+==============+====================+==============+
1423| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1424+--------------------+--------------+--------------------+--------------+
1425| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1426+--------------------+--------------+--------------------+--------------+
1427| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1428+--------------------+--------------+--------------------+--------------+
1429| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1430+--------------------+--------------+--------------------+--------------+
1431| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1432+--------------------+--------------+--------------------+--------------+
1433| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1434+--------------------+--------------+--------------------+--------------+
1435| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1436+--------------------+--------------+--------------------+--------------+
1437| I | (i, i, i, i) | (i, i, i, i) | N/A |
1438+--------------------+--------------+--------------------+--------------+
1439| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1440| | | [#envmap-bumpmap]_ | |
1441+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001442| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001443| | | [#depth-tex-mode]_ | |
1444+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001445
Corbin Simpson516e7152010-02-02 12:44:22 -08001446.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001447.. [#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 -08001448 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.