blob: 34d80da1d340ce7a8d3e5dfac4eb99ca2193f346 [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 Simpson5bcd26c2009-12-21 21:04:10 -08009Instruction Set
10---------------
11
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080012From GL_NV_vertex_program
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080013^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000014
15
Corbin Simpson85805222010-02-02 16:20:12 -080016.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080017
18.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000019
Corbin Simpsond92a6852009-12-21 19:30:29 -080020 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080021
Corbin Simpsond92a6852009-12-21 19:30:29 -080022 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080023
Corbin Simpsond92a6852009-12-21 19:30:29 -080024 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080025
Corbin Simpsond92a6852009-12-21 19:30:29 -080026 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000027
28
Corbin Simpson85805222010-02-02 16:20:12 -080029.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080030
31.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000032
33 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080034
Keith Whitwella62aaa72009-12-21 23:25:15 +000035 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080036
Keith Whitwella62aaa72009-12-21 23:25:15 +000037 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080038
Keith Whitwella62aaa72009-12-21 23:25:15 +000039 dst.w = src.w
40
41
Corbin Simpson85805222010-02-02 16:20:12 -080042.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080043
44.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000045
Corbin Simpsonda65ac62009-12-21 20:32:46 -080046 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080047
Corbin Simpsonda65ac62009-12-21 20:32:46 -080048 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080049
Corbin Simpsonda65ac62009-12-21 20:32:46 -080050 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080051
Corbin Simpsonda65ac62009-12-21 20:32:46 -080052 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000053
54
Corbin Simpson85805222010-02-02 16:20:12 -080055.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080056
57.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000058
Corbin Simpson14743ac2009-12-21 19:57:56 -080059 dst.x = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080060
Corbin Simpson14743ac2009-12-21 19:57:56 -080061 dst.y = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080062
Corbin Simpson14743ac2009-12-21 19:57:56 -080063 dst.z = \frac{1}{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080064
Corbin Simpson14743ac2009-12-21 19:57:56 -080065 dst.w = \frac{1}{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +000066
67
Corbin Simpson85805222010-02-02 16:20:12 -080068.. opcode:: RSQ - Reciprocal Square Root
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}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080073
Corbin Simpson14743ac2009-12-21 19:57:56 -080074 dst.y = \frac{1}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080075
Corbin Simpson14743ac2009-12-21 19:57:56 -080076 dst.z = \frac{1}{\sqrt{|src.x|}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080077
Corbin Simpson14743ac2009-12-21 19:57:56 -080078 dst.w = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +000079
80
Corbin Simpson85805222010-02-02 16:20:12 -080081.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080082
83.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000084
Corbin Simpsondd801e52009-12-21 19:41:09 -080085 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080086
Corbin Simpsond92a6852009-12-21 19:30:29 -080087 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080088
Corbin Simpsondd801e52009-12-21 19:41:09 -080089 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080090
Corbin Simpsonda65ac62009-12-21 20:32:46 -080091 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000092
93
Corbin Simpson85805222010-02-02 16:20:12 -080094.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080095
96.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000097
Corbin Simpson14743ac2009-12-21 19:57:56 -080098 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099
Corbin Simpson14743ac2009-12-21 19:57:56 -0800100 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800101
Corbin Simpson14743ac2009-12-21 19:57:56 -0800102 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800103
Corbin Simpson14743ac2009-12-21 19:57:56 -0800104 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000105
106
Corbin Simpson85805222010-02-02 16:20:12 -0800107.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800108
109.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000110
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800111 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800112
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800113 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800114
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800115 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800116
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800117 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000118
119
Corbin Simpson85805222010-02-02 16:20:12 -0800120.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800121
122.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000123
124 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800125
Keith Whitwella62aaa72009-12-21 23:25:15 +0000126 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800127
Keith Whitwella62aaa72009-12-21 23:25:15 +0000128 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800129
Keith Whitwella62aaa72009-12-21 23:25:15 +0000130 dst.w = src0.w + src1.w
131
132
Corbin Simpson85805222010-02-02 16:20:12 -0800133.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800134
135.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000136
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800137 dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800138
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800139 dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800140
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800141 dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800142
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800143 dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000144
145
Corbin Simpson85805222010-02-02 16:20:12 -0800146.. opcode:: DP4 - 4-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 + src0.w \times src1.w
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 + src0.w \times src1.w
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 + src0.w \times src1.w
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 + src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000157
158
Corbin Simpson85805222010-02-02 16:20:12 -0800159.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800160
161.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000162
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800163 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800164
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800165 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800166
Keith Whitwella62aaa72009-12-21 23:25:15 +0000167 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800168
Keith Whitwella62aaa72009-12-21 23:25:15 +0000169 dst.w = src1.w
170
171
Corbin Simpson85805222010-02-02 16:20:12 -0800172.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800173
174.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000175
176 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800177
Keith Whitwella62aaa72009-12-21 23:25:15 +0000178 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800179
Keith Whitwella62aaa72009-12-21 23:25:15 +0000180 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800181
Keith Whitwella62aaa72009-12-21 23:25:15 +0000182 dst.w = min(src0.w, src1.w)
183
184
Corbin Simpson85805222010-02-02 16:20:12 -0800185.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800186
187.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000188
189 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800190
Keith Whitwella62aaa72009-12-21 23:25:15 +0000191 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800192
Keith Whitwella62aaa72009-12-21 23:25:15 +0000193 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800194
Keith Whitwella62aaa72009-12-21 23:25:15 +0000195 dst.w = max(src0.w, src1.w)
196
197
Corbin Simpson85805222010-02-02 16:20:12 -0800198.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800199
200.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000201
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800202 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800203
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800204 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800205
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800206 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800207
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800208 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000209
210
Corbin Simpson85805222010-02-02 16:20:12 -0800211.. opcode:: SGE - Set On Greater Equal 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:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800225
226.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000227
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800228 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800229
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800230 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800231
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800232 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800233
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800234 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000235
236
Corbin Simpson85805222010-02-02 16:20:12 -0800237.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800238
239.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000240
241 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800242
Keith Whitwella62aaa72009-12-21 23:25:15 +0000243 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800244
Keith Whitwella62aaa72009-12-21 23:25:15 +0000245 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800246
Keith Whitwella62aaa72009-12-21 23:25:15 +0000247 dst.w = src0.w - src1.w
248
249
Corbin Simpson85805222010-02-02 16:20:12 -0800250.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800251
252.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000253
Michal Krolb3567fc2010-01-04 12:59:17 +0100254 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800255
Michal Krolb3567fc2010-01-04 12:59:17 +0100256 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800257
Michal Krolb3567fc2010-01-04 12:59:17 +0100258 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800259
Michal Krolb3567fc2010-01-04 12:59:17 +0100260 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000261
262
Corbin Simpson85805222010-02-02 16:20:12 -0800263.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800264
265.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000266
267 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800268
Keith Whitwella62aaa72009-12-21 23:25:15 +0000269 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800270
Keith Whitwella62aaa72009-12-21 23:25:15 +0000271 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800272
Keith Whitwella62aaa72009-12-21 23:25:15 +0000273 dst.w = (src2.w > 0.5) ? src0.w : src1.w
274
275
Corbin Simpson85805222010-02-02 16:20:12 -0800276.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800277
278.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000279
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800280 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800281
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800282 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800283
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800284 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800285
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800286 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000287
288
Corbin Simpson85805222010-02-02 16:20:12 -0800289.. opcode:: FRAC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800290
291.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000292
Corbin Simpsond92a6852009-12-21 19:30:29 -0800293 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800294
Corbin Simpsond92a6852009-12-21 19:30:29 -0800295 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800296
Corbin Simpsond92a6852009-12-21 19:30:29 -0800297 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800298
Corbin Simpsond92a6852009-12-21 19:30:29 -0800299 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000300
301
Corbin Simpson85805222010-02-02 16:20:12 -0800302.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800303
304.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000305
306 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800307
Keith Whitwella62aaa72009-12-21 23:25:15 +0000308 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800309
Keith Whitwella62aaa72009-12-21 23:25:15 +0000310 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800311
Keith Whitwella62aaa72009-12-21 23:25:15 +0000312 dst.w = clamp(src0.w, src1.w, src2.w)
313
314
Corbin Simpson85805222010-02-02 16:20:12 -0800315.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800316
317This is identical to ARL.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000318
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800319.. math::
320
Corbin Simpsond92a6852009-12-21 19:30:29 -0800321 dst.x = \lfloor src.x\rfloor
322
323 dst.y = \lfloor src.y\rfloor
324
325 dst.z = \lfloor src.z\rfloor
326
327 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000328
329
Corbin Simpson85805222010-02-02 16:20:12 -0800330.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000331
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800332.. math::
333
Keith Whitwella62aaa72009-12-21 23:25:15 +0000334 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800335
Keith Whitwella62aaa72009-12-21 23:25:15 +0000336 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800337
Keith Whitwella62aaa72009-12-21 23:25:15 +0000338 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800339
Keith Whitwella62aaa72009-12-21 23:25:15 +0000340 dst.w = round(src.w)
341
342
Corbin Simpson85805222010-02-02 16:20:12 -0800343.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000344
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800345.. math::
346
Corbin Simpsondd801e52009-12-21 19:41:09 -0800347 dst.x = 2^{src.x}
348
349 dst.y = 2^{src.x}
350
351 dst.z = 2^{src.x}
352
353 dst.w = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000354
355
Corbin Simpson85805222010-02-02 16:20:12 -0800356.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000357
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800358.. math::
359
Corbin Simpson14743ac2009-12-21 19:57:56 -0800360 dst.x = \log_2{src.x}
361
362 dst.y = \log_2{src.x}
363
364 dst.z = \log_2{src.x}
365
366 dst.w = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000367
368
Corbin Simpson85805222010-02-02 16:20:12 -0800369.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000370
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800371.. math::
372
Corbin Simpsondd801e52009-12-21 19:41:09 -0800373 dst.x = src0.x^{src1.x}
374
375 dst.y = src0.x^{src1.x}
376
377 dst.z = src0.x^{src1.x}
378
379 dst.w = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000380
Corbin Simpson85805222010-02-02 16:20:12 -0800381.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000382
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800383.. math::
384
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800385 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800386
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800387 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800388
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800389 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800390
391 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000392
393
Corbin Simpson85805222010-02-02 16:20:12 -0800394.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000395
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800396.. math::
397
Corbin Simpson14743ac2009-12-21 19:57:56 -0800398 dst.x = |src.x|
399
400 dst.y = |src.y|
401
402 dst.z = |src.z|
403
404 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000405
406
Corbin Simpson85805222010-02-02 16:20:12 -0800407.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800408
409XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000410
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800411.. math::
412
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800413 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)
414
415 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)
416
417 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)
418
419 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 +0000420
421
Corbin Simpson85805222010-02-02 16:20:12 -0800422.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000423
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800424.. math::
425
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800426 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 -0800427
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800428 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 -0800429
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800430 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 -0800431
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800432 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 +0000433
434
Corbin Simpson85805222010-02-02 16:20:12 -0800435.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000436
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800437.. math::
438
Corbin Simpsond92a6852009-12-21 19:30:29 -0800439 dst.x = \cos{src.x}
440
441 dst.y = \cos{src.x}
442
443 dst.z = \cos{src.x}
444
Michal Krolc9296642010-01-04 13:12:27 +0100445 dst.w = \cos{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000446
447
Corbin Simpson85805222010-02-02 16:20:12 -0800448.. opcode:: DDX - Derivative Relative To X
Keith Whitwella62aaa72009-12-21 23:25:15 +0000449
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800450.. math::
451
Keith Whitwella62aaa72009-12-21 23:25:15 +0000452 dst.x = partialx(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800453
Keith Whitwella62aaa72009-12-21 23:25:15 +0000454 dst.y = partialx(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800455
Keith Whitwella62aaa72009-12-21 23:25:15 +0000456 dst.z = partialx(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800457
Keith Whitwella62aaa72009-12-21 23:25:15 +0000458 dst.w = partialx(src.w)
459
460
Corbin Simpson85805222010-02-02 16:20:12 -0800461.. opcode:: DDY - Derivative Relative To Y
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 = partialy(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800466
Keith Whitwella62aaa72009-12-21 23:25:15 +0000467 dst.y = partialy(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800468
Keith Whitwella62aaa72009-12-21 23:25:15 +0000469 dst.z = partialy(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800470
Keith Whitwella62aaa72009-12-21 23:25:15 +0000471 dst.w = partialy(src.w)
472
473
Corbin Simpson85805222010-02-02 16:20:12 -0800474.. opcode:: KILP - Predicated Discard
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800475
Keith Whitwella62aaa72009-12-21 23:25:15 +0000476 discard
477
478
Corbin Simpson85805222010-02-02 16:20:12 -0800479.. opcode:: PK2H - Pack Two 16-bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000480
481 TBD
482
483
Corbin Simpson85805222010-02-02 16:20:12 -0800484.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000485
486 TBD
487
488
Corbin Simpson85805222010-02-02 16:20:12 -0800489.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000490
491 TBD
492
493
Corbin Simpson85805222010-02-02 16:20:12 -0800494.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000495
496 TBD
497
498
Corbin Simpson85805222010-02-02 16:20:12 -0800499.. opcode:: RFL - Reflection Vector
Keith Whitwella62aaa72009-12-21 23:25:15 +0000500
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800501.. math::
502
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800503 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
504
505 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
506
507 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
508
509 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000510
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800511Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000512
Keith Whitwella62aaa72009-12-21 23:25:15 +0000513
Corbin Simpson85805222010-02-02 16:20:12 -0800514.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000515
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800516.. math::
517
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800518 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800519
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800520 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800521
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800522 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800523
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800524 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000525
526
Corbin Simpson85805222010-02-02 16:20:12 -0800527.. opcode:: SFL - Set On False
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 = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800532
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800533 dst.y = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800534
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800535 dst.z = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800536
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800537 dst.w = 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000538
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800539Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000540
Corbin Simpson85805222010-02-02 16:20:12 -0800541.. opcode:: SGT - Set On Greater 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:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000555
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800556.. math::
557
Corbin Simpsond92a6852009-12-21 19:30:29 -0800558 dst.x = \sin{src.x}
559
560 dst.y = \sin{src.x}
561
562 dst.z = \sin{src.x}
563
Michal Krolc9296642010-01-04 13:12:27 +0100564 dst.w = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000565
566
Corbin Simpson85805222010-02-02 16:20:12 -0800567.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000568
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800569.. math::
570
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800571 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800572
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800573 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800574
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800575 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800576
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800577 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000578
579
Corbin Simpson85805222010-02-02 16:20:12 -0800580.. opcode:: SNE - Set On Not Equal
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:: STR - Set On True
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 = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800598
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800599 dst.y = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800600
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800601 dst.z = 1
Corbin Simpson04771912010-01-18 17:31:56 -0800602
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800603 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000604
605
Corbin Simpson85805222010-02-02 16:20:12 -0800606.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000607
608 TBD
609
610
Corbin Simpson85805222010-02-02 16:20:12 -0800611.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000612
613 TBD
614
615
Corbin Simpson85805222010-02-02 16:20:12 -0800616.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000617
618 TBD
619
620
Corbin Simpson85805222010-02-02 16:20:12 -0800621.. opcode:: UP2H - Unpack Two 16-Bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000622
623 TBD
624
Keith Whitwell14eacb02009-12-21 23:38:29 +0000625 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000626
Corbin Simpson85805222010-02-02 16:20:12 -0800627.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000628
629 TBD
630
Keith Whitwell14eacb02009-12-21 23:38:29 +0000631 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000632
Corbin Simpson85805222010-02-02 16:20:12 -0800633.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000634
635 TBD
636
Keith Whitwell14eacb02009-12-21 23:38:29 +0000637 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000638
Corbin Simpson85805222010-02-02 16:20:12 -0800639.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000640
641 TBD
642
Keith Whitwell14eacb02009-12-21 23:38:29 +0000643 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000644
Corbin Simpson85805222010-02-02 16:20:12 -0800645.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000646
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800647.. math::
648
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800649 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800650
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800651 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800652
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800653 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800654
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800655 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000656
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800657Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000658
Keith Whitwella62aaa72009-12-21 23:25:15 +0000659
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800660From GL_NV_vertex_program2
661^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000662
663
Corbin Simpson85805222010-02-02 16:20:12 -0800664.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000665
666 TBD
667
Keith Whitwell14eacb02009-12-21 23:38:29 +0000668 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000669
Corbin Simpson85805222010-02-02 16:20:12 -0800670.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000671
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800672.. math::
673
Keith Whitwella62aaa72009-12-21 23:25:15 +0000674 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800675
Keith Whitwella62aaa72009-12-21 23:25:15 +0000676 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800677
Keith Whitwella62aaa72009-12-21 23:25:15 +0000678 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800679
Keith Whitwella62aaa72009-12-21 23:25:15 +0000680 dst.w = round(src.w)
681
682
Corbin Simpson85805222010-02-02 16:20:12 -0800683.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000684
685 pc = target
686
Keith Whitwell14eacb02009-12-21 23:38:29 +0000687 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000688
Corbin Simpson85805222010-02-02 16:20:12 -0800689.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000690
691 push(pc)
692 pc = target
693
694
Corbin Simpson85805222010-02-02 16:20:12 -0800695.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000696
697 pc = pop()
698
Keith Whitwell14eacb02009-12-21 23:38:29 +0000699 Potential restrictions:
Michal Krolcef21802010-01-04 13:15:28 +0100700 * Only occurs at end of function.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000701
Corbin Simpson85805222010-02-02 16:20:12 -0800702.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000703
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800704.. math::
705
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800706 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
707
708 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
709
710 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
711
712 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000713
714
Corbin Simpson85805222010-02-02 16:20:12 -0800715.. opcode:: CMP - Compare
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 = (src0.x < 0) ? src1.x : src2.x
720
721 dst.y = (src0.y < 0) ? src1.y : src2.y
722
723 dst.z = (src0.z < 0) ? src1.z : src2.z
724
725 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000726
727
Corbin Simpson85805222010-02-02 16:20:12 -0800728.. opcode:: KIL - Conditional Discard
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 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000733 discard
734 endif
735
736
Corbin Simpson85805222010-02-02 16:20:12 -0800737.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000738
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800739.. math::
740
Corbin Simpsond92a6852009-12-21 19:30:29 -0800741 dst.x = \cos{src.x}
742
743 dst.y = \sin{src.x}
744
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800745 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800746
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800747 dst.y = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000748
749
Corbin Simpson85805222010-02-02 16:20:12 -0800750.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000751
752 TBD
753
754
Corbin Simpson85805222010-02-02 16:20:12 -0800755.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000756
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800757.. math::
758
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800759 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 -0800760
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800761 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 -0800762
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800763 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 -0800764
765 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000766
767
Corbin Simpson85805222010-02-02 16:20:12 -0800768.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000769
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800770.. math::
771
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800772 dst.x = \frac{src0.x}{src1.x}
773
774 dst.y = \frac{src0.y}{src1.y}
775
776 dst.z = \frac{src0.z}{src1.z}
777
778 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000779
780
Corbin Simpson85805222010-02-02 16:20:12 -0800781.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000782
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800783.. math::
784
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800785 dst.x = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800786
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800787 dst.y = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800788
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800789 dst.z = src0.x \times src1.x + src0.y \times src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800790
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800791 dst.w = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000792
793
Corbin Simpson85805222010-02-02 16:20:12 -0800794.. opcode:: TXL - Texture Lookup With LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000795
796 TBD
797
798
Corbin Simpson85805222010-02-02 16:20:12 -0800799.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000800
801 TBD
802
803
Corbin Simpson85805222010-02-02 16:20:12 -0800804.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000805
806 TBD
807
808
Corbin Simpson85805222010-02-02 16:20:12 -0800809.. opcode:: BGNFOR - Begin a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000810
811 dst.x = floor(src.x)
812 dst.y = floor(src.y)
813 dst.z = floor(src.z)
814
815 if (dst.y <= 0)
816 pc = [matching ENDFOR] + 1
817 endif
818
819 Note: The destination must be a loop register.
820 The source must be a constant register.
821
Keith Whitwell14eacb02009-12-21 23:38:29 +0000822 Considered for cleanup / removal.
823
Keith Whitwella62aaa72009-12-21 23:25:15 +0000824
Corbin Simpson85805222010-02-02 16:20:12 -0800825.. opcode:: REP - Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000826
827 TBD
828
829
Corbin Simpson85805222010-02-02 16:20:12 -0800830.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000831
832 TBD
833
834
Corbin Simpson85805222010-02-02 16:20:12 -0800835.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000836
837 TBD
838
839
Corbin Simpson85805222010-02-02 16:20:12 -0800840.. opcode:: ENDFOR - End a For-Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +0000841
842 dst.x = dst.x + dst.z
843 dst.y = dst.y - 1.0
844
845 if (dst.y > 0)
846 pc = [matching BGNFOR instruction] + 1
847 endif
848
849 Note: The destination must be a loop register.
850
Keith Whitwell14eacb02009-12-21 23:38:29 +0000851 Considered for cleanup / removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000852
Corbin Simpson85805222010-02-02 16:20:12 -0800853.. opcode:: ENDREP - End Repeat
Keith Whitwella62aaa72009-12-21 23:25:15 +0000854
855 TBD
856
857
Corbin Simpson85805222010-02-02 16:20:12 -0800858.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000859
860 push(src.x)
861 push(src.y)
862 push(src.z)
863 push(src.w)
864
Keith Whitwell14eacb02009-12-21 23:38:29 +0000865 Considered for cleanup / removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000866
Corbin Simpson85805222010-02-02 16:20:12 -0800867.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000868
869 dst.w = pop()
870 dst.z = pop()
871 dst.y = pop()
872 dst.x = pop()
873
Keith Whitwell14eacb02009-12-21 23:38:29 +0000874 Considered for cleanup / removal.
875
Keith Whitwella62aaa72009-12-21 23:25:15 +0000876
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800877From GL_NV_gpu_program4
878^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000879
Keith Whitwell14eacb02009-12-21 23:38:29 +0000880Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000881
Corbin Simpson85805222010-02-02 16:20:12 -0800882.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000883
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800884.. math::
885
Corbin Simpson14743ac2009-12-21 19:57:56 -0800886 dst.x = \lceil src.x\rceil
887
888 dst.y = \lceil src.y\rceil
889
890 dst.z = \lceil src.z\rceil
891
892 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000893
894
Corbin Simpson85805222010-02-02 16:20:12 -0800895.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000896
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800897.. math::
898
Keith Whitwella62aaa72009-12-21 23:25:15 +0000899 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800900
Keith Whitwella62aaa72009-12-21 23:25:15 +0000901 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800902
Keith Whitwella62aaa72009-12-21 23:25:15 +0000903 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800904
Keith Whitwella62aaa72009-12-21 23:25:15 +0000905 dst.w = (float) src.w
906
907
Corbin Simpson85805222010-02-02 16:20:12 -0800908.. opcode:: NOT - Bitwise Not
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 = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800913
Keith Whitwella62aaa72009-12-21 23:25:15 +0000914 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800915
Keith Whitwella62aaa72009-12-21 23:25:15 +0000916 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.w = ~src.w
919
920
Corbin Simpson85805222010-02-02 16:20:12 -0800921.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800922
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800923.. math::
924
Keith Whitwella62aaa72009-12-21 23:25:15 +0000925 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800926
Keith Whitwella62aaa72009-12-21 23:25:15 +0000927 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800928
Keith Whitwella62aaa72009-12-21 23:25:15 +0000929 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.w = trunc(src.w)
932
933
Corbin Simpson85805222010-02-02 16:20:12 -0800934.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000935
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800936.. math::
937
Keith Whitwella62aaa72009-12-21 23:25:15 +0000938 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800939
Keith Whitwella62aaa72009-12-21 23:25:15 +0000940 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800941
Keith Whitwella62aaa72009-12-21 23:25:15 +0000942 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800943
Keith Whitwella62aaa72009-12-21 23:25:15 +0000944 dst.w = src0.w << src1.x
945
946
Corbin Simpson85805222010-02-02 16:20:12 -0800947.. opcode:: SHR - Shift Right
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:: AND - Bitwise And
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.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800967
Keith Whitwella62aaa72009-12-21 23:25:15 +0000968 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800969
Keith Whitwella62aaa72009-12-21 23:25:15 +0000970 dst.w = src0.w & src1.w
971
972
Corbin Simpson85805222010-02-02 16:20:12 -0800973.. opcode:: OR - Bitwise Or
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:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000987
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800988.. math::
989
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800990 dst.x = src0.x \bmod src1.x
991
992 dst.y = src0.y \bmod src1.y
993
994 dst.z = src0.z \bmod src1.z
995
996 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000997
998
Corbin Simpson85805222010-02-02 16:20:12 -0800999.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +00001000
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001001.. math::
1002
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001003 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001004
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001005 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001006
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001007 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001008
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001009 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001010
1011
Corbin Simpson85805222010-02-02 16:20:12 -08001012.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +00001013
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001014.. math::
1015
Corbin Simpson14743ac2009-12-21 19:57:56 -08001016 dst.x = |src0.x - src1.x| + src2.x
1017
1018 dst.y = |src0.y - src1.y| + src2.y
1019
1020 dst.z = |src0.z - src1.z| + src2.z
1021
1022 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001023
1024
Corbin Simpson85805222010-02-02 16:20:12 -08001025.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +00001026
1027 TBD
1028
1029
Corbin Simpson85805222010-02-02 16:20:12 -08001030.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +00001031
1032 TBD
1033
1034
Corbin Simpson85805222010-02-02 16:20:12 -08001035.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +00001036
1037 TBD
1038
1039
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001040From GL_NV_geometry_program4
1041^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001042
1043
Corbin Simpson85805222010-02-02 16:20:12 -08001044.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001045
1046 TBD
1047
1048
Corbin Simpson85805222010-02-02 16:20:12 -08001049.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001050
1051 TBD
1052
1053
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001054From GLSL
1055^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001056
1057
Corbin Simpson85805222010-02-02 16:20:12 -08001058.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001059
1060 TBD
1061
1062
Corbin Simpson85805222010-02-02 16:20:12 -08001063.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001064
1065 TBD
1066
1067
Corbin Simpson85805222010-02-02 16:20:12 -08001068.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001069
1070 TBD
1071
1072
Corbin Simpson85805222010-02-02 16:20:12 -08001073.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001074
1075 TBD
1076
1077
Corbin Simpson85805222010-02-02 16:20:12 -08001078.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001079
Michal Krol8ab89d72010-01-04 13:23:41 +01001080 Do nothing.
1081
Keith Whitwella62aaa72009-12-21 23:25:15 +00001082
Corbin Simpson85805222010-02-02 16:20:12 -08001083.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001084
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001085.. math::
1086
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001087 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}
1088
1089 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}
1090
1091 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}
1092
1093 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 +00001094
1095
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001096ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001097^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001098
1099
Corbin Simpson85805222010-02-02 16:20:12 -08001100.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001101
1102 TBD
1103
1104
Corbin Simpson85805222010-02-02 16:20:12 -08001105.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001106
1107 TBD
1108
1109
Corbin Simpson85805222010-02-02 16:20:12 -08001110.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001111
1112 TBD
1113
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001114Double Opcodes
1115^^^^^^^^^^^^^^^
1116
Corbin Simpson85805222010-02-02 16:20:12 -08001117.. opcode:: DADD - Add Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001118
1119.. math::
1120
1121 dst.xy = src0.xy + src1.xy
1122
1123 dst.zw = src0.zw + src1.zw
1124
1125
Corbin Simpson85805222010-02-02 16:20:12 -08001126.. opcode:: DDIV - Divide Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001127
1128.. math::
1129
1130 dst.xy = src0.xy / src1.xy
1131
1132 dst.zw = src0.zw / src1.zw
1133
Corbin Simpson85805222010-02-02 16:20:12 -08001134.. opcode:: DSEQ - Set Double on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001135
1136.. math::
1137
1138 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1139
1140 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1141
Corbin Simpson85805222010-02-02 16:20:12 -08001142.. opcode:: DSLT - Set Double on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001143
1144.. math::
1145
1146 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1147
1148 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1149
Corbin Simpson85805222010-02-02 16:20:12 -08001150.. opcode:: DFRAC - Double Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001151
1152.. math::
1153
1154 dst.xy = src.xy - \lfloor src.xy\rfloor
1155
1156 dst.zw = src.zw - \lfloor src.zw\rfloor
1157
1158
Corbin Simpson85805222010-02-02 16:20:12 -08001159.. opcode:: DFRACEXP - Convert Double Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001160
1161.. math::
1162
1163 dst0.xy = frexp(src.xy, dst1.xy)
1164
1165 dst0.zw = frexp(src.zw, dst1.zw)
1166
Corbin Simpson85805222010-02-02 16:20:12 -08001167.. opcode:: DLDEXP - Multiple Double Number by Integral Power of 2
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001168
1169.. math::
1170
1171 dst.xy = ldexp(src0.xy, src1.xy)
1172
1173 dst.zw = ldexp(src0.zw, src1.zw)
1174
Corbin Simpson85805222010-02-02 16:20:12 -08001175.. opcode:: DMIN - Minimum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001176
1177.. math::
1178
1179 dst.xy = min(src0.xy, src1.xy)
1180
1181 dst.zw = min(src0.zw, src1.zw)
1182
Corbin Simpson85805222010-02-02 16:20:12 -08001183.. opcode:: DMAX - Maximum Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001184
1185.. math::
1186
1187 dst.xy = max(src0.xy, src1.xy)
1188
1189 dst.zw = max(src0.zw, src1.zw)
1190
Corbin Simpson85805222010-02-02 16:20:12 -08001191.. opcode:: DMUL - Multiply Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001192
1193.. math::
1194
1195 dst.xy = src0.xy \times src1.xy
1196
1197 dst.zw = src0.zw \times src1.zw
1198
1199
Corbin Simpson85805222010-02-02 16:20:12 -08001200.. opcode:: DMAD - Multiply And Add Doubles
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001201
1202.. math::
1203
1204 dst.xy = src0.xy \times src1.xy + src2.xy
1205
1206 dst.zw = src0.zw \times src1.zw + src2.zw
1207
1208
Corbin Simpson85805222010-02-02 16:20:12 -08001209.. opcode:: DRCP - Reciprocal Double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001210
1211.. math::
1212
1213 dst.xy = \frac{1}{src.xy}
1214
1215 dst.zw = \frac{1}{src.zw}
1216
Corbin Simpson85805222010-02-02 16:20:12 -08001217.. opcode:: DSQRT - Square root double
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001218
1219.. math::
1220
1221 dst.xy = \sqrt{src.xy}
1222
1223 dst.zw = \sqrt{src.zw}
1224
Keith Whitwella62aaa72009-12-21 23:25:15 +00001225
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001226Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001227------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001228
1229
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001230Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001231^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001232
1233
Corbin Simpson14743ac2009-12-21 19:57:56 -08001234 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001235
Corbin Simpson14743ac2009-12-21 19:57:56 -08001236 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001237
1238 clamp(x,y,z) Clamp x between y and z.
1239 (x < y) ? y : (x > z) ? z : x
1240
Corbin Simpsondd801e52009-12-21 19:41:09 -08001241 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001242
Corbin Simpson14743ac2009-12-21 19:57:56 -08001243 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001244
1245 max(x,y) Maximum of x and y.
1246 (x > y) ? x : y
1247
1248 min(x,y) Minimum of x and y.
1249 (x < y) ? x : y
1250
1251 partialx(x) Derivative of x relative to fragment's X.
1252
1253 partialy(x) Derivative of x relative to fragment's Y.
1254
1255 pop() Pop from stack.
1256
Corbin Simpsondd801e52009-12-21 19:41:09 -08001257 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001258
1259 push(x) Push x on stack.
1260
1261 round(x) Round x.
1262
Michal Krol07f416c2010-01-04 13:21:32 +01001263 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001264
1265
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001266Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001267^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001268
1269
1270 discard Discard fragment.
1271
1272 dst First destination register.
1273
1274 dst0 First destination register.
1275
1276 pc Program counter.
1277
1278 src First source register.
1279
1280 src0 First source register.
1281
1282 src1 Second source register.
1283
1284 src2 Third source register.
1285
1286 target Label of target instruction.
1287
1288
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001289Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001290---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001291
1292
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001293Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001294^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001295
1296
1297 Follows Declaration token if Semantic bit is set.
1298
1299 Since its purpose is to link a shader with other stages of the pipeline,
1300 it is valid to follow only those Declaration tokens that declare a register
1301 either in INPUT or OUTPUT file.
1302
1303 SemanticName field contains the semantic name of the register being declared.
1304 There is no default value.
1305
1306 SemanticIndex is an optional subscript that can be used to distinguish
1307 different register declarations with the same semantic name. The default value
1308 is 0.
1309
1310 The meanings of the individual semantic names are explained in the following
1311 sections.
1312
Corbin Simpson54ddf642009-12-23 23:36:06 -08001313TGSI_SEMANTIC_POSITION
1314""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001315
Corbin Simpson54ddf642009-12-23 23:36:06 -08001316Position, sometimes known as HPOS or WPOS for historical reasons, is the
1317location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
1318are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
1319for the perspective divide, if enabled.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001320
Corbin Simpson54ddf642009-12-23 23:36:06 -08001321As a vertex shader output, position should be scaled to the viewport. When
Luca Barbieri73317132010-01-21 05:36:14 +01001322used in fragment shaders, position will be in window coordinates. The convention
1323used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001324
1325XXX additionally, is there a way to configure the perspective divide? it's
1326accelerated on most chipsets AFAIK...
1327
1328Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
1329be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
1330
1331XXX usually? can we solidify that?
1332
1333TGSI_SEMANTIC_COLOR
1334"""""""""""""""""""
1335
1336Colors are used to, well, color the primitives. Colors are always in
1337``(r, g, b, a)`` format.
1338
1339If alpha is not specified, it defaults to 1.
1340
1341TGSI_SEMANTIC_BCOLOR
1342""""""""""""""""""""
1343
1344Back-facing colors are only used for back-facing polygons, and are only valid
1345in vertex shader outputs. After rasterization, all polygons are front-facing
1346and COLOR and BCOLOR end up occupying the same slots in the fragment, so
1347all BCOLORs effectively become regular COLORs in the fragment shader.
1348
1349TGSI_SEMANTIC_FOG
1350"""""""""""""""""
1351
1352The fog coordinate historically has been used to replace the depth coordinate
1353for generation of fog in dedicated fog blocks. Gallium, however, does not use
1354dedicated fog acceleration, placing it entirely in the fragment shader
1355instead.
1356
1357The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
1358component matters when writing from the vertex shader; the driver will ensure
1359that the coordinate is in this format when used as a fragment shader input.
1360
1361TGSI_SEMANTIC_PSIZE
1362"""""""""""""""""""
1363
1364PSIZE, or point size, is used to specify point sizes per-vertex. It should
1365be in ``(p, n, x, f)`` format, where ``p`` is the point size, ``n`` is the minimum
1366size, ``x`` is the maximum size, and ``f`` is the fade threshold.
1367
1368XXX this is arb_vp. is this what we actually do? should double-check...
1369
1370When using this semantic, be sure to set the appropriate state in the
1371:ref:`rasterizer` first.
1372
1373TGSI_SEMANTIC_GENERIC
1374"""""""""""""""""""""
1375
1376Generic semantics are nearly always used for texture coordinate attributes,
1377in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
1378of lookups, and ``q`` is the level-of-detail bias for biased sampling.
1379
1380These attributes are called "generic" because they may be used for anything
1381else, including parameters, texture generation information, or anything that
1382can be stored inside a four-component vector.
1383
1384TGSI_SEMANTIC_NORMAL
1385""""""""""""""""""""
1386
Michal Krol86b336f2010-01-04 13:38:58 +01001387Vertex normal; could be used to implement per-pixel lighting for legacy APIs
1388that allow mixing fixed-function and programmable stages.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001389
1390TGSI_SEMANTIC_FACE
1391""""""""""""""""""
1392
1393FACE is the facing bit, to store the facing information for the fragment
1394shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
1395when the fragment is front-facing, and negative when the component is
1396back-facing.
1397
1398TGSI_SEMANTIC_EDGEFLAG
1399""""""""""""""""""""""
1400
1401XXX no clue
Luca Barbieri73317132010-01-21 05:36:14 +01001402
1403
1404Properties
1405^^^^^^^^^^^^^^^^^^^^^^^^
1406
1407
1408 Properties are general directives that apply to the whole TGSI program.
1409
1410FS_COORD_ORIGIN
1411"""""""""""""""
1412
1413Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1414The default value is UPPER_LEFT.
1415
1416If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1417increase downward and rightward.
1418If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1419increase upward and rightward.
1420
1421OpenGL defaults to LOWER_LEFT, and is configurable with the
1422GL_ARB_fragment_coord_conventions extension.
1423
1424DirectX 9/10 use UPPER_LEFT.
1425
1426FS_COORD_PIXEL_CENTER
1427"""""""""""""""""""""
1428
1429Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1430The default value is HALF_INTEGER.
1431
1432If HALF_INTEGER, the fractionary part of the position will be 0.5
1433If INTEGER, the fractionary part of the position will be 0.0
1434
1435Note that this does not affect the set of fragments generated by
1436rasterization, which is instead controlled by gl_rasterization_rules in the
1437rasterizer.
1438
1439OpenGL defaults to HALF_INTEGER, and is configurable with the
1440GL_ARB_fragment_coord_conventions extension.
1441
1442DirectX 9 uses INTEGER.
1443DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001444
1445
1446
1447Texture Sampling and Texture Formats
1448------------------------------------
1449
1450This table shows how texture image components are returned as (x,y,z,w)
1451tuples by TGSI texture instructions, such as TEX, TXD, and TXP.
Brian Paul3a3d8fb2010-02-02 16:20:26 -07001452For reference, OpenGL and Direct3D conventions are shown as well.
Brian Paul4778f462010-02-02 08:14:40 -07001453
Corbin Simpson516e7152010-02-02 12:44:22 -08001454+--------------------+--------------+--------------------+--------------+
1455| Texture Components | Gallium | OpenGL | Direct3D 9 |
1456+====================+==============+====================+==============+
1457| R | XXX TBD | (r, 0, 0, 1) | (r, 1, 1, 1) |
1458+--------------------+--------------+--------------------+--------------+
1459| RG | XXX TBD | (r, g, 0, 1) | (r, g, 1, 1) |
1460+--------------------+--------------+--------------------+--------------+
1461| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1462+--------------------+--------------+--------------------+--------------+
1463| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1464+--------------------+--------------+--------------------+--------------+
1465| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1466+--------------------+--------------+--------------------+--------------+
1467| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1468+--------------------+--------------+--------------------+--------------+
1469| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1470+--------------------+--------------+--------------------+--------------+
1471| I | (i, i, i, i) | (i, i, i, i) | N/A |
1472+--------------------+--------------+--------------------+--------------+
1473| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1474| | | [#envmap-bumpmap]_ | |
1475+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001476| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001477| | | [#depth-tex-mode]_ | |
1478+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001479
Corbin Simpson516e7152010-02-02 12:44:22 -08001480.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001481.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
1482 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.