blob: a528fd27688f4cdd70c70e9c45f0d63b093b7953 [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
Roland Scheideggercb2e6782013-02-16 02:26:14 +010026Modifiers
27^^^^^^^^^^^^^^^
28
29TGSI supports modifiers on inputs (as well as saturate modifier on instructions).
30
31For inputs which have a floating point type, both absolute value and negation
32modifiers are supported (with absolute value being applied first).
33TGSI_OPCODE_MOV is considered to have float input type for applying modifiers.
34
Zack Rusin999cd792013-04-28 10:50:55 -040035For inputs which have signed or unsigned type only the negate modifier is
36supported.
Roland Scheideggercb2e6782013-02-16 02:26:14 +010037
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080038Instruction Set
39---------------
40
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070041Core ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -080042^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +000043
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -070044These opcodes are guaranteed to be available regardless of the driver being
45used.
Keith Whitwella62aaa72009-12-21 23:25:15 +000046
Corbin Simpson85805222010-02-02 16:20:12 -080047.. opcode:: ARL - Address Register Load
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080048
49.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000050
Corbin Simpsond92a6852009-12-21 19:30:29 -080051 dst.x = \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080052
Corbin Simpsond92a6852009-12-21 19:30:29 -080053 dst.y = \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080054
Corbin Simpsond92a6852009-12-21 19:30:29 -080055 dst.z = \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080056
Corbin Simpsond92a6852009-12-21 19:30:29 -080057 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +000058
59
Corbin Simpson85805222010-02-02 16:20:12 -080060.. opcode:: MOV - Move
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080061
62.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000063
64 dst.x = src.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080065
Keith Whitwella62aaa72009-12-21 23:25:15 +000066 dst.y = src.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080067
Keith Whitwella62aaa72009-12-21 23:25:15 +000068 dst.z = src.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080069
Keith Whitwella62aaa72009-12-21 23:25:15 +000070 dst.w = src.w
71
72
Corbin Simpson85805222010-02-02 16:20:12 -080073.. opcode:: LIT - Light Coefficients
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080074
75.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000076
Corbin Simpsonda65ac62009-12-21 20:32:46 -080077 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080078
Corbin Simpsonda65ac62009-12-21 20:32:46 -080079 dst.y = max(src.x, 0)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080080
Corbin Simpsonda65ac62009-12-21 20:32:46 -080081 dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080082
Corbin Simpsonda65ac62009-12-21 20:32:46 -080083 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +000084
85
Corbin Simpson85805222010-02-02 16:20:12 -080086.. opcode:: RCP - Reciprocal
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080087
Corbin Simpson17c2a442010-02-02 17:02:28 -080088This instruction replicates its result.
89
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080090.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +000091
Corbin Simpson17c2a442010-02-02 17:02:28 -080092 dst = \frac{1}{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +000093
94
Corbin Simpson85805222010-02-02 16:20:12 -080095.. opcode:: RSQ - Reciprocal Square Root
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080096
Corbin Simpson17c2a442010-02-02 17:02:28 -080097This instruction replicates its result.
98
Corbin Simpsone8ed3b92009-12-21 19:12:55 -080099.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000100
Corbin Simpson17c2a442010-02-02 17:02:28 -0800101 dst = \frac{1}{\sqrt{|src.x|}}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000102
103
Brian Pauld276a402013-02-01 10:59:43 -0700104.. opcode:: SQRT - Square Root
105
106This instruction replicates its result.
107
108.. math::
109
110 dst = {\sqrt{src.x}}
111
112
Corbin Simpson85805222010-02-02 16:20:12 -0800113.. opcode:: EXP - Approximate Exponential Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800114
115.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000116
Corbin Simpsondd801e52009-12-21 19:41:09 -0800117 dst.x = 2^{\lfloor src.x\rfloor}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800118
Corbin Simpsond92a6852009-12-21 19:30:29 -0800119 dst.y = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800120
Corbin Simpsondd801e52009-12-21 19:41:09 -0800121 dst.z = 2^{src.x}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800122
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800123 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000124
125
Corbin Simpson85805222010-02-02 16:20:12 -0800126.. opcode:: LOG - Approximate Logarithm Base 2
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800127
128.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000129
Corbin Simpson14743ac2009-12-21 19:57:56 -0800130 dst.x = \lfloor\log_2{|src.x|}\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800131
Corbin Simpson14743ac2009-12-21 19:57:56 -0800132 dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800133
Corbin Simpson14743ac2009-12-21 19:57:56 -0800134 dst.z = \log_2{|src.x|}
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800135
Corbin Simpson14743ac2009-12-21 19:57:56 -0800136 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000137
138
Corbin Simpson85805222010-02-02 16:20:12 -0800139.. opcode:: MUL - Multiply
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800140
141.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000142
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800143 dst.x = src0.x \times src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800144
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800145 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800146
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800147 dst.z = src0.z \times src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800148
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800149 dst.w = src0.w \times src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000150
151
Corbin Simpson85805222010-02-02 16:20:12 -0800152.. opcode:: ADD - Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800153
154.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000155
156 dst.x = src0.x + src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800157
Keith Whitwella62aaa72009-12-21 23:25:15 +0000158 dst.y = src0.y + src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800159
Keith Whitwella62aaa72009-12-21 23:25:15 +0000160 dst.z = src0.z + src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800161
Keith Whitwella62aaa72009-12-21 23:25:15 +0000162 dst.w = src0.w + src1.w
163
164
Corbin Simpson85805222010-02-02 16:20:12 -0800165.. opcode:: DP3 - 3-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800166
Corbin Simpson17c2a442010-02-02 17:02:28 -0800167This instruction replicates its result.
168
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800169.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000170
Corbin Simpson17c2a442010-02-02 17:02:28 -0800171 dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
Keith Whitwella62aaa72009-12-21 23:25:15 +0000172
173
Corbin Simpson85805222010-02-02 16:20:12 -0800174.. opcode:: DP4 - 4-component Dot Product
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800175
Corbin Simpson17c2a442010-02-02 17:02:28 -0800176This instruction replicates its result.
177
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800178.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000179
Corbin Simpson17c2a442010-02-02 17:02:28 -0800180 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 +0000181
182
Corbin Simpson85805222010-02-02 16:20:12 -0800183.. opcode:: DST - Distance Vector
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800184
185.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000186
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800187 dst.x = 1
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800188
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800189 dst.y = src0.y \times src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800190
Keith Whitwella62aaa72009-12-21 23:25:15 +0000191 dst.z = src0.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800192
Keith Whitwella62aaa72009-12-21 23:25:15 +0000193 dst.w = src1.w
194
195
Corbin Simpson85805222010-02-02 16:20:12 -0800196.. opcode:: MIN - Minimum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800197
198.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000199
200 dst.x = min(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800201
Keith Whitwella62aaa72009-12-21 23:25:15 +0000202 dst.y = min(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800203
Keith Whitwella62aaa72009-12-21 23:25:15 +0000204 dst.z = min(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800205
Keith Whitwella62aaa72009-12-21 23:25:15 +0000206 dst.w = min(src0.w, src1.w)
207
208
Corbin Simpson85805222010-02-02 16:20:12 -0800209.. opcode:: MAX - Maximum
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800210
211.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000212
213 dst.x = max(src0.x, src1.x)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800214
Keith Whitwella62aaa72009-12-21 23:25:15 +0000215 dst.y = max(src0.y, src1.y)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800216
Keith Whitwella62aaa72009-12-21 23:25:15 +0000217 dst.z = max(src0.z, src1.z)
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800218
Keith Whitwella62aaa72009-12-21 23:25:15 +0000219 dst.w = max(src0.w, src1.w)
220
221
Corbin Simpson85805222010-02-02 16:20:12 -0800222.. opcode:: SLT - Set On Less Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800223
224.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000225
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800226 dst.x = (src0.x < src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800227
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800228 dst.y = (src0.y < src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800229
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800230 dst.z = (src0.z < src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800231
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800232 dst.w = (src0.w < src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000233
234
Corbin Simpson85805222010-02-02 16:20:12 -0800235.. opcode:: SGE - Set On Greater Equal Than
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800236
237.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000238
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800239 dst.x = (src0.x >= src1.x) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800240
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800241 dst.y = (src0.y >= src1.y) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800242
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800243 dst.z = (src0.z >= src1.z) ? 1 : 0
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800244
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800245 dst.w = (src0.w >= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000246
247
Corbin Simpson85805222010-02-02 16:20:12 -0800248.. opcode:: MAD - Multiply And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800249
250.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000251
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800252 dst.x = src0.x \times src1.x + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800253
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800254 dst.y = src0.y \times src1.y + src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800255
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800256 dst.z = src0.z \times src1.z + src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800257
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800258 dst.w = src0.w \times src1.w + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000259
260
Corbin Simpson85805222010-02-02 16:20:12 -0800261.. opcode:: SUB - Subtract
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800262
263.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000264
265 dst.x = src0.x - src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800266
Keith Whitwella62aaa72009-12-21 23:25:15 +0000267 dst.y = src0.y - src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800268
Keith Whitwella62aaa72009-12-21 23:25:15 +0000269 dst.z = src0.z - src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800270
Keith Whitwella62aaa72009-12-21 23:25:15 +0000271 dst.w = src0.w - src1.w
272
273
Corbin Simpson85805222010-02-02 16:20:12 -0800274.. opcode:: LRP - Linear Interpolate
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800275
276.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000277
Michal Krolb3567fc2010-01-04 12:59:17 +0100278 dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800279
Michal Krolb3567fc2010-01-04 12:59:17 +0100280 dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800281
Michal Krolb3567fc2010-01-04 12:59:17 +0100282 dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800283
Michal Krolb3567fc2010-01-04 12:59:17 +0100284 dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000285
286
Corbin Simpson85805222010-02-02 16:20:12 -0800287.. opcode:: CND - Condition
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800288
289.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000290
291 dst.x = (src2.x > 0.5) ? src0.x : src1.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800292
Keith Whitwella62aaa72009-12-21 23:25:15 +0000293 dst.y = (src2.y > 0.5) ? src0.y : src1.y
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800294
Keith Whitwella62aaa72009-12-21 23:25:15 +0000295 dst.z = (src2.z > 0.5) ? src0.z : src1.z
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800296
Keith Whitwella62aaa72009-12-21 23:25:15 +0000297 dst.w = (src2.w > 0.5) ? src0.w : src1.w
298
299
Corbin Simpson85805222010-02-02 16:20:12 -0800300.. opcode:: DP2A - 2-component Dot Product And Add
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800301
302.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000303
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800304 dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800305
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800306 dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800307
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800308 dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800309
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800310 dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
Keith Whitwella62aaa72009-12-21 23:25:15 +0000311
312
José Fonsecad9c6ebb2010-06-01 16:25:05 +0100313.. opcode:: FRC - Fraction
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800314
315.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000316
Corbin Simpsond92a6852009-12-21 19:30:29 -0800317 dst.x = src.x - \lfloor src.x\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800318
Corbin Simpsond92a6852009-12-21 19:30:29 -0800319 dst.y = src.y - \lfloor src.y\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800320
Corbin Simpsond92a6852009-12-21 19:30:29 -0800321 dst.z = src.z - \lfloor src.z\rfloor
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800322
Corbin Simpsond92a6852009-12-21 19:30:29 -0800323 dst.w = src.w - \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000324
325
Corbin Simpson85805222010-02-02 16:20:12 -0800326.. opcode:: CLAMP - Clamp
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800327
328.. math::
Keith Whitwella62aaa72009-12-21 23:25:15 +0000329
330 dst.x = clamp(src0.x, src1.x, src2.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800331
Keith Whitwella62aaa72009-12-21 23:25:15 +0000332 dst.y = clamp(src0.y, src1.y, src2.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800333
Keith Whitwella62aaa72009-12-21 23:25:15 +0000334 dst.z = clamp(src0.z, src1.z, src2.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800335
Keith Whitwella62aaa72009-12-21 23:25:15 +0000336 dst.w = clamp(src0.w, src1.w, src2.w)
337
338
Corbin Simpson85805222010-02-02 16:20:12 -0800339.. opcode:: FLR - Floor
Corbin Simpsond92a6852009-12-21 19:30:29 -0800340
Corbin Simpson17c2a442010-02-02 17:02:28 -0800341This is identical to :opcode:`ARL`.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000342
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800343.. math::
344
Corbin Simpsond92a6852009-12-21 19:30:29 -0800345 dst.x = \lfloor src.x\rfloor
346
347 dst.y = \lfloor src.y\rfloor
348
349 dst.z = \lfloor src.z\rfloor
350
351 dst.w = \lfloor src.w\rfloor
Keith Whitwella62aaa72009-12-21 23:25:15 +0000352
353
Corbin Simpson85805222010-02-02 16:20:12 -0800354.. opcode:: ROUND - Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000355
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800356.. math::
357
Keith Whitwella62aaa72009-12-21 23:25:15 +0000358 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800359
Keith Whitwella62aaa72009-12-21 23:25:15 +0000360 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800361
Keith Whitwella62aaa72009-12-21 23:25:15 +0000362 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800363
Keith Whitwella62aaa72009-12-21 23:25:15 +0000364 dst.w = round(src.w)
365
366
Corbin Simpson85805222010-02-02 16:20:12 -0800367.. opcode:: EX2 - Exponential Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000368
Corbin Simpson17c2a442010-02-02 17:02:28 -0800369This instruction replicates its result.
370
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800371.. math::
372
Corbin Simpson17c2a442010-02-02 17:02:28 -0800373 dst = 2^{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000374
375
Corbin Simpson85805222010-02-02 16:20:12 -0800376.. opcode:: LG2 - Logarithm Base 2
Keith Whitwella62aaa72009-12-21 23:25:15 +0000377
Corbin Simpson17c2a442010-02-02 17:02:28 -0800378This instruction replicates its result.
379
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800380.. math::
381
Corbin Simpson17c2a442010-02-02 17:02:28 -0800382 dst = \log_2{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000383
384
Corbin Simpson85805222010-02-02 16:20:12 -0800385.. opcode:: POW - Power
Keith Whitwella62aaa72009-12-21 23:25:15 +0000386
Corbin Simpson17c2a442010-02-02 17:02:28 -0800387This instruction replicates its result.
388
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800389.. math::
390
Corbin Simpson17c2a442010-02-02 17:02:28 -0800391 dst = src0.x^{src1.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000392
Corbin Simpson85805222010-02-02 16:20:12 -0800393.. opcode:: XPD - Cross Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000394
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800395.. math::
396
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800397 dst.x = src0.y \times src1.z - src1.y \times src0.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800398
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800399 dst.y = src0.z \times src1.x - src1.z \times src0.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800400
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800401 dst.z = src0.x \times src1.y - src1.x \times src0.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800402
403 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000404
405
Corbin Simpson85805222010-02-02 16:20:12 -0800406.. opcode:: ABS - Absolute
Keith Whitwella62aaa72009-12-21 23:25:15 +0000407
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800408.. math::
409
Corbin Simpson14743ac2009-12-21 19:57:56 -0800410 dst.x = |src.x|
411
412 dst.y = |src.y|
413
414 dst.z = |src.z|
415
416 dst.w = |src.w|
Keith Whitwella62aaa72009-12-21 23:25:15 +0000417
418
Corbin Simpson85805222010-02-02 16:20:12 -0800419.. opcode:: RCC - Reciprocal Clamped
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800420
Corbin Simpson17c2a442010-02-02 17:02:28 -0800421This instruction replicates its result.
422
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800423XXX cleanup on aisle three
Keith Whitwella62aaa72009-12-21 23:25:15 +0000424
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800425.. math::
426
Corbin Simpson17c2a442010-02-02 17:02:28 -0800427 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 +0000428
429
Corbin Simpson85805222010-02-02 16:20:12 -0800430.. opcode:: DPH - Homogeneous Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000431
Corbin Simpson17c2a442010-02-02 17:02:28 -0800432This instruction replicates its result.
433
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800434.. math::
435
Corbin Simpson17c2a442010-02-02 17:02:28 -0800436 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 +0000437
438
Corbin Simpson85805222010-02-02 16:20:12 -0800439.. opcode:: COS - Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000440
Corbin Simpson17c2a442010-02-02 17:02:28 -0800441This instruction replicates its result.
442
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800443.. math::
444
Corbin Simpson17c2a442010-02-02 17:02:28 -0800445 dst = \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 Simpson17c2a442010-02-02 17:02:28 -0800511.. note::
512
513 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000514
Keith Whitwella62aaa72009-12-21 23:25:15 +0000515
Corbin Simpson85805222010-02-02 16:20:12 -0800516.. opcode:: SEQ - Set On Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000517
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800518.. math::
519
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800520 dst.x = (src0.x == src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800521
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800522 dst.y = (src0.y == src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800523
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800524 dst.z = (src0.z == src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800525
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800526 dst.w = (src0.w == src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000527
528
Corbin Simpson85805222010-02-02 16:20:12 -0800529.. opcode:: SFL - Set On False
Keith Whitwella62aaa72009-12-21 23:25:15 +0000530
Corbin Simpson17c2a442010-02-02 17:02:28 -0800531This instruction replicates its result.
532
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800533.. math::
534
Corbin Simpson17c2a442010-02-02 17:02:28 -0800535 dst = 0
Corbin Simpson04771912010-01-18 17:31:56 -0800536
Corbin Simpson17c2a442010-02-02 17:02:28 -0800537.. note::
Corbin Simpson04771912010-01-18 17:31:56 -0800538
Corbin Simpson17c2a442010-02-02 17:02:28 -0800539 Considered for removal.
Corbin Simpson04771912010-01-18 17:31:56 -0800540
Keith Whitwella62aaa72009-12-21 23:25:15 +0000541
Corbin Simpson85805222010-02-02 16:20:12 -0800542.. opcode:: SGT - Set On Greater Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000543
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800544.. math::
545
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800546 dst.x = (src0.x > src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800547
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800548 dst.y = (src0.y > src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800549
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800550 dst.z = (src0.z > src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800551
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800552 dst.w = (src0.w > src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000553
554
Corbin Simpson85805222010-02-02 16:20:12 -0800555.. opcode:: SIN - Sine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000556
Corbin Simpson17c2a442010-02-02 17:02:28 -0800557This instruction replicates its result.
558
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800559.. math::
560
Corbin Simpson17c2a442010-02-02 17:02:28 -0800561 dst = \sin{src.x}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000562
563
Corbin Simpson85805222010-02-02 16:20:12 -0800564.. opcode:: SLE - Set On Less Equal Than
Keith Whitwella62aaa72009-12-21 23:25:15 +0000565
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800566.. math::
567
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800568 dst.x = (src0.x <= src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800569
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800570 dst.y = (src0.y <= src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800571
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800572 dst.z = (src0.z <= src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800573
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800574 dst.w = (src0.w <= src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000575
576
Corbin Simpson85805222010-02-02 16:20:12 -0800577.. opcode:: SNE - Set On Not Equal
Keith Whitwella62aaa72009-12-21 23:25:15 +0000578
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800579.. math::
580
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800581 dst.x = (src0.x != src1.x) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800582
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800583 dst.y = (src0.y != src1.y) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800584
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800585 dst.z = (src0.z != src1.z) ? 1 : 0
Corbin Simpson04771912010-01-18 17:31:56 -0800586
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800587 dst.w = (src0.w != src1.w) ? 1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000588
589
Corbin Simpson85805222010-02-02 16:20:12 -0800590.. opcode:: STR - Set On True
Keith Whitwella62aaa72009-12-21 23:25:15 +0000591
Corbin Simpson17c2a442010-02-02 17:02:28 -0800592This instruction replicates its result.
593
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800594.. math::
595
Corbin Simpson17c2a442010-02-02 17:02:28 -0800596 dst = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000597
598
Corbin Simpson85805222010-02-02 16:20:12 -0800599.. opcode:: TEX - Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000600
Brian Paul2a77c3c2010-12-14 12:45:36 -0700601.. math::
602
603 coord = src0
604
605 bias = 0.0
606
607 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000608
Dave Airlie35db3262011-12-19 16:40:05 +0000609 for array textures src0.y contains the slice for 1D,
610 and src0.z contain the slice for 2D.
611 for shadow textures with no arrays, src0.z contains
612 the reference value.
613 for shadow textures with arrays, src0.z contains
614 the reference value for 1D arrays, and src0.w contains
615 the reference value for 2D arrays.
616 There is no way to pass a bias in the .w value for
617 shadow arrays, and GLSL doesn't allow this.
618 GLSL does allow cube shadows maps to take a bias value,
619 and we have to determine how this will look in TGSI.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000620
Corbin Simpson85805222010-02-02 16:20:12 -0800621.. opcode:: TXD - Texture Lookup with Derivatives
Keith Whitwella62aaa72009-12-21 23:25:15 +0000622
Brian Paul2a77c3c2010-12-14 12:45:36 -0700623.. math::
624
625 coord = src0
626
627 ddx = src1
628
629 ddy = src2
630
631 bias = 0.0
632
633 dst = texture_sample_deriv(unit, coord, bias, ddx, ddy)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000634
635
Corbin Simpson85805222010-02-02 16:20:12 -0800636.. opcode:: TXP - Projective Texture Lookup
Keith Whitwella62aaa72009-12-21 23:25:15 +0000637
Brian Paul2a77c3c2010-12-14 12:45:36 -0700638.. math::
639
640 coord.x = src0.x / src.w
641
642 coord.y = src0.y / src.w
643
644 coord.z = src0.z / src.w
645
646 coord.w = src0.w
647
648 bias = 0.0
649
650 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000651
652
Corbin Simpson85805222010-02-02 16:20:12 -0800653.. opcode:: UP2H - Unpack Two 16-Bit Floats
Keith Whitwella62aaa72009-12-21 23:25:15 +0000654
655 TBD
656
Corbin Simpson17c2a442010-02-02 17:02:28 -0800657.. note::
658
659 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000660
Corbin Simpson85805222010-02-02 16:20:12 -0800661.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000662
663 TBD
664
Corbin Simpson17c2a442010-02-02 17:02:28 -0800665.. note::
666
667 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000668
Corbin Simpson85805222010-02-02 16:20:12 -0800669.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
Keith Whitwella62aaa72009-12-21 23:25:15 +0000670
671 TBD
672
Corbin Simpson17c2a442010-02-02 17:02:28 -0800673.. note::
674
675 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000676
Corbin Simpson85805222010-02-02 16:20:12 -0800677.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
Keith Whitwella62aaa72009-12-21 23:25:15 +0000678
679 TBD
680
Corbin Simpson17c2a442010-02-02 17:02:28 -0800681.. note::
682
683 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000684
Corbin Simpson85805222010-02-02 16:20:12 -0800685.. opcode:: X2D - 2D Coordinate Transformation
Keith Whitwella62aaa72009-12-21 23:25:15 +0000686
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800687.. math::
688
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800689 dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800690
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800691 dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
Corbin Simpson04771912010-01-18 17:31:56 -0800692
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800693 dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
Corbin Simpson04771912010-01-18 17:31:56 -0800694
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800695 dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000696
Corbin Simpson17c2a442010-02-02 17:02:28 -0800697.. note::
698
699 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000700
Keith Whitwella62aaa72009-12-21 23:25:15 +0000701
Corbin Simpson85805222010-02-02 16:20:12 -0800702.. opcode:: ARA - Address Register Add
Keith Whitwella62aaa72009-12-21 23:25:15 +0000703
704 TBD
705
Corbin Simpson17c2a442010-02-02 17:02:28 -0800706.. note::
707
708 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000709
Corbin Simpson85805222010-02-02 16:20:12 -0800710.. opcode:: ARR - Address Register Load With Round
Keith Whitwella62aaa72009-12-21 23:25:15 +0000711
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800712.. math::
713
Keith Whitwella62aaa72009-12-21 23:25:15 +0000714 dst.x = round(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800715
Keith Whitwella62aaa72009-12-21 23:25:15 +0000716 dst.y = round(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800717
Keith Whitwella62aaa72009-12-21 23:25:15 +0000718 dst.z = round(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800719
Keith Whitwella62aaa72009-12-21 23:25:15 +0000720 dst.w = round(src.w)
721
722
Corbin Simpson85805222010-02-02 16:20:12 -0800723.. opcode:: BRA - Branch
Keith Whitwella62aaa72009-12-21 23:25:15 +0000724
725 pc = target
726
Corbin Simpson17c2a442010-02-02 17:02:28 -0800727.. note::
728
729 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000730
Corbin Simpson85805222010-02-02 16:20:12 -0800731.. opcode:: CAL - Subroutine Call
Keith Whitwella62aaa72009-12-21 23:25:15 +0000732
733 push(pc)
734 pc = target
735
736
Corbin Simpson85805222010-02-02 16:20:12 -0800737.. opcode:: RET - Subroutine Call Return
Keith Whitwella62aaa72009-12-21 23:25:15 +0000738
739 pc = pop()
740
741
Corbin Simpson85805222010-02-02 16:20:12 -0800742.. opcode:: SSG - Set Sign
Keith Whitwella62aaa72009-12-21 23:25:15 +0000743
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800744.. math::
745
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800746 dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
747
748 dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
749
750 dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
751
752 dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
Keith Whitwella62aaa72009-12-21 23:25:15 +0000753
754
Corbin Simpson85805222010-02-02 16:20:12 -0800755.. opcode:: CMP - Compare
Keith Whitwella62aaa72009-12-21 23:25:15 +0000756
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800757.. math::
758
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800759 dst.x = (src0.x < 0) ? src1.x : src2.x
760
761 dst.y = (src0.y < 0) ? src1.y : src2.y
762
763 dst.z = (src0.z < 0) ? src1.z : src2.z
764
765 dst.w = (src0.w < 0) ? src1.w : src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +0000766
767
Corbin Simpson85805222010-02-02 16:20:12 -0800768.. opcode:: KIL - Conditional Discard
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 if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000773 discard
774 endif
775
776
Corbin Simpson85805222010-02-02 16:20:12 -0800777.. opcode:: SCS - Sine Cosine
Keith Whitwella62aaa72009-12-21 23:25:15 +0000778
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800779.. math::
780
Corbin Simpsond92a6852009-12-21 19:30:29 -0800781 dst.x = \cos{src.x}
782
783 dst.y = \sin{src.x}
784
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800785 dst.z = 0
Corbin Simpsond92a6852009-12-21 19:30:29 -0800786
Tilman Sauerbeckd3231182010-09-19 09:03:11 +0200787 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000788
789
Corbin Simpson85805222010-02-02 16:20:12 -0800790.. opcode:: TXB - Texture Lookup With Bias
Keith Whitwella62aaa72009-12-21 23:25:15 +0000791
Brian Paul2a77c3c2010-12-14 12:45:36 -0700792.. math::
793
794 coord.x = src.x
795
796 coord.y = src.y
797
798 coord.z = src.z
799
800 coord.w = 1.0
801
802 bias = src.z
803
804 dst = texture_sample(unit, coord, bias)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000805
806
Corbin Simpson85805222010-02-02 16:20:12 -0800807.. opcode:: NRM - 3-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +0000808
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800809.. math::
810
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800811 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 -0800812
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800813 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 -0800814
Corbin Simpsonecb2f2a2009-12-21 20:07:10 -0800815 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 -0800816
817 dst.w = 1
Keith Whitwella62aaa72009-12-21 23:25:15 +0000818
819
Corbin Simpson85805222010-02-02 16:20:12 -0800820.. opcode:: DIV - Divide
Keith Whitwella62aaa72009-12-21 23:25:15 +0000821
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800822.. math::
823
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800824 dst.x = \frac{src0.x}{src1.x}
825
826 dst.y = \frac{src0.y}{src1.y}
827
828 dst.z = \frac{src0.z}{src1.z}
829
830 dst.w = \frac{src0.w}{src1.w}
Keith Whitwella62aaa72009-12-21 23:25:15 +0000831
832
Corbin Simpson85805222010-02-02 16:20:12 -0800833.. opcode:: DP2 - 2-component Dot Product
Keith Whitwella62aaa72009-12-21 23:25:15 +0000834
Corbin Simpson17c2a442010-02-02 17:02:28 -0800835This instruction replicates its result.
836
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800837.. math::
838
Corbin Simpson17c2a442010-02-02 17:02:28 -0800839 dst = src0.x \times src1.x + src0.y \times src1.y
Keith Whitwella62aaa72009-12-21 23:25:15 +0000840
841
Brian Paul2a77c3c2010-12-14 12:45:36 -0700842.. opcode:: TXL - Texture Lookup With explicit LOD
Keith Whitwella62aaa72009-12-21 23:25:15 +0000843
Brian Paul2a77c3c2010-12-14 12:45:36 -0700844.. math::
845
846 coord.x = src0.x
847
848 coord.y = src0.y
849
850 coord.z = src0.z
851
852 coord.w = 1.0
853
854 lod = src0.w
855
856 dst = texture_sample(unit, coord, lod)
Keith Whitwella62aaa72009-12-21 23:25:15 +0000857
858
Corbin Simpson85805222010-02-02 16:20:12 -0800859.. opcode:: BRK - Break
Keith Whitwella62aaa72009-12-21 23:25:15 +0000860
Roland Scheidegger79457912013-04-20 00:34:20 +0200861 Unconditionally moves the point of execution to the instruction after the
862 next endloop or endswitch. The instruction must appear within a loop/endloop
863 or switch/endswitch.
864
865
866.. opcode:: BREAKC - Break Conditional
867
868 Conditionally moves the point of execution to the instruction after the
869 next endloop or endswitch. The instruction must appear within a loop/endloop
870 or switch/endswitch.
871 Condition evaluates to true if src0.x != 0 where src0.x is interpreted
872 as an integer register.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000873
874
José Fonseca50b3fc62013-04-17 10:47:03 +0100875.. opcode:: IF - Float If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000876
José Fonseca50b3fc62013-04-17 10:47:03 +0100877 Start an IF ... ELSE .. ENDIF block. Condition evaluates to true if
878
879 src0.x != 0.0
880
881 where src0.x is interpreted as a floating point register.
882
883
884.. opcode:: UIF - Bitwise If
885
886 Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
887
888 src0.x != 0
889
890 where src0.x is interpreted as an integer register.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000891
892
Corbin Simpson85805222010-02-02 16:20:12 -0800893.. opcode:: ELSE - Else
Keith Whitwella62aaa72009-12-21 23:25:15 +0000894
José Fonseca50b3fc62013-04-17 10:47:03 +0100895 Starts an else block, after an IF or UIF statement.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000896
897
Corbin Simpson85805222010-02-02 16:20:12 -0800898.. opcode:: ENDIF - End If
Keith Whitwella62aaa72009-12-21 23:25:15 +0000899
José Fonseca50b3fc62013-04-17 10:47:03 +0100900 Ends an IF or UIF block.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000901
902
Roland Scheidegger79457912013-04-20 00:34:20 +0200903.. opcode:: SWITCH - Switch
904
905 Starts a C-style switch expression. The switch consists of one or multiple
906 CASE statements, and at most one DEFAULT statement. Execution of a statement
907 ends when a BRK is hit, but just like in C falling through to other cases
908 without a break is allowed. Similarly, DEFAULT label is allowed anywhere not
909 just as last statement, and fallthrough is allowed into/from it.
910 CASE src arguments are evaluated at bit level against the SWITCH src argument.
911
912 Example:
913 SWITCH src[0].x
914 CASE src[0].x
915 (some instructions here)
916 (optional BRK here)
917 DEFAULT
918 (some instructions here)
919 (optional BRK here)
920 CASE src[0].x
921 (some instructions here)
922 (optional BRK here)
923 ENDSWITCH
924
925
926.. opcode:: CASE - Switch case
927
928 This represents a switch case label. The src arg must be an integer immediate.
929
930
931.. opcode:: DEFAULT - Switch default
932
933 This represents the default case in the switch, which is taken if no other
934 case matches.
935
936
937.. opcode:: ENDSWITCH - End of switch
938
939 Ends a switch expression.
940
941
Corbin Simpson85805222010-02-02 16:20:12 -0800942.. opcode:: PUSHA - Push Address Register On Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000943
944 push(src.x)
945 push(src.y)
946 push(src.z)
947 push(src.w)
948
Corbin Simpson17c2a442010-02-02 17:02:28 -0800949.. note::
950
951 Considered for cleanup.
952
953.. note::
954
955 Considered for removal.
Keith Whitwella62aaa72009-12-21 23:25:15 +0000956
Corbin Simpson85805222010-02-02 16:20:12 -0800957.. opcode:: POPA - Pop Address Register From Stack
Keith Whitwella62aaa72009-12-21 23:25:15 +0000958
959 dst.w = pop()
960 dst.z = pop()
961 dst.y = pop()
962 dst.x = pop()
963
Corbin Simpson17c2a442010-02-02 17:02:28 -0800964.. note::
965
966 Considered for cleanup.
967
968.. note::
969
970 Considered for removal.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000971
Keith Whitwella62aaa72009-12-21 23:25:15 +0000972
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700973Compute ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -0800974^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +0000975
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700976These opcodes are primarily provided for special-use computational shaders.
Keith Whitwell14eacb02009-12-21 23:38:29 +0000977Support for these opcodes indicated by a special pipe capability bit (TBD).
Keith Whitwella62aaa72009-12-21 23:25:15 +0000978
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -0700979XXX so let's discuss it, yeah?
980
Corbin Simpson85805222010-02-02 16:20:12 -0800981.. opcode:: CEIL - Ceiling
Keith Whitwella62aaa72009-12-21 23:25:15 +0000982
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800983.. math::
984
Corbin Simpson14743ac2009-12-21 19:57:56 -0800985 dst.x = \lceil src.x\rceil
986
987 dst.y = \lceil src.y\rceil
988
989 dst.z = \lceil src.z\rceil
990
991 dst.w = \lceil src.w\rceil
Keith Whitwella62aaa72009-12-21 23:25:15 +0000992
993
Corbin Simpson85805222010-02-02 16:20:12 -0800994.. opcode:: I2F - Integer To Float
Keith Whitwella62aaa72009-12-21 23:25:15 +0000995
Corbin Simpsone8ed3b92009-12-21 19:12:55 -0800996.. math::
997
Keith Whitwella62aaa72009-12-21 23:25:15 +0000998 dst.x = (float) src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -0800999
Keith Whitwella62aaa72009-12-21 23:25:15 +00001000 dst.y = (float) src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001001
Keith Whitwella62aaa72009-12-21 23:25:15 +00001002 dst.z = (float) src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001003
Keith Whitwella62aaa72009-12-21 23:25:15 +00001004 dst.w = (float) src.w
1005
1006
Corbin Simpson85805222010-02-02 16:20:12 -08001007.. opcode:: NOT - Bitwise Not
Keith Whitwella62aaa72009-12-21 23:25:15 +00001008
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001009.. math::
1010
Keith Whitwella62aaa72009-12-21 23:25:15 +00001011 dst.x = ~src.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001012
Keith Whitwella62aaa72009-12-21 23:25:15 +00001013 dst.y = ~src.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001014
Keith Whitwella62aaa72009-12-21 23:25:15 +00001015 dst.z = ~src.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001016
Keith Whitwella62aaa72009-12-21 23:25:15 +00001017 dst.w = ~src.w
1018
1019
Corbin Simpson85805222010-02-02 16:20:12 -08001020.. opcode:: TRUNC - Truncate
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001021
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001022.. math::
1023
Keith Whitwella62aaa72009-12-21 23:25:15 +00001024 dst.x = trunc(src.x)
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001025
Keith Whitwella62aaa72009-12-21 23:25:15 +00001026 dst.y = trunc(src.y)
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001027
Keith Whitwella62aaa72009-12-21 23:25:15 +00001028 dst.z = trunc(src.z)
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001029
Keith Whitwella62aaa72009-12-21 23:25:15 +00001030 dst.w = trunc(src.w)
1031
1032
Corbin Simpson85805222010-02-02 16:20:12 -08001033.. opcode:: SHL - Shift Left
Keith Whitwella62aaa72009-12-21 23:25:15 +00001034
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001035.. math::
1036
Keith Whitwella62aaa72009-12-21 23:25:15 +00001037 dst.x = src0.x << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001038
Keith Whitwella62aaa72009-12-21 23:25:15 +00001039 dst.y = src0.y << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001040
Keith Whitwella62aaa72009-12-21 23:25:15 +00001041 dst.z = src0.z << src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001042
Keith Whitwella62aaa72009-12-21 23:25:15 +00001043 dst.w = src0.w << src1.x
1044
1045
Corbin Simpson85805222010-02-02 16:20:12 -08001046.. opcode:: SHR - Shift Right
Keith Whitwella62aaa72009-12-21 23:25:15 +00001047
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001048.. math::
1049
Keith Whitwella62aaa72009-12-21 23:25:15 +00001050 dst.x = src0.x >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001051
Keith Whitwella62aaa72009-12-21 23:25:15 +00001052 dst.y = src0.y >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001053
Keith Whitwella62aaa72009-12-21 23:25:15 +00001054 dst.z = src0.z >> src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001055
Keith Whitwella62aaa72009-12-21 23:25:15 +00001056 dst.w = src0.w >> src1.x
1057
1058
Corbin Simpson85805222010-02-02 16:20:12 -08001059.. opcode:: AND - Bitwise And
Keith Whitwella62aaa72009-12-21 23:25:15 +00001060
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001061.. math::
1062
Keith Whitwella62aaa72009-12-21 23:25:15 +00001063 dst.x = src0.x & src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001064
Keith Whitwella62aaa72009-12-21 23:25:15 +00001065 dst.y = src0.y & src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001066
Keith Whitwella62aaa72009-12-21 23:25:15 +00001067 dst.z = src0.z & src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001068
Keith Whitwella62aaa72009-12-21 23:25:15 +00001069 dst.w = src0.w & src1.w
1070
1071
Corbin Simpson85805222010-02-02 16:20:12 -08001072.. opcode:: OR - Bitwise Or
Keith Whitwella62aaa72009-12-21 23:25:15 +00001073
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001074.. math::
1075
Keith Whitwella62aaa72009-12-21 23:25:15 +00001076 dst.x = src0.x | src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001077
Keith Whitwella62aaa72009-12-21 23:25:15 +00001078 dst.y = src0.y | src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001079
Keith Whitwella62aaa72009-12-21 23:25:15 +00001080 dst.z = src0.z | src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001081
Keith Whitwella62aaa72009-12-21 23:25:15 +00001082 dst.w = src0.w | src1.w
1083
1084
Corbin Simpson85805222010-02-02 16:20:12 -08001085.. opcode:: MOD - Modulus
Keith Whitwella62aaa72009-12-21 23:25:15 +00001086
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001087.. math::
1088
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001089 dst.x = src0.x \bmod src1.x
1090
1091 dst.y = src0.y \bmod src1.y
1092
1093 dst.z = src0.z \bmod src1.z
1094
1095 dst.w = src0.w \bmod src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001096
1097
Corbin Simpson85805222010-02-02 16:20:12 -08001098.. opcode:: XOR - Bitwise Xor
Keith Whitwella62aaa72009-12-21 23:25:15 +00001099
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001100.. math::
1101
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001102 dst.x = src0.x \oplus src1.x
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001103
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001104 dst.y = src0.y \oplus src1.y
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001105
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001106 dst.z = src0.z \oplus src1.z
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001107
Corbin Simpsonf90733c2010-01-18 17:37:25 -08001108 dst.w = src0.w \oplus src1.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001109
1110
Bryan Cain324ac982011-09-10 12:31:54 -05001111.. opcode:: UCMP - Integer Conditional Move
1112
1113.. math::
1114
1115 dst.x = src0.x ? src1.x : src2.x
1116
1117 dst.y = src0.y ? src1.y : src2.y
1118
1119 dst.z = src0.z ? src1.z : src2.z
1120
1121 dst.w = src0.w ? src1.w : src2.w
1122
1123
1124.. opcode:: UARL - Integer Address Register Load
1125
1126 Moves the contents of the source register, assumed to be an integer, into the
1127 destination register, which is assumed to be an address (ADDR) register.
1128
1129
Bryan Cain4c0f1fb2012-01-07 10:43:04 -06001130.. opcode:: IABS - Integer Absolute Value
1131
1132.. math::
1133
1134 dst.x = |src.x|
1135
1136 dst.y = |src.y|
1137
1138 dst.z = |src.z|
1139
1140 dst.w = |src.w|
1141
1142
Corbin Simpson85805222010-02-02 16:20:12 -08001143.. opcode:: SAD - Sum Of Absolute Differences
Keith Whitwella62aaa72009-12-21 23:25:15 +00001144
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001145.. math::
1146
Corbin Simpson14743ac2009-12-21 19:57:56 -08001147 dst.x = |src0.x - src1.x| + src2.x
1148
1149 dst.y = |src0.y - src1.y| + src2.y
1150
1151 dst.z = |src0.z - src1.z| + src2.z
1152
1153 dst.w = |src0.w - src1.w| + src2.w
Keith Whitwella62aaa72009-12-21 23:25:15 +00001154
1155
Dave Airlie2083a272011-08-26 10:59:18 +01001156.. opcode:: TXF - Texel Fetch (as per NV_gpu_shader4), extract a single texel
1157 from a specified texture image. The source sampler may
1158 not be a CUBE or SHADOW.
1159 src 0 is a four-component signed integer vector used to
1160 identify the single texel accessed. 3 components + level.
1161 src 1 is a 3 component constant signed integer vector,
1162 with each component only have a range of
1163 -8..+8 (hw only seems to deal with this range, interface
1164 allows for up to unsigned int).
1165 TXF(uint_vec coord, int_vec offset).
Keith Whitwella62aaa72009-12-21 23:25:15 +00001166
1167
Dave Airlie6fb12bf2011-08-25 13:03:19 +01001168.. opcode:: TXQ - Texture Size Query (as per NV_gpu_program4)
1169 retrieve the dimensions of the texture
1170 depending on the target. For 1D (width), 2D/RECT/CUBE
1171 (width, height), 3D (width, height, depth),
1172 1D array (width, layers), 2D array (width, height, layers)
Keith Whitwella62aaa72009-12-21 23:25:15 +00001173
Dave Airlie6fb12bf2011-08-25 13:03:19 +01001174.. math::
1175
1176 lod = src0
1177
1178 dst.x = texture_width(unit, lod)
1179
1180 dst.y = texture_height(unit, lod)
1181
1182 dst.z = texture_depth(unit, lod)
Keith Whitwella62aaa72009-12-21 23:25:15 +00001183
1184
Corbin Simpson85805222010-02-02 16:20:12 -08001185.. opcode:: CONT - Continue
Keith Whitwella62aaa72009-12-21 23:25:15 +00001186
1187 TBD
1188
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001189.. note::
Keith Whitwella62aaa72009-12-21 23:25:15 +00001190
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001191 Support for CONT is determined by a special capability bit,
1192 ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information.
1193
1194
1195Geometry ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001196^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001197
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001198These opcodes are only supported in geometry shaders; they have no meaning
1199in any other type of shader.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001200
Corbin Simpson85805222010-02-02 16:20:12 -08001201.. opcode:: EMIT - Emit
Keith Whitwella62aaa72009-12-21 23:25:15 +00001202
1203 TBD
1204
1205
Corbin Simpson85805222010-02-02 16:20:12 -08001206.. opcode:: ENDPRIM - End Primitive
Keith Whitwella62aaa72009-12-21 23:25:15 +00001207
1208 TBD
1209
1210
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001211GLSL ISA
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001212^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001213
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001214These opcodes are part of :term:`GLSL`'s opcode set. Support for these
1215opcodes is determined by a special capability bit, ``GLSL``.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001216
Corbin Simpson85805222010-02-02 16:20:12 -08001217.. opcode:: BGNLOOP - Begin a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001218
1219 TBD
1220
1221
Corbin Simpson85805222010-02-02 16:20:12 -08001222.. opcode:: BGNSUB - Begin Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001223
1224 TBD
1225
1226
Corbin Simpson85805222010-02-02 16:20:12 -08001227.. opcode:: ENDLOOP - End a Loop
Keith Whitwella62aaa72009-12-21 23:25:15 +00001228
1229 TBD
1230
1231
Corbin Simpson85805222010-02-02 16:20:12 -08001232.. opcode:: ENDSUB - End Subroutine
Keith Whitwella62aaa72009-12-21 23:25:15 +00001233
1234 TBD
1235
1236
Corbin Simpson85805222010-02-02 16:20:12 -08001237.. opcode:: NOP - No Operation
Keith Whitwella62aaa72009-12-21 23:25:15 +00001238
Michal Krol8ab89d72010-01-04 13:23:41 +01001239 Do nothing.
1240
Keith Whitwella62aaa72009-12-21 23:25:15 +00001241
Corbin Simpson85805222010-02-02 16:20:12 -08001242.. opcode:: NRM4 - 4-component Vector Normalise
Keith Whitwella62aaa72009-12-21 23:25:15 +00001243
Corbin Simpson17c2a442010-02-02 17:02:28 -08001244This instruction replicates its result.
1245
Corbin Simpsone8ed3b92009-12-21 19:12:55 -08001246.. math::
1247
Corbin Simpson17c2a442010-02-02 17:02:28 -08001248 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 +00001249
1250
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001251ps_2_x
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001252^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001253
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001254XXX wait what
Keith Whitwella62aaa72009-12-21 23:25:15 +00001255
Corbin Simpson85805222010-02-02 16:20:12 -08001256.. opcode:: CALLNZ - Subroutine Call If Not Zero
Keith Whitwella62aaa72009-12-21 23:25:15 +00001257
1258 TBD
1259
Corbin Simpson62ca7b82010-02-02 16:36:34 -08001260.. _doubleopcodes:
1261
Corbin Simpson9d4cb6e2010-06-16 18:34:32 -07001262Double ISA
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001263^^^^^^^^^^^^^^^
1264
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001265The double-precision opcodes reinterpret four-component vectors into
1266two-component vectors with doubled precision in each component.
1267
1268Support for these opcodes is XXX undecided. :T
1269
1270.. opcode:: DADD - Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001271
1272.. math::
1273
1274 dst.xy = src0.xy + src1.xy
1275
1276 dst.zw = src0.zw + src1.zw
1277
1278
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001279.. opcode:: DDIV - Divide
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001280
1281.. math::
1282
1283 dst.xy = src0.xy / src1.xy
1284
1285 dst.zw = src0.zw / src1.zw
1286
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001287.. opcode:: DSEQ - Set on Equal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001288
1289.. math::
1290
1291 dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F
1292
1293 dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F
1294
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001295.. opcode:: DSLT - Set on Less than
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001296
1297.. math::
1298
1299 dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F
1300
1301 dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F
1302
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001303.. opcode:: DFRAC - Fraction
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001304
1305.. math::
1306
1307 dst.xy = src.xy - \lfloor src.xy\rfloor
1308
1309 dst.zw = src.zw - \lfloor src.zw\rfloor
1310
1311
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001312.. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001313
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001314Like the ``frexp()`` routine in many math libraries, this opcode stores the
1315exponent of its source to ``dst0``, and the significand to ``dst1``, such that
1316:math:`dst1 \times 2^{dst0} = src` .
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001317
1318.. math::
1319
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001320 dst0.xy = exp(src.xy)
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001321
Corbin Simpsonf98c4622010-06-16 18:45:50 -07001322 dst1.xy = frac(src.xy)
1323
1324 dst0.zw = exp(src.zw)
1325
1326 dst1.zw = frac(src.zw)
1327
1328.. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1329
1330This opcode is the inverse of :opcode:`DFRACEXP`.
1331
1332.. math::
1333
1334 dst.xy = src0.xy \times 2^{src1.xy}
1335
1336 dst.zw = src0.zw \times 2^{src1.zw}
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001337
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001338.. opcode:: DMIN - Minimum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001339
1340.. math::
1341
1342 dst.xy = min(src0.xy, src1.xy)
1343
1344 dst.zw = min(src0.zw, src1.zw)
1345
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001346.. opcode:: DMAX - Maximum
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001347
1348.. math::
1349
1350 dst.xy = max(src0.xy, src1.xy)
1351
1352 dst.zw = max(src0.zw, src1.zw)
1353
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001354.. opcode:: DMUL - Multiply
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001355
1356.. math::
1357
1358 dst.xy = src0.xy \times src1.xy
1359
1360 dst.zw = src0.zw \times src1.zw
1361
1362
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001363.. opcode:: DMAD - Multiply And Add
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001364
1365.. math::
1366
1367 dst.xy = src0.xy \times src1.xy + src2.xy
1368
1369 dst.zw = src0.zw \times src1.zw + src2.zw
1370
1371
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001372.. opcode:: DRCP - Reciprocal
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001373
1374.. math::
1375
1376 dst.xy = \frac{1}{src.xy}
1377
1378 dst.zw = \frac{1}{src.zw}
1379
Corbin Simpsondbc95e82010-06-16 18:34:51 -07001380.. opcode:: DSQRT - Square Root
Igor Oliveiradb89bf42010-01-25 19:23:04 -04001381
1382.. math::
1383
1384 dst.xy = \sqrt{src.xy}
1385
1386 dst.zw = \sqrt{src.zw}
1387
Keith Whitwella62aaa72009-12-21 23:25:15 +00001388
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001389.. _samplingopcodes:
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001390
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001391Resource Sampling Opcodes
1392^^^^^^^^^^^^^^^^^^^^^^^^^
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001393
1394Those opcodes follow very closely semantics of the respective Direct3D
1395instructions. If in doubt double check Direct3D documentation.
1396
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001397.. opcode:: SAMPLE - Using provided address, sample data from the
1398 specified texture using the filtering mode identified
1399 by the gven sampler. The source data may come from
1400 any resource type other than buffers.
1401 SAMPLE dst, address, sampler_view, sampler
1402 e.g.
1403 SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]
1404
1405.. opcode:: SAMPLE_I - Simplified alternative to the SAMPLE instruction.
1406 Using the provided integer address, SAMPLE_I fetches data
1407 from the specified sampler view without any filtering.
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001408 The source data may come from any resource type other
1409 than CUBE.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001410 SAMPLE_I dst, address, sampler_view
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001411 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001412 SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]
Zack Rusin3fa814d2011-01-24 21:45:37 -05001413 The 'address' is specified as unsigned integers. If the
1414 'address' is out of range [0...(# texels - 1)] the
1415 result of the fetch is always 0 in all components.
1416 As such the instruction doesn't honor address wrap
1417 modes, in cases where that behavior is desirable
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001418 'SAMPLE' instruction should be used.
Zack Rusin3fa814d2011-01-24 21:45:37 -05001419 address.w always provides an unsigned integer mipmap
1420 level. If the value is out of the range then the
1421 instruction always returns 0 in all components.
1422 address.yz are ignored for buffers and 1d textures.
1423 address.z is ignored for 1d texture arrays and 2d
1424 textures.
1425 For 1D texture arrays address.y provides the array
1426 index (also as unsigned integer). If the value is
1427 out of the range of available array indices
1428 [0... (array size - 1)] then the opcode always returns
1429 0 in all components.
1430 For 2D texture arrays address.z provides the array
1431 index, otherwise it exhibits the same behavior as in
1432 the case for 1D texture arrays.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001433 The exact semantics of the source address are presented
Zack Rusin3fa814d2011-01-24 21:45:37 -05001434 in the table below:
1435 resource type X Y Z W
1436 ------------- ------------------------
1437 PIPE_BUFFER x ignored
1438 PIPE_TEXTURE_1D x mpl
1439 PIPE_TEXTURE_2D x y mpl
1440 PIPE_TEXTURE_3D x y z mpl
1441 PIPE_TEXTURE_RECT x y mpl
1442 PIPE_TEXTURE_CUBE not allowed as source
1443 PIPE_TEXTURE_1D_ARRAY x idx mpl
1444 PIPE_TEXTURE_2D_ARRAY x y idx mpl
1445
1446 Where 'mpl' is a mipmap level and 'idx' is the
1447 array index.
1448
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001449.. opcode:: SAMPLE_I_MS - Just like SAMPLE_I but allows fetch data from
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001450 multi-sampled surfaces.
Roland Scheidegger98704592013-02-12 16:48:52 +01001451 SAMPLE_I_MS dst, address, sampler_view, sample
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001452
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001453.. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the
Roland Scheidegger98704592013-02-12 16:48:52 +01001454 exception that an additional bias is applied to the
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001455 level of detail computed as part of the instruction
1456 execution.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001457 SAMPLE_B dst, address, sampler_view, sampler, lod_bias
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001458 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001459 SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001460
Zack Rusin3fa814d2011-01-24 21:45:37 -05001461.. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001462 performs a comparison filter. The operands to SAMPLE_C
Roland Scheidegger98704592013-02-12 16:48:52 +01001463 are identical to SAMPLE, except that there is an additional
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001464 float32 operand, reference value, which must be a register
1465 with single-component, or a scalar literal.
1466 SAMPLE_C makes the hardware use the current samplers
1467 compare_func (in pipe_sampler_state) to compare
1468 reference value against the red component value for the
1469 surce resource at each texel that the currently configured
1470 texture filter covers based on the provided coordinates.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001471 SAMPLE_C dst, address, sampler_view.r, sampler, ref_value
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001472 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001473 SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001474
1475.. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives
1476 are ignored. The LZ stands for level-zero.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001477 SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001478 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001479 SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001480
1481
1482.. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except
1483 that the derivatives for the source address in the x
1484 direction and the y direction are provided by extra
1485 parameters.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001486 SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001487 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001488 SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001489
1490.. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except
1491 that the LOD is provided directly as a scalar value,
Roland Scheidegger427d36a2013-02-12 16:41:56 +01001492 representing no anisotropy.
1493 SAMPLE_L dst, address, sampler_view, sampler, explicit_lod
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001494 e.g.
Roland Scheidegger427d36a2013-02-12 16:41:56 +01001495 SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001496
1497.. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear
1498 filtering operation and packs them into a single register.
Brian Paul0cd68002012-03-30 09:41:42 -06001499 Only works with 2D, 2D array, cubemaps, and cubemaps arrays.
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001500 For 2D textures, only the addressing modes of the sampler and
1501 the top level of any mip pyramid are used. Set W to zero.
1502 It behaves like the SAMPLE instruction, but a filtered
1503 sample is not generated. The four samples that contribute
Brian Paul0cd68002012-03-30 09:41:42 -06001504 to filtering are placed into xyzw in counter-clockwise order,
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001505 starting with the (u,v) texture coordinate delta at the
1506 following locations (-, +), (+, +), (+, -), (-, -), where
1507 the magnitude of the deltas are half a texel.
1508
1509
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001510.. opcode:: SVIEWINFO - query the dimensions of a given sampler view.
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001511 dst receives width, height, depth or array size and
Roland Scheidegger614982d32013-02-05 13:37:57 -08001512 number of mipmap levels as int4. The dst can have a writemask
Zack Rusin3fa814d2011-01-24 21:45:37 -05001513 which will specify what info is the caller interested
1514 in.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001515 SVIEWINFO dst, src_mip_level, sampler_view
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001516 e.g.
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001517 SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]
Zack Rusin3fa814d2011-01-24 21:45:37 -05001518 src_mip_level is an unsigned integer scalar. If it's
1519 out of range then returns 0 for width, height and
1520 depth/array size but the total number of mipmap is
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001521 still returned correctly for the given sampler view.
Zack Rusin3fa814d2011-01-24 21:45:37 -05001522 The returned width, height and depth values are for
1523 the mipmap level selected by the src_mip_level and
1524 are in the number of texels.
1525 For 1d texture array width is in dst.x, array size
1526 is in dst.y and dst.zw are always 0.
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001527
1528.. opcode:: SAMPLE_POS - query the position of a given sample.
1529 dst receives float4 (x, y, 0, 0) indicated where the
1530 sample is located. If the resource is not a multi-sample
1531 resource and not a render target, the result is 0.
1532
Zack Rusin3fa814d2011-01-24 21:45:37 -05001533.. opcode:: SAMPLE_INFO - dst receives number of samples in x.
1534 If the resource is not a multi-sample resource and
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001535 not a render target, the result is 0.
1536
1537
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001538.. _resourceopcodes:
1539
1540Resource Access Opcodes
1541^^^^^^^^^^^^^^^^^^^^^^^
1542
1543.. opcode:: LOAD - Fetch data from a shader resource
1544
1545 Syntax: ``LOAD dst, resource, address``
1546
1547 Example: ``LOAD TEMP[0], RES[0], TEMP[1]``
1548
1549 Using the provided integer address, LOAD fetches data
1550 from the specified buffer or texture without any
1551 filtering.
1552
1553 The 'address' is specified as a vector of unsigned
1554 integers. If the 'address' is out of range the result
1555 is unspecified.
1556
1557 Only the first mipmap level of a resource can be read
1558 from using this instruction.
1559
1560 For 1D or 2D texture arrays, the array index is
1561 provided as an unsigned integer in address.y or
1562 address.z, respectively. address.yz are ignored for
1563 buffers and 1D textures. address.z is ignored for 1D
1564 texture arrays and 2D textures. address.w is always
1565 ignored.
1566
Francisco Jerezb8e808f2012-04-30 20:20:29 +02001567.. opcode:: STORE - Write data to a shader resource
1568
1569 Syntax: ``STORE resource, address, src``
1570
1571 Example: ``STORE RES[0], TEMP[0], TEMP[1]``
1572
1573 Using the provided integer address, STORE writes data
1574 to the specified buffer or texture.
1575
1576 The 'address' is specified as a vector of unsigned
1577 integers. If the 'address' is out of range the result
1578 is unspecified.
1579
1580 Only the first mipmap level of a resource can be
1581 written to using this instruction.
1582
1583 For 1D or 2D texture arrays, the array index is
1584 provided as an unsigned integer in address.y or
1585 address.z, respectively. address.yz are ignored for
1586 buffers and 1D textures. address.z is ignored for 1D
1587 texture arrays and 2D textures. address.w is always
1588 ignored.
1589
Francisco Jereza5f44cc2012-05-01 02:38:51 +02001590
Francisco Jerez9e550c32012-04-30 20:21:38 +02001591.. _threadsyncopcodes:
1592
1593Inter-thread synchronization opcodes
1594^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1595
1596These opcodes are intended for communication between threads running
1597within the same compute grid. For now they're only valid in compute
1598programs.
1599
1600.. opcode:: MFENCE - Memory fence
1601
1602 Syntax: ``MFENCE resource``
1603
1604 Example: ``MFENCE RES[0]``
1605
1606 This opcode forces strong ordering between any memory access
1607 operations that affect the specified resource. This means that
1608 previous loads and stores (and only those) will be performed and
1609 visible to other threads before the program execution continues.
1610
1611
1612.. opcode:: LFENCE - Load memory fence
1613
1614 Syntax: ``LFENCE resource``
1615
1616 Example: ``LFENCE RES[0]``
1617
1618 Similar to MFENCE, but it only affects the ordering of memory loads.
1619
1620
1621.. opcode:: SFENCE - Store memory fence
1622
1623 Syntax: ``SFENCE resource``
1624
1625 Example: ``SFENCE RES[0]``
1626
1627 Similar to MFENCE, but it only affects the ordering of memory stores.
1628
1629
1630.. opcode:: BARRIER - Thread group barrier
1631
1632 ``BARRIER``
1633
1634 This opcode suspends the execution of the current thread until all
1635 the remaining threads in the working group reach the same point of
1636 the program. Results are unspecified if any of the remaining
1637 threads terminates or never reaches an executed BARRIER instruction.
1638
1639
Francisco Jerezc2d31a82012-04-30 20:22:23 +02001640.. _atomopcodes:
1641
1642Atomic opcodes
1643^^^^^^^^^^^^^^
1644
1645These opcodes provide atomic variants of some common arithmetic and
1646logical operations. In this context atomicity means that another
1647concurrent memory access operation that affects the same memory
1648location is guaranteed to be performed strictly before or after the
1649entire execution of the atomic operation.
1650
1651For the moment they're only valid in compute programs.
1652
1653.. opcode:: ATOMUADD - Atomic integer addition
1654
1655 Syntax: ``ATOMUADD dst, resource, offset, src``
1656
1657 Example: ``ATOMUADD TEMP[0], RES[0], TEMP[1], TEMP[2]``
1658
1659 The following operation is performed atomically on each component:
1660
1661.. math::
1662
1663 dst_i = resource[offset]_i
1664
1665 resource[offset]_i = dst_i + src_i
1666
1667
1668.. opcode:: ATOMXCHG - Atomic exchange
1669
1670 Syntax: ``ATOMXCHG dst, resource, offset, src``
1671
1672 Example: ``ATOMXCHG TEMP[0], RES[0], TEMP[1], TEMP[2]``
1673
1674 The following operation is performed atomically on each component:
1675
1676.. math::
1677
1678 dst_i = resource[offset]_i
1679
1680 resource[offset]_i = src_i
1681
1682
1683.. opcode:: ATOMCAS - Atomic compare-and-exchange
1684
1685 Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
1686
1687 Example: ``ATOMCAS TEMP[0], RES[0], TEMP[1], TEMP[2], TEMP[3]``
1688
1689 The following operation is performed atomically on each component:
1690
1691.. math::
1692
1693 dst_i = resource[offset]_i
1694
1695 resource[offset]_i = (dst_i == cmp_i ? src_i : dst_i)
1696
1697
1698.. opcode:: ATOMAND - Atomic bitwise And
1699
1700 Syntax: ``ATOMAND dst, resource, offset, src``
1701
1702 Example: ``ATOMAND TEMP[0], RES[0], TEMP[1], TEMP[2]``
1703
1704 The following operation is performed atomically on each component:
1705
1706.. math::
1707
1708 dst_i = resource[offset]_i
1709
1710 resource[offset]_i = dst_i \& src_i
1711
1712
1713.. opcode:: ATOMOR - Atomic bitwise Or
1714
1715 Syntax: ``ATOMOR dst, resource, offset, src``
1716
1717 Example: ``ATOMOR TEMP[0], RES[0], TEMP[1], TEMP[2]``
1718
1719 The following operation is performed atomically on each component:
1720
1721.. math::
1722
1723 dst_i = resource[offset]_i
1724
1725 resource[offset]_i = dst_i | src_i
1726
1727
1728.. opcode:: ATOMXOR - Atomic bitwise Xor
1729
1730 Syntax: ``ATOMXOR dst, resource, offset, src``
1731
1732 Example: ``ATOMXOR TEMP[0], RES[0], TEMP[1], TEMP[2]``
1733
1734 The following operation is performed atomically on each component:
1735
1736.. math::
1737
1738 dst_i = resource[offset]_i
1739
1740 resource[offset]_i = dst_i \oplus src_i
1741
1742
1743.. opcode:: ATOMUMIN - Atomic unsigned minimum
1744
1745 Syntax: ``ATOMUMIN dst, resource, offset, src``
1746
1747 Example: ``ATOMUMIN TEMP[0], RES[0], TEMP[1], TEMP[2]``
1748
1749 The following operation is performed atomically on each component:
1750
1751.. math::
1752
1753 dst_i = resource[offset]_i
1754
1755 resource[offset]_i = (dst_i < src_i ? dst_i : src_i)
1756
1757
1758.. opcode:: ATOMUMAX - Atomic unsigned maximum
1759
1760 Syntax: ``ATOMUMAX dst, resource, offset, src``
1761
1762 Example: ``ATOMUMAX TEMP[0], RES[0], TEMP[1], TEMP[2]``
1763
1764 The following operation is performed atomically on each component:
1765
1766.. math::
1767
1768 dst_i = resource[offset]_i
1769
1770 resource[offset]_i = (dst_i > src_i ? dst_i : src_i)
1771
1772
1773.. opcode:: ATOMIMIN - Atomic signed minimum
1774
1775 Syntax: ``ATOMIMIN dst, resource, offset, src``
1776
1777 Example: ``ATOMIMIN TEMP[0], RES[0], TEMP[1], TEMP[2]``
1778
1779 The following operation is performed atomically on each component:
1780
1781.. math::
1782
1783 dst_i = resource[offset]_i
1784
1785 resource[offset]_i = (dst_i < src_i ? dst_i : src_i)
1786
1787
1788.. opcode:: ATOMIMAX - Atomic signed maximum
1789
1790 Syntax: ``ATOMIMAX dst, resource, offset, src``
1791
1792 Example: ``ATOMIMAX TEMP[0], RES[0], TEMP[1], TEMP[2]``
1793
1794 The following operation is performed atomically on each component:
1795
1796.. math::
1797
1798 dst_i = resource[offset]_i
1799
1800 resource[offset]_i = (dst_i > src_i ? dst_i : src_i)
1801
1802
1803
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001804Explanation of symbols used
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001805------------------------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001806
1807
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001808Functions
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001809^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001810
1811
Corbin Simpson14743ac2009-12-21 19:57:56 -08001812 :math:`|x|` Absolute value of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001813
Corbin Simpson14743ac2009-12-21 19:57:56 -08001814 :math:`\lceil x \rceil` Ceiling of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001815
1816 clamp(x,y,z) Clamp x between y and z.
1817 (x < y) ? y : (x > z) ? z : x
1818
Corbin Simpsondd801e52009-12-21 19:41:09 -08001819 :math:`\lfloor x\rfloor` Floor of `x`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001820
Corbin Simpson14743ac2009-12-21 19:57:56 -08001821 :math:`\log_2{x}` Logarithm of `x`, base 2.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001822
1823 max(x,y) Maximum of x and y.
1824 (x > y) ? x : y
1825
1826 min(x,y) Minimum of x and y.
1827 (x < y) ? x : y
1828
1829 partialx(x) Derivative of x relative to fragment's X.
1830
1831 partialy(x) Derivative of x relative to fragment's Y.
1832
1833 pop() Pop from stack.
1834
Corbin Simpsondd801e52009-12-21 19:41:09 -08001835 :math:`x^y` `x` to the power `y`.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001836
1837 push(x) Push x on stack.
1838
1839 round(x) Round x.
1840
Michal Krol07f416c2010-01-04 13:21:32 +01001841 trunc(x) Truncate x, i.e. drop the fraction bits.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001842
1843
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001844Keywords
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001845^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001846
1847
1848 discard Discard fragment.
1849
Keith Whitwella62aaa72009-12-21 23:25:15 +00001850 pc Program counter.
1851
Keith Whitwella62aaa72009-12-21 23:25:15 +00001852 target Label of target instruction.
1853
1854
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001855Other tokens
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001856---------------
Keith Whitwella62aaa72009-12-21 23:25:15 +00001857
1858
Michal Krol63d60972010-02-03 15:45:32 +01001859Declaration
1860^^^^^^^^^^^
1861
1862
1863Declares a register that is will be referenced as an operand in Instruction
1864tokens.
1865
1866File field contains register file that is being declared and is one
1867of TGSI_FILE.
1868
1869UsageMask field specifies which of the register components can be accessed
1870and is one of TGSI_WRITEMASK.
1871
Francisco Jerez26449522012-03-18 19:21:36 +01001872The Local flag specifies that a given value isn't intended for
1873subroutine parameter passing and, as a result, the implementation
1874isn't required to give any guarantees of it being preserved across
1875subroutine boundaries. As it's merely a compiler hint, the
1876implementation is free to ignore it.
1877
Michal Krol63d60972010-02-03 15:45:32 +01001878If Dimension flag is set to 1, a Declaration Dimension token follows.
1879
1880If Semantic flag is set to 1, a Declaration Semantic token follows.
1881
Francisco Jerez12799232012-04-30 18:27:52 +02001882If Interpolate flag is set to 1, a Declaration Interpolate token follows.
Michal Krol63d60972010-02-03 15:45:32 +01001883
Zack Rusinbdbe77f2011-01-24 17:47:10 -05001884If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows.
1885
Christian König897303f2013-03-14 11:10:16 +01001886If Array flag is set to 1, a Declaration Array token follows.
1887
1888Array Declaration
1889^^^^^^^^^^^^^^^^^^^^^^^^
1890
1891Declarations can optional have an ArrayID attribute which can be referred by
1892indirect addressing operands. An ArrayID of zero is reserved and treaded as
1893if no ArrayID is specified.
1894
1895If an indirect addressing operand refers to a specific declaration by using
1896an ArrayID only the registers in this declaration are guaranteed to be
1897accessed, accessing any register outside this declaration results in undefined
1898behavior. Note that for compatibility the effective index is zero-based and
1899not relative to the specified declaration
1900
1901If no ArrayID is specified with an indirect addressing operand the whole
1902register file might be accessed by this operand. This is strongly discouraged
1903and will prevent packing of scalar/vec2 arrays and effective alias analysis.
Michal Krol63d60972010-02-03 15:45:32 +01001904
Corbin Simpsonda65ac62009-12-21 20:32:46 -08001905Declaration Semantic
Corbin Simpson5bcd26c2009-12-21 21:04:10 -08001906^^^^^^^^^^^^^^^^^^^^^^^^
Keith Whitwella62aaa72009-12-21 23:25:15 +00001907
Brian Paul05a18f42010-06-24 07:21:15 -06001908 Vertex and fragment shader input and output registers may be labeled
1909 with semantic information consisting of a name and index.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001910
1911 Follows Declaration token if Semantic bit is set.
1912
1913 Since its purpose is to link a shader with other stages of the pipeline,
1914 it is valid to follow only those Declaration tokens that declare a register
1915 either in INPUT or OUTPUT file.
1916
1917 SemanticName field contains the semantic name of the register being declared.
1918 There is no default value.
1919
1920 SemanticIndex is an optional subscript that can be used to distinguish
1921 different register declarations with the same semantic name. The default value
1922 is 0.
1923
1924 The meanings of the individual semantic names are explained in the following
1925 sections.
1926
Corbin Simpson54ddf642009-12-23 23:36:06 -08001927TGSI_SEMANTIC_POSITION
1928""""""""""""""""""""""
Keith Whitwella62aaa72009-12-21 23:25:15 +00001929
Brian Paul50b3f2e2010-06-23 17:00:10 -06001930For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader
1931output register which contains the homogeneous vertex position in the clip
1932space coordinate system. After clipping, the X, Y and Z components of the
1933vertex will be divided by the W value to get normalized device coordinates.
Keith Whitwella62aaa72009-12-21 23:25:15 +00001934
Brian Paul50b3f2e2010-06-23 17:00:10 -06001935For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that
1936fragment shader input contains the fragment's window position. The X
1937component starts at zero and always increases from left to right.
1938The Y component starts at zero and always increases but Y=0 may either
1939indicate the top of the window or the bottom depending on the fragment
1940coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN).
1941The Z coordinate ranges from 0 to 1 to represent depth from the front
1942to the back of the Z buffer. The W component contains the reciprocol
1943of the interpolated vertex position W component.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001944
Brian Paul05a18f42010-06-24 07:21:15 -06001945Fragment shaders may also declare an output register with
1946TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows
1947the fragment shader to change the fragment's Z position.
1948
Corbin Simpson54ddf642009-12-23 23:36:06 -08001949
Corbin Simpson54ddf642009-12-23 23:36:06 -08001950
1951TGSI_SEMANTIC_COLOR
1952"""""""""""""""""""
1953
Brian Paul50b3f2e2010-06-23 17:00:10 -06001954For vertex shader outputs or fragment shader inputs/outputs, this
1955label indicates that the resister contains an R,G,B,A color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001956
Brian Paul50b3f2e2010-06-23 17:00:10 -06001957Several shader inputs/outputs may contain colors so the semantic index
1958is used to distinguish them. For example, color[0] may be the diffuse
1959color while color[1] may be the specular color.
1960
1961This label is needed so that the flat/smooth shading can be applied
1962to the right interpolants during rasterization.
1963
1964
Corbin Simpson54ddf642009-12-23 23:36:06 -08001965
1966TGSI_SEMANTIC_BCOLOR
1967""""""""""""""""""""
1968
1969Back-facing colors are only used for back-facing polygons, and are only valid
1970in vertex shader outputs. After rasterization, all polygons are front-facing
Brian Paul50b3f2e2010-06-23 17:00:10 -06001971and COLOR and BCOLOR end up occupying the same slots in the fragment shader,
1972so all BCOLORs effectively become regular COLORs in the fragment shader.
1973
Corbin Simpson54ddf642009-12-23 23:36:06 -08001974
1975TGSI_SEMANTIC_FOG
1976"""""""""""""""""
1977
Brian Paul05a18f42010-06-24 07:21:15 -06001978Vertex shader inputs and outputs and fragment shader inputs may be
1979labeled with TGSI_SEMANTIC_FOG to indicate that the register contains
1980a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment
1981shader will use the fog coordinate to compute a fog blend factor which
1982is used to blend the normal fragment color with a constant fog color.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001983
Brian Paul05a18f42010-06-24 07:21:15 -06001984Only the first component matters when writing from the vertex shader;
1985the driver will ensure that the coordinate is in this format when used
1986as a fragment shader input.
1987
Corbin Simpson54ddf642009-12-23 23:36:06 -08001988
1989TGSI_SEMANTIC_PSIZE
1990"""""""""""""""""""
1991
Brian Paul05a18f42010-06-24 07:21:15 -06001992Vertex shader input and output registers may be labeled with
1993TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size
1994in the form (S, 0, 0, 1). The point size controls the width or diameter
1995of points for rasterization. This label cannot be used in fragment
1996shaders.
Corbin Simpson54ddf642009-12-23 23:36:06 -08001997
1998When using this semantic, be sure to set the appropriate state in the
1999:ref:`rasterizer` first.
2000
Brian Paul05a18f42010-06-24 07:21:15 -06002001
Christoph Bumiller8acaf862013-03-15 22:11:31 +01002002TGSI_SEMANTIC_TEXCOORD
2003""""""""""""""""""""""
2004
2005Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
2006
2007Vertex shader outputs and fragment shader inputs may be labeled with
2008this semantic to make them replaceable by sprite coordinates via the
2009sprite_coord_enable state in the :ref:`rasterizer`.
2010The semantic index permitted with this semantic is limited to <= 7.
2011
2012If the driver does not support TEXCOORD, sprite coordinate replacement
2013applies to inputs with the GENERIC semantic instead.
2014
2015The intended use case for this semantic is gl_TexCoord.
2016
2017
2018TGSI_SEMANTIC_PCOORD
2019""""""""""""""""""""
2020
2021Only available if PIPE_CAP_TGSI_TEXCOORD is exposed !
2022
2023Fragment shader inputs may be labeled with TGSI_SEMANTIC_PCOORD to indicate
2024that the register contains sprite coordinates in the form (x, y, 0, 1), if
2025the current primitive is a point and point sprites are enabled. Otherwise,
2026the contents of the register are undefined.
2027
2028The intended use case for this semantic is gl_PointCoord.
2029
2030
Corbin Simpson54ddf642009-12-23 23:36:06 -08002031TGSI_SEMANTIC_GENERIC
2032"""""""""""""""""""""
2033
Brian Paul05a18f42010-06-24 07:21:15 -06002034All vertex/fragment shader inputs/outputs not labeled with any other
2035semantic label can be considered to be generic attributes. Typical
2036uses of generic inputs/outputs are texcoords and user-defined values.
Corbin Simpson54ddf642009-12-23 23:36:06 -08002037
Corbin Simpson54ddf642009-12-23 23:36:06 -08002038
2039TGSI_SEMANTIC_NORMAL
2040""""""""""""""""""""
2041
Brian Paul05a18f42010-06-24 07:21:15 -06002042Indicates that a vertex shader input is a normal vector. This is
2043typically only used for legacy graphics APIs.
2044
Corbin Simpson54ddf642009-12-23 23:36:06 -08002045
2046TGSI_SEMANTIC_FACE
2047""""""""""""""""""
2048
Brian Paul05a18f42010-06-24 07:21:15 -06002049This label applies to fragment shader inputs only and indicates that
2050the register contains front/back-face information of the form (F, 0,
20510, 1). The first component will be positive when the fragment belongs
2052to a front-facing polygon, and negative when the fragment belongs to a
2053back-facing polygon.
2054
Corbin Simpson54ddf642009-12-23 23:36:06 -08002055
2056TGSI_SEMANTIC_EDGEFLAG
2057""""""""""""""""""""""
2058
Brian Paul73153002010-06-23 17:38:58 -06002059For vertex shaders, this sematic label indicates that an input or
2060output is a boolean edge flag. The register layout is [F, x, x, x]
2061where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader
2062simply copies the edge flag input to the edgeflag output.
2063
2064Edge flags are used to control which lines or points are actually
2065drawn when the polygon mode converts triangles/quads/polygons into
2066points or lines.
2067
Dave Airlie4ecb2c12010-10-06 09:28:46 +10002068TGSI_SEMANTIC_STENCIL
2069""""""""""""""""""""""
2070
2071For fragment shaders, this semantic label indicates than an output
2072is a writable stencil reference value. Only the Y component is writable.
2073This allows the fragment shader to change the fragments stencilref value.
Luca Barbieri73317132010-01-21 05:36:14 +01002074
2075
Francisco Jerez12799232012-04-30 18:27:52 +02002076Declaration Interpolate
2077^^^^^^^^^^^^^^^^^^^^^^^
2078
2079This token is only valid for fragment shader INPUT declarations.
2080
2081The Interpolate field specifes the way input is being interpolated by
2082the rasteriser and is one of TGSI_INTERPOLATE_*.
2083
2084The CylindricalWrap bitfield specifies which register components
2085should be subject to cylindrical wrapping when interpolating by the
2086rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component
2087should be interpolated according to cylindrical wrapping rules.
2088
2089
Francisco Jereza5f44cc2012-05-01 02:38:51 +02002090Declaration Sampler View
Zack Rusinbdbe77f2011-01-24 17:47:10 -05002091^^^^^^^^^^^^^^^^^^^^^^^^
2092
Francisco Jereza5f44cc2012-05-01 02:38:51 +02002093 Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
2094
2095 DCL SVIEW[#], resource, type(s)
2096
2097 Declares a shader input sampler view and assigns it to a SVIEW[#]
2098 register.
2099
2100 resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
2101
2102 type must be 1 or 4 entries (if specifying on a per-component
2103 level) out of UNORM, SNORM, SINT, UINT and FLOAT.
2104
2105
2106Declaration Resource
2107^^^^^^^^^^^^^^^^^^^^
2108
Zack Rusinbdbe77f2011-01-24 17:47:10 -05002109 Follows Declaration token if file is TGSI_FILE_RESOURCE.
2110
Francisco Jerezb8e808f2012-04-30 20:20:29 +02002111 DCL RES[#], resource [, WR] [, RAW]
Zack Rusinbdbe77f2011-01-24 17:47:10 -05002112
2113 Declares a shader input resource and assigns it to a RES[#]
2114 register.
2115
2116 resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
2117 2DArray.
2118
Francisco Jerez82c90b22012-04-30 19:08:55 +02002119 If the RAW keyword is not specified, the texture data will be
2120 subject to conversion, swizzling and scaling as required to yield
2121 the specified data type from the physical data format of the bound
2122 resource.
2123
2124 If the RAW keyword is specified, no channel conversion will be
2125 performed: the values read for each of the channels (X,Y,Z,W) will
2126 correspond to consecutive words in the same order and format
2127 they're found in memory. No element-to-address conversion will be
2128 performed either: the value of the provided X coordinate will be
2129 interpreted in byte units instead of texel units. The result of
2130 accessing a misaligned address is undefined.
2131
Francisco Jerezb8e808f2012-04-30 20:20:29 +02002132 Usage of the STORE opcode is only allowed if the WR (writable) flag
2133 is set.
2134
Zack Rusinbdbe77f2011-01-24 17:47:10 -05002135
Luca Barbieri73317132010-01-21 05:36:14 +01002136Properties
2137^^^^^^^^^^^^^^^^^^^^^^^^
2138
2139
2140 Properties are general directives that apply to the whole TGSI program.
2141
2142FS_COORD_ORIGIN
2143"""""""""""""""
2144
2145Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin.
2146The default value is UPPER_LEFT.
2147
2148If UPPER_LEFT, the position will be (0,0) at the upper left corner and
2149increase downward and rightward.
2150If LOWER_LEFT, the position will be (0,0) at the lower left corner and
2151increase upward and rightward.
2152
2153OpenGL defaults to LOWER_LEFT, and is configurable with the
2154GL_ARB_fragment_coord_conventions extension.
2155
2156DirectX 9/10 use UPPER_LEFT.
2157
2158FS_COORD_PIXEL_CENTER
2159"""""""""""""""""""""
2160
2161Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention.
2162The default value is HALF_INTEGER.
2163
2164If HALF_INTEGER, the fractionary part of the position will be 0.5
2165If INTEGER, the fractionary part of the position will be 0.0
2166
2167Note that this does not affect the set of fragments generated by
José Fonseca2737abb2013-04-23 19:40:05 +01002168rasterization, which is instead controlled by half_pixel_center in the
Luca Barbieri73317132010-01-21 05:36:14 +01002169rasterizer.
2170
2171OpenGL defaults to HALF_INTEGER, and is configurable with the
2172GL_ARB_fragment_coord_conventions extension.
2173
2174DirectX 9 uses INTEGER.
2175DirectX 10 uses HALF_INTEGER.
Brian Paul4778f462010-02-02 08:14:40 -07002176
Dave Airliec9c8a5e2010-12-18 10:34:35 +10002177FS_COLOR0_WRITES_ALL_CBUFS
2178""""""""""""""""""""""""""
2179Specifies that writes to the fragment shader color 0 are replicated to all
2180bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where
2181fragData is directed to a single color buffer, but fragColor is broadcast.
Brian Paul4778f462010-02-02 08:14:40 -07002182
Marek Olšákdc4c8212012-01-10 00:19:00 +01002183VS_PROHIBIT_UCPS
2184""""""""""""""""""""""""""
2185If this property is set on the program bound to the shader stage before the
2186fragment shader, user clip planes should have no effect (be disabled) even if
2187that shader does not write to any clip distance outputs and the rasterizer's
2188clip_plane_enable is non-zero.
2189This property is only supported by drivers that also support shader clip
2190distance outputs.
2191This is useful for APIs that don't have UCPs and where clip distances written
2192by a shader cannot be disabled.
2193
Brian Paul4778f462010-02-02 08:14:40 -07002194
2195Texture Sampling and Texture Formats
2196------------------------------------
2197
Corbin Simpson797dcc02010-02-02 17:07:26 -08002198This table shows how texture image components are returned as (x,y,z,w) tuples
2199by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and
2200:opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as
2201well.
Brian Paul4778f462010-02-02 08:14:40 -07002202
Corbin Simpson516e7152010-02-02 12:44:22 -08002203+--------------------+--------------+--------------------+--------------+
2204| Texture Components | Gallium | OpenGL | Direct3D 9 |
2205+====================+==============+====================+==============+
Corbin Simpson92867dc2010-06-16 16:56:55 -07002206| R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08002207+--------------------+--------------+--------------------+--------------+
Corbin Simpson92867dc2010-06-16 16:56:55 -07002208| RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08002209+--------------------+--------------+--------------------+--------------+
2210| RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) |
2211+--------------------+--------------+--------------------+--------------+
2212| RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) |
2213+--------------------+--------------+--------------------+--------------+
2214| A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) |
2215+--------------------+--------------+--------------------+--------------+
2216| L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) |
2217+--------------------+--------------+--------------------+--------------+
2218| LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) |
2219+--------------------+--------------+--------------------+--------------+
2220| I | (i, i, i, i) | (i, i, i, i) | N/A |
2221+--------------------+--------------+--------------------+--------------+
2222| UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) |
2223| | | [#envmap-bumpmap]_ | |
2224+--------------------+--------------+--------------------+--------------+
Brian Paul3e572eb2010-02-02 16:27:07 -07002225| Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) |
Corbin Simpson516e7152010-02-02 12:44:22 -08002226| | | [#depth-tex-mode]_ | |
2227+--------------------+--------------+--------------------+--------------+
Dave Airlie66a0d1e2010-10-06 09:30:17 +10002228| S | (s, s, s, s) | unknown | unknown |
2229+--------------------+--------------+--------------------+--------------+
Brian Paul4778f462010-02-02 08:14:40 -07002230
Corbin Simpson516e7152010-02-02 12:44:22 -08002231.. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt
Brian Paul3e572eb2010-02-02 16:27:07 -07002232.. [#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 -08002233 or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE.