blob: 7e6dce995389a17b3624cbac9a3af49f8f0e6306 [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 Simpson5bcd26c2009-12-21 21:04:10 -080022Instruction Set
23---------------
24
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080025From GL_NV_vertex_program
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080026^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000027
28
Corbin Simpson85805222010-02-02 16:20:12 -080029.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080030
31.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000032
Corbin Simpsond92a6852009-12-21 19:30:29 -080033 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080034
Corbin Simpsond92a6852009-12-21 19:30:29 -080035 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080036
Corbin Simpsond92a6852009-12-21 19:30:29 -080037 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080038
Corbin Simpsond92a6852009-12-21 19:30:29 -080039 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000040
41
Corbin Simpson85805222010-02-02 16:20:12 -080042.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080043
44.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000045
46 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080047
Keith Whitwella62aaa72009-12-21 23:25:15 +000048 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080049
Keith Whitwella62aaa72009-12-21 23:25:15 +000050 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080051
Keith Whitwella62aaa72009-12-21 23:25:15 +000052 dst.w = src.w
53
54
Corbin Simpson85805222010-02-02 16:20:12 -080055.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080056
57.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000058
Corbin Simpsonda65ac62009-12-21 20:32:46 -080059 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080060
Corbin Simpsonda65ac62009-12-21 20:32:46 -080061 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080062
Corbin Simpsonda65ac62009-12-21 20:32:46 -080063 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080064
Corbin Simpsonda65ac62009-12-21 20:32:46 -080065 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000066
67
Corbin Simpson85805222010-02-02 16:20:12 -080068.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080069
70.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000071
Corbin Simpson14743ac2009-12-21 19:57:56 -080072 dst.x = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080073
Corbin Simpson14743ac2009-12-21 19:57:56 -080074 dst.y = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080075
Corbin Simpson14743ac2009-12-21 19:57:56 -080076 dst.z = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080077
Corbin Simpson14743ac2009-12-21 19:57:56 -080078 dst.w = \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
83.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000084
Corbin Simpson14743ac2009-12-21 19:57:56 -080085 dst.x = \frac{1}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080086
Corbin Simpson14743ac2009-12-21 19:57:56 -080087 dst.y = \frac{1}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080088
Corbin Simpson14743ac2009-12-21 19:57:56 -080089 dst.z = \frac{1}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080090
Corbin Simpson14743ac2009-12-21 19:57:56 -080091 dst.w = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +000092
93
Corbin Simpson85805222010-02-02 16:20:12 -080094.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080095
96.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000097
Corbin Simpsondd801e52009-12-21 19:41:09 -080098 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099
Corbin Simpsond92a6852009-12-21 19:30:29 -0800100 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800101
Corbin Simpsondd801e52009-12-21 19:41:09 -0800102 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800103
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800104 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000105
106
Corbin Simpson85805222010-02-02 16:20:12 -0800107.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800108
109.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000110
Corbin Simpson14743ac2009-12-21 19:57:56 -0800111 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800112
Corbin Simpson14743ac2009-12-21 19:57:56 -0800113 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800114
Corbin Simpson14743ac2009-12-21 19:57:56 -0800115 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800116
Corbin Simpson14743ac2009-12-21 19:57:56 -0800117 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000118
119
Corbin Simpson85805222010-02-02 16:20:12 -0800120.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800121
122.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000123
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800124 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800125
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800126 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800127
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800128 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800129
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800130 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000131
132
Corbin Simpson85805222010-02-02 16:20:12 -0800133.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800134
135.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000136
137 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800138
Keith Whitwella62aaa72009-12-21 23:25:15 +0000139 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800140
Keith Whitwella62aaa72009-12-21 23:25:15 +0000141 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800142
Keith Whitwella62aaa72009-12-21 23:25:15 +0000143 dst.w = src0.w + src1.w
144
145
Corbin Simpson85805222010-02-02 16:20:12 -0800146.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800147
148.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000149
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800150 dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800151
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800152 dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800153
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800154 dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800155
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800156 dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000157
158
Corbin Simpson85805222010-02-02 16:20:12 -0800159.. opcode:: DP4 - 4-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800160
161.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000162
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800163 dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800164
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800165 dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800166
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800167 dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800168
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800169 dst.w = 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 +0000170
171
Corbin Simpson85805222010-02-02 16:20:12 -0800172.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800173
174.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000175
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800176 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800177
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800178 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800179
Keith Whitwella62aaa72009-12-21 23:25:15 +0000180 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800181
Keith Whitwella62aaa72009-12-21 23:25:15 +0000182 dst.w = src1.w
183
184
Corbin Simpson85805222010-02-02 16:20:12 -0800185.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800186
187.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000188
189 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800190
Keith Whitwella62aaa72009-12-21 23:25:15 +0000191 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800192
Keith Whitwella62aaa72009-12-21 23:25:15 +0000193 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800194
Keith Whitwella62aaa72009-12-21 23:25:15 +0000195 dst.w = min(src0.w, src1.w)
196
197
Corbin Simpson85805222010-02-02 16:20:12 -0800198.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800199
200.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000201
202 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800203
Keith Whitwella62aaa72009-12-21 23:25:15 +0000204 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800205
Keith Whitwella62aaa72009-12-21 23:25:15 +0000206 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800207
Keith Whitwella62aaa72009-12-21 23:25:15 +0000208 dst.w = max(src0.w, src1.w)
209
210
Corbin Simpson85805222010-02-02 16:20:12 -0800211.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800212
213.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000214
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800215 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800216
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800217 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800218
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800219 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800220
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800221 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000222
223
Corbin Simpson85805222010-02-02 16:20:12 -0800224.. opcode:: SGE - Set On Greater Equal Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800225
226.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000227
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800228 dst.x = (src0.x >= src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800229
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800230 dst.y = (src0.y >= src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800231
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800232 dst.z = (src0.z >= src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800233
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800234 dst.w = (src0.w >= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000235
236
Corbin Simpson85805222010-02-02 16:20:12 -0800237.. opcode:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800238
239.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000240
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800241 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800242
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800243 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800244
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800245 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800246
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800247 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000248
249
Corbin Simpson85805222010-02-02 16:20:12 -0800250.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800251
252.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000253
254 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800255
Keith Whitwella62aaa72009-12-21 23:25:15 +0000256 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800257
Keith Whitwella62aaa72009-12-21 23:25:15 +0000258 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800259
Keith Whitwella62aaa72009-12-21 23:25:15 +0000260 dst.w = src0.w - src1.w
261
262
Corbin Simpson85805222010-02-02 16:20:12 -0800263.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800264
265.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000266
Michal Krolb3567fc2010-01-04 12:59:17 +0100267 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800268
Michal Krolb3567fc2010-01-04 12:59:17 +0100269 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800270
Michal Krolb3567fc2010-01-04 12:59:17 +0100271 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800272
Michal Krolb3567fc2010-01-04 12:59:17 +0100273 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000274
275
Corbin Simpson85805222010-02-02 16:20:12 -0800276.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800277
278.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000279
280 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800281
Keith Whitwella62aaa72009-12-21 23:25:15 +0000282 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800283
Keith Whitwella62aaa72009-12-21 23:25:15 +0000284 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800285
Keith Whitwella62aaa72009-12-21 23:25:15 +0000286 dst.w = (src2.w > 0.5) ? src0.w : src1.w
287
288
Corbin Simpson85805222010-02-02 16:20:12 -0800289.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800290
291.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000292
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800293 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800294
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800295 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800296
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800297 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800298
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800299 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000300
301
Corbin Simpson85805222010-02-02 16:20:12 -0800302.. opcode:: FRAC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800303
304.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000305
Corbin Simpsond92a6852009-12-21 19:30:29 -0800306 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800307
Corbin Simpsond92a6852009-12-21 19:30:29 -0800308 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800309
Corbin Simpsond92a6852009-12-21 19:30:29 -0800310 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800311
Corbin Simpsond92a6852009-12-21 19:30:29 -0800312 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000313
314
Corbin Simpson85805222010-02-02 16:20:12 -0800315.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800316
317.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000318
319 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800320
Keith Whitwella62aaa72009-12-21 23:25:15 +0000321 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800322
Keith Whitwella62aaa72009-12-21 23:25:15 +0000323 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800324
Keith Whitwella62aaa72009-12-21 23:25:15 +0000325 dst.w = clamp(src0.w, src1.w, src2.w)
326
327
Corbin Simpson85805222010-02-02 16:20:12 -0800328.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800329
330This is identical to ARL.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000331
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800332.. math::
333
Corbin Simpsond92a6852009-12-21 19:30:29 -0800334 dst.x = \lfloor src.x\rfloor
335
336 dst.y = \lfloor src.y\rfloor
337
338 dst.z = \lfloor src.z\rfloor
339
340 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000341
342
Corbin Simpson85805222010-02-02 16:20:12 -0800343.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000344
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800345.. math::
346
Keith Whitwella62aaa72009-12-21 23:25:15 +0000347 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800348
Keith Whitwella62aaa72009-12-21 23:25:15 +0000349 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800350
Keith Whitwella62aaa72009-12-21 23:25:15 +0000351 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800352
Keith Whitwella62aaa72009-12-21 23:25:15 +0000353 dst.w = round(src.w)
354
355
Corbin Simpson85805222010-02-02 16:20:12 -0800356.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000357
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800358.. math::
359
Corbin Simpsondd801e52009-12-21 19:41:09 -0800360 dst.x = 2^{src.x}
361
362 dst.y = 2^{src.x}
363
364 dst.z = 2^{src.x}
365
366 dst.w = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000367
368
Corbin Simpson85805222010-02-02 16:20:12 -0800369.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000370
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800371.. math::
372
Corbin Simpson14743ac2009-12-21 19:57:56 -0800373 dst.x = \log_2{src.x}
374
375 dst.y = \log_2{src.x}
376
377 dst.z = \log_2{src.x}
378
379 dst.w = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000380
381
Corbin Simpson85805222010-02-02 16:20:12 -0800382.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000383
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800384.. math::
385
Corbin Simpsondd801e52009-12-21 19:41:09 -0800386 dst.x = src0.x^{src1.x}
387
388 dst.y = src0.x^{src1.x}
389
390 dst.z = src0.x^{src1.x}
391
392 dst.w = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000393
Corbin Simpson85805222010-02-02 16:20:12 -0800394.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000395
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800396.. math::
397
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800398 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800399
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800400 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800401
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800402 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800403
404 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000405
406
Corbin Simpson85805222010-02-02 16:20:12 -0800407.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000408
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800409.. math::
410
Corbin Simpson14743ac2009-12-21 19:57:56 -0800411 dst.x = |src.x|
412
413 dst.y = |src.y|
414
415 dst.z = |src.z|
416
417 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000418
419
Corbin Simpson85805222010-02-02 16:20:12 -0800420.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800421
422XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000423
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800424.. math::
425
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800426 dst.x = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
427
428 dst.y = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
429
430 dst.z = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
431
432 dst.w = (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 +0000433
434
Corbin Simpson85805222010-02-02 16:20:12 -0800435.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000436
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800437.. math::
438
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800439 dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800440
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800441 dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800442
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800443 dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800444
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800445 dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000446
447
Corbin Simpson85805222010-02-02 16:20:12 -0800448.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000449
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800450.. math::
451
Corbin Simpsond92a6852009-12-21 19:30:29 -0800452 dst.x = \cos{src.x}
453
454 dst.y = \cos{src.x}
455
456 dst.z = \cos{src.x}
457
Michal Krolc9296642010-01-04 13:12:27 +0100458 dst.w = \cos{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000459
460
Corbin Simpson85805222010-02-02 16:20:12 -0800461.. opcode:: DDX - Derivative Relative To X
Keith Whitwella62aaa72009-12-21 23:25:15 +0000462
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800463.. math::
464
Keith Whitwella62aaa72009-12-21 23:25:15 +0000465 dst.x = partialx(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800466
Keith Whitwella62aaa72009-12-21 23:25:15 +0000467 dst.y = partialx(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800468
Keith Whitwella62aaa72009-12-21 23:25:15 +0000469 dst.z = partialx(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800470
Keith Whitwella62aaa72009-12-21 23:25:15 +0000471 dst.w = partialx(src.w)
472
473
Corbin Simpson85805222010-02-02 16:20:12 -0800474.. opcode:: DDY - Derivative Relative To Y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000475
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800476.. math::
477
Keith Whitwella62aaa72009-12-21 23:25:15 +0000478 dst.x = partialy(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800479
Keith Whitwella62aaa72009-12-21 23:25:15 +0000480 dst.y = partialy(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800481
Keith Whitwella62aaa72009-12-21 23:25:15 +0000482 dst.z = partialy(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800483
Keith Whitwella62aaa72009-12-21 23:25:15 +0000484 dst.w = partialy(src.w)
485
486
Corbin Simpson85805222010-02-02 16:20:12 -0800487.. opcode:: KILP - Predicated Discard
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800488
Keith Whitwella62aaa72009-12-21 23:25:15 +0000489 discard
490
491
Corbin Simpson85805222010-02-02 16:20:12 -0800492.. opcode:: PK2H - Pack Two 16-bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000493
494 TBD
495
496
Corbin Simpson85805222010-02-02 16:20:12 -0800497.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000498
499 TBD
500
501
Corbin Simpson85805222010-02-02 16:20:12 -0800502.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000503
504 TBD
505
506
Corbin Simpson85805222010-02-02 16:20:12 -0800507.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000508
509 TBD
510
511
Corbin Simpson85805222010-02-02 16:20:12 -0800512.. opcode:: RFL - Reflection Vector
Keith Whitwella62aaa72009-12-21 23:25:15 +0000513
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800514.. math::
515
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800516 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
517
518 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
519
520 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
521
522 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000523
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800524Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000525
Keith Whitwella62aaa72009-12-21 23:25:15 +0000526
Corbin Simpson85805222010-02-02 16:20:12 -0800527.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000528
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800529.. math::
530
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800531 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800532
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800533 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800534
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800535 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800536
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800537 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000538
539
Corbin Simpson85805222010-02-02 16:20:12 -0800540.. opcode:: SFL - Set On False
Keith Whitwella62aaa72009-12-21 23:25:15 +0000541
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800542.. math::
543
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800544 dst.x = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800545
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800546 dst.y = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800547
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800548 dst.z = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800549
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800550 dst.w = 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000551
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800552Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000553
Corbin Simpson85805222010-02-02 16:20:12 -0800554.. opcode:: SGT - Set On Greater Than
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:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000568
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800569.. math::
570
Corbin Simpsond92a6852009-12-21 19:30:29 -0800571 dst.x = \sin{src.x}
572
573 dst.y = \sin{src.x}
574
575 dst.z = \sin{src.x}
576
Michal Krolc9296642010-01-04 13:12:27 +0100577 dst.w = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000578
579
Corbin Simpson85805222010-02-02 16:20:12 -0800580.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000581
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800582.. math::
583
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800584 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800585
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800586 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800587
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800588 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800589
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800590 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000591
592
Corbin Simpson85805222010-02-02 16:20:12 -0800593.. opcode:: SNE - Set On Not Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000594
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800595.. math::
596
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800597 dst.x = (src0.x != src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800598
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800599 dst.y = (src0.y != src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800600
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800601 dst.z = (src0.z != src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800602
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800603 dst.w = (src0.w != src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000604
605
Corbin Simpson85805222010-02-02 16:20:12 -0800606.. opcode:: STR - Set On True
Keith Whitwella62aaa72009-12-21 23:25:15 +0000607
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800608.. math::
609
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800610 dst.x = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800611
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800612 dst.y = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800613
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800614 dst.z = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800615
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800616 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000617
618
Corbin Simpson85805222010-02-02 16:20:12 -0800619.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000620
621 TBD
622
623
Corbin Simpson85805222010-02-02 16:20:12 -0800624.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000625
626 TBD
627
628
Corbin Simpson85805222010-02-02 16:20:12 -0800629.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000630
631 TBD
632
633
Corbin Simpson85805222010-02-02 16:20:12 -0800634.. opcode:: UP2H - Unpack Two 16-Bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000635
636 TBD
637
Keith Whitwell14eacb02009-12-21 23:38:29 +0000638 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000639
Corbin Simpson85805222010-02-02 16:20:12 -0800640.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000641
642 TBD
643
Keith Whitwell14eacb02009-12-21 23:38:29 +0000644 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000645
Corbin Simpson85805222010-02-02 16:20:12 -0800646.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000647
648 TBD
649
Keith Whitwell14eacb02009-12-21 23:38:29 +0000650 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000651
Corbin Simpson85805222010-02-02 16:20:12 -0800652.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000653
654 TBD
655
Keith Whitwell14eacb02009-12-21 23:38:29 +0000656 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000657
Corbin Simpson85805222010-02-02 16:20:12 -0800658.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000659
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800660.. math::
661
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800662 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800663
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800664 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800665
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800666 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800667
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800668 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000669
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800670Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000671
Keith Whitwella62aaa72009-12-21 23:25:15 +0000672
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800673From GL_NV_vertex_program2
674^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000675
676
Corbin Simpson85805222010-02-02 16:20:12 -0800677.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000678
679 TBD
680
Keith Whitwell14eacb02009-12-21 23:38:29 +0000681 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000682
Corbin Simpson85805222010-02-02 16:20:12 -0800683.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000684
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800685.. math::
686
Keith Whitwella62aaa72009-12-21 23:25:15 +0000687 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800688
Keith Whitwella62aaa72009-12-21 23:25:15 +0000689 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800690
Keith Whitwella62aaa72009-12-21 23:25:15 +0000691 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800692
Keith Whitwella62aaa72009-12-21 23:25:15 +0000693 dst.w = round(src.w)
694
695
Corbin Simpson85805222010-02-02 16:20:12 -0800696.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000697
698 pc = target
699
Keith Whitwell14eacb02009-12-21 23:38:29 +0000700 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000701
Corbin Simpson85805222010-02-02 16:20:12 -0800702.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000703
704 push(pc)
705 pc = target
706
707
Corbin Simpson85805222010-02-02 16:20:12 -0800708.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000709
710 pc = pop()
711
Keith Whitwell14eacb02009-12-21 23:38:29 +0000712 Potential restrictions:
Michal Krolcef21802010-01-04 13:15:28 +0100713 * Only occurs at end of function.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000714
Corbin Simpson85805222010-02-02 16:20:12 -0800715.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000716
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800717.. math::
718
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800719 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
720
721 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
722
723 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
724
725 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000726
727
Corbin Simpson85805222010-02-02 16:20:12 -0800728.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000729
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800730.. math::
731
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800732 dst.x = (src0.x < 0) ? src1.x : src2.x
733
734 dst.y = (src0.y < 0) ? src1.y : src2.y
735
736 dst.z = (src0.z < 0) ? src1.z : src2.z
737
738 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000739
740
Corbin Simpson85805222010-02-02 16:20:12 -0800741.. opcode:: KIL - Conditional Discard
Keith Whitwella62aaa72009-12-21 23:25:15 +0000742
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800743.. math::
744
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800745 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000746 discard
747 endif
748
749
Corbin Simpson85805222010-02-02 16:20:12 -0800750.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000751
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800752.. math::
753
Corbin Simpsond92a6852009-12-21 19:30:29 -0800754 dst.x = \cos{src.x}
755
756 dst.y = \sin{src.x}
757
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800758 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800759
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800760 dst.y = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000761
762
Corbin Simpson85805222010-02-02 16:20:12 -0800763.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000764
765 TBD
766
767
Corbin Simpson85805222010-02-02 16:20:12 -0800768.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000769
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800770.. math::
771
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800772 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 -0800773
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800774 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 -0800775
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800776 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 -0800777
778 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000779
780
Corbin Simpson85805222010-02-02 16:20:12 -0800781.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000782
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800783.. math::
784
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800785 dst.x = \frac{src0.x}{src1.x}
786
787 dst.y = \frac{src0.y}{src1.y}
788
789 dst.z = \frac{src0.z}{src1.z}
790
791 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000792
793
Corbin Simpson85805222010-02-02 16:20:12 -0800794.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000795
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800796.. math::
797
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800798 dst.x = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800799
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800800 dst.y = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800801
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800802 dst.z = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800803
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800804 dst.w = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000805
806
Corbin Simpson85805222010-02-02 16:20:12 -0800807.. opcode:: TXL - Texture Lookup With LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000808
809 TBD
810
811
Corbin Simpson85805222010-02-02 16:20:12 -0800812.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000813
814 TBD
815
816
Corbin Simpson85805222010-02-02 16:20:12 -0800817.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000818
819 TBD
820
821
Corbin Simpson85805222010-02-02 16:20:12 -0800822.. opcode:: BGNFOR - Begin a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000823
824 dst.x = floor(src.x)
825 dst.y = floor(src.y)
826 dst.z = floor(src.z)
827
828 if (dst.y <= 0)
829 pc = [matching ENDFOR] + 1
830 endif
831
832 Note: The destination must be a loop register.
833 The source must be a constant register.
834
Keith Whitwell14eacb02009-12-21 23:38:29 +0000835 Considered for cleanup / removal.
836
Keith Whitwella62aaa72009-12-21 23:25:15 +0000837
Corbin Simpson85805222010-02-02 16:20:12 -0800838.. opcode:: REP - Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000839
840 TBD
841
842
Corbin Simpson85805222010-02-02 16:20:12 -0800843.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000844
845 TBD
846
847
Corbin Simpson85805222010-02-02 16:20:12 -0800848.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000849
850 TBD
851
852
Corbin Simpson85805222010-02-02 16:20:12 -0800853.. opcode:: ENDFOR - End a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000854
855 dst.x = dst.x + dst.z
856 dst.y = dst.y - 1.0
857
858 if (dst.y > 0)
859 pc = [matching BGNFOR instruction] + 1
860 endif
861
862 Note: The destination must be a loop register.
863
Keith Whitwell14eacb02009-12-21 23:38:29 +0000864 Considered for cleanup / removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000865
Corbin Simpson85805222010-02-02 16:20:12 -0800866.. opcode:: ENDREP - End Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000867
868 TBD
869
870
Corbin Simpson85805222010-02-02 16:20:12 -0800871.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000872
873 push(src.x)
874 push(src.y)
875 push(src.z)
876 push(src.w)
877
Keith Whitwell14eacb02009-12-21 23:38:29 +0000878 Considered for cleanup / removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000879
Corbin Simpson85805222010-02-02 16:20:12 -0800880.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000881
882 dst.w = pop()
883 dst.z = pop()
884 dst.y = pop()
885 dst.x = pop()
886
Keith Whitwell14eacb02009-12-21 23:38:29 +0000887 Considered for cleanup / removal.
888
Keith Whitwella62aaa72009-12-21 23:25:15 +0000889
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800890From GL_NV_gpu_program4
891^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000892
Keith Whitwell14eacb02009-12-21 23:38:29 +0000893Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000894
Corbin Simpson85805222010-02-02 16:20:12 -0800895.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000896
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800897.. math::
898
Corbin Simpson14743ac2009-12-21 19:57:56 -0800899 dst.x = \lceil src.x\rceil
900
901 dst.y = \lceil src.y\rceil
902
903 dst.z = \lceil src.z\rceil
904
905 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000906
907
Corbin Simpson85805222010-02-02 16:20:12 -0800908.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000909
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800910.. math::
911
Keith Whitwella62aaa72009-12-21 23:25:15 +0000912 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800913
Keith Whitwella62aaa72009-12-21 23:25:15 +0000914 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800915
Keith Whitwella62aaa72009-12-21 23:25:15 +0000916 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.w = (float) src.w
919
920
Corbin Simpson85805222010-02-02 16:20:12 -0800921.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +0000922
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800923.. math::
924
Keith Whitwella62aaa72009-12-21 23:25:15 +0000925 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800926
Keith Whitwella62aaa72009-12-21 23:25:15 +0000927 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800928
Keith Whitwella62aaa72009-12-21 23:25:15 +0000929 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.w = ~src.w
932
933
Corbin Simpson85805222010-02-02 16:20:12 -0800934.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800935
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800936.. math::
937
Keith Whitwella62aaa72009-12-21 23:25:15 +0000938 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800939
Keith Whitwella62aaa72009-12-21 23:25:15 +0000940 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800941
Keith Whitwella62aaa72009-12-21 23:25:15 +0000942 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800943
Keith Whitwella62aaa72009-12-21 23:25:15 +0000944 dst.w = trunc(src.w)
945
946
Corbin Simpson85805222010-02-02 16:20:12 -0800947.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000948
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800949.. math::
950
Keith Whitwella62aaa72009-12-21 23:25:15 +0000951 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800952
Keith Whitwella62aaa72009-12-21 23:25:15 +0000953 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800954
Keith Whitwella62aaa72009-12-21 23:25:15 +0000955 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800956
Keith Whitwella62aaa72009-12-21 23:25:15 +0000957 dst.w = src0.w << src1.x
958
959
Corbin Simpson85805222010-02-02 16:20:12 -0800960.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000961
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800962.. math::
963
Keith Whitwella62aaa72009-12-21 23:25:15 +0000964 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800965
Keith Whitwella62aaa72009-12-21 23:25:15 +0000966 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800967
Keith Whitwella62aaa72009-12-21 23:25:15 +0000968 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800969
Keith Whitwella62aaa72009-12-21 23:25:15 +0000970 dst.w = src0.w >> src1.x
971
972
Corbin Simpson85805222010-02-02 16:20:12 -0800973.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000974
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800975.. math::
976
Keith Whitwella62aaa72009-12-21 23:25:15 +0000977 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800978
Keith Whitwella62aaa72009-12-21 23:25:15 +0000979 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800980
Keith Whitwella62aaa72009-12-21 23:25:15 +0000981 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800982
Keith Whitwella62aaa72009-12-21 23:25:15 +0000983 dst.w = src0.w & src1.w
984
985
Corbin Simpson85805222010-02-02 16:20:12 -0800986.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000987
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800988.. math::
989
Keith Whitwella62aaa72009-12-21 23:25:15 +0000990 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800991
Keith Whitwella62aaa72009-12-21 23:25:15 +0000992 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800993
Keith Whitwella62aaa72009-12-21 23:25:15 +0000994 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800995
Keith Whitwella62aaa72009-12-21 23:25:15 +0000996 dst.w = src0.w | src1.w
997
998
Corbin Simpson85805222010-02-02 16:20:12 -0800999.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +00001000
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001001.. math::
1002
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001003 dst.x = src0.x \bmod src1.x
1004
1005 dst.y = src0.y \bmod src1.y
1006
1007 dst.z = src0.z \bmod src1.z
1008
1009 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001010
1011
Corbin Simpson85805222010-02-02 16:20:12 -08001012.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +00001013
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001014.. math::
1015
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001016 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001017
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001018 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001019
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001020 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001021
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001022 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001023
1024
Corbin Simpson85805222010-02-02 16:20:12 -08001025.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +00001026
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001027.. math::
1028
Corbin Simpson14743ac2009-12-21 19:57:56 -08001029 dst.x = |src0.x - src1.x| + src2.x
1030
1031 dst.y = |src0.y - src1.y| + src2.y
1032
1033 dst.z = |src0.z - src1.z| + src2.z
1034
1035 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001036
1037
Corbin Simpson85805222010-02-02 16:20:12 -08001038.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +00001039
1040 TBD
1041
1042
Corbin Simpson85805222010-02-02 16:20:12 -08001043.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +00001044
1045 TBD
1046
1047
Corbin Simpson85805222010-02-02 16:20:12 -08001048.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +00001049
1050 TBD
1051
1052
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001053From GL_NV_geometry_program4
1054^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001055
1056
Corbin Simpson85805222010-02-02 16:20:12 -08001057.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001058
1059 TBD
1060
1061
Corbin Simpson85805222010-02-02 16:20:12 -08001062.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001063
1064 TBD
1065
1066
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001067From GLSL
1068^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001069
1070
Corbin Simpson85805222010-02-02 16:20:12 -08001071.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001072
1073 TBD
1074
1075
Corbin Simpson85805222010-02-02 16:20:12 -08001076.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001077
1078 TBD
1079
1080
Corbin Simpson85805222010-02-02 16:20:12 -08001081.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001082
1083 TBD
1084
1085
Corbin Simpson85805222010-02-02 16:20:12 -08001086.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001087
1088 TBD
1089
1090
Corbin Simpson85805222010-02-02 16:20:12 -08001091.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001092
Michal Krol8ab89d72010-01-04 13:23:41 +01001093 Do nothing.
1094
Keith Whitwella62aaa72009-12-21 23:25:15 +00001095
Corbin Simpson85805222010-02-02 16:20:12 -08001096.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001097
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001098.. math::
1099
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001100 dst.x = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
1101
1102 dst.y = \frac{src.y}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
1103
1104 dst.z = \frac{src.z}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
1105
1106 dst.w = \frac{src.w}{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 +00001107
1108
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001109ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001110^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001111
1112
Corbin Simpson85805222010-02-02 16:20:12 -08001113.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001114
1115 TBD
1116
1117
Corbin Simpson85805222010-02-02 16:20:12 -08001118.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001119
1120 TBD
1121
1122
Corbin Simpson85805222010-02-02 16:20:12 -08001123.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001124
1125 TBD
1126
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001127.. _doubleopcodes:
1128
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001129Double Opcodes
1130^^^^^^^^^^^^^^^
1131
Corbin Simpson85805222010-02-02 16:20:12 -08001132.. opcode:: DADD - Add Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001133
1134.. math::
1135
1136 dst.xy = src0.xy + src1.xy
1137
1138 dst.zw = src0.zw + src1.zw
1139
1140
Corbin Simpson85805222010-02-02 16:20:12 -08001141.. opcode:: DDIV - Divide Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001142
1143.. math::
1144
1145 dst.xy = src0.xy / src1.xy
1146
1147 dst.zw = src0.zw / src1.zw
1148
Corbin Simpson85805222010-02-02 16:20:12 -08001149.. opcode:: DSEQ - Set Double on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001150
1151.. math::
1152
1153 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1154
1155 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1156
Corbin Simpson85805222010-02-02 16:20:12 -08001157.. opcode:: DSLT - Set Double on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001158
1159.. math::
1160
1161 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1162
1163 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1164
Corbin Simpson85805222010-02-02 16:20:12 -08001165.. opcode:: DFRAC - Double Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001166
1167.. math::
1168
1169 dst.xy = src.xy - \lfloor src.xy\rfloor
1170
1171 dst.zw = src.zw - \lfloor src.zw\rfloor
1172
1173
Corbin Simpson85805222010-02-02 16:20:12 -08001174.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001175
1176.. math::
1177
1178 dst0.xy = frexp(src.xy, dst1.xy)
1179
1180 dst0.zw = frexp(src.zw, dst1.zw)
1181
Corbin Simpson85805222010-02-02 16:20:12 -08001182.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001183
1184.. math::
1185
1186 dst.xy = ldexp(src0.xy, src1.xy)
1187
1188 dst.zw = ldexp(src0.zw, src1.zw)
1189
Corbin Simpson85805222010-02-02 16:20:12 -08001190.. opcode:: DMIN - Minimum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001191
1192.. math::
1193
1194 dst.xy = min(src0.xy, src1.xy)
1195
1196 dst.zw = min(src0.zw, src1.zw)
1197
Corbin Simpson85805222010-02-02 16:20:12 -08001198.. opcode:: DMAX - Maximum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001199
1200.. math::
1201
1202 dst.xy = max(src0.xy, src1.xy)
1203
1204 dst.zw = max(src0.zw, src1.zw)
1205
Corbin Simpson85805222010-02-02 16:20:12 -08001206.. opcode:: DMUL - Multiply Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001207
1208.. math::
1209
1210 dst.xy = src0.xy \times src1.xy
1211
1212 dst.zw = src0.zw \times src1.zw
1213
1214
Corbin Simpson85805222010-02-02 16:20:12 -08001215.. opcode:: DMAD - Multiply And Add Doubles
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001216
1217.. math::
1218
1219 dst.xy = src0.xy \times src1.xy + src2.xy
1220
1221 dst.zw = src0.zw \times src1.zw + src2.zw
1222
1223
Corbin Simpson85805222010-02-02 16:20:12 -08001224.. opcode:: DRCP - Reciprocal Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001225
1226.. math::
1227
1228 dst.xy = \frac{1}{src.xy}
1229
1230 dst.zw = \frac{1}{src.zw}
1231
Corbin Simpson85805222010-02-02 16:20:12 -08001232.. opcode:: DSQRT - Square root double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001233
1234.. math::
1235
1236 dst.xy = \sqrt{src.xy}
1237
1238 dst.zw = \sqrt{src.zw}
1239
Keith Whitwella62aaa72009-12-21 23:25:15 +00001240
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001241Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001242------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001243
1244
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001245Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001246^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001247
1248
Corbin Simpson14743ac2009-12-21 19:57:56 -08001249 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001250
Corbin Simpson14743ac2009-12-21 19:57:56 -08001251 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001252
1253 clamp(x,y,z) Clamp x between y and z.
1254 (x < y) ? y : (x > z) ? z : x
1255
Corbin Simpsondd801e52009-12-21 19:41:09 -08001256 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001257
Corbin Simpson14743ac2009-12-21 19:57:56 -08001258 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001259
1260 max(x,y) Maximum of x and y.
1261 (x > y) ? x : y
1262
1263 min(x,y) Minimum of x and y.
1264 (x < y) ? x : y
1265
1266 partialx(x) Derivative of x relative to fragment's X.
1267
1268 partialy(x) Derivative of x relative to fragment's Y.
1269
1270 pop() Pop from stack.
1271
Corbin Simpsondd801e52009-12-21 19:41:09 -08001272 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001273
1274 push(x) Push x on stack.
1275
1276 round(x) Round x.
1277
Michal Krol07f416c2010-01-04 13:21:32 +01001278 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001279
1280
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001281Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001282^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001283
1284
1285 discard Discard fragment.
1286
Keith Whitwella62aaa72009-12-21 23:25:15 +00001287 pc Program counter.
1288
Keith Whitwella62aaa72009-12-21 23:25:15 +00001289 target Label of target instruction.
1290
1291
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001292Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001293---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001294
1295
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001296Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001297^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001298
1299
1300 Follows Declaration token if Semantic bit is set.
1301
1302 Since its purpose is to link a shader with other stages of the pipeline,
1303 it is valid to follow only those Declaration tokens that declare a register
1304 either in INPUT or OUTPUT file.
1305
1306 SemanticName field contains the semantic name of the register being declared.
1307 There is no default value.
1308
1309 SemanticIndex is an optional subscript that can be used to distinguish
1310 different register declarations with the same semantic name. The default value
1311 is 0.
1312
1313 The meanings of the individual semantic names are explained in the following
1314 sections.
1315
Corbin Simpson54ddf642009-12-23 23:36:06 -08001316TGSI_SEMANTIC_POSITION
1317""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001318
Corbin Simpson54ddf642009-12-23 23:36:06 -08001319Position, sometimes known as HPOS or WPOS for historical reasons, is the
1320location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1321are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1322for the perspective divide, if enabled.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001323
Corbin Simpson54ddf642009-12-23 23:36:06 -08001324As a vertex shader output, position should be scaled to the viewport. When
Luca Barbieri73317132010-01-21 05:36:14 +01001325used in fragment shaders, position will be in window coordinates. The convention
1326used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001327
1328XXX additionally, is there a way to configure the perspective divide? it's
1329accelerated on most chipsets AFAIK...
1330
1331Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1332be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1333
1334XXX usually? can we solidify that?
1335
1336TGSI_SEMANTIC_COLOR
1337"""""""""""""""""""
1338
1339Colors are used to, well, color the primitives. Colors are always in
1340``(r, g, b, a)`` format.
1341
1342If alpha is not specified, it defaults to 1.
1343
1344TGSI_SEMANTIC_BCOLOR
1345""""""""""""""""""""
1346
1347Back-facing colors are only used for back-facing polygons, and are only valid
1348in vertex shader outputs. After rasterization, all polygons are front-facing
1349and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1350all BCOLORs effectively become regular COLORs in the fragment shader.
1351
1352TGSI_SEMANTIC_FOG
1353"""""""""""""""""
1354
1355The fog coordinate historically has been used to replace the depth coordinate
1356for generation of fog in dedicated fog blocks. Gallium, however, does not use
1357dedicated fog acceleration, placing it entirely in the fragment shader
1358instead.
1359
1360The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1361component matters when writing from the vertex shader; the driver will ensure
1362that the coordinate is in this format when used as a fragment shader input.
1363
1364TGSI_SEMANTIC_PSIZE
1365"""""""""""""""""""
1366
1367PSIZE, or point size, is used to specify point sizes per-vertex. It should
1368be in ``(p, n, x, f)`` format, where ``p`` is the point size, ``n`` is the minimum
1369size, ``x`` is the maximum size, and ``f`` is the fade threshold.
1370
1371XXX this is arb_vp. is this what we actually do? should double-check...
1372
1373When using this semantic, be sure to set the appropriate state in the
1374:ref:`rasterizer` first.
1375
1376TGSI_SEMANTIC_GENERIC
1377"""""""""""""""""""""
1378
1379Generic semantics are nearly always used for texture coordinate attributes,
1380in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1381of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1382
1383These attributes are called "generic" because they may be used for anything
1384else, including parameters, texture generation information, or anything that
1385can be stored inside a four-component vector.
1386
1387TGSI_SEMANTIC_NORMAL
1388""""""""""""""""""""
1389
Michal Krol86b336f2010-01-04 13:38:58 +01001390Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1391that allow mixing fixed-function and programmable stages.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001392
1393TGSI_SEMANTIC_FACE
1394""""""""""""""""""
1395
1396FACE is the facing bit, to store the facing information for the fragment
1397shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1398when the fragment is front-facing, and negative when the component is
1399back-facing.
1400
1401TGSI_SEMANTIC_EDGEFLAG
1402""""""""""""""""""""""
1403
1404XXX no clue
Luca Barbieri73317132010-01-21 05:36:14 +01001405
1406
1407Properties
1408^^^^^^^^^^^^^^^^^^^^^^^^
1409
1410
1411 Properties are general directives that apply to the whole TGSI program.
1412
1413FS_COORD_ORIGIN
1414"""""""""""""""
1415
1416Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1417The default value is UPPER_LEFT.
1418
1419If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1420increase downward and rightward.
1421If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1422increase upward and rightward.
1423
1424OpenGL defaults to LOWER_LEFT, and is configurable with the
1425GL_ARB_fragment_coord_conventions extension.
1426
1427DirectX 9/10 use UPPER_LEFT.
1428
1429FS_COORD_PIXEL_CENTER
1430"""""""""""""""""""""
1431
1432Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1433The default value is HALF_INTEGER.
1434
1435If HALF_INTEGER, the fractionary part of the position will be 0.5
1436If INTEGER, the fractionary part of the position will be 0.0
1437
1438Note that this does not affect the set of fragments generated by
1439rasterization, which is instead controlled by gl_rasterization_rules in the
1440rasterizer.
1441
1442OpenGL defaults to HALF_INTEGER, and is configurable with the
1443GL_ARB_fragment_coord_conventions extension.
1444
1445DirectX 9 uses INTEGER.
1446DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001447
1448
1449
1450Texture Sampling and Texture Formats
1451------------------------------------
1452
1453This table shows how texture image components are returned as (x,y,z,w)
1454tuples by TGSI texture instructions, such as TEX, TXD, and TXP.
Brian Paul3a3d8fb2010-02-02 16:20:26 -07001455For reference, OpenGL and Direct3D conventions are shown as well.
Brian Paul4778f462010-02-02 08:14:40 -07001456
Corbin Simpson516e7152010-02-02 12:44:22 -08001457+--------------------+--------------+--------------------+--------------+
1458| Texture Components | Gallium | OpenGL | Direct3D 9 |
1459+====================+==============+====================+==============+
1460| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1461+--------------------+--------------+--------------------+--------------+
1462| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1463+--------------------+--------------+--------------------+--------------+
1464| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1465+--------------------+--------------+--------------------+--------------+
1466| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1467+--------------------+--------------+--------------------+--------------+
1468| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1469+--------------------+--------------+--------------------+--------------+
1470| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1471+--------------------+--------------+--------------------+--------------+
1472| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1473+--------------------+--------------+--------------------+--------------+
1474| I | (i, i, i, i) | (i, i, i, i) | N/A |
1475+--------------------+--------------+--------------------+--------------+
1476| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1477| | | [#envmap-bumpmap]_ | |
1478+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001479| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001480| | | [#depth-tex-mode]_ | |
1481+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001482
Corbin Simpson516e7152010-02-02 12:44:22 -08001483.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001484.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
1485 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.