blob: 49877206fea5828d5809478f32530f3feab2cef8 [file] [log] [blame]
Corbin Simpsonc686e172009-12-20 15:00:40 -08001TGSI
2====
3
Michal Krolb6659682010-01-04 12:52:43 +01004TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language
Corbin Simpsonc686e172009-12-20 15:00:40 -08005for describing shaders. Since Gallium is inherently shaderful, shaders are
6an important part of the API. TGSI is the only intermediate representation
7used by all drivers.
Keith Whitwella62aaa72009-12-21 23:25:15 +00008
Corbin Simpson62ca7b82010-02-02 16:36:34 -08009Basics
10------
11
12All TGSI instructions, known as *opcodes*, operate on arbitrary-precision
13floating-point four-component vectors. An opcode may have up to one
14destination register, known as *dst*, and between zero and three source
15registers, called *src0* through *src2*, or simply *src* if there is only
16one.
17
18Some instructions, like :opcode:`I2F`, permit re-interpretation of vector
19components as integers. Other instructions permit using registers as
20two-component vectors with double precision; see :ref:`Double Opcodes`.
21
Corbin Simpson17c2a442010-02-02 17:02:28 -080022When an instruction has a scalar result, the result is usually copied into
23each of the components of *dst*. When this happens, the result is said to be
24*replicated* to *dst*. :opcode:`RCP` is one such instruction.
25
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080026Instruction Set
27---------------
28
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070029Core ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080030^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000031
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070032These opcodes are guaranteed to be available regardless of the driver being
33used.
Keith Whitwella62aaa72009-12-21 23:25:15 +000034
Corbin Simpson85805222010-02-02 16:20:12 -080035.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080036
37.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000038
Corbin Simpsond92a6852009-12-21 19:30:29 -080039 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080040
Corbin Simpsond92a6852009-12-21 19:30:29 -080041 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080042
Corbin Simpsond92a6852009-12-21 19:30:29 -080043 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080044
Corbin Simpsond92a6852009-12-21 19:30:29 -080045 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000046
47
Corbin Simpson85805222010-02-02 16:20:12 -080048.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080049
50.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000051
52 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080053
Keith Whitwella62aaa72009-12-21 23:25:15 +000054 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080055
Keith Whitwella62aaa72009-12-21 23:25:15 +000056 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080057
Keith Whitwella62aaa72009-12-21 23:25:15 +000058 dst.w = src.w
59
60
Corbin Simpson85805222010-02-02 16:20:12 -080061.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080062
63.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000064
Corbin Simpsonda65ac62009-12-21 20:32:46 -080065 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080066
Corbin Simpsonda65ac62009-12-21 20:32:46 -080067 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080068
Corbin Simpsonda65ac62009-12-21 20:32:46 -080069 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080070
Corbin Simpsonda65ac62009-12-21 20:32:46 -080071 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000072
73
Corbin Simpson85805222010-02-02 16:20:12 -080074.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080075
Corbin Simpson17c2a442010-02-02 17:02:28 -080076This instruction replicates its result.
77
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080078.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000079
Corbin Simpson17c2a442010-02-02 17:02:28 -080080 dst = \frac{1}{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +000081
82
Corbin Simpson85805222010-02-02 16:20:12 -080083.. opcode:: RSQ - Reciprocal Square Root
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080084
Corbin Simpson17c2a442010-02-02 17:02:28 -080085This instruction replicates its result.
86
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080087.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000088
Corbin Simpson17c2a442010-02-02 17:02:28 -080089 dst = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +000090
91
Corbin Simpson85805222010-02-02 16:20:12 -080092.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080093
94.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000095
Corbin Simpsondd801e52009-12-21 19:41:09 -080096 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080097
Corbin Simpsond92a6852009-12-21 19:30:29 -080098 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099
Corbin Simpsondd801e52009-12-21 19:41:09 -0800100 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800101
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800102 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000103
104
Corbin Simpson85805222010-02-02 16:20:12 -0800105.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800106
107.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000108
Corbin Simpson14743ac2009-12-21 19:57:56 -0800109 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800110
Corbin Simpson14743ac2009-12-21 19:57:56 -0800111 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800112
Corbin Simpson14743ac2009-12-21 19:57:56 -0800113 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800114
Corbin Simpson14743ac2009-12-21 19:57:56 -0800115 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000116
117
Corbin Simpson85805222010-02-02 16:20:12 -0800118.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800119
120.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000121
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800122 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800123
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800124 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800125
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800126 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800127
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800128 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000129
130
Corbin Simpson85805222010-02-02 16:20:12 -0800131.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800132
133.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000134
135 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800136
Keith Whitwella62aaa72009-12-21 23:25:15 +0000137 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800138
Keith Whitwella62aaa72009-12-21 23:25:15 +0000139 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800140
Keith Whitwella62aaa72009-12-21 23:25:15 +0000141 dst.w = src0.w + src1.w
142
143
Corbin Simpson85805222010-02-02 16:20:12 -0800144.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800145
Corbin Simpson17c2a442010-02-02 17:02:28 -0800146This instruction replicates its result.
147
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800148.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000149
Corbin Simpson17c2a442010-02-02 17:02:28 -0800150 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000151
152
Corbin Simpson85805222010-02-02 16:20:12 -0800153.. opcode:: DP4 - 4-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800154
Corbin Simpson17c2a442010-02-02 17:02:28 -0800155This instruction replicates its result.
156
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800157.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000158
Corbin Simpson17c2a442010-02-02 17:02:28 -0800159 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000160
161
Corbin Simpson85805222010-02-02 16:20:12 -0800162.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800163
164.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000165
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800166 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800167
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800168 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800169
Keith Whitwella62aaa72009-12-21 23:25:15 +0000170 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800171
Keith Whitwella62aaa72009-12-21 23:25:15 +0000172 dst.w = src1.w
173
174
Corbin Simpson85805222010-02-02 16:20:12 -0800175.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800176
177.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000178
179 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800180
Keith Whitwella62aaa72009-12-21 23:25:15 +0000181 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800182
Keith Whitwella62aaa72009-12-21 23:25:15 +0000183 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800184
Keith Whitwella62aaa72009-12-21 23:25:15 +0000185 dst.w = min(src0.w, src1.w)
186
187
Corbin Simpson85805222010-02-02 16:20:12 -0800188.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800189
190.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000191
192 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800193
Keith Whitwella62aaa72009-12-21 23:25:15 +0000194 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800195
Keith Whitwella62aaa72009-12-21 23:25:15 +0000196 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800197
Keith Whitwella62aaa72009-12-21 23:25:15 +0000198 dst.w = max(src0.w, src1.w)
199
200
Corbin Simpson85805222010-02-02 16:20:12 -0800201.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800202
203.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000204
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800205 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800206
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800207 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800208
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800209 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800210
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800211 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000212
213
Corbin Simpson85805222010-02-02 16:20:12 -0800214.. opcode:: SGE - Set On Greater Equal Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800215
216.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000217
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800218 dst.x = (src0.x >= src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800219
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800220 dst.y = (src0.y >= src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800221
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800222 dst.z = (src0.z >= src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800223
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800224 dst.w = (src0.w >= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000225
226
Corbin Simpson85805222010-02-02 16:20:12 -0800227.. opcode:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800228
229.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000230
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800231 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800232
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800233 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800234
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800235 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800236
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800237 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000238
239
Corbin Simpson85805222010-02-02 16:20:12 -0800240.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800241
242.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000243
244 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800245
Keith Whitwella62aaa72009-12-21 23:25:15 +0000246 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800247
Keith Whitwella62aaa72009-12-21 23:25:15 +0000248 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800249
Keith Whitwella62aaa72009-12-21 23:25:15 +0000250 dst.w = src0.w - src1.w
251
252
Corbin Simpson85805222010-02-02 16:20:12 -0800253.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800254
255.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000256
Michal Krolb3567fc2010-01-04 12:59:17 +0100257 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800258
Michal Krolb3567fc2010-01-04 12:59:17 +0100259 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800260
Michal Krolb3567fc2010-01-04 12:59:17 +0100261 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800262
Michal Krolb3567fc2010-01-04 12:59:17 +0100263 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000264
265
Corbin Simpson85805222010-02-02 16:20:12 -0800266.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800267
268.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000269
270 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800271
Keith Whitwella62aaa72009-12-21 23:25:15 +0000272 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800273
Keith Whitwella62aaa72009-12-21 23:25:15 +0000274 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800275
Keith Whitwella62aaa72009-12-21 23:25:15 +0000276 dst.w = (src2.w > 0.5) ? src0.w : src1.w
277
278
Corbin Simpson85805222010-02-02 16:20:12 -0800279.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800280
281.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000282
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800283 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800284
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800285 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800286
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800287 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800288
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800289 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000290
291
José Fonsecad9c6ebb2010-06-01 16:25:05 +0100292.. opcode:: FRC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800293
294.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000295
Corbin Simpsond92a6852009-12-21 19:30:29 -0800296 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800297
Corbin Simpsond92a6852009-12-21 19:30:29 -0800298 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800299
Corbin Simpsond92a6852009-12-21 19:30:29 -0800300 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800301
Corbin Simpsond92a6852009-12-21 19:30:29 -0800302 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000303
304
Corbin Simpson85805222010-02-02 16:20:12 -0800305.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800306
307.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000308
309 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800310
Keith Whitwella62aaa72009-12-21 23:25:15 +0000311 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800312
Keith Whitwella62aaa72009-12-21 23:25:15 +0000313 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800314
Keith Whitwella62aaa72009-12-21 23:25:15 +0000315 dst.w = clamp(src0.w, src1.w, src2.w)
316
317
Corbin Simpson85805222010-02-02 16:20:12 -0800318.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800319
Corbin Simpson17c2a442010-02-02 17:02:28 -0800320This is identical to :opcode:`ARL`.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000321
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800322.. math::
323
Corbin Simpsond92a6852009-12-21 19:30:29 -0800324 dst.x = \lfloor src.x\rfloor
325
326 dst.y = \lfloor src.y\rfloor
327
328 dst.z = \lfloor src.z\rfloor
329
330 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000331
332
Corbin Simpson85805222010-02-02 16:20:12 -0800333.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000334
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800335.. math::
336
Keith Whitwella62aaa72009-12-21 23:25:15 +0000337 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800338
Keith Whitwella62aaa72009-12-21 23:25:15 +0000339 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800340
Keith Whitwella62aaa72009-12-21 23:25:15 +0000341 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800342
Keith Whitwella62aaa72009-12-21 23:25:15 +0000343 dst.w = round(src.w)
344
345
Corbin Simpson85805222010-02-02 16:20:12 -0800346.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000347
Corbin Simpson17c2a442010-02-02 17:02:28 -0800348This instruction replicates its result.
349
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800350.. math::
351
Corbin Simpson17c2a442010-02-02 17:02:28 -0800352 dst = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000353
354
Corbin Simpson85805222010-02-02 16:20:12 -0800355.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000356
Corbin Simpson17c2a442010-02-02 17:02:28 -0800357This instruction replicates its result.
358
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800359.. math::
360
Corbin Simpson17c2a442010-02-02 17:02:28 -0800361 dst = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000362
363
Corbin Simpson85805222010-02-02 16:20:12 -0800364.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000365
Corbin Simpson17c2a442010-02-02 17:02:28 -0800366This instruction replicates its result.
367
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800368.. math::
369
Corbin Simpson17c2a442010-02-02 17:02:28 -0800370 dst = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000371
Corbin Simpson85805222010-02-02 16:20:12 -0800372.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000373
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800374.. math::
375
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800376 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800377
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800378 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800379
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800380 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800381
382 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000383
384
Corbin Simpson85805222010-02-02 16:20:12 -0800385.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000386
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800387.. math::
388
Corbin Simpson14743ac2009-12-21 19:57:56 -0800389 dst.x = |src.x|
390
391 dst.y = |src.y|
392
393 dst.z = |src.z|
394
395 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000396
397
Corbin Simpson85805222010-02-02 16:20:12 -0800398.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800399
Corbin Simpson17c2a442010-02-02 17:02:28 -0800400This instruction replicates its result.
401
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800402XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000403
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800404.. math::
405
Corbin Simpson17c2a442010-02-02 17:02:28 -0800406 dst = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000407
408
Corbin Simpson85805222010-02-02 16:20:12 -0800409.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000410
Corbin Simpson17c2a442010-02-02 17:02:28 -0800411This instruction replicates its result.
412
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800413.. math::
414
Corbin Simpson17c2a442010-02-02 17:02:28 -0800415 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000416
417
Corbin Simpson85805222010-02-02 16:20:12 -0800418.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000419
Corbin Simpson17c2a442010-02-02 17:02:28 -0800420This instruction replicates its result.
421
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800422.. math::
423
Corbin Simpson17c2a442010-02-02 17:02:28 -0800424 dst = \cos{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000425
426
Corbin Simpson85805222010-02-02 16:20:12 -0800427.. opcode:: DDX - Derivative Relative To X
Keith Whitwella62aaa72009-12-21 23:25:15 +0000428
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800429.. math::
430
Keith Whitwella62aaa72009-12-21 23:25:15 +0000431 dst.x = partialx(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800432
Keith Whitwella62aaa72009-12-21 23:25:15 +0000433 dst.y = partialx(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800434
Keith Whitwella62aaa72009-12-21 23:25:15 +0000435 dst.z = partialx(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800436
Keith Whitwella62aaa72009-12-21 23:25:15 +0000437 dst.w = partialx(src.w)
438
439
Corbin Simpson85805222010-02-02 16:20:12 -0800440.. opcode:: DDY - Derivative Relative To Y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000441
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800442.. math::
443
Keith Whitwella62aaa72009-12-21 23:25:15 +0000444 dst.x = partialy(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800445
Keith Whitwella62aaa72009-12-21 23:25:15 +0000446 dst.y = partialy(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800447
Keith Whitwella62aaa72009-12-21 23:25:15 +0000448 dst.z = partialy(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800449
Keith Whitwella62aaa72009-12-21 23:25:15 +0000450 dst.w = partialy(src.w)
451
452
Corbin Simpson85805222010-02-02 16:20:12 -0800453.. opcode:: KILP - Predicated Discard
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800454
Keith Whitwella62aaa72009-12-21 23:25:15 +0000455 discard
456
457
Corbin Simpson85805222010-02-02 16:20:12 -0800458.. opcode:: PK2H - Pack Two 16-bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000459
460 TBD
461
462
Corbin Simpson85805222010-02-02 16:20:12 -0800463.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000464
465 TBD
466
467
Corbin Simpson85805222010-02-02 16:20:12 -0800468.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000469
470 TBD
471
472
Corbin Simpson85805222010-02-02 16:20:12 -0800473.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000474
475 TBD
476
477
Corbin Simpson85805222010-02-02 16:20:12 -0800478.. opcode:: RFL - Reflection Vector
Keith Whitwella62aaa72009-12-21 23:25:15 +0000479
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800480.. math::
481
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800482 dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x
483
484 dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
485
486 dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
487
488 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000489
Corbin Simpson17c2a442010-02-02 17:02:28 -0800490.. note::
491
492 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000493
Keith Whitwella62aaa72009-12-21 23:25:15 +0000494
Corbin Simpson85805222010-02-02 16:20:12 -0800495.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000496
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800497.. math::
498
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800499 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800500
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800501 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800502
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800503 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800504
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800505 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000506
507
Corbin Simpson85805222010-02-02 16:20:12 -0800508.. opcode:: SFL - Set On False
Keith Whitwella62aaa72009-12-21 23:25:15 +0000509
Corbin Simpson17c2a442010-02-02 17:02:28 -0800510This instruction replicates its result.
511
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800512.. math::
513
Corbin Simpson17c2a442010-02-02 17:02:28 -0800514 dst = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800515
Corbin Simpson17c2a442010-02-02 17:02:28 -0800516.. note::
Corbin Simpson04771912010-01-18 17:31:56 -0800517
Corbin Simpson17c2a442010-02-02 17:02:28 -0800518 Considered for removal.
Corbin Simpson04771912010-01-18 17:31:56 -0800519
Keith Whitwella62aaa72009-12-21 23:25:15 +0000520
Corbin Simpson85805222010-02-02 16:20:12 -0800521.. opcode:: SGT - Set On Greater Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000522
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800523.. math::
524
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800525 dst.x = (src0.x > src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800526
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800527 dst.y = (src0.y > src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800528
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800529 dst.z = (src0.z > src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800530
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800531 dst.w = (src0.w > src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000532
533
Corbin Simpson85805222010-02-02 16:20:12 -0800534.. opcode:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000535
Corbin Simpson17c2a442010-02-02 17:02:28 -0800536This instruction replicates its result.
537
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800538.. math::
539
Corbin Simpson17c2a442010-02-02 17:02:28 -0800540 dst = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000541
542
Corbin Simpson85805222010-02-02 16:20:12 -0800543.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000544
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800545.. math::
546
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800547 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800548
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800549 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800550
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800551 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800552
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800553 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000554
555
Corbin Simpson85805222010-02-02 16:20:12 -0800556.. opcode:: SNE - Set On Not Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000557
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800558.. math::
559
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800560 dst.x = (src0.x != src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800561
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800562 dst.y = (src0.y != src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800563
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800564 dst.z = (src0.z != src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800565
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800566 dst.w = (src0.w != src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000567
568
Corbin Simpson85805222010-02-02 16:20:12 -0800569.. opcode:: STR - Set On True
Keith Whitwella62aaa72009-12-21 23:25:15 +0000570
Corbin Simpson17c2a442010-02-02 17:02:28 -0800571This instruction replicates its result.
572
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800573.. math::
574
Corbin Simpson17c2a442010-02-02 17:02:28 -0800575 dst = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000576
577
Corbin Simpson85805222010-02-02 16:20:12 -0800578.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000579
Brian Paul2a77c3c2010-12-14 12:45:36 -0700580.. math::
581
582 coord = src0
583
584 bias = 0.0
585
586 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000587
588
Corbin Simpson85805222010-02-02 16:20:12 -0800589.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000590
Brian Paul2a77c3c2010-12-14 12:45:36 -0700591.. math::
592
593 coord = src0
594
595 ddx = src1
596
597 ddy = src2
598
599 bias = 0.0
600
601 dst = texture_sample_deriv(unit, coord, bias, ddx, ddy)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000602
603
Corbin Simpson85805222010-02-02 16:20:12 -0800604.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000605
Brian Paul2a77c3c2010-12-14 12:45:36 -0700606.. math::
607
608 coord.x = src0.x / src.w
609
610 coord.y = src0.y / src.w
611
612 coord.z = src0.z / src.w
613
614 coord.w = src0.w
615
616 bias = 0.0
617
618 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000619
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
Corbin Simpson17c2a442010-02-02 17:02:28 -0800625.. note::
626
627 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000628
Corbin Simpson85805222010-02-02 16:20:12 -0800629.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000630
631 TBD
632
Corbin Simpson17c2a442010-02-02 17:02:28 -0800633.. note::
634
635 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000636
Corbin Simpson85805222010-02-02 16:20:12 -0800637.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000638
639 TBD
640
Corbin Simpson17c2a442010-02-02 17:02:28 -0800641.. note::
642
643 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000644
Corbin Simpson85805222010-02-02 16:20:12 -0800645.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000646
647 TBD
648
Corbin Simpson17c2a442010-02-02 17:02:28 -0800649.. note::
650
651 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000652
Corbin Simpson85805222010-02-02 16:20:12 -0800653.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000654
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800655.. math::
656
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800657 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800658
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800659 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800660
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800661 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800662
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800663 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000664
Corbin Simpson17c2a442010-02-02 17:02:28 -0800665.. note::
666
667 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000668
Keith Whitwella62aaa72009-12-21 23:25:15 +0000669
Corbin Simpson85805222010-02-02 16:20:12 -0800670.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000671
672 TBD
673
Corbin Simpson17c2a442010-02-02 17:02:28 -0800674.. note::
675
676 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000677
Corbin Simpson85805222010-02-02 16:20:12 -0800678.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000679
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800680.. math::
681
Keith Whitwella62aaa72009-12-21 23:25:15 +0000682 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800683
Keith Whitwella62aaa72009-12-21 23:25:15 +0000684 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800685
Keith Whitwella62aaa72009-12-21 23:25:15 +0000686 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800687
Keith Whitwella62aaa72009-12-21 23:25:15 +0000688 dst.w = round(src.w)
689
690
Corbin Simpson85805222010-02-02 16:20:12 -0800691.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000692
693 pc = target
694
Corbin Simpson17c2a442010-02-02 17:02:28 -0800695.. note::
696
697 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000698
Corbin Simpson85805222010-02-02 16:20:12 -0800699.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000700
701 push(pc)
702 pc = target
703
704
Corbin Simpson85805222010-02-02 16:20:12 -0800705.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000706
707 pc = pop()
708
709
Corbin Simpson85805222010-02-02 16:20:12 -0800710.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000711
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800712.. math::
713
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800714 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
715
716 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
717
718 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
719
720 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000721
722
Corbin Simpson85805222010-02-02 16:20:12 -0800723.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000724
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800725.. math::
726
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800727 dst.x = (src0.x < 0) ? src1.x : src2.x
728
729 dst.y = (src0.y < 0) ? src1.y : src2.y
730
731 dst.z = (src0.z < 0) ? src1.z : src2.z
732
733 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000734
735
Corbin Simpson85805222010-02-02 16:20:12 -0800736.. opcode:: KIL - Conditional Discard
Keith Whitwella62aaa72009-12-21 23:25:15 +0000737
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800738.. math::
739
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800740 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000741 discard
742 endif
743
744
Corbin Simpson85805222010-02-02 16:20:12 -0800745.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000746
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800747.. math::
748
Corbin Simpsond92a6852009-12-21 19:30:29 -0800749 dst.x = \cos{src.x}
750
751 dst.y = \sin{src.x}
752
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800753 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800754
Tilman Sauerbeckd3231182010-09-19 09:03:11 +0200755 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000756
757
Corbin Simpson85805222010-02-02 16:20:12 -0800758.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000759
Brian Paul2a77c3c2010-12-14 12:45:36 -0700760.. math::
761
762 coord.x = src.x
763
764 coord.y = src.y
765
766 coord.z = src.z
767
768 coord.w = 1.0
769
770 bias = src.z
771
772 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000773
774
Corbin Simpson85805222010-02-02 16:20:12 -0800775.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000776
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800777.. math::
778
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800779 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 -0800780
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800781 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 -0800782
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800783 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 -0800784
785 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000786
787
Corbin Simpson85805222010-02-02 16:20:12 -0800788.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000789
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800790.. math::
791
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800792 dst.x = \frac{src0.x}{src1.x}
793
794 dst.y = \frac{src0.y}{src1.y}
795
796 dst.z = \frac{src0.z}{src1.z}
797
798 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000799
800
Corbin Simpson85805222010-02-02 16:20:12 -0800801.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000802
Corbin Simpson17c2a442010-02-02 17:02:28 -0800803This instruction replicates its result.
804
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800805.. math::
806
Corbin Simpson17c2a442010-02-02 17:02:28 -0800807 dst = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000808
809
Brian Paul2a77c3c2010-12-14 12:45:36 -0700810.. opcode:: TXL - Texture Lookup With explicit LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000811
Brian Paul2a77c3c2010-12-14 12:45:36 -0700812.. math::
813
814 coord.x = src0.x
815
816 coord.y = src0.y
817
818 coord.z = src0.z
819
820 coord.w = 1.0
821
822 lod = src0.w
823
824 dst = texture_sample(unit, coord, lod)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000825
826
Corbin Simpson85805222010-02-02 16:20:12 -0800827.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000828
829 TBD
830
831
Corbin Simpson85805222010-02-02 16:20:12 -0800832.. opcode:: IF - If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000833
834 TBD
835
836
Corbin Simpson85805222010-02-02 16:20:12 -0800837.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000838
839 TBD
840
841
Corbin Simpson85805222010-02-02 16:20:12 -0800842.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000843
844 TBD
845
846
Corbin Simpson85805222010-02-02 16:20:12 -0800847.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000848
849 push(src.x)
850 push(src.y)
851 push(src.z)
852 push(src.w)
853
Corbin Simpson17c2a442010-02-02 17:02:28 -0800854.. note::
855
856 Considered for cleanup.
857
858.. note::
859
860 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000861
Corbin Simpson85805222010-02-02 16:20:12 -0800862.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000863
864 dst.w = pop()
865 dst.z = pop()
866 dst.y = pop()
867 dst.x = pop()
868
Corbin Simpson17c2a442010-02-02 17:02:28 -0800869.. note::
870
871 Considered for cleanup.
872
873.. note::
874
875 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000876
Keith Whitwella62aaa72009-12-21 23:25:15 +0000877
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700878Compute ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800879^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000880
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700881These opcodes are primarily provided for special-use computational shaders.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000882Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000883
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700884XXX so let's discuss it, yeah?
885
Corbin Simpson85805222010-02-02 16:20:12 -0800886.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000887
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800888.. math::
889
Corbin Simpson14743ac2009-12-21 19:57:56 -0800890 dst.x = \lceil src.x\rceil
891
892 dst.y = \lceil src.y\rceil
893
894 dst.z = \lceil src.z\rceil
895
896 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000897
898
Corbin Simpson85805222010-02-02 16:20:12 -0800899.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000900
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800901.. math::
902
Keith Whitwella62aaa72009-12-21 23:25:15 +0000903 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800904
Keith Whitwella62aaa72009-12-21 23:25:15 +0000905 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800906
Keith Whitwella62aaa72009-12-21 23:25:15 +0000907 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800908
Keith Whitwella62aaa72009-12-21 23:25:15 +0000909 dst.w = (float) src.w
910
911
Corbin Simpson85805222010-02-02 16:20:12 -0800912.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +0000913
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800914.. math::
915
Keith Whitwella62aaa72009-12-21 23:25:15 +0000916 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800917
Keith Whitwella62aaa72009-12-21 23:25:15 +0000918 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800919
Keith Whitwella62aaa72009-12-21 23:25:15 +0000920 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800921
Keith Whitwella62aaa72009-12-21 23:25:15 +0000922 dst.w = ~src.w
923
924
Corbin Simpson85805222010-02-02 16:20:12 -0800925.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800926
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800927.. math::
928
Keith Whitwella62aaa72009-12-21 23:25:15 +0000929 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800930
Keith Whitwella62aaa72009-12-21 23:25:15 +0000931 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800932
Keith Whitwella62aaa72009-12-21 23:25:15 +0000933 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800934
Keith Whitwella62aaa72009-12-21 23:25:15 +0000935 dst.w = trunc(src.w)
936
937
Corbin Simpson85805222010-02-02 16:20:12 -0800938.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +0000939
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800940.. math::
941
Keith Whitwella62aaa72009-12-21 23:25:15 +0000942 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800943
Keith Whitwella62aaa72009-12-21 23:25:15 +0000944 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800945
Keith Whitwella62aaa72009-12-21 23:25:15 +0000946 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800947
Keith Whitwella62aaa72009-12-21 23:25:15 +0000948 dst.w = src0.w << src1.x
949
950
Corbin Simpson85805222010-02-02 16:20:12 -0800951.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +0000952
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800953.. math::
954
Keith Whitwella62aaa72009-12-21 23:25:15 +0000955 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800956
Keith Whitwella62aaa72009-12-21 23:25:15 +0000957 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800958
Keith Whitwella62aaa72009-12-21 23:25:15 +0000959 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800960
Keith Whitwella62aaa72009-12-21 23:25:15 +0000961 dst.w = src0.w >> src1.x
962
963
Corbin Simpson85805222010-02-02 16:20:12 -0800964.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +0000965
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800966.. math::
967
Keith Whitwella62aaa72009-12-21 23:25:15 +0000968 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800969
Keith Whitwella62aaa72009-12-21 23:25:15 +0000970 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800971
Keith Whitwella62aaa72009-12-21 23:25:15 +0000972 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800973
Keith Whitwella62aaa72009-12-21 23:25:15 +0000974 dst.w = src0.w & src1.w
975
976
Corbin Simpson85805222010-02-02 16:20:12 -0800977.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +0000978
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800979.. math::
980
Keith Whitwella62aaa72009-12-21 23:25:15 +0000981 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800982
Keith Whitwella62aaa72009-12-21 23:25:15 +0000983 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800984
Keith Whitwella62aaa72009-12-21 23:25:15 +0000985 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800986
Keith Whitwella62aaa72009-12-21 23:25:15 +0000987 dst.w = src0.w | src1.w
988
989
Corbin Simpson85805222010-02-02 16:20:12 -0800990.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +0000991
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800992.. math::
993
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800994 dst.x = src0.x \bmod src1.x
995
996 dst.y = src0.y \bmod src1.y
997
998 dst.z = src0.z \bmod src1.z
999
1000 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001001
1002
Corbin Simpson85805222010-02-02 16:20:12 -08001003.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +00001004
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001005.. math::
1006
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001007 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001008
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001009 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001010
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001011 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001012
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001013 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001014
1015
Corbin Simpson85805222010-02-02 16:20:12 -08001016.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +00001017
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001018.. math::
1019
Corbin Simpson14743ac2009-12-21 19:57:56 -08001020 dst.x = |src0.x - src1.x| + src2.x
1021
1022 dst.y = |src0.y - src1.y| + src2.y
1023
1024 dst.z = |src0.z - src1.z| + src2.z
1025
1026 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001027
1028
Corbin Simpson85805222010-02-02 16:20:12 -08001029.. opcode:: TXF - Texel Fetch
Keith Whitwella62aaa72009-12-21 23:25:15 +00001030
1031 TBD
1032
1033
Corbin Simpson85805222010-02-02 16:20:12 -08001034.. opcode:: TXQ - Texture Size Query
Keith Whitwella62aaa72009-12-21 23:25:15 +00001035
1036 TBD
1037
1038
Corbin Simpson85805222010-02-02 16:20:12 -08001039.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +00001040
1041 TBD
1042
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001043.. note::
Keith Whitwella62aaa72009-12-21 23:25:15 +00001044
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001045 Support for CONT is determined by a special capability bit,
1046 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1047
1048
1049Geometry ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001050^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001051
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001052These opcodes are only supported in geometry shaders; they have no meaning
1053in any other type of shader.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001054
Corbin Simpson85805222010-02-02 16:20:12 -08001055.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001056
1057 TBD
1058
1059
Corbin Simpson85805222010-02-02 16:20:12 -08001060.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001061
1062 TBD
1063
1064
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001065GLSL ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001066^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001067
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001068These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1069opcodes is determined by a special capability bit, ``GLSL``.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001070
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 Simpson17c2a442010-02-02 17:02:28 -08001098This instruction replicates its result.
1099
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001100.. math::
1101
Corbin Simpson17c2a442010-02-02 17:02:28 -08001102 dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +00001103
1104
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001105ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001106^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001107
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001108XXX wait what
Keith Whitwella62aaa72009-12-21 23:25:15 +00001109
Corbin Simpson85805222010-02-02 16:20:12 -08001110.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001111
1112 TBD
1113
1114
Corbin Simpson85805222010-02-02 16:20:12 -08001115.. opcode:: IFC - If
Keith Whitwella62aaa72009-12-21 23:25:15 +00001116
1117 TBD
1118
1119
Corbin Simpson85805222010-02-02 16:20:12 -08001120.. opcode:: BREAKC - Break Conditional
Keith Whitwella62aaa72009-12-21 23:25:15 +00001121
1122 TBD
1123
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001124.. _doubleopcodes:
1125
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001126Double ISA
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001127^^^^^^^^^^^^^^^
1128
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001129The double-precision opcodes reinterpret four-component vectors into
1130two-component vectors with doubled precision in each component.
1131
1132Support for these opcodes is XXX undecided. :T
1133
1134.. opcode:: DADD - Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001135
1136.. math::
1137
1138 dst.xy = src0.xy + src1.xy
1139
1140 dst.zw = src0.zw + src1.zw
1141
1142
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001143.. opcode:: DDIV - Divide
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001144
1145.. math::
1146
1147 dst.xy = src0.xy / src1.xy
1148
1149 dst.zw = src0.zw / src1.zw
1150
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001151.. opcode:: DSEQ - Set on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001152
1153.. math::
1154
1155 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1156
1157 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1158
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001159.. opcode:: DSLT - Set on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001160
1161.. math::
1162
1163 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1164
1165 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1166
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001167.. opcode:: DFRAC - Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001168
1169.. math::
1170
1171 dst.xy = src.xy - \lfloor src.xy\rfloor
1172
1173 dst.zw = src.zw - \lfloor src.zw\rfloor
1174
1175
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001176.. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001177
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001178Like the ``frexp()`` routine in many math libraries, this opcode stores the
1179exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1180:math:`dst1 \times 2^{dst0} = src` .
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001181
1182.. math::
1183
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001184 dst0.xy = exp(src.xy)
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001185
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001186 dst1.xy = frac(src.xy)
1187
1188 dst0.zw = exp(src.zw)
1189
1190 dst1.zw = frac(src.zw)
1191
1192.. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1193
1194This opcode is the inverse of :opcode:`DFRACEXP`.
1195
1196.. math::
1197
1198 dst.xy = src0.xy \times 2^{src1.xy}
1199
1200 dst.zw = src0.zw \times 2^{src1.zw}
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001201
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001202.. opcode:: DMIN - Minimum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001203
1204.. math::
1205
1206 dst.xy = min(src0.xy, src1.xy)
1207
1208 dst.zw = min(src0.zw, src1.zw)
1209
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001210.. opcode:: DMAX - Maximum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001211
1212.. math::
1213
1214 dst.xy = max(src0.xy, src1.xy)
1215
1216 dst.zw = max(src0.zw, src1.zw)
1217
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001218.. opcode:: DMUL - Multiply
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001219
1220.. math::
1221
1222 dst.xy = src0.xy \times src1.xy
1223
1224 dst.zw = src0.zw \times src1.zw
1225
1226
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001227.. opcode:: DMAD - Multiply And Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001228
1229.. math::
1230
1231 dst.xy = src0.xy \times src1.xy + src2.xy
1232
1233 dst.zw = src0.zw \times src1.zw + src2.zw
1234
1235
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001236.. opcode:: DRCP - Reciprocal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001237
1238.. math::
1239
1240 dst.xy = \frac{1}{src.xy}
1241
1242 dst.zw = \frac{1}{src.zw}
1243
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001244.. opcode:: DSQRT - Square Root
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001245
1246.. math::
1247
1248 dst.xy = \sqrt{src.xy}
1249
1250 dst.zw = \sqrt{src.zw}
1251
Keith Whitwella62aaa72009-12-21 23:25:15 +00001252
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001253.. _resourceopcodes:
1254
1255Resource Access Opcodes
1256^^^^^^^^^^^^^^^^^^^^^^^^
1257
1258Those opcodes follow very closely semantics of the respective Direct3D
1259instructions. If in doubt double check Direct3D documentation.
1260
1261.. opcode:: LOAD - Simplified alternative to the "SAMPLE" instruction.
1262 Using the provided integer address, LOAD fetches data
1263 from the specified buffer/texture without any filtering.
1264 The source data may come from any resource type other
1265 than CUBE.
1266 LOAD dst, address, resource
1267 e.g.
1268 LOAD TEMP[0], TEMP[1], RES[0]
1269
1270.. opcode:: LOAD_MS - Just like LOAD but allows fetch data from
1271 multi-sampled surfaces.
1272
1273.. opcode:: SAMPLE - Using provided address, sample data from the
1274 specified texture using the filtering mode identified
1275 by the gven sampler. The source data may come from
1276 any resource type other than buffers.
1277 SAMPLE dst, address, resource, sampler
1278 e.g.
1279 SAMPLE TEMP[0], TEMP[1], RES[0], SAMP[0]
1280
1281.. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the
1282 exception that an additiona bias is applied to the
1283 level of detail computed as part of the instruction
1284 execution.
1285 SAMPLE_B dst, address, resource, sampler, lod_bias
1286 e.g.
1287 SAMPLE_B TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2].x
1288
1289.. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it
1290 performs a comparison filter. The operands to SAMPLE_C
1291 are identical to SAMPLE, except that tere is an additional
1292 float32 operand, reference value, which must be a register
1293 with single-component, or a scalar literal.
1294 SAMPLE_C makes the hardware use the current samplers
1295 compare_func (in pipe_sampler_state) to compare
1296 reference value against the red component value for the
1297 surce resource at each texel that the currently configured
1298 texture filter covers based on the provided coordinates.
1299 SAMPLE_C dst, address, resource.r, sampler, ref_value
1300 e.g.
1301 SAMPLE_C TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
1302
1303.. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives
1304 are ignored. The LZ stands for level-zero.
1305 SAMPLE_C_LZ dst, address, resource.r, sampler, ref_value
1306 e.g.
1307 SAMPLE_C_LZ TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
1308
1309
1310.. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except
1311 that the derivatives for the source address in the x
1312 direction and the y direction are provided by extra
1313 parameters.
1314 SAMPLE_D dst, address, resource, sampler, der_x, der_y
1315 e.g.
1316 SAMPLE_D TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2], TEMP[3]
1317
1318.. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except
1319 that the LOD is provided directly as a scalar value,
1320 representing no anisotropy. Source addresses A channel
1321 is used as the LOD.
1322 SAMPLE_L dst, address, resource, sampler
1323 e.g.
1324 SAMPLE_L TEMP[0], TEMP[1], RES[0], SAMP[0]
1325
1326
1327.. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear
1328 filtering operation and packs them into a single register.
1329 Only woth with 2D, 2D array, cubemaps, and cubemaps arrays.
1330 For 2D textures, only the addressing modes of the sampler and
1331 the top level of any mip pyramid are used. Set W to zero.
1332 It behaves like the SAMPLE instruction, but a filtered
1333 sample is not generated. The four samples that contribute
1334 to filtering are places into xyzw in cunter-clockwise order,
1335 starting with the (u,v) texture coordinate delta at the
1336 following locations (-, +), (+, +), (+, -), (-, -), where
1337 the magnitude of the deltas are half a texel.
1338
1339
1340.. opcode:: RESINFO - query the dimentions of a given input buffer.
1341 dst receives width, height, depth or array size and
1342 total mip count (also can be slected by writemask).
1343 RESINFO dst, src_mip_level, resource
1344 e.g.
1345 RESINFO TEMP[0], TEMP[1].x, RES[0]
1346
1347.. opcode:: SAMPLE_POS - query the position of a given sample.
1348 dst receives float4 (x, y, 0, 0) indicated where the
1349 sample is located. If the resource is not a multi-sample
1350 resource and not a render target, the result is 0.
1351
1352.. opcode:: SAMPLE_INFO - dst receives number of components in x.
1353 If the resource is not a multi-sample resource and
1354 not a render target, the result is 0.
1355
1356
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001357Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001358------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001359
1360
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001361Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001362^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001363
1364
Corbin Simpson14743ac2009-12-21 19:57:56 -08001365 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001366
Corbin Simpson14743ac2009-12-21 19:57:56 -08001367 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001368
1369 clamp(x,y,z) Clamp x between y and z.
1370 (x < y) ? y : (x > z) ? z : x
1371
Corbin Simpsondd801e52009-12-21 19:41:09 -08001372 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001373
Corbin Simpson14743ac2009-12-21 19:57:56 -08001374 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001375
1376 max(x,y) Maximum of x and y.
1377 (x > y) ? x : y
1378
1379 min(x,y) Minimum of x and y.
1380 (x < y) ? x : y
1381
1382 partialx(x) Derivative of x relative to fragment's X.
1383
1384 partialy(x) Derivative of x relative to fragment's Y.
1385
1386 pop() Pop from stack.
1387
Corbin Simpsondd801e52009-12-21 19:41:09 -08001388 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001389
1390 push(x) Push x on stack.
1391
1392 round(x) Round x.
1393
Michal Krol07f416c2010-01-04 13:21:32 +01001394 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001395
1396
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001397Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001398^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001399
1400
1401 discard Discard fragment.
1402
Keith Whitwella62aaa72009-12-21 23:25:15 +00001403 pc Program counter.
1404
Keith Whitwella62aaa72009-12-21 23:25:15 +00001405 target Label of target instruction.
1406
1407
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001408Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001409---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001410
1411
Michal Krol63d60972010-02-03 15:45:32 +01001412Declaration
1413^^^^^^^^^^^
1414
1415
1416Declares a register that is will be referenced as an operand in Instruction
1417tokens.
1418
1419File field contains register file that is being declared and is one
1420of TGSI_FILE.
1421
1422UsageMask field specifies which of the register components can be accessed
1423and is one of TGSI_WRITEMASK.
1424
1425Interpolate field is only valid for fragment shader INPUT register files.
1426It specifes the way input is being interpolated by the rasteriser and is one
1427of TGSI_INTERPOLATE.
1428
1429If Dimension flag is set to 1, a Declaration Dimension token follows.
1430
1431If Semantic flag is set to 1, a Declaration Semantic token follows.
1432
1433CylindricalWrap bitfield is only valid for fragment shader INPUT register
1434files. It specifies which register components should be subject to cylindrical
1435wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X
1436is set to 1, the X component should be interpolated according to cylindrical
1437wrapping rules.
1438
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001439If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
1440
Michal Krol63d60972010-02-03 15:45:32 +01001441
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001442Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001443^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001444
Brian Paul05a18f42010-06-24 07:21:15 -06001445 Vertex and fragment shader input and output registers may be labeled
1446 with semantic information consisting of a name and index.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001447
1448 Follows Declaration token if Semantic bit is set.
1449
1450 Since its purpose is to link a shader with other stages of the pipeline,
1451 it is valid to follow only those Declaration tokens that declare a register
1452 either in INPUT or OUTPUT file.
1453
1454 SemanticName field contains the semantic name of the register being declared.
1455 There is no default value.
1456
1457 SemanticIndex is an optional subscript that can be used to distinguish
1458 different register declarations with the same semantic name. The default value
1459 is 0.
1460
1461 The meanings of the individual semantic names are explained in the following
1462 sections.
1463
Corbin Simpson54ddf642009-12-23 23:36:06 -08001464TGSI_SEMANTIC_POSITION
1465""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001466
Brian Paul50b3f2e2010-06-23 17:00:10 -06001467For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
1468output register which contains the homogeneous vertex position in the clip
1469space coordinate system. After clipping, the X, Y and Z components of the
1470vertex will be divided by the W value to get normalized device coordinates.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001471
Brian Paul50b3f2e2010-06-23 17:00:10 -06001472For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
1473fragment shader input contains the fragment's window position. The X
1474component starts at zero and always increases from left to right.
1475The Y component starts at zero and always increases but Y=0 may either
1476indicate the top of the window or the bottom depending on the fragment
1477coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
1478The Z coordinate ranges from 0 to 1 to represent depth from the front
1479to the back of the Z buffer. The W component contains the reciprocol
1480of the interpolated vertex position W component.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001481
Brian Paul05a18f42010-06-24 07:21:15 -06001482Fragment shaders may also declare an output register with
1483TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
1484the fragment shader to change the fragment's Z position.
1485
Corbin Simpson54ddf642009-12-23 23:36:06 -08001486
Corbin Simpson54ddf642009-12-23 23:36:06 -08001487
1488TGSI_SEMANTIC_COLOR
1489"""""""""""""""""""
1490
Brian Paul50b3f2e2010-06-23 17:00:10 -06001491For vertex shader outputs or fragment shader inputs/outputs, this
1492label indicates that the resister contains an R,G,B,A color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001493
Brian Paul50b3f2e2010-06-23 17:00:10 -06001494Several shader inputs/outputs may contain colors so the semantic index
1495is used to distinguish them. For example, color[0] may be the diffuse
1496color while color[1] may be the specular color.
1497
1498This label is needed so that the flat/smooth shading can be applied
1499to the right interpolants during rasterization.
1500
1501
Corbin Simpson54ddf642009-12-23 23:36:06 -08001502
1503TGSI_SEMANTIC_BCOLOR
1504""""""""""""""""""""
1505
1506Back-facing colors are only used for back-facing polygons, and are only valid
1507in vertex shader outputs. After rasterization, all polygons are front-facing
Brian Paul50b3f2e2010-06-23 17:00:10 -06001508and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
1509so all BCOLORs effectively become regular COLORs in the fragment shader.
1510
Corbin Simpson54ddf642009-12-23 23:36:06 -08001511
1512TGSI_SEMANTIC_FOG
1513"""""""""""""""""
1514
Brian Paul05a18f42010-06-24 07:21:15 -06001515Vertex shader inputs and outputs and fragment shader inputs may be
1516labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
1517a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
1518shader will use the fog coordinate to compute a fog blend factor which
1519is used to blend the normal fragment color with a constant fog color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001520
Brian Paul05a18f42010-06-24 07:21:15 -06001521Only the first component matters when writing from the vertex shader;
1522the driver will ensure that the coordinate is in this format when used
1523as a fragment shader input.
1524
Corbin Simpson54ddf642009-12-23 23:36:06 -08001525
1526TGSI_SEMANTIC_PSIZE
1527"""""""""""""""""""
1528
Brian Paul05a18f42010-06-24 07:21:15 -06001529Vertex shader input and output registers may be labeled with
1530TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
1531in the form (S, 0, 0, 1). The point size controls the width or diameter
1532of points for rasterization. This label cannot be used in fragment
1533shaders.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001534
1535When using this semantic, be sure to set the appropriate state in the
1536:ref:`rasterizer` first.
1537
Brian Paul05a18f42010-06-24 07:21:15 -06001538
Corbin Simpson54ddf642009-12-23 23:36:06 -08001539TGSI_SEMANTIC_GENERIC
1540"""""""""""""""""""""
1541
Brian Paul05a18f42010-06-24 07:21:15 -06001542All vertex/fragment shader inputs/outputs not labeled with any other
1543semantic label can be considered to be generic attributes. Typical
1544uses of generic inputs/outputs are texcoords and user-defined values.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001545
Corbin Simpson54ddf642009-12-23 23:36:06 -08001546
1547TGSI_SEMANTIC_NORMAL
1548""""""""""""""""""""
1549
Brian Paul05a18f42010-06-24 07:21:15 -06001550Indicates that a vertex shader input is a normal vector. This is
1551typically only used for legacy graphics APIs.
1552
Corbin Simpson54ddf642009-12-23 23:36:06 -08001553
1554TGSI_SEMANTIC_FACE
1555""""""""""""""""""
1556
Brian Paul05a18f42010-06-24 07:21:15 -06001557This label applies to fragment shader inputs only and indicates that
1558the register contains front/back-face information of the form (F, 0,
15590, 1). The first component will be positive when the fragment belongs
1560to a front-facing polygon, and negative when the fragment belongs to a
1561back-facing polygon.
1562
Corbin Simpson54ddf642009-12-23 23:36:06 -08001563
1564TGSI_SEMANTIC_EDGEFLAG
1565""""""""""""""""""""""
1566
Brian Paul73153002010-06-23 17:38:58 -06001567For vertex shaders, this sematic label indicates that an input or
1568output is a boolean edge flag. The register layout is [F, x, x, x]
1569where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
1570simply copies the edge flag input to the edgeflag output.
1571
1572Edge flags are used to control which lines or points are actually
1573drawn when the polygon mode converts triangles/quads/polygons into
1574points or lines.
1575
Dave Airlie4ecb2c12010-10-06 09:28:46 +10001576TGSI_SEMANTIC_STENCIL
1577""""""""""""""""""""""
1578
1579For fragment shaders, this semantic label indicates than an output
1580is a writable stencil reference value. Only the Y component is writable.
1581This allows the fragment shader to change the fragments stencilref value.
Luca Barbieri73317132010-01-21 05:36:14 +01001582
1583
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001584Declaration Resource
1585^^^^^^^^^^^^^^^^^^^^^^^^
1586
1587 Follows Declaration token if file is TGSI_FILE_RESOURCE.
1588
1589 DCL RES[#], resource, type(s)
1590
1591 Declares a shader input resource and assigns it to a RES[#]
1592 register.
1593
1594 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
1595 2DArray.
1596
1597 type must be 1 or 4 entries (if specifying on a per-component
1598 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
1599
1600
Luca Barbieri73317132010-01-21 05:36:14 +01001601Properties
1602^^^^^^^^^^^^^^^^^^^^^^^^
1603
1604
1605 Properties are general directives that apply to the whole TGSI program.
1606
1607FS_COORD_ORIGIN
1608"""""""""""""""
1609
1610Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
1611The default value is UPPER_LEFT.
1612
1613If UPPER_LEFT, the position will be (0,0) at the upper left corner and
1614increase downward and rightward.
1615If LOWER_LEFT, the position will be (0,0) at the lower left corner and
1616increase upward and rightward.
1617
1618OpenGL defaults to LOWER_LEFT, and is configurable with the
1619GL_ARB_fragment_coord_conventions extension.
1620
1621DirectX 9/10 use UPPER_LEFT.
1622
1623FS_COORD_PIXEL_CENTER
1624"""""""""""""""""""""
1625
1626Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
1627The default value is HALF_INTEGER.
1628
1629If HALF_INTEGER, the fractionary part of the position will be 0.5
1630If INTEGER, the fractionary part of the position will be 0.0
1631
1632Note that this does not affect the set of fragments generated by
1633rasterization, which is instead controlled by gl_rasterization_rules in the
1634rasterizer.
1635
1636OpenGL defaults to HALF_INTEGER, and is configurable with the
1637GL_ARB_fragment_coord_conventions extension.
1638
1639DirectX 9 uses INTEGER.
1640DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07001641
Dave Airliec9c8a5e2010-12-18 10:34:35 +10001642FS_COLOR0_WRITES_ALL_CBUFS
1643""""""""""""""""""""""""""
1644Specifies that writes to the fragment shader color 0 are replicated to all
1645bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
1646fragData is directed to a single color buffer, but fragColor is broadcast.
Brian Paul4778f462010-02-02 08:14:40 -07001647
1648
1649Texture Sampling and Texture Formats
1650------------------------------------
1651
Corbin Simpson797dcc02010-02-02 17:07:26 -08001652This table shows how texture image components are returned as (x,y,z,w) tuples
1653by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
1654:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
1655well.
Brian Paul4778f462010-02-02 08:14:40 -07001656
Corbin Simpson516e7152010-02-02 12:44:22 -08001657+--------------------+--------------+--------------------+--------------+
1658| Texture Components | Gallium | OpenGL | Direct3D 9 |
1659+====================+==============+====================+==============+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001660| R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001661+--------------------+--------------+--------------------+--------------+
Corbin Simpson92867dc2010-06-16 16:56:55 -07001662| RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001663+--------------------+--------------+--------------------+--------------+
1664| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
1665+--------------------+--------------+--------------------+--------------+
1666| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
1667+--------------------+--------------+--------------------+--------------+
1668| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
1669+--------------------+--------------+--------------------+--------------+
1670| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
1671+--------------------+--------------+--------------------+--------------+
1672| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
1673+--------------------+--------------+--------------------+--------------+
1674| I | (i, i, i, i) | (i, i, i, i) | N/A |
1675+--------------------+--------------+--------------------+--------------+
1676| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
1677| | | [#envmap-bumpmap]_ | |
1678+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07001679| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08001680| | | [#depth-tex-mode]_ | |
1681+--------------------+--------------+--------------------+--------------+
Dave Airlie66a0d1e2010-10-06 09:30:17 +10001682| S | (s, s, s, s) | unknown | unknown |
1683+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07001684
Corbin Simpson516e7152010-02-02 12:44:22 -08001685.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07001686.. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z)
Corbin Simpson797dcc02010-02-02 17:07:26 -08001687 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.