~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to docs/gallium/tgsi.rst

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 
58
58
.. opcode:: ARL - Address Register Load
59
59
 
60
 
.. math::
61
 
 
62
 
  dst.x = (int) \lfloor src.x\rfloor
63
 
 
64
 
  dst.y = (int) \lfloor src.y\rfloor
65
 
 
66
 
  dst.z = (int) \lfloor src.z\rfloor
67
 
 
68
 
  dst.w = (int) \lfloor src.w\rfloor
 
60
   .. math::
 
61
 
 
62
      dst.x = (int) \lfloor src.x\rfloor
 
63
 
 
64
      dst.y = (int) \lfloor src.y\rfloor
 
65
 
 
66
      dst.z = (int) \lfloor src.z\rfloor
 
67
 
 
68
      dst.w = (int) \lfloor src.w\rfloor
69
69
 
70
70
 
71
71
.. opcode:: MOV - Move
72
72
 
73
 
.. math::
74
 
 
75
 
  dst.x = src.x
76
 
 
77
 
  dst.y = src.y
78
 
 
79
 
  dst.z = src.z
80
 
 
81
 
  dst.w = src.w
 
73
   .. math::
 
74
 
 
75
      dst.x = src.x
 
76
 
 
77
      dst.y = src.y
 
78
 
 
79
      dst.z = src.z
 
80
 
 
81
      dst.w = src.w
82
82
 
83
83
 
84
84
.. opcode:: LIT - Light Coefficients
85
85
 
86
 
.. math::
87
 
 
88
 
  dst.x &= 1 \\
89
 
  dst.y &= max(src.x, 0) \\
90
 
  dst.z &= (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 \\
91
 
  dst.w &= 1
 
86
   .. math::
 
87
 
 
88
      dst.x = 1
 
89
 
 
90
      dst.y = max(src.x, 0)
 
91
 
 
92
      dst.z =
 
93
      \left\{
 
94
      \begin{array}{ c l }
 
95
         max(src.y, 0)^{clamp(src.w, -128, 128)} & \quad \textrm{if } src.x \gt 0 \\
 
96
         0                                       & \quad \textrm{otherwise}
 
97
      \end{array}
 
98
      \right.
 
99
 
 
100
      dst.w = 1
92
101
 
93
102
 
94
103
.. opcode:: RCP - Reciprocal
95
104
 
96
 
This instruction replicates its result.
97
 
 
98
 
.. math::
99
 
 
100
 
  dst = \frac{1}{src.x}
 
105
   This instruction replicates its result.
 
106
 
 
107
   .. math::
 
108
 
 
109
      dst = \frac{1}{src.x}
101
110
 
102
111
 
103
112
.. opcode:: RSQ - Reciprocal Square Root
104
113
 
105
 
This instruction replicates its result. The results are undefined for *src* <= 0.
106
 
 
107
 
.. math::
108
 
 
109
 
  dst = \frac{1}{\sqrt{src.x}}
 
114
   This instruction replicates its result. The results are undefined for *src* <= 0.
 
115
 
 
116
   .. math::
 
117
 
 
118
      dst = \frac{1}{\sqrt{src.x}}
110
119
 
111
120
 
112
121
.. opcode:: SQRT - Square Root
113
122
 
114
 
This instruction replicates its result. The results are undefined for *src* < 0.
115
 
 
116
 
.. math::
117
 
 
118
 
  dst = {\sqrt{src.x}}
 
123
   This instruction replicates its result. The results are undefined for *src* < 0.
 
124
 
 
125
   .. math::
 
126
 
 
127
      dst = {\sqrt{src.x}}
119
128
 
120
129
 
121
130
.. opcode:: EXP - Approximate Exponential Base 2
122
131
 
123
 
.. math::
 
132
   .. math::
124
133
 
125
 
  dst.x &= 2^{\lfloor src.x\rfloor} \\
126
 
  dst.y &= src.x - \lfloor src.x\rfloor \\
127
 
  dst.z &= 2^{src.x} \\
128
 
  dst.w &= 1
 
134
      dst.x &= 2^{\lfloor src.x\rfloor} \\
 
135
      dst.y &= src.x - \lfloor src.x\rfloor \\
 
136
      dst.z &= 2^{src.x} \\
 
137
      dst.w &= 1
129
138
 
130
139
 
131
140
.. opcode:: LOG - Approximate Logarithm Base 2
132
141
 
133
 
.. math::
 
142
   .. math::
134
143
 
135
 
  dst.x &= \lfloor\log_2{|src.x|}\rfloor \\
136
 
  dst.y &= \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} \\
137
 
  dst.z &= \log_2{|src.x|} \\
138
 
  dst.w &= 1
 
144
      dst.x &= \lfloor\log_2{|src.x|}\rfloor \\
 
145
      dst.y &= \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} \\
 
146
      dst.z &= \log_2{|src.x|} \\
 
147
      dst.w &= 1
139
148
 
140
149
 
141
150
.. opcode:: MUL - Multiply
142
151
 
143
 
.. math::
144
 
 
145
 
  dst.x = src0.x \times src1.x
146
 
 
147
 
  dst.y = src0.y \times src1.y
148
 
 
149
 
  dst.z = src0.z \times src1.z
150
 
 
151
 
  dst.w = src0.w \times src1.w
 
152
   .. math::
 
153
 
 
154
      dst.x = src0.x \times src1.x
 
155
 
 
156
      dst.y = src0.y \times src1.y
 
157
 
 
158
      dst.z = src0.z \times src1.z
 
159
 
 
160
      dst.w = src0.w \times src1.w
152
161
 
153
162
 
154
163
.. opcode:: ADD - Add
155
164
 
156
 
.. math::
157
 
 
158
 
  dst.x = src0.x + src1.x
159
 
 
160
 
  dst.y = src0.y + src1.y
161
 
 
162
 
  dst.z = src0.z + src1.z
163
 
 
164
 
  dst.w = src0.w + src1.w
 
165
   .. math::
 
166
 
 
167
      dst.x = src0.x + src1.x
 
168
 
 
169
      dst.y = src0.y + src1.y
 
170
 
 
171
      dst.z = src0.z + src1.z
 
172
 
 
173
      dst.w = src0.w + src1.w
165
174
 
166
175
 
167
176
.. opcode:: DP3 - 3-component Dot Product
168
177
 
169
 
This instruction replicates its result.
170
 
 
171
 
.. math::
172
 
 
173
 
  dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
 
178
   This instruction replicates its result.
 
179
 
 
180
   .. math::
 
181
 
 
182
      \begin{aligned}
 
183
      dst = & src0.x \times src1.x +\\
 
184
            & src0.y \times src1.y +\\
 
185
            & src0.z \times src1.z
 
186
      \end{aligned}
174
187
 
175
188
 
176
189
.. opcode:: DP4 - 4-component Dot Product
177
190
 
178
 
This instruction replicates its result.
179
 
 
180
 
.. math::
181
 
 
182
 
  dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
 
191
   This instruction replicates its result.
 
192
 
 
193
   .. math::
 
194
 
 
195
      \begin{aligned}
 
196
      dst = & src0.x \times src1.x +\\
 
197
            & src0.y \times src1.y +\\
 
198
            & src0.z \times src1.z +\\
 
199
            & src0.w \times src1.w
 
200
      \end{aligned}
183
201
 
184
202
 
185
203
.. opcode:: DST - Distance Vector
186
204
 
187
 
.. math::
 
205
   .. math::
188
206
 
189
 
  dst.x &= 1\\
190
 
  dst.y &= src0.y \times src1.y\\
191
 
  dst.z &= src0.z\\
192
 
  dst.w &= src1.w
 
207
      dst.x &= 1\\
 
208
      dst.y &= src0.y \times src1.y\\
 
209
      dst.z &= src0.z\\
 
210
      dst.w &= src1.w
193
211
 
194
212
 
195
213
.. opcode:: MIN - Minimum
196
214
 
197
 
.. math::
198
 
 
199
 
  dst.x = min(src0.x, src1.x)
200
 
 
201
 
  dst.y = min(src0.y, src1.y)
202
 
 
203
 
  dst.z = min(src0.z, src1.z)
204
 
 
205
 
  dst.w = min(src0.w, src1.w)
 
215
   .. math::
 
216
 
 
217
      dst.x = min(src0.x, src1.x)
 
218
 
 
219
      dst.y = min(src0.y, src1.y)
 
220
 
 
221
      dst.z = min(src0.z, src1.z)
 
222
 
 
223
      dst.w = min(src0.w, src1.w)
206
224
 
207
225
 
208
226
.. opcode:: MAX - Maximum
209
227
 
210
 
.. math::
211
 
 
212
 
  dst.x = max(src0.x, src1.x)
213
 
 
214
 
  dst.y = max(src0.y, src1.y)
215
 
 
216
 
  dst.z = max(src0.z, src1.z)
217
 
 
218
 
  dst.w = max(src0.w, src1.w)
 
228
   .. math::
 
229
 
 
230
      dst.x = max(src0.x, src1.x)
 
231
 
 
232
      dst.y = max(src0.y, src1.y)
 
233
 
 
234
      dst.z = max(src0.z, src1.z)
 
235
 
 
236
      dst.w = max(src0.w, src1.w)
219
237
 
220
238
 
221
239
.. opcode:: SLT - Set On Less Than
222
240
 
223
 
.. math::
224
 
 
225
 
  dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
226
 
 
227
 
  dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
228
 
 
229
 
  dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
230
 
 
231
 
  dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
 
241
   .. math::
 
242
 
 
243
      dst.x = (src0.x < src1.x) ? 1.0F : 0.0F
 
244
 
 
245
      dst.y = (src0.y < src1.y) ? 1.0F : 0.0F
 
246
 
 
247
      dst.z = (src0.z < src1.z) ? 1.0F : 0.0F
 
248
 
 
249
      dst.w = (src0.w < src1.w) ? 1.0F : 0.0F
232
250
 
233
251
 
234
252
.. opcode:: SGE - Set On Greater Equal Than
235
253
 
236
 
.. math::
237
 
 
238
 
  dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
239
 
 
240
 
  dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
241
 
 
242
 
  dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
243
 
 
244
 
  dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
 
254
   .. math::
 
255
 
 
256
      dst.x = (src0.x >= src1.x) ? 1.0F : 0.0F
 
257
 
 
258
      dst.y = (src0.y >= src1.y) ? 1.0F : 0.0F
 
259
 
 
260
      dst.z = (src0.z >= src1.z) ? 1.0F : 0.0F
 
261
 
 
262
      dst.w = (src0.w >= src1.w) ? 1.0F : 0.0F
245
263
 
246
264
 
247
265
.. opcode:: MAD - Multiply And Add
248
266
 
249
 
Perform a * b + c. The implementation is free to decide whether there is an
250
 
intermediate rounding step or not.
251
 
 
252
 
.. math::
253
 
 
254
 
  dst.x = src0.x \times src1.x + src2.x
255
 
 
256
 
  dst.y = src0.y \times src1.y + src2.y
257
 
 
258
 
  dst.z = src0.z \times src1.z + src2.z
259
 
 
260
 
  dst.w = src0.w \times src1.w + src2.w
 
267
   Perform a * b + c. The implementation is free to decide whether there is an
 
268
   intermediate rounding step or not.
 
269
 
 
270
   .. math::
 
271
 
 
272
      dst.x = src0.x \times src1.x + src2.x
 
273
 
 
274
      dst.y = src0.y \times src1.y + src2.y
 
275
 
 
276
      dst.z = src0.z \times src1.z + src2.z
 
277
 
 
278
      dst.w = src0.w \times src1.w + src2.w
261
279
 
262
280
 
263
281
.. opcode:: LRP - Linear Interpolate
264
282
 
265
 
.. math::
266
 
 
267
 
  dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
268
 
 
269
 
  dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
270
 
 
271
 
  dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
272
 
 
273
 
  dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
 
283
   .. math::
 
284
 
 
285
      dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
 
286
 
 
287
      dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
 
288
 
 
289
      dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
 
290
 
 
291
      dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
274
292
 
275
293
 
276
294
.. opcode:: FMA - Fused Multiply-Add
277
295
 
278
 
Perform a * b + c with no intermediate rounding step.
279
 
 
280
 
.. math::
281
 
 
282
 
  dst.x = src0.x \times src1.x + src2.x
283
 
 
284
 
  dst.y = src0.y \times src1.y + src2.y
285
 
 
286
 
  dst.z = src0.z \times src1.z + src2.z
287
 
 
288
 
  dst.w = src0.w \times src1.w + src2.w
 
296
   Perform a * b + c with no intermediate rounding step.
 
297
 
 
298
   .. math::
 
299
 
 
300
      dst.x = src0.x \times src1.x + src2.x
 
301
 
 
302
      dst.y = src0.y \times src1.y + src2.y
 
303
 
 
304
      dst.z = src0.z \times src1.z + src2.z
 
305
 
 
306
      dst.w = src0.w \times src1.w + src2.w
289
307
 
290
308
 
291
309
.. opcode:: FRC - Fraction
292
310
 
293
 
.. math::
294
 
 
295
 
  dst.x = src.x - \lfloor src.x\rfloor
296
 
 
297
 
  dst.y = src.y - \lfloor src.y\rfloor
298
 
 
299
 
  dst.z = src.z - \lfloor src.z\rfloor
300
 
 
301
 
  dst.w = src.w - \lfloor src.w\rfloor
 
311
   .. math::
 
312
 
 
313
      dst.x = src.x - \lfloor src.x\rfloor
 
314
 
 
315
      dst.y = src.y - \lfloor src.y\rfloor
 
316
 
 
317
      dst.z = src.z - \lfloor src.z\rfloor
 
318
 
 
319
      dst.w = src.w - \lfloor src.w\rfloor
302
320
 
303
321
 
304
322
.. opcode:: FLR - Floor
305
323
 
306
 
.. math::
307
 
 
308
 
  dst.x = \lfloor src.x\rfloor
309
 
 
310
 
  dst.y = \lfloor src.y\rfloor
311
 
 
312
 
  dst.z = \lfloor src.z\rfloor
313
 
 
314
 
  dst.w = \lfloor src.w\rfloor
 
324
   .. math::
 
325
 
 
326
      dst.x = \lfloor src.x\rfloor
 
327
 
 
328
      dst.y = \lfloor src.y\rfloor
 
329
 
 
330
      dst.z = \lfloor src.z\rfloor
 
331
 
 
332
      dst.w = \lfloor src.w\rfloor
315
333
 
316
334
 
317
335
.. opcode:: ROUND - Round
318
336
 
319
 
.. math::
320
 
 
321
 
  dst.x = round(src.x)
322
 
 
323
 
  dst.y = round(src.y)
324
 
 
325
 
  dst.z = round(src.z)
326
 
 
327
 
  dst.w = round(src.w)
 
337
   .. math::
 
338
 
 
339
      dst.x = round(src.x)
 
340
 
 
341
      dst.y = round(src.y)
 
342
 
 
343
      dst.z = round(src.z)
 
344
 
 
345
      dst.w = round(src.w)
328
346
 
329
347
 
330
348
.. opcode:: EX2 - Exponential Base 2
331
349
 
332
 
This instruction replicates its result.
333
 
 
334
 
.. math::
335
 
 
336
 
  dst = 2^{src.x}
 
350
   This instruction replicates its result.
 
351
 
 
352
   .. math::
 
353
 
 
354
      dst = 2^{src.x}
337
355
 
338
356
 
339
357
.. opcode:: LG2 - Logarithm Base 2
340
358
 
341
 
This instruction replicates its result.
342
 
 
343
 
.. math::
344
 
 
345
 
  dst = \log_2{src.x}
 
359
   This instruction replicates its result.
 
360
 
 
361
   .. math::
 
362
 
 
363
      dst = \log_2{src.x}
346
364
 
347
365
 
348
366
.. opcode:: POW - Power
349
367
 
350
 
This instruction replicates its result.
351
 
 
352
 
.. math::
353
 
 
354
 
  dst = src0.x^{src1.x}
 
368
   This instruction replicates its result.
 
369
 
 
370
   .. math::
 
371
 
 
372
      dst = src0.x^{src1.x}
355
373
 
356
374
 
357
375
.. opcode:: LDEXP - Multiply Number by Integral Power of 2
358
376
 
359
 
*src1* is an integer.
360
 
 
361
 
.. math::
362
 
 
363
 
  dst.x = src0.x * 2^{src1.x}
364
 
  dst.y = src0.y * 2^{src1.y}
365
 
  dst.z = src0.z * 2^{src1.z}
366
 
  dst.w = src0.w * 2^{src1.w}
 
377
   *src1* is an integer.
 
378
 
 
379
   .. math::
 
380
 
 
381
      dst.x = src0.x * 2^{src1.x}
 
382
 
 
383
      dst.y = src0.y * 2^{src1.y}
 
384
 
 
385
      dst.z = src0.z * 2^{src1.z}
 
386
 
 
387
      dst.w = src0.w * 2^{src1.w}
367
388
 
368
389
 
369
390
.. opcode:: COS - Cosine
370
391
 
371
 
This instruction replicates its result.
372
 
 
373
 
.. math::
374
 
 
375
 
  dst = \cos{src.x}
 
392
   This instruction replicates its result.
 
393
 
 
394
   .. math::
 
395
 
 
396
      dst = \cos{src.x}
376
397
 
377
398
 
378
399
.. opcode:: DDX, DDX_FINE - Derivative Relative To X
379
400
 
380
 
The fine variant is only used when ``PIPE_CAP_FS_FINE_DERIVATIVE`` is
381
 
advertised. When it is, the fine version guarantees one derivative per row
382
 
while DDX is allowed to be the same for the entire 2x2 quad.
383
 
 
384
 
.. math::
385
 
 
386
 
  dst.x = partialx(src.x)
387
 
 
388
 
  dst.y = partialx(src.y)
389
 
 
390
 
  dst.z = partialx(src.z)
391
 
 
392
 
  dst.w = partialx(src.w)
 
401
   The fine variant is only used when ``PIPE_CAP_FS_FINE_DERIVATIVE`` is
 
402
   advertised. When it is, the fine version guarantees one derivative per
 
403
   row while DDX is allowed to be the same for the entire 2x2 quad.
 
404
 
 
405
   .. math::
 
406
 
 
407
      dst.x = partialx(src.x)
 
408
 
 
409
      dst.y = partialx(src.y)
 
410
 
 
411
      dst.z = partialx(src.z)
 
412
 
 
413
      dst.w = partialx(src.w)
393
414
 
394
415
 
395
416
.. opcode:: DDY, DDY_FINE - Derivative Relative To Y
396
417
 
397
 
The fine variant is only used when ``PIPE_CAP_FS_FINE_DERIVATIVE`` is
398
 
advertised. When it is, the fine version guarantees one derivative per column
399
 
while DDY is allowed to be the same for the entire 2x2 quad.
400
 
 
401
 
.. math::
402
 
 
403
 
  dst.x = partialy(src.x)
404
 
 
405
 
  dst.y = partialy(src.y)
406
 
 
407
 
  dst.z = partialy(src.z)
408
 
 
409
 
  dst.w = partialy(src.w)
 
418
   The fine variant is only used when ``PIPE_CAP_FS_FINE_DERIVATIVE`` is
 
419
   advertised. When it is, the fine version guarantees one derivative per
 
420
   column while DDY is allowed to be the same for the entire 2x2 quad.
 
421
 
 
422
   .. math::
 
423
 
 
424
      dst.x = partialy(src.x)
 
425
 
 
426
      dst.y = partialy(src.y)
 
427
 
 
428
      dst.z = partialy(src.z)
 
429
 
 
430
      dst.w = partialy(src.w)
410
431
 
411
432
 
412
433
.. opcode:: PK2H - Pack Two 16-bit Floats
413
434
 
414
 
This instruction replicates its result.
415
 
 
416
 
.. math::
417
 
 
418
 
  dst = f32\_to\_f16(src.x) | f32\_to\_f16(src.y) << 16
419
 
 
 
435
   This instruction replicates its result.
 
436
 
 
437
   .. math::
 
438
 
 
439
      \begin{aligned}
 
440
      dst = & f32\_to\_f16(src.x) | \\
 
441
          ( & f32\_to\_f16(src.y) \ll 16)
 
442
      \end{aligned}
420
443
 
421
444
.. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars
422
445
 
423
 
This instruction replicates its result.
424
 
 
425
 
.. math::
426
 
 
427
 
  dst = f32\_to\_unorm16(src.x) | f32\_to\_unorm16(src.y) << 16
 
446
   This instruction replicates its result.
 
447
 
 
448
   .. math::
 
449
 
 
450
      \begin{aligned}
 
451
      dst = & f32\_to\_unorm16(src.x) | \\
 
452
          ( & f32\_to\_unorm16(src.y) \ll 16)
 
453
      \end{aligned}
428
454
 
429
455
 
430
456
.. opcode:: PK4B - Pack Four Signed 8-bit Scalars
431
457
 
432
 
This instruction replicates its result.
433
 
 
434
 
.. math::
435
 
 
436
 
  dst = f32\_to\_snorm8(src.x) |
437
 
        (f32\_to\_snorm8(src.y) << 8) |
438
 
        (f32\_to\_snorm8(src.z) << 16) |
439
 
        (f32\_to\_snorm8(src.w) << 24)
 
458
   This instruction replicates its result.
 
459
 
 
460
   .. math::
 
461
 
 
462
      \begin{aligned}
 
463
      dst = & f32\_to\_snorm8(src.x) | \\
 
464
          ( & f32\_to\_snorm8(src.y) \ll 8) | \\
 
465
          ( & f32\_to\_snorm8(src.z) \ll 16) | \\
 
466
          ( & f32\_to\_snorm8(src.w) \ll 24)
 
467
      \end{aligned}
440
468
 
441
469
 
442
470
.. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars
443
471
 
444
 
This instruction replicates its result.
445
 
 
446
 
.. math::
447
 
 
448
 
  dst = f32\_to\_unorm8(src.x) |
449
 
        (f32\_to\_unorm8(src.y) << 8) |
450
 
        (f32\_to\_unorm8(src.z) << 16) |
451
 
        (f32\_to\_unorm8(src.w) << 24)
 
472
   This instruction replicates its result.
 
473
 
 
474
   .. math::
 
475
 
 
476
      \begin{aligned}
 
477
      dst = & f32\_to\_unorm8(src.x) | \\
 
478
          ( & f32\_to\_unorm8(src.y) \ll 8) | \\
 
479
          ( & f32\_to\_unorm8(src.z) \ll 16) | \\
 
480
          ( & f32\_to\_unorm8(src.w) \ll 24)
 
481
      \end{aligned}
452
482
 
453
483
 
454
484
.. opcode:: SEQ - Set On Equal
455
485
 
456
 
.. math::
457
 
 
458
 
  dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
459
 
 
460
 
  dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
461
 
 
462
 
  dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
463
 
 
464
 
  dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
 
486
   .. math::
 
487
 
 
488
      dst.x = (src0.x == src1.x) ? 1.0F : 0.0F
 
489
 
 
490
      dst.y = (src0.y == src1.y) ? 1.0F : 0.0F
 
491
 
 
492
      dst.z = (src0.z == src1.z) ? 1.0F : 0.0F
 
493
 
 
494
      dst.w = (src0.w == src1.w) ? 1.0F : 0.0F
465
495
 
466
496
 
467
497
.. opcode:: SGT - Set On Greater Than
468
498
 
469
 
.. math::
470
 
 
471
 
  dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
472
 
 
473
 
  dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
474
 
 
475
 
  dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
476
 
 
477
 
  dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
 
499
   .. math::
 
500
 
 
501
      dst.x = (src0.x > src1.x) ? 1.0F : 0.0F
 
502
 
 
503
      dst.y = (src0.y > src1.y) ? 1.0F : 0.0F
 
504
 
 
505
      dst.z = (src0.z > src1.z) ? 1.0F : 0.0F
 
506
 
 
507
      dst.w = (src0.w > src1.w) ? 1.0F : 0.0F
478
508
 
479
509
 
480
510
.. opcode:: SIN - Sine
481
511
 
482
 
This instruction replicates its result.
483
 
 
484
 
.. math::
485
 
 
486
 
  dst = \sin{src.x}
 
512
   This instruction replicates its result.
 
513
 
 
514
   .. math::
 
515
 
 
516
      dst = \sin{src.x}
487
517
 
488
518
 
489
519
.. opcode:: SLE - Set On Less Equal Than
490
520
 
491
 
.. math::
492
 
 
493
 
  dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
494
 
 
495
 
  dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
496
 
 
497
 
  dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
498
 
 
499
 
  dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
 
521
   .. math::
 
522
 
 
523
      dst.x = (src0.x <= src1.x) ? 1.0F : 0.0F
 
524
 
 
525
      dst.y = (src0.y <= src1.y) ? 1.0F : 0.0F
 
526
 
 
527
      dst.z = (src0.z <= src1.z) ? 1.0F : 0.0F
 
528
 
 
529
      dst.w = (src0.w <= src1.w) ? 1.0F : 0.0F
500
530
 
501
531
 
502
532
.. opcode:: SNE - Set On Not Equal
503
533
 
504
 
.. math::
505
 
 
506
 
  dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
507
 
 
508
 
  dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
509
 
 
510
 
  dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
511
 
 
512
 
  dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
 
534
   .. math::
 
535
 
 
536
      dst.x = (src0.x != src1.x) ? 1.0F : 0.0F
 
537
 
 
538
      dst.y = (src0.y != src1.y) ? 1.0F : 0.0F
 
539
 
 
540
      dst.z = (src0.z != src1.z) ? 1.0F : 0.0F
 
541
 
 
542
      dst.w = (src0.w != src1.w) ? 1.0F : 0.0F
513
543
 
514
544
 
515
545
.. opcode:: TEX - Texture Lookup
516
546
 
517
 
  for array textures *src0.y* contains the slice for 1D,
518
 
  and *src0.z* contain the slice for 2D.
519
 
 
520
 
  for shadow textures with no arrays (and not cube map),
521
 
  *src0.z* contains the reference value.
522
 
 
523
 
  for shadow textures with arrays, *src0.z* contains
524
 
  the reference value for 1D arrays, and *src0.w* contains
525
 
  the reference value for 2D arrays and cube maps.
526
 
 
527
 
  for cube map array shadow textures, the reference value
528
 
  cannot be passed in *src0.w*, and TEX2 must be used instead.
529
 
 
530
 
.. math::
531
 
 
532
 
  coord = src0
533
 
 
534
 
  shadow_ref = src0.z or src0.w (optional)
535
 
 
536
 
  unit = src1
537
 
 
538
 
  dst = texture\_sample(unit, coord, shadow_ref)
 
547
   for array textures *src0.y* contains the slice for 1D,
 
548
   and *src0.z* contain the slice for 2D.
 
549
 
 
550
   for shadow textures with no arrays (and not cube map),
 
551
   *src0.z* contains the reference value.
 
552
 
 
553
   for shadow textures with arrays, *src0.z* contains
 
554
   the reference value for 1D arrays, and *src0.w* contains
 
555
   the reference value for 2D arrays and cube maps.
 
556
 
 
557
   for cube map array shadow textures, the reference value
 
558
   cannot be passed in *src0.w*, and TEX2 must be used instead.
 
559
 
 
560
   .. math::
 
561
 
 
562
      coord = src0
 
563
 
 
564
      shadow\_ref = src0.z \textrm{ or } src0.w \textrm{ (optional)}
 
565
 
 
566
      unit = src1
 
567
 
 
568
      dst = texture\_sample(unit, coord, shadow\_ref)
539
569
 
540
570
 
541
571
.. opcode:: TEX2 - Texture Lookup (for shadow cube map arrays only)
542
572
 
543
 
  this is the same as TEX, but uses another reg to encode the
544
 
  reference value.
545
 
 
546
 
.. math::
547
 
 
548
 
  coord = src0
549
 
 
550
 
  shadow_ref = src1.x
551
 
 
552
 
  unit = src2
553
 
 
554
 
  dst = texture\_sample(unit, coord, shadow_ref)
555
 
 
556
 
 
 
573
   this is the same as TEX, but uses another reg to encode the
 
574
   reference value.
 
575
 
 
576
   .. math::
 
577
 
 
578
      coord = src0
 
579
 
 
580
      shadow\_ref = src1.x
 
581
 
 
582
      unit = src2
 
583
 
 
584
      dst = texture\_sample(unit, coord, shadow\_ref)
557
585
 
558
586
 
559
587
.. opcode:: TXD - Texture Lookup with Derivatives
560
588
 
561
 
.. math::
562
 
 
563
 
  coord = src0
564
 
 
565
 
  ddx = src1
566
 
 
567
 
  ddy = src2
568
 
 
569
 
  unit = src3
570
 
 
571
 
  dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
 
589
   .. math::
 
590
 
 
591
      coord = src0
 
592
 
 
593
      ddx = src1
 
594
 
 
595
      ddy = src2
 
596
 
 
597
      unit = src3
 
598
 
 
599
      dst = texture\_sample\_deriv(unit, coord, ddx, ddy)
572
600
 
573
601
 
574
602
.. opcode:: TXP - Projective Texture Lookup
575
603
 
576
 
.. math::
577
 
 
578
 
  coord.x = src0.x / src0.w
579
 
 
580
 
  coord.y = src0.y / src0.w
581
 
 
582
 
  coord.z = src0.z / src0.w
583
 
 
584
 
  coord.w = src0.w
585
 
 
586
 
  unit = src1
587
 
 
588
 
  dst = texture\_sample(unit, coord)
 
604
   .. math::
 
605
 
 
606
      coord.x = src0.x / src0.w
 
607
 
 
608
      coord.y = src0.y / src0.w
 
609
 
 
610
      coord.z = src0.z / src0.w
 
611
 
 
612
      coord.w = src0.w
 
613
 
 
614
      unit = src1
 
615
 
 
616
      dst = texture\_sample(unit, coord)
589
617
 
590
618
 
591
619
.. opcode:: UP2H - Unpack Two 16-Bit Floats
592
620
 
593
 
.. math::
594
 
 
595
 
  dst.x = f16\_to\_f32(src0.x \& 0xffff)
596
 
 
597
 
  dst.y = f16\_to\_f32(src0.x >> 16)
598
 
 
599
 
  dst.z = f16\_to\_f32(src0.x \& 0xffff)
600
 
 
601
 
  dst.w = f16\_to\_f32(src0.x >> 16)
602
 
 
603
 
.. note::
604
 
 
605
 
   Considered for removal.
 
621
   .. math::
 
622
 
 
623
      dst.x = f16\_to\_f32(src0.x \& 0xffff)
 
624
 
 
625
      dst.y = f16\_to\_f32(src0.x \gg 16)
 
626
 
 
627
      dst.z = f16\_to\_f32(src0.x \& 0xffff)
 
628
 
 
629
      dst.w = f16\_to\_f32(src0.x \gg 16)
 
630
 
 
631
   .. note::
 
632
 
 
633
      Considered for removal.
606
634
 
607
635
.. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars
608
636
 
609
 
  TBD
610
 
 
611
 
.. note::
612
 
 
613
 
   Considered for removal.
 
637
   TBD
 
638
 
 
639
   .. note::
 
640
 
 
641
      Considered for removal.
614
642
 
615
643
.. opcode:: UP4B - Unpack Four Signed 8-Bit Values
616
644
 
617
 
  TBD
618
 
 
619
 
.. note::
620
 
 
621
 
   Considered for removal.
 
645
   TBD
 
646
 
 
647
   .. note::
 
648
 
 
649
      Considered for removal.
622
650
 
623
651
.. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars
624
652
 
625
 
  TBD
626
 
 
627
 
.. note::
628
 
 
629
 
   Considered for removal.
 
653
   TBD
 
654
 
 
655
   .. note::
 
656
 
 
657
      Considered for removal.
630
658
 
631
659
 
632
660
.. opcode:: ARR - Address Register Load With Round
633
661
 
634
 
.. math::
635
 
 
636
 
  dst.x = (int) round(src.x)
637
 
 
638
 
  dst.y = (int) round(src.y)
639
 
 
640
 
  dst.z = (int) round(src.z)
641
 
 
642
 
  dst.w = (int) round(src.w)
 
662
   .. math::
 
663
 
 
664
      dst.x = (int) round(src.x)
 
665
 
 
666
      dst.y = (int) round(src.y)
 
667
 
 
668
      dst.z = (int) round(src.z)
 
669
 
 
670
      dst.w = (int) round(src.w)
643
671
 
644
672
 
645
673
.. opcode:: SSG - Set Sign
646
674
 
647
 
.. math::
648
 
 
649
 
  dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
650
 
 
651
 
  dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
652
 
 
653
 
  dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
654
 
 
655
 
  dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
 
675
   .. math::
 
676
 
 
677
      dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
 
678
 
 
679
      dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
 
680
 
 
681
      dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
 
682
 
 
683
      dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
656
684
 
657
685
 
658
686
.. opcode:: CMP - Compare
659
687
 
660
 
.. math::
661
 
 
662
 
  dst.x = (src0.x < 0) ? src1.x : src2.x
663
 
 
664
 
  dst.y = (src0.y < 0) ? src1.y : src2.y
665
 
 
666
 
  dst.z = (src0.z < 0) ? src1.z : src2.z
667
 
 
668
 
  dst.w = (src0.w < 0) ? src1.w : src2.w
 
688
   .. math::
 
689
 
 
690
      dst.x = (src0.x < 0) ? src1.x : src2.x
 
691
 
 
692
      dst.y = (src0.y < 0) ? src1.y : src2.y
 
693
 
 
694
      dst.z = (src0.z < 0) ? src1.z : src2.z
 
695
 
 
696
      dst.w = (src0.w < 0) ? src1.w : src2.w
669
697
 
670
698
 
671
699
.. opcode:: KILL_IF - Conditional Discard
672
700
 
673
 
  Conditional discard.  Allowed in fragment shaders only.
674
 
 
675
 
.. math::
676
 
 
677
 
  if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
678
 
    discard
679
 
  endif
 
701
   Conditional discard.  Allowed in fragment shaders only.
 
702
 
 
703
   Pseudocode::
 
704
 
 
705
      if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
 
706
         discard
 
707
      endif
680
708
 
681
709
 
682
710
.. opcode:: KILL - Discard
683
711
 
684
 
  Unconditional discard.  Allowed in fragment shaders only.
 
712
   Unconditional discard.  Allowed in fragment shaders only.
685
713
 
686
714
 
687
715
.. opcode:: DEMOTE - Demote Invocation to a Helper
688
716
 
689
 
  This demotes the current invocation to a helper, but continues
690
 
  execution (while KILL may or may not terminate the
691
 
  invocation). After this runs, all the usual helper invocation rules
692
 
  apply about discarding buffer and render target writes. This is
693
 
  useful for having accurate derivatives in the other invocations
694
 
  which have not been demoted.
 
717
   This demotes the current invocation to a helper, but continues
 
718
   execution (while KILL may or may not terminate the
 
719
   invocation). After this runs, all the usual helper invocation rules
 
720
   apply about discarding buffer and render target writes. This is
 
721
   useful for having accurate derivatives in the other invocations
 
722
   which have not been demoted.
695
723
 
696
 
  Allowed in fragment shaders only.
 
724
   Allowed in fragment shaders only.
697
725
 
698
726
 
699
727
.. opcode:: READ_HELPER - Reads Invocation Helper Status
700
728
 
701
 
  This is identical to ``TGSI_SEMANTIC_HELPER_INVOCATION``, except
702
 
  this will read the current value, which might change as a result of
703
 
  a ``DEMOTE`` instruction.
 
729
   This is identical to ``TGSI_SEMANTIC_HELPER_INVOCATION``, except
 
730
   this will read the current value, which might change as a result of
 
731
   a ``DEMOTE`` instruction.
704
732
 
705
 
  Allowed in fragment shaders only.
 
733
   Allowed in fragment shaders only.
706
734
 
707
735
 
708
736
.. opcode:: TXB - Texture Lookup With Bias
709
737
 
710
 
  for cube map array textures and shadow cube maps, the bias value
711
 
  cannot be passed in *src0.w*, and TXB2 must be used instead.
712
 
 
713
 
  if the target is a shadow texture, the reference value is always
714
 
  in *src.z* (this prevents shadow 3d and shadow 2d arrays from
715
 
  using this instruction, but this is not needed).
716
 
 
717
 
.. math::
718
 
 
719
 
  coord.x = src0.x
720
 
 
721
 
  coord.y = src0.y
722
 
 
723
 
  coord.z = src0.z
724
 
 
725
 
  coord.w = none
726
 
 
727
 
  bias = src0.w
728
 
 
729
 
  unit = src1
730
 
 
731
 
  dst = texture\_sample(unit, coord, bias)
 
738
   for cube map array textures and shadow cube maps, the bias value
 
739
   cannot be passed in *src0.w*, and TXB2 must be used instead.
 
740
 
 
741
   if the target is a shadow texture, the reference value is always
 
742
   in *src.z* (this prevents shadow 3d and shadow 2d arrays from
 
743
   using this instruction, but this is not needed).
 
744
 
 
745
   .. math::
 
746
 
 
747
      coord.x = src0.x
 
748
 
 
749
      coord.y = src0.y
 
750
 
 
751
      coord.z = src0.z
 
752
 
 
753
      coord.w = none
 
754
 
 
755
      bias = src0.w
 
756
 
 
757
      unit = src1
 
758
 
 
759
      dst = texture\_sample(unit, coord, bias)
732
760
 
733
761
 
734
762
.. opcode:: TXB2 - Texture Lookup With Bias (some cube maps only)
735
763
 
736
 
  this is the same as TXB, but uses another reg to encode the
737
 
  LOD bias value for cube map arrays and shadow cube maps.
738
 
  Presumably shadow 2d arrays and shadow 3d targets could use
739
 
  this encoding too, but this is not legal.
740
 
 
741
 
  if the target is a shadow cube map array, the reference value is in
742
 
  *src1.y*.
743
 
 
744
 
.. math::
745
 
 
746
 
  coord = src0
747
 
 
748
 
  bias = src1.x
749
 
 
750
 
  unit = src2
751
 
 
752
 
  dst = texture\_sample(unit, coord, bias)
 
764
   this is the same as TXB, but uses another reg to encode the
 
765
   LOD bias value for cube map arrays and shadow cube maps.
 
766
   Presumably shadow 2d arrays and shadow 3d targets could use
 
767
   this encoding too, but this is not legal.
 
768
 
 
769
   if the target is a shadow cube map array, the reference value is in
 
770
   *src1.y*.
 
771
 
 
772
   .. math::
 
773
 
 
774
      coord = src0
 
775
 
 
776
      bias = src1.x
 
777
 
 
778
      unit = src2
 
779
 
 
780
      dst = texture\_sample(unit, coord, bias)
753
781
 
754
782
 
755
783
.. opcode:: DIV - Divide
756
784
 
757
 
.. math::
758
 
 
759
 
  dst.x = \frac{src0.x}{src1.x}
760
 
 
761
 
  dst.y = \frac{src0.y}{src1.y}
762
 
 
763
 
  dst.z = \frac{src0.z}{src1.z}
764
 
 
765
 
  dst.w = \frac{src0.w}{src1.w}
 
785
   .. math::
 
786
 
 
787
      dst.x = \frac{src0.x}{src1.x}
 
788
 
 
789
      dst.y = \frac{src0.y}{src1.y}
 
790
 
 
791
      dst.z = \frac{src0.z}{src1.z}
 
792
 
 
793
      dst.w = \frac{src0.w}{src1.w}
766
794
 
767
795
 
768
796
.. opcode:: DP2 - 2-component Dot Product
769
797
 
770
 
This instruction replicates its result.
771
 
 
772
 
.. math::
773
 
 
774
 
  dst = src0.x \times src1.x + src0.y \times src1.y
775
 
 
 
798
   This instruction replicates its result.
 
799
 
 
800
   .. math::
 
801
 
 
802
      \begin{aligned}
 
803
      dst = & src0.x \times src1.x + \\
 
804
            & src0.y \times src1.y
 
805
      \end{aligned}
776
806
 
777
807
.. opcode:: TEX_LZ - Texture Lookup With LOD = 0
778
808
 
779
 
  This is the same as TXL with LOD = 0. Like every texture opcode, it obeys
780
 
  pipe_sampler_view::u.tex.first_level and pipe_sampler_state::min_lod.
781
 
  There is no way to override those two in shaders.
782
 
 
783
 
.. math::
784
 
 
785
 
  coord.x = src0.x
786
 
 
787
 
  coord.y = src0.y
788
 
 
789
 
  coord.z = src0.z
790
 
 
791
 
  coord.w = none
792
 
 
793
 
  lod = 0
794
 
 
795
 
  unit = src1
796
 
 
797
 
  dst = texture\_sample(unit, coord, lod)
 
809
   This is the same as TXL with LOD = 0. Like every texture opcode, it obeys
 
810
   pipe_sampler_view::u.tex.first_level and pipe_sampler_state::min_lod.
 
811
   There is no way to override those two in shaders.
 
812
 
 
813
   .. math::
 
814
 
 
815
      coord.x = src0.x
 
816
 
 
817
      coord.y = src0.y
 
818
 
 
819
      coord.z = src0.z
 
820
 
 
821
      coord.w = none
 
822
 
 
823
      lod = 0
 
824
 
 
825
      unit = src1
 
826
 
 
827
      dst = texture\_sample(unit, coord, lod)
798
828
 
799
829
 
800
830
.. opcode:: TXL - Texture Lookup With explicit LOD
801
831
 
802
 
  for cube map array textures, the explicit LOD value
803
 
  cannot be passed in *src0.w*, and TXL2 must be used instead.
804
 
 
805
 
  if the target is a shadow texture, the reference value is always
806
 
  in *src.z* (this prevents shadow 3d / 2d array / cube targets from
807
 
  using this instruction, but this is not needed).
808
 
 
809
 
.. math::
810
 
 
811
 
  coord.x = src0.x
812
 
 
813
 
  coord.y = src0.y
814
 
 
815
 
  coord.z = src0.z
816
 
 
817
 
  coord.w = none
818
 
 
819
 
  lod = src0.w
820
 
 
821
 
  unit = src1
822
 
 
823
 
  dst = texture\_sample(unit, coord, lod)
 
832
   for cube map array textures, the explicit LOD value
 
833
   cannot be passed in *src0.w*, and TXL2 must be used instead.
 
834
 
 
835
   if the target is a shadow texture, the reference value is always
 
836
   in *src.z* (this prevents shadow 3d / 2d array / cube targets from
 
837
   using this instruction, but this is not needed).
 
838
 
 
839
   .. math::
 
840
 
 
841
      coord.x = src0.x
 
842
 
 
843
      coord.y = src0.y
 
844
 
 
845
      coord.z = src0.z
 
846
 
 
847
      coord.w = none
 
848
 
 
849
      lod = src0.w
 
850
 
 
851
      unit = src1
 
852
 
 
853
      dst = texture\_sample(unit, coord, lod)
824
854
 
825
855
 
826
856
.. opcode:: TXL2 - Texture Lookup With explicit LOD (for cube map arrays only)
827
857
 
828
 
  this is the same as TXL, but uses another reg to encode the
829
 
  explicit LOD value.
830
 
  Presumably shadow 3d / 2d array / cube targets could use
831
 
  this encoding too, but this is not legal.
832
 
 
833
 
  if the target is a shadow cube map array, the reference value is in
834
 
  *src1.y*.
835
 
 
836
 
.. math::
837
 
 
838
 
  coord = src0
839
 
 
840
 
  lod = src1.x
841
 
 
842
 
  unit = src2
843
 
 
844
 
  dst = texture\_sample(unit, coord, lod)
 
858
   this is the same as TXL, but uses another reg to encode the
 
859
   explicit LOD value.
 
860
   Presumably shadow 3d / 2d array / cube targets could use
 
861
   this encoding too, but this is not legal.
 
862
 
 
863
   if the target is a shadow cube map array, the reference value is in
 
864
   *src1.y*.
 
865
 
 
866
   .. math::
 
867
 
 
868
      coord = src0
 
869
 
 
870
      lod = src1.x
 
871
 
 
872
      unit = src2
 
873
 
 
874
      dst = texture\_sample(unit, coord, lod)
845
875
 
846
876
 
847
877
Compute ISA
854
884
 
855
885
.. opcode:: CEIL - Ceiling
856
886
 
857
 
.. math::
858
 
 
859
 
  dst.x = \lceil src.x\rceil
860
 
 
861
 
  dst.y = \lceil src.y\rceil
862
 
 
863
 
  dst.z = \lceil src.z\rceil
864
 
 
865
 
  dst.w = \lceil src.w\rceil
 
887
   .. math::
 
888
 
 
889
      dst.x = \lceil src.x\rceil
 
890
 
 
891
      dst.y = \lceil src.y\rceil
 
892
 
 
893
      dst.z = \lceil src.z\rceil
 
894
 
 
895
      dst.w = \lceil src.w\rceil
866
896
 
867
897
 
868
898
.. opcode:: TRUNC - Truncate
869
899
 
870
 
.. math::
871
 
 
872
 
  dst.x = trunc(src.x)
873
 
 
874
 
  dst.y = trunc(src.y)
875
 
 
876
 
  dst.z = trunc(src.z)
877
 
 
878
 
  dst.w = trunc(src.w)
 
900
   .. math::
 
901
 
 
902
      dst.x = trunc(src.x)
 
903
 
 
904
      dst.y = trunc(src.y)
 
905
 
 
906
      dst.z = trunc(src.z)
 
907
 
 
908
      dst.w = trunc(src.w)
879
909
 
880
910
 
881
911
.. opcode:: MOD - Modulus
882
912
 
883
 
.. math::
884
 
 
885
 
  dst.x = src0.x \bmod src1.x
886
 
 
887
 
  dst.y = src0.y \bmod src1.y
888
 
 
889
 
  dst.z = src0.z \bmod src1.z
890
 
 
891
 
  dst.w = src0.w \bmod src1.w
 
913
   .. math::
 
914
 
 
915
      dst.x = src0.x \bmod src1.x
 
916
 
 
917
      dst.y = src0.y \bmod src1.y
 
918
 
 
919
      dst.z = src0.z \bmod src1.z
 
920
 
 
921
      dst.w = src0.w \bmod src1.w
892
922
 
893
923
 
894
924
.. opcode:: UARL - Integer Address Register Load
895
925
 
896
 
  Moves the contents of the source register, assumed to be an integer, into the
897
 
  destination register, which is assumed to be an address (ADDR) register.
 
926
   Moves the contents of the source register, assumed to be an integer, into the
 
927
   destination register, which is assumed to be an address (ADDR) register.
898
928
 
899
929
 
900
930
.. opcode:: TXF - Texel Fetch
901
931
 
902
 
  As per :ext:`GL_NV_gpu_program4`, extract a single texel from a specified
903
 
  texture image or PIPE_BUFFER resource. The source sampler may not be a
904
 
  CUBE or SHADOW.  *src0* is a
905
 
  four-component signed integer vector used to identify the single texel
906
 
  accessed. 3 components + level.  If the texture is multisampled, then
907
 
  the fourth component indicates the sample, not the mipmap level.
908
 
  Just like texture instructions, an optional
909
 
  offset vector is provided, which is subject to various driver restrictions
910
 
  (regarding range, source of offsets). This instruction ignores the sampler
911
 
  state.
 
932
   As per :ext:`GL_NV_gpu_program4`, extract a single texel from a specified
 
933
   texture image or PIPE_BUFFER resource. The source sampler may not be a
 
934
   CUBE or SHADOW.  *src0* is a
 
935
   four-component signed integer vector used to identify the single texel
 
936
   accessed. 3 components + level.  If the texture is multisampled, then
 
937
   the fourth component indicates the sample, not the mipmap level.
 
938
   Just like texture instructions, an optional
 
939
   offset vector is provided, which is subject to various driver restrictions
 
940
   (regarding range, source of offsets). This instruction ignores the sampler
 
941
   state.
912
942
 
913
 
  TXF(uint_vec coord, int_vec offset).
 
943
   TXF(uint_vec coord, int_vec offset).
914
944
 
915
945
 
916
946
.. opcode:: TXQ - Texture Size Query
917
947
 
918
 
  As per :ext:`GL_NV_gpu_program4`, retrieve the dimensions of the texture
919
 
  depending on   the target. For 1D (width), 2D/RECT/CUBE (width, height),
920
 
  3D (width, height, depth), 1D array (width, layers), 2D array (width,
921
 
  height, layers).  Also return the number of accessible levels
922
 
  (last_level - first_level + 1) in W.
923
 
 
924
 
  For components which don't return a resource dimension, their value
925
 
  is undefined.
926
 
 
927
 
.. math::
928
 
 
929
 
  lod = src0.x
930
 
 
931
 
  dst.x = texture\_width(unit, lod)
932
 
 
933
 
  dst.y = texture\_height(unit, lod)
934
 
 
935
 
  dst.z = texture\_depth(unit, lod)
936
 
 
937
 
  dst.w = texture\_levels(unit)
 
948
   As per :ext:`GL_NV_gpu_program4`, retrieve the dimensions of the texture
 
949
   depending on   the target. For 1D (width), 2D/RECT/CUBE (width, height),
 
950
   3D (width, height, depth), 1D array (width, layers), 2D array (width,
 
951
   height, layers).  Also return the number of accessible levels
 
952
   (last_level - first_level + 1) in W.
 
953
 
 
954
   For components which don't return a resource dimension, their value
 
955
   is undefined.
 
956
 
 
957
   .. math::
 
958
 
 
959
      lod = src0.x
 
960
 
 
961
      dst.x = texture\_width(unit, lod)
 
962
 
 
963
      dst.y = texture\_height(unit, lod)
 
964
 
 
965
      dst.z = texture\_depth(unit, lod)
 
966
 
 
967
      dst.w = texture\_levels(unit)
938
968
 
939
969
 
940
970
.. opcode:: TXQS - Texture Samples Query
941
971
 
942
 
  This retrieves the number of samples in the texture, and stores it
943
 
  into the x component as an unsigned integer. The other components are
944
 
  undefined.  If the texture is not multisampled, this function returns
945
 
  (1, undef, undef, undef).
946
 
 
947
 
.. math::
948
 
 
949
 
  dst.x = texture\_samples(unit)
 
972
   This retrieves the number of samples in the texture, and stores it
 
973
   into the x component as an unsigned integer. The other components are
 
974
   undefined.  If the texture is not multisampled, this function returns
 
975
   (1, undef, undef, undef).
 
976
 
 
977
   .. math::
 
978
 
 
979
      dst.x = texture\_samples(unit)
950
980
 
951
981
 
952
982
.. opcode:: TG4 - Texture Gather
953
983
 
954
 
  As per :ext:`GL_ARB_texture_gather`, gathers the four texels to be used in a
955
 
  bi-linear   filtering operation and packs them into a single register.
956
 
  Only works with 2D, 2D array, cubemaps, and cubemaps arrays.  For 2D
957
 
  textures, only the addressing modes of the sampler and the top level of any
958
 
  mip pyramid are used. Set W to zero.  It behaves like the TEX instruction,
959
 
  but a filtered sample is not generated. The four samples that contribute to
960
 
  filtering are placed into XYZW in clockwise order, starting with the (u,v)
961
 
  texture coordinate delta at the following locations (-, +), (+, +), (+, -),
962
 
  (-, -), where the magnitude of the deltas are half a texel.
963
 
 
964
 
  PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
965
 
  depth compares, single component selection, and a non-constant offset. It
966
 
  doesn't allow support for the GL independent offset to get i0,j0. This would
967
 
  require another CAP is HW can do it natively. For now we lower that before
968
 
  TGSI.
969
 
 
970
 
  PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE changes the encoding so that component
971
 
  is stored in the sampler source swizzle x.
972
 
 
973
 
.. math::
974
 
 
975
 
   coord = src0
 
984
   As per :ext:`GL_ARB_texture_gather`, gathers the four texels to be used in a
 
985
   bi-linear   filtering operation and packs them into a single register.
 
986
   Only works with 2D, 2D array, cubemaps, and cubemaps arrays.  For 2D
 
987
   textures, only the addressing modes of the sampler and the top level of any
 
988
   mip pyramid are used. Set W to zero.  It behaves like the TEX instruction,
 
989
   but a filtered sample is not generated. The four samples that contribute to
 
990
   filtering are placed into XYZW in clockwise order, starting with the (u,v)
 
991
   texture coordinate delta at the following locations (-, +), (+, +), (+, -),
 
992
   (-, -), where the magnitude of the deltas are half a texel.
 
993
 
 
994
   PIPE_CAP_TEXTURE_SM5 enhances this instruction to support shadow per-sample
 
995
   depth compares, single component selection, and a non-constant offset. It
 
996
   doesn't allow support for the GL independent offset to get i0,j0. This would
 
997
   require another CAP is HW can do it natively. For now we lower that before
 
998
   TGSI.
 
999
 
 
1000
   PIPE_CAP_TGSI_TG4_COMPONENT_IN_SWIZZLE changes the encoding so that component
 
1001
   is stored in the sampler source swizzle x.
976
1002
 
977
1003
   (without TGSI_TG4_COMPONENT_IN_SWIZZLE)
978
 
   component = src1
979
 
 
980
 
   dst = texture\_gather4 (unit, coord, component)
 
1004
 
 
1005
   .. math::
 
1006
 
 
1007
      coord = src0
 
1008
 
 
1009
      component = src1
 
1010
 
 
1011
      dst = texture\_gather4 (unit, coord, component)
981
1012
 
982
1013
   (with TGSI_TG4_COMPONENT_IN_SWIZZLE)
983
 
   dst = texture\_gather4 (unit, coord)
984
 
   component is encoded in sampler swizzle.
985
 
 
986
 
(with SM5 - cube array shadow)
987
 
 
988
 
.. math::
989
 
 
990
 
   coord = src0
991
 
 
992
 
   compare = src1
993
 
 
994
 
   dst = texture\_gather (uint, coord, compare)
 
1014
 
 
1015
   .. math::
 
1016
 
 
1017
      coord = src0
 
1018
 
 
1019
      dst = texture\_gather4 (unit, coord)
 
1020
 
 
1021
      \text{component is encoded in sampler swizzle.}
 
1022
 
 
1023
   (with SM5 - cube array shadow)
 
1024
 
 
1025
   .. math::
 
1026
 
 
1027
      coord = src0
 
1028
 
 
1029
      compare = src1
 
1030
 
 
1031
      dst = texture\_gather (uint, coord, compare)
995
1032
 
996
1033
.. opcode:: LODQ - level of detail query
997
1034
 
1000
1037
   component contains the LOD that will be accessed, based on min/max LODs
1001
1038
   and mipmap filters.
1002
1039
 
1003
 
.. math::
1004
 
 
1005
 
   coord = src0
1006
 
 
1007
 
   dst.xy = lodq(uint, coord);
 
1040
   .. math::
 
1041
 
 
1042
      coord = src0
 
1043
 
 
1044
      dst.xy = lodq(uint, coord);
1008
1045
 
1009
1046
.. opcode:: CLOCK - retrieve the current shader time
1010
1047
 
1015
1052
   should be shifted up so that the most significant bit of the time
1016
1053
   is the most significant bit of the 64-bit value.
1017
1054
 
1018
 
.. math::
 
1055
   .. math::
1019
1056
 
1020
 
   dst.xy = clock()
 
1057
      dst.xy = clock()
1021
1058
 
1022
1059
 
1023
1060
Integer ISA
1030
1067
 
1031
1068
   Rounding is unspecified (round to nearest even suggested).
1032
1069
 
1033
 
.. math::
1034
 
 
1035
 
  dst.x = (float) src.x
1036
 
 
1037
 
  dst.y = (float) src.y
1038
 
 
1039
 
  dst.z = (float) src.z
1040
 
 
1041
 
  dst.w = (float) src.w
 
1070
   .. math::
 
1071
 
 
1072
      dst.x = (float) src.x
 
1073
 
 
1074
      dst.y = (float) src.y
 
1075
 
 
1076
      dst.z = (float) src.z
 
1077
 
 
1078
      dst.w = (float) src.w
1042
1079
 
1043
1080
 
1044
1081
.. opcode:: U2F - Unsigned Integer To Float
1045
1082
 
1046
1083
   Rounding is unspecified (round to nearest even suggested).
1047
1084
 
1048
 
.. math::
1049
 
 
1050
 
  dst.x = (float) src.x
1051
 
 
1052
 
  dst.y = (float) src.y
1053
 
 
1054
 
  dst.z = (float) src.z
1055
 
 
1056
 
  dst.w = (float) src.w
 
1085
   .. math::
 
1086
 
 
1087
      dst.x = (float) src.x
 
1088
 
 
1089
      dst.y = (float) src.y
 
1090
 
 
1091
      dst.z = (float) src.z
 
1092
 
 
1093
      dst.w = (float) src.w
1057
1094
 
1058
1095
 
1059
1096
.. opcode:: F2I - Float to Signed Integer
1061
1098
   Rounding is towards zero (truncate).
1062
1099
   Values outside signed range (including NaNs) produce undefined results.
1063
1100
 
1064
 
.. math::
1065
 
 
1066
 
  dst.x = (int) src.x
1067
 
 
1068
 
  dst.y = (int) src.y
1069
 
 
1070
 
  dst.z = (int) src.z
1071
 
 
1072
 
  dst.w = (int) src.w
 
1101
   .. math::
 
1102
 
 
1103
      dst.x = (int) src.x
 
1104
 
 
1105
      dst.y = (int) src.y
 
1106
 
 
1107
      dst.z = (int) src.z
 
1108
 
 
1109
      dst.w = (int) src.w
1073
1110
 
1074
1111
 
1075
1112
.. opcode:: F2U - Float to Unsigned Integer
1077
1114
   Rounding is towards zero (truncate).
1078
1115
   Values outside unsigned range (including NaNs) produce undefined results.
1079
1116
 
1080
 
.. math::
1081
 
 
1082
 
  dst.x = (unsigned) src.x
1083
 
 
1084
 
  dst.y = (unsigned) src.y
1085
 
 
1086
 
  dst.z = (unsigned) src.z
1087
 
 
1088
 
  dst.w = (unsigned) src.w
 
1117
   .. math::
 
1118
 
 
1119
      dst.x = (unsigned) src.x
 
1120
 
 
1121
      dst.y = (unsigned) src.y
 
1122
 
 
1123
      dst.z = (unsigned) src.z
 
1124
 
 
1125
      dst.w = (unsigned) src.w
1089
1126
 
1090
1127
 
1091
1128
.. opcode:: UADD - Integer Add
1093
1130
   This instruction works the same for signed and unsigned integers.
1094
1131
   The low 32bit of the result is returned.
1095
1132
 
1096
 
.. math::
1097
 
 
1098
 
  dst.x = src0.x + src1.x
1099
 
 
1100
 
  dst.y = src0.y + src1.y
1101
 
 
1102
 
  dst.z = src0.z + src1.z
1103
 
 
1104
 
  dst.w = src0.w + src1.w
 
1133
   .. math::
 
1134
 
 
1135
      dst.x = src0.x + src1.x
 
1136
 
 
1137
      dst.y = src0.y + src1.y
 
1138
 
 
1139
      dst.z = src0.z + src1.z
 
1140
 
 
1141
      dst.w = src0.w + src1.w
1105
1142
 
1106
1143
 
1107
1144
.. opcode:: UMAD - Integer Multiply And Add
1109
1146
   This instruction works the same for signed and unsigned integers.
1110
1147
   The multiplication returns the low 32bit (as does the result itself).
1111
1148
 
1112
 
.. math::
1113
 
 
1114
 
  dst.x = src0.x \times src1.x + src2.x
1115
 
 
1116
 
  dst.y = src0.y \times src1.y + src2.y
1117
 
 
1118
 
  dst.z = src0.z \times src1.z + src2.z
1119
 
 
1120
 
  dst.w = src0.w \times src1.w + src2.w
 
1149
   .. math::
 
1150
 
 
1151
      dst.x = src0.x \times src1.x + src2.x
 
1152
 
 
1153
      dst.y = src0.y \times src1.y + src2.y
 
1154
 
 
1155
      dst.z = src0.z \times src1.z + src2.z
 
1156
 
 
1157
      dst.w = src0.w \times src1.w + src2.w
1121
1158
 
1122
1159
 
1123
1160
.. opcode:: UMUL - Integer Multiply
1125
1162
   This instruction works the same for signed and unsigned integers.
1126
1163
   The low 32bit of the result is returned.
1127
1164
 
1128
 
.. math::
1129
 
 
1130
 
  dst.x = src0.x \times src1.x
1131
 
 
1132
 
  dst.y = src0.y \times src1.y
1133
 
 
1134
 
  dst.z = src0.z \times src1.z
1135
 
 
1136
 
  dst.w = src0.w \times src1.w
 
1165
   .. math::
 
1166
 
 
1167
      dst.x = src0.x \times src1.x
 
1168
 
 
1169
      dst.y = src0.y \times src1.y
 
1170
 
 
1171
      dst.z = src0.z \times src1.z
 
1172
 
 
1173
      dst.w = src0.w \times src1.w
1137
1174
 
1138
1175
 
1139
1176
.. opcode:: IMUL_HI - Signed Integer Multiply High Bits
1140
1177
 
1141
1178
   The high 32bits of the multiplication of 2 signed integers are returned.
1142
1179
 
1143
 
.. math::
1144
 
 
1145
 
  dst.x = (src0.x \times src1.x) >> 32
1146
 
 
1147
 
  dst.y = (src0.y \times src1.y) >> 32
1148
 
 
1149
 
  dst.z = (src0.z \times src1.z) >> 32
1150
 
 
1151
 
  dst.w = (src0.w \times src1.w) >> 32
 
1180
   .. math::
 
1181
 
 
1182
      dst.x = (src0.x \times src1.x) \gg 32
 
1183
 
 
1184
      dst.y = (src0.y \times src1.y) \gg 32
 
1185
 
 
1186
      dst.z = (src0.z \times src1.z) \gg 32
 
1187
 
 
1188
      dst.w = (src0.w \times src1.w) \gg 32
1152
1189
 
1153
1190
 
1154
1191
.. opcode:: UMUL_HI - Unsigned Integer Multiply High Bits
1155
1192
 
1156
1193
   The high 32bits of the multiplication of 2 unsigned integers are returned.
1157
1194
 
1158
 
.. math::
1159
 
 
1160
 
  dst.x = (src0.x \times src1.x) >> 32
1161
 
 
1162
 
  dst.y = (src0.y \times src1.y) >> 32
1163
 
 
1164
 
  dst.z = (src0.z \times src1.z) >> 32
1165
 
 
1166
 
  dst.w = (src0.w \times src1.w) >> 32
 
1195
   .. math::
 
1196
 
 
1197
      dst.x = (src0.x \times src1.x) \gg 32
 
1198
 
 
1199
      dst.y = (src0.y \times src1.y) \gg 32
 
1200
 
 
1201
      dst.z = (src0.z \times src1.z) \gg 32
 
1202
 
 
1203
      dst.w = (src0.w \times src1.w) \gg 32
1167
1204
 
1168
1205
 
1169
1206
.. opcode:: IDIV - Signed Integer Division
1170
1207
 
1171
1208
   TBD: behavior for division by zero.
1172
1209
 
1173
 
.. math::
1174
 
 
1175
 
  dst.x = \frac{src0.x}{src1.x}
1176
 
 
1177
 
  dst.y = \frac{src0.y}{src1.y}
1178
 
 
1179
 
  dst.z = \frac{src0.z}{src1.z}
1180
 
 
1181
 
  dst.w = \frac{src0.w}{src1.w}
 
1210
   .. math::
 
1211
 
 
1212
      dst.x = \frac{src0.x}{src1.x}
 
1213
 
 
1214
      dst.y = \frac{src0.y}{src1.y}
 
1215
 
 
1216
      dst.z = \frac{src0.z}{src1.z}
 
1217
 
 
1218
      dst.w = \frac{src0.w}{src1.w}
1182
1219
 
1183
1220
 
1184
1221
.. opcode:: UDIV - Unsigned Integer Division
1185
1222
 
1186
1223
   For division by zero, ``0xffffffff`` is returned.
1187
1224
 
1188
 
.. math::
1189
 
 
1190
 
  dst.x = \frac{src0.x}{src1.x}
1191
 
 
1192
 
  dst.y = \frac{src0.y}{src1.y}
1193
 
 
1194
 
  dst.z = \frac{src0.z}{src1.z}
1195
 
 
1196
 
  dst.w = \frac{src0.w}{src1.w}
 
1225
   .. math::
 
1226
 
 
1227
      dst.x = \frac{src0.x}{src1.x}
 
1228
 
 
1229
      dst.y = \frac{src0.y}{src1.y}
 
1230
 
 
1231
      dst.z = \frac{src0.z}{src1.z}
 
1232
 
 
1233
      dst.w = \frac{src0.w}{src1.w}
1197
1234
 
1198
1235
 
1199
1236
.. opcode:: UMOD - Unsigned Integer Remainder
1200
1237
 
1201
1238
   If *src1* is zero, ``0xffffffff`` is returned.
1202
1239
 
1203
 
.. math::
1204
 
 
1205
 
  dst.x = src0.x \bmod src1.x
1206
 
 
1207
 
  dst.y = src0.y \bmod src1.y
1208
 
 
1209
 
  dst.z = src0.z \bmod src1.z
1210
 
 
1211
 
  dst.w = src0.w \bmod src1.w
 
1240
   .. math::
 
1241
 
 
1242
      dst.x = src0.x \bmod src1.x
 
1243
 
 
1244
      dst.y = src0.y \bmod src1.y
 
1245
 
 
1246
      dst.z = src0.z \bmod src1.z
 
1247
 
 
1248
      dst.w = src0.w \bmod src1.w
1212
1249
 
1213
1250
 
1214
1251
.. opcode:: NOT - Bitwise Not
1215
1252
 
1216
 
.. math::
1217
 
 
1218
 
  dst.x = \sim src.x
1219
 
 
1220
 
  dst.y = \sim src.y
1221
 
 
1222
 
  dst.z = \sim src.z
1223
 
 
1224
 
  dst.w = \sim src.w
 
1253
   .. math::
 
1254
 
 
1255
      dst.x = \sim src.x
 
1256
 
 
1257
      dst.y = \sim src.y
 
1258
 
 
1259
      dst.z = \sim src.z
 
1260
 
 
1261
      dst.w = \sim src.w
1225
1262
 
1226
1263
 
1227
1264
.. opcode:: AND - Bitwise And
1228
1265
 
1229
 
.. math::
1230
 
 
1231
 
  dst.x = src0.x \& src1.x
1232
 
 
1233
 
  dst.y = src0.y \& src1.y
1234
 
 
1235
 
  dst.z = src0.z \& src1.z
1236
 
 
1237
 
  dst.w = src0.w \& src1.w
 
1266
   .. math::
 
1267
 
 
1268
      dst.x = src0.x \& src1.x
 
1269
 
 
1270
      dst.y = src0.y \& src1.y
 
1271
 
 
1272
      dst.z = src0.z \& src1.z
 
1273
 
 
1274
      dst.w = src0.w \& src1.w
1238
1275
 
1239
1276
 
1240
1277
.. opcode:: OR - Bitwise Or
1241
1278
 
1242
 
.. math::
1243
 
 
1244
 
  dst.x = src0.x | src1.x
1245
 
 
1246
 
  dst.y = src0.y | src1.y
1247
 
 
1248
 
  dst.z = src0.z | src1.z
1249
 
 
1250
 
  dst.w = src0.w | src1.w
 
1279
   .. math::
 
1280
 
 
1281
      dst.x = src0.x | src1.x
 
1282
 
 
1283
      dst.y = src0.y | src1.y
 
1284
 
 
1285
      dst.z = src0.z | src1.z
 
1286
 
 
1287
      dst.w = src0.w | src1.w
1251
1288
 
1252
1289
 
1253
1290
.. opcode:: XOR - Bitwise Xor
1254
1291
 
1255
 
.. math::
1256
 
 
1257
 
  dst.x = src0.x \oplus src1.x
1258
 
 
1259
 
  dst.y = src0.y \oplus src1.y
1260
 
 
1261
 
  dst.z = src0.z \oplus src1.z
1262
 
 
1263
 
  dst.w = src0.w \oplus src1.w
 
1292
   .. math::
 
1293
 
 
1294
      dst.x = src0.x \oplus src1.x
 
1295
 
 
1296
      dst.y = src0.y \oplus src1.y
 
1297
 
 
1298
      dst.z = src0.z \oplus src1.z
 
1299
 
 
1300
      dst.w = src0.w \oplus src1.w
1264
1301
 
1265
1302
 
1266
1303
.. opcode:: IMAX - Maximum of Signed Integers
1267
1304
 
1268
 
.. math::
1269
 
 
1270
 
  dst.x = max(src0.x, src1.x)
1271
 
 
1272
 
  dst.y = max(src0.y, src1.y)
1273
 
 
1274
 
  dst.z = max(src0.z, src1.z)
1275
 
 
1276
 
  dst.w = max(src0.w, src1.w)
 
1305
   .. math::
 
1306
 
 
1307
      dst.x = max(src0.x, src1.x)
 
1308
 
 
1309
      dst.y = max(src0.y, src1.y)
 
1310
 
 
1311
      dst.z = max(src0.z, src1.z)
 
1312
 
 
1313
      dst.w = max(src0.w, src1.w)
1277
1314
 
1278
1315
 
1279
1316
.. opcode:: UMAX - Maximum of Unsigned Integers
1280
1317
 
1281
 
.. math::
1282
 
 
1283
 
  dst.x = max(src0.x, src1.x)
1284
 
 
1285
 
  dst.y = max(src0.y, src1.y)
1286
 
 
1287
 
  dst.z = max(src0.z, src1.z)
1288
 
 
1289
 
  dst.w = max(src0.w, src1.w)
 
1318
   .. math::
 
1319
 
 
1320
      dst.x = max(src0.x, src1.x)
 
1321
 
 
1322
      dst.y = max(src0.y, src1.y)
 
1323
 
 
1324
      dst.z = max(src0.z, src1.z)
 
1325
 
 
1326
      dst.w = max(src0.w, src1.w)
1290
1327
 
1291
1328
 
1292
1329
.. opcode:: IMIN - Minimum of Signed Integers
1293
1330
 
1294
 
.. math::
1295
 
 
1296
 
  dst.x = min(src0.x, src1.x)
1297
 
 
1298
 
  dst.y = min(src0.y, src1.y)
1299
 
 
1300
 
  dst.z = min(src0.z, src1.z)
1301
 
 
1302
 
  dst.w = min(src0.w, src1.w)
 
1331
   .. math::
 
1332
 
 
1333
      dst.x = min(src0.x, src1.x)
 
1334
 
 
1335
      dst.y = min(src0.y, src1.y)
 
1336
 
 
1337
      dst.z = min(src0.z, src1.z)
 
1338
 
 
1339
      dst.w = min(src0.w, src1.w)
1303
1340
 
1304
1341
 
1305
1342
.. opcode:: UMIN - Minimum of Unsigned Integers
1306
1343
 
1307
 
.. math::
1308
 
 
1309
 
  dst.x = min(src0.x, src1.x)
1310
 
 
1311
 
  dst.y = min(src0.y, src1.y)
1312
 
 
1313
 
  dst.z = min(src0.z, src1.z)
1314
 
 
1315
 
  dst.w = min(src0.w, src1.w)
 
1344
   .. math::
 
1345
 
 
1346
      dst.x = min(src0.x, src1.x)
 
1347
 
 
1348
      dst.y = min(src0.y, src1.y)
 
1349
 
 
1350
      dst.z = min(src0.z, src1.z)
 
1351
 
 
1352
      dst.w = min(src0.w, src1.w)
1316
1353
 
1317
1354
 
1318
1355
.. opcode:: SHL - Shift Left
1319
1356
 
1320
1357
   The shift count is masked with ``0x1f`` before the shift is applied.
1321
1358
 
1322
 
.. math::
1323
 
 
1324
 
  dst.x = src0.x << (0x1f \& src1.x)
1325
 
 
1326
 
  dst.y = src0.y << (0x1f \& src1.y)
1327
 
 
1328
 
  dst.z = src0.z << (0x1f \& src1.z)
1329
 
 
1330
 
  dst.w = src0.w << (0x1f \& src1.w)
 
1359
   .. math::
 
1360
 
 
1361
      dst.x = src0.x \ll (0x1f \& src1.x)
 
1362
 
 
1363
      dst.y = src0.y \ll (0x1f \& src1.y)
 
1364
 
 
1365
      dst.z = src0.z \ll (0x1f \& src1.z)
 
1366
 
 
1367
      dst.w = src0.w \ll (0x1f \& src1.w)
1331
1368
 
1332
1369
 
1333
1370
.. opcode:: ISHR - Arithmetic Shift Right (of Signed Integer)
1334
1371
 
1335
1372
   The shift count is masked with ``0x1f`` before the shift is applied.
1336
1373
 
1337
 
.. math::
1338
 
 
1339
 
  dst.x = src0.x >> (0x1f \& src1.x)
1340
 
 
1341
 
  dst.y = src0.y >> (0x1f \& src1.y)
1342
 
 
1343
 
  dst.z = src0.z >> (0x1f \& src1.z)
1344
 
 
1345
 
  dst.w = src0.w >> (0x1f \& src1.w)
 
1374
   .. math::
 
1375
 
 
1376
      dst.x = src0.x \gg (0x1f \& src1.x)
 
1377
 
 
1378
      dst.y = src0.y \gg (0x1f \& src1.y)
 
1379
 
 
1380
      dst.z = src0.z \gg (0x1f \& src1.z)
 
1381
 
 
1382
      dst.w = src0.w \gg (0x1f \& src1.w)
1346
1383
 
1347
1384
 
1348
1385
.. opcode:: USHR - Logical Shift Right
1349
1386
 
1350
1387
   The shift count is masked with ``0x1f`` before the shift is applied.
1351
1388
 
1352
 
.. math::
1353
 
 
1354
 
  dst.x = src0.x >> (unsigned) (0x1f \& src1.x)
1355
 
 
1356
 
  dst.y = src0.y >> (unsigned) (0x1f \& src1.y)
1357
 
 
1358
 
  dst.z = src0.z >> (unsigned) (0x1f \& src1.z)
1359
 
 
1360
 
  dst.w = src0.w >> (unsigned) (0x1f \& src1.w)
 
1389
   .. math::
 
1390
 
 
1391
      dst.x = src0.x \gg (unsigned) (0x1f \& src1.x)
 
1392
 
 
1393
      dst.y = src0.y \gg (unsigned) (0x1f \& src1.y)
 
1394
 
 
1395
      dst.z = src0.z \gg (unsigned) (0x1f \& src1.z)
 
1396
 
 
1397
      dst.w = src0.w \gg (unsigned) (0x1f \& src1.w)
1361
1398
 
1362
1399
 
1363
1400
.. opcode:: UCMP - Integer Conditional Move
1364
1401
 
1365
 
.. math::
1366
 
 
1367
 
  dst.x = src0.x ? src1.x : src2.x
1368
 
 
1369
 
  dst.y = src0.y ? src1.y : src2.y
1370
 
 
1371
 
  dst.z = src0.z ? src1.z : src2.z
1372
 
 
1373
 
  dst.w = src0.w ? src1.w : src2.w
 
1402
   .. math::
 
1403
 
 
1404
      dst.x = src0.x ? src1.x : src2.x
 
1405
 
 
1406
      dst.y = src0.y ? src1.y : src2.y
 
1407
 
 
1408
      dst.z = src0.z ? src1.z : src2.z
 
1409
 
 
1410
      dst.w = src0.w ? src1.w : src2.w
1374
1411
 
1375
1412
 
1376
1413
 
1377
1414
.. opcode:: ISSG - Integer Set Sign
1378
1415
 
1379
 
.. math::
1380
 
 
1381
 
  dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
1382
 
 
1383
 
  dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
1384
 
 
1385
 
  dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
1386
 
 
1387
 
  dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
 
1416
   .. math::
 
1417
 
 
1418
      dst.x = (src0.x < 0) ? -1 : (src0.x > 0) ? 1 : 0
 
1419
 
 
1420
      dst.y = (src0.y < 0) ? -1 : (src0.y > 0) ? 1 : 0
 
1421
 
 
1422
      dst.z = (src0.z < 0) ? -1 : (src0.z > 0) ? 1 : 0
 
1423
 
 
1424
      dst.w = (src0.w < 0) ? -1 : (src0.w > 0) ? 1 : 0
1388
1425
 
1389
1426
 
1390
1427
 
1392
1429
 
1393
1430
   Same comparison as SLT but returns integer instead of 1.0/0.0 float
1394
1431
 
1395
 
.. math::
1396
 
 
1397
 
  dst.x = (src0.x < src1.x) ? \sim 0 : 0
1398
 
 
1399
 
  dst.y = (src0.y < src1.y) ? \sim 0 : 0
1400
 
 
1401
 
  dst.z = (src0.z < src1.z) ? \sim 0 : 0
1402
 
 
1403
 
  dst.w = (src0.w < src1.w) ? \sim 0 : 0
 
1432
   .. math::
 
1433
 
 
1434
      dst.x = (src0.x < src1.x) ? \sim 0 : 0
 
1435
 
 
1436
      dst.y = (src0.y < src1.y) ? \sim 0 : 0
 
1437
 
 
1438
      dst.z = (src0.z < src1.z) ? \sim 0 : 0
 
1439
 
 
1440
      dst.w = (src0.w < src1.w) ? \sim 0 : 0
1404
1441
 
1405
1442
 
1406
1443
.. opcode:: ISLT - Signed Integer Set On Less Than
1407
1444
 
1408
 
.. math::
1409
 
 
1410
 
  dst.x = (src0.x < src1.x) ? \sim 0 : 0
1411
 
 
1412
 
  dst.y = (src0.y < src1.y) ? \sim 0 : 0
1413
 
 
1414
 
  dst.z = (src0.z < src1.z) ? \sim 0 : 0
1415
 
 
1416
 
  dst.w = (src0.w < src1.w) ? \sim 0 : 0
 
1445
   .. math::
 
1446
 
 
1447
      dst.x = (src0.x < src1.x) ? \sim 0 : 0
 
1448
 
 
1449
      dst.y = (src0.y < src1.y) ? \sim 0 : 0
 
1450
 
 
1451
      dst.z = (src0.z < src1.z) ? \sim 0 : 0
 
1452
 
 
1453
      dst.w = (src0.w < src1.w) ? \sim 0 : 0
1417
1454
 
1418
1455
 
1419
1456
.. opcode:: USLT - Unsigned Integer Set On Less Than
1420
1457
 
1421
 
.. math::
1422
 
 
1423
 
  dst.x = (src0.x < src1.x) ? \sim 0 : 0
1424
 
 
1425
 
  dst.y = (src0.y < src1.y) ? \sim 0 : 0
1426
 
 
1427
 
  dst.z = (src0.z < src1.z) ? \sim 0 : 0
1428
 
 
1429
 
  dst.w = (src0.w < src1.w) ? \sim 0 : 0
 
1458
   .. math::
 
1459
 
 
1460
      dst.x = (src0.x < src1.x) ? \sim 0 : 0
 
1461
 
 
1462
      dst.y = (src0.y < src1.y) ? \sim 0 : 0
 
1463
 
 
1464
      dst.z = (src0.z < src1.z) ? \sim 0 : 0
 
1465
 
 
1466
      dst.w = (src0.w < src1.w) ? \sim 0 : 0
1430
1467
 
1431
1468
 
1432
1469
.. opcode:: FSGE - Float Set On Greater Equal Than (ordered)
1433
1470
 
1434
1471
   Same comparison as SGE but returns integer instead of 1.0/0.0 float
1435
1472
 
1436
 
.. math::
1437
 
 
1438
 
  dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1439
 
 
1440
 
  dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1441
 
 
1442
 
  dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1443
 
 
1444
 
  dst.w = (src0.w >= src1.w) ? \sim 0 : 0
 
1473
   .. math::
 
1474
 
 
1475
      dst.x = (src0.x >= src1.x) ? \sim 0 : 0
 
1476
 
 
1477
      dst.y = (src0.y >= src1.y) ? \sim 0 : 0
 
1478
 
 
1479
      dst.z = (src0.z >= src1.z) ? \sim 0 : 0
 
1480
 
 
1481
      dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1445
1482
 
1446
1483
 
1447
1484
.. opcode:: ISGE - Signed Integer Set On Greater Equal Than
1448
1485
 
1449
 
.. math::
1450
 
 
1451
 
  dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1452
 
 
1453
 
  dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1454
 
 
1455
 
  dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1456
 
 
1457
 
  dst.w = (src0.w >= src1.w) ? \sim 0 : 0
 
1486
   .. math::
 
1487
 
 
1488
      dst.x = (src0.x >= src1.x) ? \sim 0 : 0
 
1489
 
 
1490
      dst.y = (src0.y >= src1.y) ? \sim 0 : 0
 
1491
 
 
1492
      dst.z = (src0.z >= src1.z) ? \sim 0 : 0
 
1493
 
 
1494
      dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1458
1495
 
1459
1496
 
1460
1497
.. opcode:: USGE - Unsigned Integer Set On Greater Equal Than
1461
1498
 
1462
 
.. math::
1463
 
 
1464
 
  dst.x = (src0.x >= src1.x) ? \sim 0 : 0
1465
 
 
1466
 
  dst.y = (src0.y >= src1.y) ? \sim 0 : 0
1467
 
 
1468
 
  dst.z = (src0.z >= src1.z) ? \sim 0 : 0
1469
 
 
1470
 
  dst.w = (src0.w >= src1.w) ? \sim 0 : 0
 
1499
   .. math::
 
1500
 
 
1501
      dst.x = (src0.x >= src1.x) ? \sim 0 : 0
 
1502
 
 
1503
      dst.y = (src0.y >= src1.y) ? \sim 0 : 0
 
1504
 
 
1505
      dst.z = (src0.z >= src1.z) ? \sim 0 : 0
 
1506
 
 
1507
      dst.w = (src0.w >= src1.w) ? \sim 0 : 0
1471
1508
 
1472
1509
 
1473
1510
.. opcode:: FSEQ - Float Set On Equal (ordered)
1474
1511
 
1475
1512
   Same comparison as SEQ but returns integer instead of 1.0/0.0 float
1476
1513
 
1477
 
.. math::
1478
 
 
1479
 
  dst.x = (src0.x == src1.x) ? \sim 0 : 0
1480
 
 
1481
 
  dst.y = (src0.y == src1.y) ? \sim 0 : 0
1482
 
 
1483
 
  dst.z = (src0.z == src1.z) ? \sim 0 : 0
1484
 
 
1485
 
  dst.w = (src0.w == src1.w) ? \sim 0 : 0
 
1514
   .. math::
 
1515
 
 
1516
      dst.x = (src0.x == src1.x) ? \sim 0 : 0
 
1517
 
 
1518
      dst.y = (src0.y == src1.y) ? \sim 0 : 0
 
1519
 
 
1520
      dst.z = (src0.z == src1.z) ? \sim 0 : 0
 
1521
 
 
1522
      dst.w = (src0.w == src1.w) ? \sim 0 : 0
1486
1523
 
1487
1524
 
1488
1525
.. opcode:: USEQ - Integer Set On Equal
1489
1526
 
1490
 
.. math::
1491
 
 
1492
 
  dst.x = (src0.x == src1.x) ? \sim 0 : 0
1493
 
 
1494
 
  dst.y = (src0.y == src1.y) ? \sim 0 : 0
1495
 
 
1496
 
  dst.z = (src0.z == src1.z) ? \sim 0 : 0
1497
 
 
1498
 
  dst.w = (src0.w == src1.w) ? \sim 0 : 0
 
1527
   .. math::
 
1528
 
 
1529
      dst.x = (src0.x == src1.x) ? \sim 0 : 0
 
1530
 
 
1531
      dst.y = (src0.y == src1.y) ? \sim 0 : 0
 
1532
 
 
1533
      dst.z = (src0.z == src1.z) ? \sim 0 : 0
 
1534
 
 
1535
      dst.w = (src0.w == src1.w) ? \sim 0 : 0
1499
1536
 
1500
1537
 
1501
1538
.. opcode:: FSNE - Float Set On Not Equal (unordered)
1502
1539
 
1503
1540
   Same comparison as SNE but returns integer instead of 1.0/0.0 float
1504
1541
 
1505
 
.. math::
1506
 
 
1507
 
  dst.x = (src0.x != src1.x) ? \sim 0 : 0
1508
 
 
1509
 
  dst.y = (src0.y != src1.y) ? \sim 0 : 0
1510
 
 
1511
 
  dst.z = (src0.z != src1.z) ? \sim 0 : 0
1512
 
 
1513
 
  dst.w = (src0.w != src1.w) ? \sim 0 : 0
 
1542
   .. math::
 
1543
 
 
1544
      dst.x = (src0.x != src1.x) ? \sim 0 : 0
 
1545
 
 
1546
      dst.y = (src0.y != src1.y) ? \sim 0 : 0
 
1547
 
 
1548
      dst.z = (src0.z != src1.z) ? \sim 0 : 0
 
1549
 
 
1550
      dst.w = (src0.w != src1.w) ? \sim 0 : 0
1514
1551
 
1515
1552
 
1516
1553
.. opcode:: USNE - Integer Set On Not Equal
1517
1554
 
1518
 
.. math::
1519
 
 
1520
 
  dst.x = (src0.x != src1.x) ? \sim 0 : 0
1521
 
 
1522
 
  dst.y = (src0.y != src1.y) ? \sim 0 : 0
1523
 
 
1524
 
  dst.z = (src0.z != src1.z) ? \sim 0 : 0
1525
 
 
1526
 
  dst.w = (src0.w != src1.w) ? \sim 0 : 0
 
1555
   .. math::
 
1556
 
 
1557
      dst.x = (src0.x != src1.x) ? \sim 0 : 0
 
1558
 
 
1559
      dst.y = (src0.y != src1.y) ? \sim 0 : 0
 
1560
 
 
1561
      dst.z = (src0.z != src1.z) ? \sim 0 : 0
 
1562
 
 
1563
      dst.w = (src0.w != src1.w) ? \sim 0 : 0
1527
1564
 
1528
1565
 
1529
1566
.. opcode:: INEG - Integer Negate
1530
1567
 
1531
1568
  Two's complement.
1532
1569
 
1533
 
.. math::
1534
 
 
1535
 
  dst.x = -src.x
1536
 
 
1537
 
  dst.y = -src.y
1538
 
 
1539
 
  dst.z = -src.z
1540
 
 
1541
 
  dst.w = -src.w
 
1570
   .. math::
 
1571
 
 
1572
      dst.x = -src.x
 
1573
 
 
1574
      dst.y = -src.y
 
1575
 
 
1576
      dst.z = -src.z
 
1577
 
 
1578
      dst.w = -src.w
1542
1579
 
1543
1580
 
1544
1581
.. opcode:: IABS - Integer Absolute Value
1545
1582
 
1546
 
.. math::
1547
 
 
1548
 
  dst.x = |src.x|
1549
 
 
1550
 
  dst.y = |src.y|
1551
 
 
1552
 
  dst.z = |src.z|
1553
 
 
1554
 
  dst.w = |src.w|
 
1583
   .. math::
 
1584
 
 
1585
      dst.x = |src.x|
 
1586
 
 
1587
      dst.y = |src.y|
 
1588
 
 
1589
      dst.z = |src.z|
 
1590
 
 
1591
      dst.w = |src.w|
1555
1592
 
1556
1593
Bitwise ISA
1557
1594
^^^^^^^^^^^
1559
1596
 
1560
1597
.. opcode:: IBFE - Signed Bitfield Extract
1561
1598
 
1562
 
  Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
1563
 
  sign-extends them if the high bit of the extracted window is set.
1564
 
 
1565
 
  Pseudocode::
1566
 
 
1567
 
    def ibfe(value, offset, bits):
1568
 
      if offset < 0 or bits < 0 or offset + bits > 32:
1569
 
        return undefined
1570
 
      if bits == 0: return 0
1571
 
      # Note: >> sign-extends
1572
 
      return (value << (32 - offset - bits)) >> (32 - bits)
 
1599
   Like GLSL bitfieldExtract. Extracts a set of bits from the input, and
 
1600
   sign-extends them if the high bit of the extracted window is set.
 
1601
 
 
1602
   Pseudocode::
 
1603
 
 
1604
      def ibfe(value, offset, bits):
 
1605
         if offset < 0 or bits < 0 or offset + bits > 32:
 
1606
            return undefined
 
1607
         if bits == 0: return 0
 
1608
         # Note: >> sign-extends
 
1609
         return (value << (32 - offset - bits)) >> (32 - bits)
1573
1610
 
1574
1611
.. opcode:: UBFE - Unsigned Bitfield Extract
1575
1612
 
1576
 
  Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
1577
 
  any sign-extension.
1578
 
 
1579
 
  Pseudocode::
1580
 
 
1581
 
    def ubfe(value, offset, bits):
1582
 
      if offset < 0 or bits < 0 or offset + bits > 32:
1583
 
        return undefined
1584
 
      if bits == 0: return 0
1585
 
      # Note: >> does not sign-extend
1586
 
      return (value << (32 - offset - bits)) >> (32 - bits)
 
1613
   Like GLSL bitfieldExtract. Extracts a set of bits from the input, without
 
1614
   any sign-extension.
 
1615
 
 
1616
   Pseudocode::
 
1617
 
 
1618
      def ubfe(value, offset, bits):
 
1619
         if offset < 0 or bits < 0 or offset + bits > 32:
 
1620
            return undefined
 
1621
         if bits == 0: return 0
 
1622
         # Note: >> does not sign-extend
 
1623
         return (value << (32 - offset - bits)) >> (32 - bits)
1587
1624
 
1588
1625
.. opcode:: BFI - Bitfield Insert
1589
1626
 
1590
 
  Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
1591
 
  of 'insert'.
1592
 
 
1593
 
  Pseudocode::
1594
 
 
1595
 
    def bfi(base, insert, offset, bits):
1596
 
      if offset < 0 or bits < 0 or offset + bits > 32:
1597
 
        return undefined
1598
 
      # << defined such that mask == ~0 when bits == 32, offset == 0
1599
 
      mask = ((1 << bits) - 1) << offset
1600
 
      return ((insert << offset) & mask) | (base & ~mask)
 
1627
   Like GLSL bitfieldInsert. Replaces a bit region of 'base' with the low bits
 
1628
   of 'insert'.
 
1629
 
 
1630
   Pseudocode::
 
1631
 
 
1632
      def bfi(base, insert, offset, bits):
 
1633
         if offset < 0 or bits < 0 or offset + bits > 32:
 
1634
            return undefined
 
1635
         # << defined such that mask == ~0 when bits == 32, offset == 0
 
1636
         mask = ((1 << bits) - 1) << offset
 
1637
         return ((insert << offset) & mask) | (base & ~mask)
1601
1638
 
1602
1639
.. opcode:: BREV - Bitfield Reverse
1603
1640
 
1604
 
  See SM5 instruction BFREV. Reverses the bits of the argument.
 
1641
   See SM5 instruction BFREV. Reverses the bits of the argument.
1605
1642
 
1606
1643
.. opcode:: POPC - Population Count
1607
1644
 
1608
 
  See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
 
1645
   See SM5 instruction COUNTBITS. Counts the number of set bits in the argument.
1609
1646
 
1610
1647
.. opcode:: LSB - Index of lowest set bit
1611
1648
 
1612
 
  See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
1613
 
  bit of the argument. Returns -1 if none are set.
 
1649
   See SM5 instruction FIRSTBIT_LO. Computes the 0-based index of the first set
 
1650
   bit of the argument. Returns -1 if none are set.
1614
1651
 
1615
1652
.. opcode:: IMSB - Index of highest non-sign bit
1616
1653
 
1617
 
  See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
1618
 
  non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
1619
 
  highest 1 bit for positive numbers). Returns -1 if all bits are the same
1620
 
  (i.e. for inputs 0 and -1).
 
1654
   See SM5 instruction FIRSTBIT_SHI. Computes the 0-based index of the highest
 
1655
   non-sign bit of the argument (i.e. highest 0 bit for negative numbers,
 
1656
   highest 1 bit for positive numbers). Returns -1 if all bits are the same
 
1657
   (i.e. for inputs 0 and -1).
1621
1658
 
1622
1659
.. opcode:: UMSB - Index of highest set bit
1623
1660
 
1624
 
  See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
1625
 
  set bit of the argument. Returns -1 if none are set.
 
1661
   See SM5 instruction FIRSTBIT_HI. Computes the 0-based index of the highest
 
1662
   set bit of the argument. Returns -1 if none are set.
1626
1663
 
1627
1664
Geometry ISA
1628
1665
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1632
1669
 
1633
1670
.. opcode:: EMIT - Emit
1634
1671
 
1635
 
  Generate a new vertex for the current primitive into the specified vertex
1636
 
  stream using the values in the output registers.
 
1672
   Generate a new vertex for the current primitive into the specified vertex
 
1673
   stream using the values in the output registers.
1637
1674
 
1638
1675
 
1639
1676
.. opcode:: ENDPRIM - End Primitive
1640
1677
 
1641
 
  Complete the current primitive in the specified vertex stream (consisting of
1642
 
  the emitted vertices), and start a new one.
 
1678
   Complete the current primitive in the specified vertex stream (consisting of
 
1679
   the emitted vertices), and start a new one.
1643
1680
 
1644
1681
 
1645
1682
GLSL ISA
1651
1688
 
1652
1689
.. opcode:: CAL - Subroutine Call
1653
1690
 
1654
 
  Pseudocode::
 
1691
   Pseudocode::
1655
1692
 
1656
 
    push(pc)
1657
 
    pc = target
 
1693
      push(pc)
 
1694
      pc = target
1658
1695
 
1659
1696
 
1660
1697
.. opcode:: RET - Subroutine Call Return
1661
1698
 
1662
 
  Pseudocode::
 
1699
   Pseudocode::
1663
1700
 
1664
 
    pc = pop()
 
1701
      pc = pop()
1665
1702
 
1666
1703
 
1667
1704
.. opcode:: CONT - Continue
1668
1705
 
1669
 
  Unconditionally moves the point of execution to the instruction after the
1670
 
  last BGNLOOP. The instruction must appear within a BGNLOOP/ENDLOOP.
 
1706
   Unconditionally moves the point of execution to the instruction after the
 
1707
   last BGNLOOP. The instruction must appear within a BGNLOOP/ENDLOOP.
1671
1708
 
1672
1709
.. note::
1673
1710
 
1677
1714
 
1678
1715
.. opcode:: BGNLOOP - Begin a Loop
1679
1716
 
1680
 
  Start a loop. Must have a matching ENDLOOP.
 
1717
   Start a loop. Must have a matching ENDLOOP.
1681
1718
 
1682
1719
 
1683
1720
.. opcode:: BGNSUB - Begin Subroutine
1684
1721
 
1685
 
  Starts definition of a subroutine. Must have a matching ENDSUB.
 
1722
   Starts definition of a subroutine. Must have a matching ENDSUB.
1686
1723
 
1687
1724
 
1688
1725
.. opcode:: ENDLOOP - End a Loop
1689
1726
 
1690
 
  End a loop started with BGNLOOP.
 
1727
   End a loop started with BGNLOOP.
1691
1728
 
1692
1729
 
1693
1730
.. opcode:: ENDSUB - End Subroutine
1694
1731
 
1695
 
  Ends definition of a subroutine.
 
1732
   Ends definition of a subroutine.
1696
1733
 
1697
1734
 
1698
1735
.. opcode:: NOP - No Operation
1699
1736
 
1700
 
  Do nothing.
 
1737
   Do nothing.
1701
1738
 
1702
1739
 
1703
1740
.. opcode:: BRK - Break
1704
1741
 
1705
 
  Unconditionally moves the point of execution to the instruction after the
1706
 
  next ENDLOOP or ENDSWITCH. The instruction must appear within a
1707
 
  BGNLOOP/ENDLOOP or SWITCH/ENDSWITCH.
 
1742
   Unconditionally moves the point of execution to the instruction after the
 
1743
   next ENDLOOP or ENDSWITCH. The instruction must appear within a
 
1744
   BGNLOOP/ENDLOOP or SWITCH/ENDSWITCH.
1708
1745
 
1709
1746
 
1710
1747
.. opcode:: IF - Float If
1711
1748
 
1712
 
  Start an IF ... ELSE .. ENDIF block.  Condition evaluates to true if
1713
 
 
1714
 
    *src0.x* != 0.0
1715
 
 
1716
 
  where *src0.x* is interpreted as a floating point register.
 
1749
   Start an IF ... ELSE .. ENDIF block.  Condition evaluates to true if
 
1750
 
 
1751
      *src0.x* != 0.0
 
1752
 
 
1753
   where *src0.x* is interpreted as a floating point register.
1717
1754
 
1718
1755
 
1719
1756
.. opcode:: UIF - Bitwise If
1720
1757
 
1721
 
  Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
1722
 
 
1723
 
    *src0.x* != 0
1724
 
 
1725
 
  where *src0.x* is interpreted as an integer register.
 
1758
   Start an UIF ... ELSE .. ENDIF block. Condition evaluates to true if
 
1759
 
 
1760
      *src0.x* != 0
 
1761
 
 
1762
   where *src0.x* is interpreted as an integer register.
1726
1763
 
1727
1764
 
1728
1765
.. opcode:: ELSE - Else
1729
1766
 
1730
 
  Starts an else block, after an IF or UIF statement.
 
1767
   Starts an else block, after an IF or UIF statement.
1731
1768
 
1732
1769
 
1733
1770
.. opcode:: ENDIF - End If
1734
1771
 
1735
 
  Ends an IF or UIF block.
 
1772
   Ends an IF or UIF block.
1736
1773
 
1737
1774
 
1738
1775
.. opcode:: SWITCH - Switch
1746
1783
 
1747
1784
   Example::
1748
1785
 
1749
 
     SWITCH src[0].x
1750
 
     CASE src[0].x
1751
 
     (some instructions here)
1752
 
     (optional BRK here)
1753
 
     DEFAULT
1754
 
     (some instructions here)
1755
 
     (optional BRK here)
1756
 
     CASE src[0].x
1757
 
     (some instructions here)
1758
 
     (optional BRK here)
1759
 
     ENDSWITCH
 
1786
      SWITCH src[0].x
 
1787
      CASE src[0].x
 
1788
      (some instructions here)
 
1789
      (optional BRK here)
 
1790
      DEFAULT
 
1791
      (some instructions here)
 
1792
      (optional BRK here)
 
1793
      CASE src[0].x
 
1794
      (some instructions here)
 
1795
      (optional BRK here)
 
1796
      ENDSWITCH
1760
1797
 
1761
1798
 
1762
1799
.. opcode:: CASE - Switch case
1808
1845
 
1809
1846
.. opcode:: DABS - Absolute
1810
1847
 
1811
 
.. math::
1812
 
 
1813
 
  dst.xy = |src0.xy|
1814
 
 
1815
 
  dst.zw = |src0.zw|
 
1848
   .. math::
 
1849
 
 
1850
      dst.xy = |src0.xy|
 
1851
 
 
1852
      dst.zw = |src0.zw|
1816
1853
 
1817
1854
.. opcode:: DADD - Add
1818
1855
 
1819
 
.. math::
1820
 
 
1821
 
  dst.xy = src0.xy + src1.xy
1822
 
 
1823
 
  dst.zw = src0.zw + src1.zw
 
1856
   .. math::
 
1857
 
 
1858
      dst.xy = src0.xy + src1.xy
 
1859
 
 
1860
      dst.zw = src0.zw + src1.zw
1824
1861
 
1825
1862
.. opcode:: DSEQ - Set on Equal
1826
1863
 
1827
 
.. math::
1828
 
 
1829
 
  dst.x = src0.xy == src1.xy ? \sim 0 : 0
1830
 
 
1831
 
  dst.z = src0.zw == src1.zw ? \sim 0 : 0
 
1864
   .. math::
 
1865
 
 
1866
      dst.x = src0.xy == src1.xy ? \sim 0 : 0
 
1867
 
 
1868
      dst.z = src0.zw == src1.zw ? \sim 0 : 0
1832
1869
 
1833
1870
.. opcode:: DSNE - Set on Not Equal
1834
1871
 
1835
 
.. math::
1836
 
 
1837
 
  dst.x = src0.xy != src1.xy ? \sim 0 : 0
1838
 
 
1839
 
  dst.z = src0.zw != src1.zw ? \sim 0 : 0
 
1872
   .. math::
 
1873
 
 
1874
      dst.x = src0.xy != src1.xy ? \sim 0 : 0
 
1875
 
 
1876
      dst.z = src0.zw != src1.zw ? \sim 0 : 0
1840
1877
 
1841
1878
.. opcode:: DSLT - Set on Less than
1842
1879
 
1843
 
.. math::
1844
 
 
1845
 
  dst.x = src0.xy < src1.xy ? \sim 0 : 0
1846
 
 
1847
 
  dst.z = src0.zw < src1.zw ? \sim 0 : 0
 
1880
   .. math::
 
1881
 
 
1882
      dst.x = src0.xy < src1.xy ? \sim 0 : 0
 
1883
 
 
1884
      dst.z = src0.zw < src1.zw ? \sim 0 : 0
1848
1885
 
1849
1886
.. opcode:: DSGE - Set on Greater equal
1850
1887
 
1851
 
.. math::
1852
 
 
1853
 
  dst.x = src0.xy >= src1.xy ? \sim 0 : 0
1854
 
 
1855
 
  dst.z = src0.zw >= src1.zw ? \sim 0 : 0
 
1888
   .. math::
 
1889
 
 
1890
      dst.x = src0.xy >= src1.xy ? \sim 0 : 0
 
1891
 
 
1892
      dst.z = src0.zw >= src1.zw ? \sim 0 : 0
1856
1893
 
1857
1894
.. opcode:: DFRAC - Fraction
1858
1895
 
1859
 
.. math::
1860
 
 
1861
 
  dst.xy = src.xy - \lfloor src.xy\rfloor
1862
 
 
1863
 
  dst.zw = src.zw - \lfloor src.zw\rfloor
 
1896
   .. math::
 
1897
 
 
1898
      dst.xy = src.xy - \lfloor src.xy\rfloor
 
1899
 
 
1900
      dst.zw = src.zw - \lfloor src.zw\rfloor
1864
1901
 
1865
1902
.. opcode:: DTRUNC - Truncate
1866
1903
 
1867
 
.. math::
1868
 
 
1869
 
  dst.xy = trunc(src.xy)
1870
 
 
1871
 
  dst.zw = trunc(src.zw)
 
1904
   .. math::
 
1905
 
 
1906
      dst.xy = trunc(src.xy)
 
1907
 
 
1908
      dst.zw = trunc(src.zw)
1872
1909
 
1873
1910
.. opcode:: DCEIL - Ceiling
1874
1911
 
1875
 
.. math::
1876
 
 
1877
 
  dst.xy = \lceil src.xy\rceil
1878
 
 
1879
 
  dst.zw = \lceil src.zw\rceil
 
1912
   .. math::
 
1913
 
 
1914
      dst.xy = \lceil src.xy\rceil
 
1915
 
 
1916
      dst.zw = \lceil src.zw\rceil
1880
1917
 
1881
1918
.. opcode:: DFLR - Floor
1882
1919
 
1883
 
.. math::
1884
 
 
1885
 
  dst.xy = \lfloor src.xy\rfloor
1886
 
 
1887
 
  dst.zw = \lfloor src.zw\rfloor
 
1920
   .. math::
 
1921
 
 
1922
      dst.xy = \lfloor src.xy\rfloor
 
1923
 
 
1924
      dst.zw = \lfloor src.zw\rfloor
1888
1925
 
1889
1926
.. opcode:: DROUND - Fraction
1890
1927
 
1891
 
.. math::
1892
 
 
1893
 
  dst.xy = round(src.xy)
1894
 
 
1895
 
  dst.zw = round(src.zw)
 
1928
   .. math::
 
1929
 
 
1930
      dst.xy = round(src.xy)
 
1931
 
 
1932
      dst.zw = round(src.zw)
1896
1933
 
1897
1934
.. opcode:: DSSG - Set Sign
1898
1935
 
1899
 
.. math::
1900
 
 
1901
 
  dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
1902
 
 
1903
 
  dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
 
1936
   .. math::
 
1937
 
 
1938
      dst.xy = (src.xy > 0) ? 1.0 : (src.xy < 0) ? -1.0 : 0.0
 
1939
 
 
1940
      dst.zw = (src.zw > 0) ? 1.0 : (src.zw < 0) ? -1.0 : 0.0
1904
1941
 
1905
1942
.. opcode:: DLDEXP - Multiply Number by Integral Power of 2
1906
1943
 
1907
 
This opcode is the inverse of frexp. The second
1908
 
source is an integer.
1909
 
 
1910
 
.. math::
1911
 
 
1912
 
  dst.xy = src0.xy \times 2^{src1.x}
1913
 
 
1914
 
  dst.zw = src0.zw \times 2^{src1.z}
 
1944
   This opcode is the inverse of frexp. The second
 
1945
   source is an integer.
 
1946
 
 
1947
   .. math::
 
1948
 
 
1949
      dst.xy = src0.xy \times 2^{src1.x}
 
1950
 
 
1951
      dst.zw = src0.zw \times 2^{src1.z}
1915
1952
 
1916
1953
.. opcode:: DMIN - Minimum
1917
1954
 
1918
 
.. math::
1919
 
 
1920
 
  dst.xy = min(src0.xy, src1.xy)
1921
 
 
1922
 
  dst.zw = min(src0.zw, src1.zw)
 
1955
   .. math::
 
1956
 
 
1957
      dst.xy = min(src0.xy, src1.xy)
 
1958
 
 
1959
      dst.zw = min(src0.zw, src1.zw)
1923
1960
 
1924
1961
.. opcode:: DMAX - Maximum
1925
1962
 
1926
 
.. math::
1927
 
 
1928
 
  dst.xy = max(src0.xy, src1.xy)
1929
 
 
1930
 
  dst.zw = max(src0.zw, src1.zw)
 
1963
   .. math::
 
1964
 
 
1965
      dst.xy = max(src0.xy, src1.xy)
 
1966
 
 
1967
      dst.zw = max(src0.zw, src1.zw)
1931
1968
 
1932
1969
.. opcode:: DMUL - Multiply
1933
1970
 
1934
 
.. math::
1935
 
 
1936
 
  dst.xy = src0.xy \times src1.xy
1937
 
 
1938
 
  dst.zw = src0.zw \times src1.zw
 
1971
   .. math::
 
1972
 
 
1973
      dst.xy = src0.xy \times src1.xy
 
1974
 
 
1975
      dst.zw = src0.zw \times src1.zw
1939
1976
 
1940
1977
 
1941
1978
.. opcode:: DMAD - Multiply And Add
1942
1979
 
1943
 
.. math::
1944
 
 
1945
 
  dst.xy = src0.xy \times src1.xy + src2.xy
1946
 
 
1947
 
  dst.zw = src0.zw \times src1.zw + src2.zw
 
1980
   .. math::
 
1981
 
 
1982
      dst.xy = src0.xy \times src1.xy + src2.xy
 
1983
 
 
1984
      dst.zw = src0.zw \times src1.zw + src2.zw
1948
1985
 
1949
1986
 
1950
1987
.. opcode:: DFMA - Fused Multiply-Add
1951
1988
 
1952
 
Perform a * b + c with no intermediate rounding step.
1953
 
 
1954
 
.. math::
1955
 
 
1956
 
  dst.xy = src0.xy \times src1.xy + src2.xy
1957
 
 
1958
 
  dst.zw = src0.zw \times src1.zw + src2.zw
 
1989
   Perform a * b + c with no intermediate rounding step.
 
1990
 
 
1991
   .. math::
 
1992
 
 
1993
      dst.xy = src0.xy \times src1.xy + src2.xy
 
1994
 
 
1995
      dst.zw = src0.zw \times src1.zw + src2.zw
1959
1996
 
1960
1997
 
1961
1998
.. opcode:: DDIV - Divide
1962
1999
 
1963
 
.. math::
1964
 
 
1965
 
  dst.xy = \frac{src0.xy}{src1.xy}
1966
 
 
1967
 
  dst.zw = \frac{src0.zw}{src1.zw}
 
2000
   .. math::
 
2001
 
 
2002
      dst.xy = \frac{src0.xy}{src1.xy}
 
2003
 
 
2004
      dst.zw = \frac{src0.zw}{src1.zw}
1968
2005
 
1969
2006
 
1970
2007
.. opcode:: DRCP - Reciprocal
1971
2008
 
1972
 
.. math::
1973
 
 
1974
 
   dst.xy = \frac{1}{src.xy}
1975
 
 
1976
 
   dst.zw = \frac{1}{src.zw}
 
2009
   .. math::
 
2010
 
 
2011
      dst.xy = \frac{1}{src.xy}
 
2012
 
 
2013
      dst.zw = \frac{1}{src.zw}
1977
2014
 
1978
2015
.. opcode:: DSQRT - Square Root
1979
2016
 
1980
 
.. math::
1981
 
 
1982
 
   dst.xy = \sqrt{src.xy}
1983
 
 
1984
 
   dst.zw = \sqrt{src.zw}
 
2017
   .. math::
 
2018
 
 
2019
      dst.xy = \sqrt{src.xy}
 
2020
 
 
2021
      dst.zw = \sqrt{src.zw}
1985
2022
 
1986
2023
.. opcode:: DRSQ - Reciprocal Square Root
1987
2024
 
1988
 
.. math::
1989
 
 
1990
 
   dst.xy = \frac{1}{\sqrt{src.xy}}
1991
 
 
1992
 
   dst.zw = \frac{1}{\sqrt{src.zw}}
 
2025
   .. math::
 
2026
 
 
2027
      dst.xy = \frac{1}{\sqrt{src.xy}}
 
2028
 
 
2029
      dst.zw = \frac{1}{\sqrt{src.zw}}
1993
2030
 
1994
2031
.. opcode:: F2D - Float to Double
1995
2032
 
1996
 
.. math::
1997
 
 
1998
 
   dst.xy = double(src0.x)
1999
 
 
2000
 
   dst.zw = double(src0.y)
 
2033
   .. math::
 
2034
 
 
2035
      dst.xy = double(src0.x)
 
2036
 
 
2037
      dst.zw = double(src0.y)
2001
2038
 
2002
2039
.. opcode:: D2F - Double to Float
2003
2040
 
2004
 
.. math::
2005
 
 
2006
 
   dst.x = float(src0.xy)
2007
 
 
2008
 
   dst.y = float(src0.zw)
 
2041
   .. math::
 
2042
 
 
2043
      dst.x = float(src0.xy)
 
2044
 
 
2045
      dst.y = float(src0.zw)
2009
2046
 
2010
2047
.. opcode:: I2D - Int to Double
2011
2048
 
2012
 
.. math::
2013
 
 
2014
 
   dst.xy = double(src0.x)
2015
 
 
2016
 
   dst.zw = double(src0.y)
 
2049
   .. math::
 
2050
 
 
2051
      dst.xy = double(src0.x)
 
2052
 
 
2053
      dst.zw = double(src0.y)
2017
2054
 
2018
2055
.. opcode:: D2I - Double to Int
2019
2056
 
2020
 
.. math::
2021
 
 
2022
 
   dst.x = int(src0.xy)
2023
 
 
2024
 
   dst.y = int(src0.zw)
 
2057
   .. math::
 
2058
 
 
2059
      dst.x = int(src0.xy)
 
2060
 
 
2061
      dst.y = int(src0.zw)
2025
2062
 
2026
2063
.. opcode:: U2D - Unsigned Int to Double
2027
2064
 
2028
 
.. math::
2029
 
 
2030
 
   dst.xy = double(src0.x)
2031
 
 
2032
 
   dst.zw = double(src0.y)
 
2065
   .. math::
 
2066
 
 
2067
      dst.xy = double(src0.x)
 
2068
 
 
2069
      dst.zw = double(src0.y)
2033
2070
 
2034
2071
.. opcode:: D2U - Double to Unsigned Int
2035
2072
 
2036
 
.. math::
2037
 
 
2038
 
   dst.x = unsigned(src0.xy)
2039
 
 
2040
 
   dst.y = unsigned(src0.zw)
 
2073
   .. math::
 
2074
 
 
2075
      dst.x = unsigned(src0.xy)
 
2076
 
 
2077
      dst.y = unsigned(src0.zw)
2041
2078
 
2042
2079
64-bit Integer ISA
2043
2080
^^^^^^^^^^^^^^^^^^
2047
2084
 
2048
2085
.. opcode:: I64ABS - 64-bit Integer Absolute Value
2049
2086
 
2050
 
.. math::
2051
 
 
2052
 
  dst.xy = |src0.xy|
2053
 
 
2054
 
  dst.zw = |src0.zw|
 
2087
   .. math::
 
2088
 
 
2089
      dst.xy = |src0.xy|
 
2090
 
 
2091
      dst.zw = |src0.zw|
2055
2092
 
2056
2093
.. opcode:: I64NEG - 64-bit Integer Negate
2057
2094
 
2058
 
  Two's complement.
2059
 
 
2060
 
.. math::
2061
 
 
2062
 
  dst.xy = -src.xy
2063
 
 
2064
 
  dst.zw = -src.zw
 
2095
   Two's complement.
 
2096
 
 
2097
   .. math::
 
2098
 
 
2099
      dst.xy = -src.xy
 
2100
 
 
2101
      dst.zw = -src.zw
2065
2102
 
2066
2103
.. opcode:: I64SSG - 64-bit Integer Set Sign
2067
2104
 
2068
 
.. math::
2069
 
 
2070
 
  dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
2071
 
 
2072
 
  dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
 
2105
   .. math::
 
2106
 
 
2107
      dst.xy = (src0.xy < 0) ? -1 : (src0.xy > 0) ? 1 : 0
 
2108
 
 
2109
      dst.zw = (src0.zw < 0) ? -1 : (src0.zw > 0) ? 1 : 0
2073
2110
 
2074
2111
.. opcode:: U64ADD - 64-bit Integer Add
2075
2112
 
2076
 
.. math::
2077
 
 
2078
 
  dst.xy = src0.xy + src1.xy
2079
 
 
2080
 
  dst.zw = src0.zw + src1.zw
 
2113
   .. math::
 
2114
 
 
2115
      dst.xy = src0.xy + src1.xy
 
2116
 
 
2117
      dst.zw = src0.zw + src1.zw
2081
2118
 
2082
2119
.. opcode:: U64MUL - 64-bit Integer Multiply
2083
2120
 
2084
 
.. math::
2085
 
 
2086
 
  dst.xy = src0.xy * src1.xy
2087
 
 
2088
 
  dst.zw = src0.zw * src1.zw
 
2121
   .. math::
 
2122
 
 
2123
      dst.xy = src0.xy * src1.xy
 
2124
 
 
2125
      dst.zw = src0.zw * src1.zw
2089
2126
 
2090
2127
.. opcode:: U64SEQ - 64-bit Integer Set on Equal
2091
2128
 
2092
 
.. math::
2093
 
 
2094
 
  dst.x = src0.xy == src1.xy ? \sim 0 : 0
2095
 
 
2096
 
  dst.z = src0.zw == src1.zw ? \sim 0 : 0
 
2129
   .. math::
 
2130
 
 
2131
      dst.x = src0.xy == src1.xy ? \sim 0 : 0
 
2132
 
 
2133
      dst.z = src0.zw == src1.zw ? \sim 0 : 0
2097
2134
 
2098
2135
.. opcode:: U64SNE - 64-bit Integer Set on Not Equal
2099
2136
 
2100
 
.. math::
2101
 
 
2102
 
  dst.x = src0.xy != src1.xy ? \sim 0 : 0
2103
 
 
2104
 
  dst.z = src0.zw != src1.zw ? \sim 0 : 0
 
2137
   .. math::
 
2138
 
 
2139
      dst.x = src0.xy != src1.xy ? \sim 0 : 0
 
2140
 
 
2141
      dst.z = src0.zw != src1.zw ? \sim 0 : 0
2105
2142
 
2106
2143
.. opcode:: U64SLT - 64-bit Unsigned Integer Set on Less Than
2107
2144
 
2108
 
.. math::
2109
 
 
2110
 
  dst.x = src0.xy < src1.xy ? \sim 0 : 0
2111
 
 
2112
 
  dst.z = src0.zw < src1.zw ? \sim 0 : 0
 
2145
   .. math::
 
2146
 
 
2147
      dst.x = src0.xy < src1.xy ? \sim 0 : 0
 
2148
 
 
2149
      dst.z = src0.zw < src1.zw ? \sim 0 : 0
2113
2150
 
2114
2151
.. opcode:: U64SGE - 64-bit Unsigned Integer Set on Greater Equal
2115
2152
 
2116
 
.. math::
2117
 
 
2118
 
  dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2119
 
 
2120
 
  dst.z = src0.zw >= src1.zw ? \sim 0 : 0
 
2153
   .. math::
 
2154
 
 
2155
      dst.x = src0.xy >= src1.xy ? \sim 0 : 0
 
2156
 
 
2157
      dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2121
2158
 
2122
2159
.. opcode:: I64SLT - 64-bit Signed Integer Set on Less Than
2123
2160
 
2124
 
.. math::
2125
 
 
2126
 
  dst.x = src0.xy < src1.xy ? \sim 0 : 0
2127
 
 
2128
 
  dst.z = src0.zw < src1.zw ? \sim 0 : 0
 
2161
   .. math::
 
2162
 
 
2163
      dst.x = src0.xy < src1.xy ? \sim 0 : 0
 
2164
 
 
2165
      dst.z = src0.zw < src1.zw ? \sim 0 : 0
2129
2166
 
2130
2167
.. opcode:: I64SGE - 64-bit Signed Integer Set on Greater Equal
2131
2168
 
2132
 
.. math::
2133
 
 
2134
 
  dst.x = src0.xy >= src1.xy ? \sim 0 : 0
2135
 
 
2136
 
  dst.z = src0.zw >= src1.zw ? \sim 0 : 0
 
2169
   .. math::
 
2170
 
 
2171
      dst.x = src0.xy >= src1.xy ? \sim 0 : 0
 
2172
 
 
2173
      dst.z = src0.zw >= src1.zw ? \sim 0 : 0
2137
2174
 
2138
2175
.. opcode:: I64MIN - Minimum of 64-bit Signed Integers
2139
2176
 
2140
 
.. math::
2141
 
 
2142
 
  dst.xy = min(src0.xy, src1.xy)
2143
 
 
2144
 
  dst.zw = min(src0.zw, src1.zw)
 
2177
   .. math::
 
2178
 
 
2179
      dst.xy = min(src0.xy, src1.xy)
 
2180
 
 
2181
      dst.zw = min(src0.zw, src1.zw)
2145
2182
 
2146
2183
.. opcode:: U64MIN - Minimum of 64-bit Unsigned Integers
2147
2184
 
2148
 
.. math::
2149
 
 
2150
 
  dst.xy = min(src0.xy, src1.xy)
2151
 
 
2152
 
  dst.zw = min(src0.zw, src1.zw)
 
2185
   .. math::
 
2186
 
 
2187
      dst.xy = min(src0.xy, src1.xy)
 
2188
 
 
2189
      dst.zw = min(src0.zw, src1.zw)
2153
2190
 
2154
2191
.. opcode:: I64MAX - Maximum of 64-bit Signed Integers
2155
2192
 
2156
 
.. math::
2157
 
 
2158
 
  dst.xy = max(src0.xy, src1.xy)
2159
 
 
2160
 
  dst.zw = max(src0.zw, src1.zw)
 
2193
   .. math::
 
2194
 
 
2195
      dst.xy = max(src0.xy, src1.xy)
 
2196
 
 
2197
      dst.zw = max(src0.zw, src1.zw)
2161
2198
 
2162
2199
.. opcode:: U64MAX - Maximum of 64-bit Unsigned Integers
2163
2200
 
2164
 
.. math::
2165
 
 
2166
 
  dst.xy = max(src0.xy, src1.xy)
2167
 
 
2168
 
  dst.zw = max(src0.zw, src1.zw)
 
2201
   .. math::
 
2202
 
 
2203
      dst.xy = max(src0.xy, src1.xy)
 
2204
 
 
2205
      dst.zw = max(src0.zw, src1.zw)
2169
2206
 
2170
2207
.. opcode:: U64SHL - Shift Left 64-bit Unsigned Integer
2171
2208
 
2172
2209
   The shift count is masked with ``0x3f`` before the shift is applied.
2173
2210
 
2174
 
.. math::
2175
 
 
2176
 
  dst.xy = src0.xy << (0x3f \& src1.x)
2177
 
 
2178
 
  dst.zw = src0.zw << (0x3f \& src1.y)
 
2211
   .. math::
 
2212
 
 
2213
      dst.xy = src0.xy \ll (0x3f \& src1.x)
 
2214
 
 
2215
      dst.zw = src0.zw \ll (0x3f \& src1.y)
2179
2216
 
2180
2217
.. opcode:: I64SHR - Arithmetic Shift Right (of 64-bit Signed Integer)
2181
2218
 
2182
2219
   The shift count is masked with ``0x3f`` before the shift is applied.
2183
2220
 
2184
 
.. math::
2185
 
 
2186
 
  dst.xy = src0.xy >> (0x3f \& src1.x)
2187
 
 
2188
 
  dst.zw = src0.zw >> (0x3f \& src1.y)
 
2221
   .. math::
 
2222
 
 
2223
      dst.xy = src0.xy \gg (0x3f \& src1.x)
 
2224
 
 
2225
      dst.zw = src0.zw \gg (0x3f \& src1.y)
2189
2226
 
2190
2227
.. opcode:: U64SHR - Logical Shift Right (of 64-bit Unsigned Integer)
2191
2228
 
2192
2229
   The shift count is masked with ``0x3f`` before the shift is applied.
2193
2230
 
2194
 
.. math::
2195
 
 
2196
 
  dst.xy = src0.xy >> (unsigned) (0x3f \& src1.x)
2197
 
 
2198
 
  dst.zw = src0.zw >> (unsigned) (0x3f \& src1.y)
 
2231
   .. math::
 
2232
 
 
2233
      dst.xy = src0.xy \gg (unsigned) (0x3f \& src1.x)
 
2234
 
 
2235
      dst.zw = src0.zw \gg (unsigned) (0x3f \& src1.y)
2199
2236
 
2200
2237
.. opcode:: I64DIV - 64-bit Signed Integer Division
2201
2238
 
2202
 
.. math::
2203
 
 
2204
 
  dst.xy = \frac{src0.xy}{src1.xy}
2205
 
 
2206
 
  dst.zw = \frac{src0.zw}{src1.zw}
 
2239
   .. math::
 
2240
 
 
2241
      dst.xy = \frac{src0.xy}{src1.xy}
 
2242
 
 
2243
      dst.zw = \frac{src0.zw}{src1.zw}
2207
2244
 
2208
2245
.. opcode:: U64DIV - 64-bit Unsigned Integer Division
2209
2246
 
2210
 
.. math::
2211
 
 
2212
 
  dst.xy = \frac{src0.xy}{src1.xy}
2213
 
 
2214
 
  dst.zw = \frac{src0.zw}{src1.zw}
 
2247
   .. math::
 
2248
 
 
2249
      dst.xy = \frac{src0.xy}{src1.xy}
 
2250
 
 
2251
      dst.zw = \frac{src0.zw}{src1.zw}
2215
2252
 
2216
2253
.. opcode:: U64MOD - 64-bit Unsigned Integer Remainder
2217
2254
 
2218
 
.. math::
2219
 
 
2220
 
  dst.xy = src0.xy \bmod src1.xy
2221
 
 
2222
 
  dst.zw = src0.zw \bmod src1.zw
 
2255
   .. math::
 
2256
 
 
2257
      dst.xy = src0.xy \bmod src1.xy
 
2258
 
 
2259
      dst.zw = src0.zw \bmod src1.zw
2223
2260
 
2224
2261
.. opcode:: I64MOD - 64-bit Signed Integer Remainder
2225
2262
 
2226
 
.. math::
2227
 
 
2228
 
  dst.xy = src0.xy \bmod src1.xy
2229
 
 
2230
 
  dst.zw = src0.zw \bmod src1.zw
 
2263
   .. math::
 
2264
 
 
2265
      dst.xy = src0.xy \bmod src1.xy
 
2266
 
 
2267
      dst.zw = src0.zw \bmod src1.zw
2231
2268
 
2232
2269
.. opcode:: F2U64 - Float to 64-bit Unsigned Int
2233
2270
 
2234
 
.. math::
2235
 
 
2236
 
   dst.xy = (uint64_t) src0.x
2237
 
 
2238
 
   dst.zw = (uint64_t) src0.y
 
2271
   .. math::
 
2272
 
 
2273
      dst.xy = (uint64_t) src0.x
 
2274
 
 
2275
      dst.zw = (uint64_t) src0.y
2239
2276
 
2240
2277
.. opcode:: F2I64 - Float to 64-bit Int
2241
2278
 
2242
 
.. math::
2243
 
 
2244
 
   dst.xy = (int64_t) src0.x
2245
 
 
2246
 
   dst.zw = (int64_t) src0.y
 
2279
   .. math::
 
2280
 
 
2281
      dst.xy = (int64_t) src0.x
 
2282
 
 
2283
      dst.zw = (int64_t) src0.y
2247
2284
 
2248
2285
.. opcode:: U2I64 - Unsigned Integer to 64-bit Integer
2249
2286
 
2250
2287
   This is a zero extension.
2251
2288
 
2252
 
.. math::
2253
 
 
2254
 
   dst.xy = (int64_t) src0.x
2255
 
 
2256
 
   dst.zw = (int64_t) src0.y
 
2289
   .. math::
 
2290
 
 
2291
      dst.xy = (int64_t) src0.x
 
2292
 
 
2293
      dst.zw = (int64_t) src0.y
2257
2294
 
2258
2295
.. opcode:: I2I64 - Signed Integer to 64-bit Integer
2259
2296
 
2260
2297
   This is a sign extension.
2261
2298
 
2262
 
.. math::
2263
 
 
2264
 
   dst.xy = (int64_t) src0.x
2265
 
 
2266
 
   dst.zw = (int64_t) src0.y
 
2299
   .. math::
 
2300
 
 
2301
      dst.xy = (int64_t) src0.x
 
2302
 
 
2303
      dst.zw = (int64_t) src0.y
2267
2304
 
2268
2305
.. opcode:: D2U64 - Double to 64-bit Unsigned Int
2269
2306
 
2270
 
.. math::
2271
 
 
2272
 
   dst.xy = (uint64_t) src0.xy
2273
 
 
2274
 
   dst.zw = (uint64_t) src0.zw
 
2307
   .. math::
 
2308
 
 
2309
      dst.xy = (uint64_t) src0.xy
 
2310
 
 
2311
      dst.zw = (uint64_t) src0.zw
2275
2312
 
2276
2313
.. opcode:: D2I64 - Double to 64-bit Int
2277
2314
 
2278
 
.. math::
2279
 
 
2280
 
   dst.xy = (int64_t) src0.xy
2281
 
 
2282
 
   dst.zw = (int64_t) src0.zw
 
2315
   .. math::
 
2316
 
 
2317
      dst.xy = (int64_t) src0.xy
 
2318
 
 
2319
      dst.zw = (int64_t) src0.zw
2283
2320
 
2284
2321
.. opcode:: U642F - 64-bit unsigned integer to float
2285
2322
 
2286
 
.. math::
2287
 
 
2288
 
   dst.x = (float) src0.xy
2289
 
 
2290
 
   dst.y = (float) src0.zw
 
2323
   .. math::
 
2324
 
 
2325
      dst.x = (float) src0.xy
 
2326
 
 
2327
      dst.y = (float) src0.zw
2291
2328
 
2292
2329
.. opcode:: I642F - 64-bit Int to Float
2293
2330
 
2294
 
.. math::
2295
 
 
2296
 
   dst.x = (float) src0.xy
2297
 
 
2298
 
   dst.y = (float) src0.zw
 
2331
   .. math::
 
2332
 
 
2333
      dst.x = (float) src0.xy
 
2334
 
 
2335
      dst.y = (float) src0.zw
2299
2336
 
2300
2337
.. opcode:: U642D - 64-bit unsigned integer to double
2301
2338
 
2302
 
.. math::
2303
 
 
2304
 
   dst.xy = (double) src0.xy
2305
 
 
2306
 
   dst.zw = (double) src0.zw
 
2339
   .. math::
 
2340
 
 
2341
      dst.xy = (double) src0.xy
 
2342
 
 
2343
      dst.zw = (double) src0.zw
2307
2344
 
2308
2345
.. opcode:: I642D - 64-bit Int to double
2309
2346
 
2310
 
.. math::
2311
 
 
2312
 
   dst.xy = (double) src0.xy
2313
 
 
2314
 
   dst.zw = (double) src0.zw
 
2347
   .. math::
 
2348
 
 
2349
      dst.xy = (double) src0.xy
 
2350
 
 
2351
      dst.zw = (double) src0.zw
2315
2352
 
2316
2353
.. _samplingopcodes:
2317
2354
 
2325
2362
 
2326
2363
.. opcode:: SAMPLE
2327
2364
 
2328
 
  Using provided address, sample data from the specified texture using the
2329
 
  filtering mode identified by the given sampler. The source data may come from
2330
 
  any resource type other than buffers.
2331
 
 
2332
 
  Syntax: ``SAMPLE dst, address, sampler_view, sampler``
2333
 
 
2334
 
  Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
 
2365
   Using provided address, sample data from the specified texture using the
 
2366
   filtering mode identified by the given sampler. The source data may come from
 
2367
   any resource type other than buffers.
 
2368
 
 
2369
   Syntax: ``SAMPLE dst, address, sampler_view, sampler``
 
2370
 
 
2371
   Example: ``SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]``
2335
2372
 
2336
2373
.. opcode:: SAMPLE_I
2337
2374
 
2338
 
  Simplified alternative to the SAMPLE instruction.  Using the provided
2339
 
  integer address, SAMPLE_I fetches data from the specified sampler view
2340
 
  without any filtering.  The source data may come from any resource type
2341
 
  other than CUBE.
2342
 
 
2343
 
  Syntax: ``SAMPLE_I dst, address, sampler_view``
2344
 
 
2345
 
  Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
2346
 
 
2347
 
  The 'address' is specified as unsigned integers. If the 'address' is out of
2348
 
  range [0...(# texels - 1)] the result of the fetch is always 0 in all
2349
 
  components.  As such the instruction doesn't honor address wrap modes, in
2350
 
  cases where that behavior is desirable 'SAMPLE' instruction should be used.
2351
 
  address.w always provides an unsigned integer mipmap level. If the value is
2352
 
  out of the range then the instruction always returns 0 in all components.
2353
 
  address.yz are ignored for buffers and 1d textures.  address.z is ignored
2354
 
  for 1d texture arrays and 2d textures.
2355
 
 
2356
 
  For 1D texture arrays address.y provides the array index (also as unsigned
2357
 
  integer). If the value is out of the range of available array indices
2358
 
  [0... (array size - 1)] then the opcode always returns 0 in all components.
2359
 
  For 2D texture arrays address.z provides the array index, otherwise it
2360
 
  exhibits the same behavior as in the case for 1D texture arrays.  The exact
2361
 
  semantics of the source address are presented in the table below:
2362
 
 
2363
 
  +---------------------------+----+-----+-----+---------+
2364
 
  | resource type             | X  |  Y  |  Z  |    W    |
2365
 
  +===========================+====+=====+=====+=========+
2366
 
  | ``PIPE_BUFFER``           | x  |     |     | ignored |
2367
 
  +---------------------------+----+-----+-----+---------+
2368
 
  | ``PIPE_TEXTURE_1D``       | x  |     |     |   mpl   |
2369
 
  +---------------------------+----+-----+-----+---------+
2370
 
  | ``PIPE_TEXTURE_2D``       | x  |  y  |     |   mpl   |
2371
 
  +---------------------------+----+-----+-----+---------+
2372
 
  | ``PIPE_TEXTURE_3D``       | x  |  y  |  z  |   mpl   |
2373
 
  +---------------------------+----+-----+-----+---------+
2374
 
  | ``PIPE_TEXTURE_RECT``     | x  |  y  |     |   mpl   |
2375
 
  +---------------------------+----+-----+-----+---------+
2376
 
  | ``PIPE_TEXTURE_CUBE``     | not allowed as source    |
2377
 
  +---------------------------+----+-----+-----+---------+
2378
 
  | ``PIPE_TEXTURE_1D_ARRAY`` | x  | idx |     |   mpl   |
2379
 
  +---------------------------+----+-----+-----+---------+
2380
 
  | ``PIPE_TEXTURE_2D_ARRAY`` | x  |  y  | idx |   mpl   |
2381
 
  +---------------------------+----+-----+-----+---------+
2382
 
 
2383
 
  Where 'mpl' is a mipmap level and 'idx' is the array index.
 
2375
   Simplified alternative to the SAMPLE instruction.  Using the provided
 
2376
   integer address, SAMPLE_I fetches data from the specified sampler view
 
2377
   without any filtering.  The source data may come from any resource type
 
2378
   other than CUBE.
 
2379
 
 
2380
   Syntax: ``SAMPLE_I dst, address, sampler_view``
 
2381
 
 
2382
   Example: ``SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]``
 
2383
 
 
2384
   The 'address' is specified as unsigned integers. If the 'address' is out of
 
2385
   range [0...(# texels - 1)] the result of the fetch is always 0 in all
 
2386
   components.  As such the instruction doesn't honor address wrap modes, in
 
2387
   cases where that behavior is desirable 'SAMPLE' instruction should be used.
 
2388
   address.w always provides an unsigned integer mipmap level. If the value is
 
2389
   out of the range then the instruction always returns 0 in all components.
 
2390
   address.yz are ignored for buffers and 1d textures.  address.z is ignored
 
2391
   for 1d texture arrays and 2d textures.
 
2392
 
 
2393
   For 1D texture arrays address.y provides the array index (also as unsigned
 
2394
   integer). If the value is out of the range of available array indices
 
2395
   [0... (array size - 1)] then the opcode always returns 0 in all components.
 
2396
   For 2D texture arrays address.z provides the array index, otherwise it
 
2397
   exhibits the same behavior as in the case for 1D texture arrays.  The exact
 
2398
   semantics of the source address are presented in the table below:
 
2399
 
 
2400
   +---------------------------+----+-----+-----+---------+
 
2401
   | resource type             | X  |  Y  |  Z  |    W    |
 
2402
   +===========================+====+=====+=====+=========+
 
2403
   | ``PIPE_BUFFER``           | x  |     |     | ignored |
 
2404
   +---------------------------+----+-----+-----+---------+
 
2405
   | ``PIPE_TEXTURE_1D``       | x  |     |     |   mpl   |
 
2406
   +---------------------------+----+-----+-----+---------+
 
2407
   | ``PIPE_TEXTURE_2D``       | x  |  y  |     |   mpl   |
 
2408
   +---------------------------+----+-----+-----+---------+
 
2409
   | ``PIPE_TEXTURE_3D``       | x  |  y  |  z  |   mpl   |
 
2410
   +---------------------------+----+-----+-----+---------+
 
2411
   | ``PIPE_TEXTURE_RECT``     | x  |  y  |     |   mpl   |
 
2412
   +---------------------------+----+-----+-----+---------+
 
2413
   | ``PIPE_TEXTURE_CUBE``     | not allowed as source    |
 
2414
   +---------------------------+----+-----+-----+---------+
 
2415
   | ``PIPE_TEXTURE_1D_ARRAY`` | x  | idx |     |   mpl   |
 
2416
   +---------------------------+----+-----+-----+---------+
 
2417
   | ``PIPE_TEXTURE_2D_ARRAY`` | x  |  y  | idx |   mpl   |
 
2418
   +---------------------------+----+-----+-----+---------+
 
2419
 
 
2420
   Where 'mpl' is a mipmap level and 'idx' is the array index.
2384
2421
 
2385
2422
.. opcode:: SAMPLE_I_MS
2386
2423
 
2387
 
  Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
 
2424
   Just like SAMPLE_I but allows fetch data from multi-sampled surfaces.
2388
2425
 
2389
 
  Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
 
2426
   Syntax: ``SAMPLE_I_MS dst, address, sampler_view, sample``
2390
2427
 
2391
2428
.. opcode:: SAMPLE_B
2392
2429
 
2393
 
  Just like the SAMPLE instruction with the exception that an additional bias
2394
 
  is applied to the level of detail computed as part of the instruction
2395
 
  execution.
2396
 
 
2397
 
  Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
2398
 
 
2399
 
  Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
 
2430
   Just like the SAMPLE instruction with the exception that an additional bias
 
2431
   is applied to the level of detail computed as part of the instruction
 
2432
   execution.
 
2433
 
 
2434
   Syntax: ``SAMPLE_B dst, address, sampler_view, sampler, lod_bias``
 
2435
 
 
2436
   Example: ``SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2400
2437
 
2401
2438
.. opcode:: SAMPLE_C
2402
2439
 
2403
 
  Similar to the SAMPLE instruction but it performs a comparison filter. The
2404
 
  operands to SAMPLE_C are identical to SAMPLE, except that there is an
2405
 
  additional float32 operand, reference value, which must be a register with
2406
 
  single-component, or a scalar literal.  SAMPLE_C makes the hardware use the
2407
 
  current samplers compare_func (in pipe_sampler_state) to compare reference
2408
 
  value against the red component value for the surce resource at each texel
2409
 
  that the currently configured texture filter covers based on the provided
2410
 
  coordinates.
2411
 
 
2412
 
  Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
2413
 
 
2414
 
  Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
 
2440
   Similar to the SAMPLE instruction but it performs a comparison filter. The
 
2441
   operands to SAMPLE_C are identical to SAMPLE, except that there is an
 
2442
   additional float32 operand, reference value, which must be a register with
 
2443
   single-component, or a scalar literal.  SAMPLE_C makes the hardware use the
 
2444
   current samplers compare_func (in pipe_sampler_state) to compare reference
 
2445
   value against the red component value for the source resource at each texel
 
2446
   that the currently configured texture filter covers based on the provided
 
2447
   coordinates.
 
2448
 
 
2449
   Syntax: ``SAMPLE_C dst, address, sampler_view.r, sampler, ref_value``
 
2450
 
 
2451
   Example: ``SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2415
2452
 
2416
2453
.. opcode:: SAMPLE_C_LZ
2417
2454
 
2418
 
  Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
2419
 
  for level-zero.
2420
 
 
2421
 
  Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
2422
 
 
2423
 
  Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
 
2455
   Same as SAMPLE_C, but LOD is 0 and derivatives are ignored. The LZ stands
 
2456
   for level-zero.
 
2457
 
 
2458
   Syntax: ``SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value``
 
2459
 
 
2460
   Example: ``SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x``
2424
2461
 
2425
2462
 
2426
2463
.. opcode:: SAMPLE_D
2427
2464
 
2428
 
  SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
2429
 
  the source address in the x direction and the y direction are provided by
2430
 
  extra parameters.
2431
 
 
2432
 
  Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
2433
 
 
2434
 
  Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
 
2465
   SAMPLE_D is identical to the SAMPLE opcode except that the derivatives for
 
2466
   the source address in the x direction and the y direction are provided by
 
2467
   extra parameters.
 
2468
 
 
2469
   Syntax: ``SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y``
 
2470
 
 
2471
   Example: ``SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]``
2435
2472
 
2436
2473
.. opcode:: SAMPLE_L
2437
2474
 
2438
 
  SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
2439
 
  directly as a scalar value, representing no anisotropy.
2440
 
 
2441
 
  Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
2442
 
 
2443
 
  Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
 
2475
   SAMPLE_L is identical to the SAMPLE opcode except that the LOD is provided
 
2476
   directly as a scalar value, representing no anisotropy.
 
2477
 
 
2478
   Syntax: ``SAMPLE_L dst, address, sampler_view, sampler, explicit_lod``
 
2479
 
 
2480
   Example: ``SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x``
2444
2481
 
2445
2482
.. opcode:: GATHER4
2446
2483
 
2447
 
  Gathers the four texels to be used in a bi-linear filtering operation and
2448
 
  packs them into a single register.  Only works with 2D, 2D array, cubemaps,
2449
 
  and cubemaps arrays.  For 2D textures, only the addressing modes of the
2450
 
  sampler and the top level of any mip pyramid are used. Set W to zero.  It
2451
 
  behaves like the SAMPLE instruction, but a filtered sample is not
2452
 
  generated. The four samples that contribute to filtering are placed into
2453
 
  XYZW in counter-clockwise order, starting with the (u,v) texture coordinate
2454
 
  delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
2455
 
  magnitude of the deltas are half a texel.
 
2484
   Gathers the four texels to be used in a bi-linear filtering operation and
 
2485
   packs them into a single register.  Only works with 2D, 2D array, cubemaps,
 
2486
   and cubemaps arrays.  For 2D textures, only the addressing modes of the
 
2487
   sampler and the top level of any mip pyramid are used. Set W to zero.  It
 
2488
   behaves like the SAMPLE instruction, but a filtered sample is not
 
2489
   generated. The four samples that contribute to filtering are placed into
 
2490
   XYZW in counter-clockwise order, starting with the (u,v) texture coordinate
 
2491
   delta at the following locations (-, +), (+, +), (+, -), (-, -), where the
 
2492
   magnitude of the deltas are half a texel.
2456
2493
 
2457
2494
 
2458
2495
.. opcode:: SVIEWINFO
2459
2496
 
2460
 
  Query the dimensions of a given sampler view.  dst receives width, height,
2461
 
  depth or array size and number of mipmap levels as int4. The dst can have a
2462
 
  writemask which will specify what info is the caller interested in.
2463
 
 
2464
 
  Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
2465
 
 
2466
 
  Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
2467
 
 
2468
 
  src_mip_level is an unsigned integer scalar. If it's out of range then
2469
 
  returns 0 for width, height and depth/array size but the total number of
2470
 
  mipmap is still returned correctly for the given sampler view.  The returned
2471
 
  width, height and depth values are for the mipmap level selected by the
2472
 
  src_mip_level and are in the number of texels.  For 1d texture array width
2473
 
  is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
2474
 
  still in dst.w.  In contrast to d3d10 resinfo, there's no way in the tgsi
2475
 
  instruction encoding to specify the return type (float/rcpfloat/uint), hence
2476
 
  always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
2477
 
  resinfo allowing swizzling dst values is ignored (due to the interaction
2478
 
  with rcpfloat modifier which requires some swizzle handling in the state
2479
 
  tracker anyway).
 
2497
   Query the dimensions of a given sampler view.  dst receives width, height,
 
2498
   depth or array size and number of mipmap levels as int4. The dst can have a
 
2499
   writemask which will specify what info is the caller interested in.
 
2500
 
 
2501
   Syntax: ``SVIEWINFO dst, src_mip_level, sampler_view``
 
2502
 
 
2503
   Example: ``SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]``
 
2504
 
 
2505
   src_mip_level is an unsigned integer scalar. If it's out of range then
 
2506
   returns 0 for width, height and depth/array size but the total number of
 
2507
   mipmap is still returned correctly for the given sampler view.  The returned
 
2508
   width, height and depth values are for the mipmap level selected by the
 
2509
   src_mip_level and are in the number of texels.  For 1d texture array width
 
2510
   is in dst.x, array size is in dst.y and dst.z is 0. The number of mipmaps is
 
2511
   still in dst.w.  In contrast to d3d10 resinfo, there's no way in the tgsi
 
2512
   instruction encoding to specify the return type (float/rcpfloat/uint), hence
 
2513
   always using uint. Also, unlike the SAMPLE instructions, the swizzle on src1
 
2514
   resinfo allowing swizzling dst values is ignored (due to the interaction
 
2515
   with rcpfloat modifier which requires some swizzle handling in the state
 
2516
   tracker anyway).
2480
2517
 
2481
2518
.. opcode:: SAMPLE_POS
2482
2519
 
2483
 
  Query the position of a sample in the given resource or render target
2484
 
  when per-sample fragment shading is in effect.
2485
 
 
2486
 
  Syntax: ``SAMPLE_POS dst, source, sample_index``
2487
 
 
2488
 
  dst receives float4 (x, y, undef, undef) indicated where the sample is
2489
 
  located. Sample locations are in the range [0, 1] where 0.5 is the center
2490
 
  of the fragment.
2491
 
 
2492
 
  source is either a sampler view (to indicate a shader resource) or temp
2493
 
  register (to indicate the render target).  The source register may have
2494
 
  an optional swizzle to apply to the returned result
2495
 
 
2496
 
  sample_index is an integer scalar indicating which sample position is to
2497
 
  be queried.
2498
 
 
2499
 
  If per-sample shading is not in effect or the source resource or render
2500
 
  target is not multisampled, the result is (0.5, 0.5, undef, undef).
2501
 
 
2502
 
  NOTE: no driver has implemented this opcode yet (and no gallium frontend
2503
 
  emits it).  This information is subject to change.
 
2520
   Query the position of a sample in the given resource or render target
 
2521
   when per-sample fragment shading is in effect.
 
2522
 
 
2523
   Syntax: ``SAMPLE_POS dst, source, sample_index``
 
2524
 
 
2525
   dst receives float4 (x, y, undef, undef) indicated where the sample is
 
2526
   located. Sample locations are in the range [0, 1] where 0.5 is the center
 
2527
   of the fragment.
 
2528
 
 
2529
   source is either a sampler view (to indicate a shader resource) or temp
 
2530
   register (to indicate the render target).  The source register may have
 
2531
   an optional swizzle to apply to the returned result
 
2532
 
 
2533
   sample_index is an integer scalar indicating which sample position is to
 
2534
   be queried.
 
2535
 
 
2536
   If per-sample shading is not in effect or the source resource or render
 
2537
   target is not multisampled, the result is (0.5, 0.5, undef, undef).
 
2538
 
 
2539
   NOTE: no driver has implemented this opcode yet (and no gallium frontend
 
2540
   emits it).  This information is subject to change.
2504
2541
 
2505
2542
.. opcode:: SAMPLE_INFO
2506
2543
 
2507
 
  Query the number of samples in a multisampled resource or render target.
2508
 
 
2509
 
  Syntax: ``SAMPLE_INFO dst, source``
2510
 
 
2511
 
  dst receives int4 (n, 0, 0, 0) where n is the number of samples in a
2512
 
  resource or the render target.
2513
 
 
2514
 
  source is either a sampler view (to indicate a shader resource) or temp
2515
 
  register (to indicate the render target).  The source register may have
2516
 
  an optional swizzle to apply to the returned result
2517
 
 
2518
 
  If per-sample shading is not in effect or the source resource or render
2519
 
  target is not multisampled, the result is (1, 0, 0, 0).
2520
 
 
2521
 
  NOTE: no driver has implemented this opcode yet (and no gallium frontend
2522
 
  emits it).  This information is subject to change.
 
2544
   Query the number of samples in a multisampled resource or render target.
 
2545
 
 
2546
   Syntax: ``SAMPLE_INFO dst, source``
 
2547
 
 
2548
   dst receives int4 (n, 0, 0, 0) where n is the number of samples in a
 
2549
   resource or the render target.
 
2550
 
 
2551
   source is either a sampler view (to indicate a shader resource) or temp
 
2552
   register (to indicate the render target).  The source register may have
 
2553
   an optional swizzle to apply to the returned result
 
2554
 
 
2555
   If per-sample shading is not in effect or the source resource or render
 
2556
   target is not multisampled, the result is (1, 0, 0, 0).
 
2557
 
 
2558
   NOTE: no driver has implemented this opcode yet (and no gallium frontend
 
2559
   emits it).  This information is subject to change.
2523
2560
 
2524
2561
.. opcode:: LOD - level of detail
2525
2562
 
2542
2579
 
2543
2580
.. opcode:: LOAD - Fetch data from a shader buffer or image
2544
2581
 
2545
 
               Syntax: ``LOAD dst, resource, address``
2546
 
 
2547
 
               Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
2548
 
 
2549
 
               Using the provided integer address, LOAD fetches data
2550
 
               from the specified buffer or texture without any
2551
 
               filtering.
2552
 
 
2553
 
               The 'address' is specified as a vector of unsigned
2554
 
               integers.  If the 'address' is out of range the result
2555
 
               is unspecified.
2556
 
 
2557
 
               Only the first mipmap level of a resource can be read
2558
 
               from using this instruction.
2559
 
 
2560
 
               For 1D or 2D texture arrays, the array index is
2561
 
               provided as an unsigned integer in address.y or
2562
 
               address.z, respectively.  address.yz are ignored for
2563
 
               buffers and 1D textures.  address.z is ignored for 1D
2564
 
               texture arrays and 2D textures.  address.w is always
2565
 
               ignored.
2566
 
 
2567
 
               A swizzle suffix may be added to the resource argument
2568
 
               this will cause the resource data to be swizzled accordingly.
 
2582
   Syntax: ``LOAD dst, resource, address``
 
2583
 
 
2584
   Example: ``LOAD TEMP[0], BUFFER[0], TEMP[1]``
 
2585
 
 
2586
   Using the provided integer address, LOAD fetches data from the
 
2587
   specified buffer or texture without any filtering.
 
2588
 
 
2589
   The 'address' is specified as a vector of unsigned integers.  If the
 
2590
   'address' is out of range the result is unspecified.
 
2591
 
 
2592
   Only the first mipmap level of a resource can be read from using this
 
2593
   instruction.
 
2594
 
 
2595
   For 1D or 2D texture arrays, the array index is provided as an
 
2596
   unsigned integer in address.y or address.z, respectively.  address.yz
 
2597
   are ignored for buffers and 1D textures.  address.z is ignored for 1D
 
2598
   texture arrays and 2D textures.  address.w is always ignored.
 
2599
 
 
2600
   A swizzle suffix may be added to the resource argument this will
 
2601
   cause the resource data to be swizzled accordingly.
2569
2602
 
2570
2603
.. opcode:: STORE - Write data to a shader resource
2571
2604
 
2572
 
               Syntax: ``STORE resource, address, src``
2573
 
 
2574
 
               Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
2575
 
 
2576
 
               Using the provided integer address, STORE writes data
2577
 
               to the specified buffer or texture.
2578
 
 
2579
 
               The 'address' is specified as a vector of unsigned
2580
 
               integers.  If the 'address' is out of range the result
2581
 
               is unspecified.
2582
 
 
2583
 
               Only the first mipmap level of a resource can be
2584
 
               written to using this instruction.
2585
 
 
2586
 
               For 1D or 2D texture arrays, the array index is
2587
 
               provided as an unsigned integer in address.y or
2588
 
               address.z, respectively.  address.yz are ignored for
2589
 
               buffers and 1D textures.  address.z is ignored for 1D
2590
 
               texture arrays and 2D textures.  address.w is always
2591
 
               ignored.
 
2605
   Syntax: ``STORE resource, address, src``
 
2606
 
 
2607
   Example: ``STORE BUFFER[0], TEMP[0], TEMP[1]``
 
2608
 
 
2609
   Using the provided integer address, STORE writes data to the
 
2610
   specified buffer or texture.
 
2611
 
 
2612
   The 'address' is specified as a vector of unsigned integers.  If the
 
2613
   'address' is out of range the result is unspecified.
 
2614
 
 
2615
   Only the first mipmap level of a resource can be written to using
 
2616
   this instruction.
 
2617
 
 
2618
   For 1D or 2D texture arrays, the array index is provided as an
 
2619
   unsigned integer in address.y or address.z, respectively.
 
2620
   address.yz are ignored for buffers and 1D textures.  address.z is
 
2621
   ignored for 1D texture arrays and 2D textures.  address.w is always
 
2622
   ignored.
2592
2623
 
2593
2624
.. opcode:: RESQ - Query information about a resource
2594
2625
 
2595
 
  Syntax: ``RESQ dst, resource``
2596
 
 
2597
 
  Example: ``RESQ TEMP[0], BUFFER[0]``
2598
 
 
2599
 
  Returns information about the buffer or image resource. For buffer
2600
 
  resources, the size (in bytes) is returned in the x component. For
2601
 
  image resources, .xyz will contain the width/height/layers of the
2602
 
  image, while .w will contain the number of samples for multi-sampled
2603
 
  images.
 
2626
   Syntax: ``RESQ dst, resource``
 
2627
 
 
2628
   Example: ``RESQ TEMP[0], BUFFER[0]``
 
2629
 
 
2630
   Returns information about the buffer or image resource. For buffer
 
2631
   resources, the size (in bytes) is returned in the x component. For
 
2632
   image resources, .xyz will contain the width/height/layers of the
 
2633
   image, while .w will contain the number of samples for multi-sampled
 
2634
   images.
2604
2635
 
2605
2636
.. opcode:: FBFETCH - Load data from framebuffer
2606
2637
 
2607
 
  Syntax: ``FBFETCH dst, output``
2608
 
 
2609
 
  Example: ``FBFETCH TEMP[0], OUT[0]``
2610
 
 
2611
 
  This is only valid on ``COLOR`` semantic outputs. Returns the color
2612
 
  of the current position in the framebuffer from before this fragment
2613
 
  shader invocation. May return the same value from multiple calls for
2614
 
  a particular output within a single invocation. Note that result may
2615
 
  be undefined if a fragment is drawn multiple times without a blend
2616
 
  barrier in between.
 
2638
   Syntax: ``FBFETCH dst, output``
 
2639
 
 
2640
   Example: ``FBFETCH TEMP[0], OUT[0]``
 
2641
 
 
2642
   This is only valid on ``COLOR`` semantic outputs. Returns the color
 
2643
   of the current position in the framebuffer from before this fragment
 
2644
   shader invocation. May return the same value from multiple calls for
 
2645
   a particular output within a single invocation. Note that result may
 
2646
   be undefined if a fragment is drawn multiple times without a blend
 
2647
   barrier in between.
2617
2648
 
2618
2649
 
2619
2650
.. _bindlessopcodes:
2626
2657
 
2627
2658
.. opcode:: IMG2HND - Get a bindless handle for a image
2628
2659
 
2629
 
  Syntax: ``IMG2HND dst, image``
2630
 
 
2631
 
  Example: ``IMG2HND TEMP[0], IMAGE[0]``
2632
 
 
2633
 
  Sets 'dst' to a bindless handle for 'image'.
 
2660
   Syntax: ``IMG2HND dst, image``
 
2661
 
 
2662
   Example: ``IMG2HND TEMP[0], IMAGE[0]``
 
2663
 
 
2664
   Sets 'dst' to a bindless handle for 'image'.
2634
2665
 
2635
2666
.. opcode:: SAMP2HND - Get a bindless handle for a sampler
2636
2667
 
2637
 
  Syntax: ``SAMP2HND dst, sampler``
2638
 
 
2639
 
  Example: ``SAMP2HND TEMP[0], SAMP[0]``
2640
 
 
2641
 
  Sets 'dst' to a bindless handle for 'sampler'.
 
2668
   Syntax: ``SAMP2HND dst, sampler``
 
2669
 
 
2670
   Example: ``SAMP2HND TEMP[0], SAMP[0]``
 
2671
 
 
2672
   Sets 'dst' to a bindless handle for 'sampler'.
2642
2673
 
2643
2674
 
2644
2675
.. _threadsyncopcodes:
2652
2683
 
2653
2684
.. opcode:: BARRIER - Thread group barrier
2654
2685
 
2655
 
  ``BARRIER``
 
2686
   ``BARRIER``
2656
2687
 
2657
 
  This opcode suspends the execution of the current thread until all
2658
 
  the remaining threads in the working group reach the same point of
2659
 
  the program.  Results are unspecified if any of the remaining
2660
 
  threads terminates or never reaches an executed BARRIER instruction.
 
2688
   This opcode suspends the execution of the current thread until all
 
2689
   the remaining threads in the working group reach the same point of
 
2690
   the program.  Results are unspecified if any of the remaining
 
2691
   threads terminates or never reaches an executed BARRIER instruction.
2661
2692
 
2662
2693
.. opcode:: MEMBAR - Memory barrier
2663
2694
 
2664
 
  ``MEMBAR type``
2665
 
 
2666
 
  This opcode waits for the completion of all memory accesses based on
2667
 
  the type passed in. The type is an immediate bitfield with the following
2668
 
  meaning:
2669
 
 
2670
 
  Bit 0: Shader storage buffers
2671
 
  Bit 1: Atomic buffers
2672
 
  Bit 2: Images
2673
 
  Bit 3: Shared memory
2674
 
  Bit 4: Thread group
2675
 
 
2676
 
  These may be passed in in any combination. An implementation is free to not
2677
 
  distinguish between these as it sees fit. However these map to all the
2678
 
  possibilities made available by GLSL.
 
2695
   ``MEMBAR type``
 
2696
 
 
2697
   This opcode waits for the completion of all memory accesses based on
 
2698
   the type passed in. The type is an immediate bitfield with the following
 
2699
   meaning:
 
2700
 
 
2701
   Bit 0: Shader storage buffers
 
2702
   Bit 1: Atomic buffers
 
2703
   Bit 2: Images
 
2704
   Bit 3: Shared memory
 
2705
   Bit 4: Thread group
 
2706
 
 
2707
   These may be passed in in any combination. An implementation is free to not
 
2708
   distinguish between these as it sees fit. However these map to all the
 
2709
   possibilities made available by GLSL.
2679
2710
 
2680
2711
.. _atomopcodes:
2681
2712
 
2695
2726
 
2696
2727
.. opcode:: ATOMUADD - Atomic integer addition
2697
2728
 
2698
 
  Syntax: ``ATOMUADD dst, resource, offset, src``
2699
 
 
2700
 
  Example: ``ATOMUADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2701
 
 
2702
 
  The following operation is performed atomically:
2703
 
 
2704
 
.. math::
2705
 
 
2706
 
  dst_x = resource[offset]
2707
 
 
2708
 
  resource[offset] = dst_x + src_x
 
2729
   Syntax: ``ATOMUADD dst, resource, offset, src``
 
2730
 
 
2731
   Example: ``ATOMUADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2732
 
 
2733
   The following operation is performed atomically:
 
2734
 
 
2735
   .. math::
 
2736
 
 
2737
      dst_x = resource[offset]
 
2738
 
 
2739
      resource[offset] = dst_x + src_x
2709
2740
 
2710
2741
 
2711
2742
.. opcode:: ATOMFADD - Atomic floating point addition
2712
2743
 
2713
 
  Syntax: ``ATOMFADD dst, resource, offset, src``
2714
 
 
2715
 
  Example: ``ATOMFADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2716
 
 
2717
 
  The following operation is performed atomically:
2718
 
 
2719
 
.. math::
2720
 
 
2721
 
  dst_x = resource[offset]
2722
 
 
2723
 
  resource[offset] = dst_x + src_x
 
2744
   Syntax: ``ATOMFADD dst, resource, offset, src``
 
2745
 
 
2746
   Example: ``ATOMFADD TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2747
 
 
2748
   The following operation is performed atomically:
 
2749
 
 
2750
   .. math::
 
2751
 
 
2752
      dst_x = resource[offset]
 
2753
 
 
2754
      resource[offset] = dst_x + src_x
2724
2755
 
2725
2756
 
2726
2757
.. opcode:: ATOMXCHG - Atomic exchange
2727
2758
 
2728
 
  Syntax: ``ATOMXCHG dst, resource, offset, src``
2729
 
 
2730
 
  Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2731
 
 
2732
 
  The following operation is performed atomically:
2733
 
 
2734
 
.. math::
2735
 
 
2736
 
  dst_x = resource[offset]
2737
 
 
2738
 
  resource[offset] = src_x
 
2759
   Syntax: ``ATOMXCHG dst, resource, offset, src``
 
2760
 
 
2761
   Example: ``ATOMXCHG TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2762
 
 
2763
   The following operation is performed atomically:
 
2764
 
 
2765
   .. math::
 
2766
 
 
2767
      dst_x = resource[offset]
 
2768
 
 
2769
      resource[offset] = src_x
2739
2770
 
2740
2771
 
2741
2772
.. opcode:: ATOMCAS - Atomic compare-and-exchange
2742
2773
 
2743
 
  Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
2744
 
 
2745
 
  Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
2746
 
 
2747
 
  The following operation is performed atomically:
2748
 
 
2749
 
.. math::
2750
 
 
2751
 
  dst_x = resource[offset]
2752
 
 
2753
 
  resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
 
2774
   Syntax: ``ATOMCAS dst, resource, offset, cmp, src``
 
2775
 
 
2776
   Example: ``ATOMCAS TEMP[0], BUFFER[0], TEMP[1], TEMP[2], TEMP[3]``
 
2777
 
 
2778
   The following operation is performed atomically:
 
2779
 
 
2780
   .. math::
 
2781
 
 
2782
      dst_x = resource[offset]
 
2783
 
 
2784
      resource[offset] = (dst_x == cmp_x ? src_x : dst_x)
2754
2785
 
2755
2786
 
2756
2787
.. opcode:: ATOMAND - Atomic bitwise And
2757
2788
 
2758
 
  Syntax: ``ATOMAND dst, resource, offset, src``
2759
 
 
2760
 
  Example: ``ATOMAND TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2761
 
 
2762
 
  The following operation is performed atomically:
2763
 
 
2764
 
.. math::
2765
 
 
2766
 
  dst_x = resource[offset]
2767
 
 
2768
 
  resource[offset] = dst_x \& src_x
 
2789
   Syntax: ``ATOMAND dst, resource, offset, src``
 
2790
 
 
2791
   Example: ``ATOMAND TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2792
 
 
2793
   The following operation is performed atomically:
 
2794
 
 
2795
   .. math::
 
2796
 
 
2797
      dst_x = resource[offset]
 
2798
 
 
2799
      resource[offset] = dst_x \& src_x
2769
2800
 
2770
2801
 
2771
2802
.. opcode:: ATOMOR - Atomic bitwise Or
2772
2803
 
2773
 
  Syntax: ``ATOMOR dst, resource, offset, src``
2774
 
 
2775
 
  Example: ``ATOMOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2776
 
 
2777
 
  The following operation is performed atomically:
2778
 
 
2779
 
.. math::
2780
 
 
2781
 
  dst_x = resource[offset]
2782
 
 
2783
 
  resource[offset] = dst_x | src_x
 
2804
   Syntax: ``ATOMOR dst, resource, offset, src``
 
2805
 
 
2806
   Example: ``ATOMOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2807
 
 
2808
   The following operation is performed atomically:
 
2809
 
 
2810
   .. math::
 
2811
 
 
2812
      dst_x = resource[offset]
 
2813
 
 
2814
      resource[offset] = dst_x | src_x
2784
2815
 
2785
2816
 
2786
2817
.. opcode:: ATOMXOR - Atomic bitwise Xor
2787
2818
 
2788
 
  Syntax: ``ATOMXOR dst, resource, offset, src``
2789
 
 
2790
 
  Example: ``ATOMXOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2791
 
 
2792
 
  The following operation is performed atomically:
2793
 
 
2794
 
.. math::
2795
 
 
2796
 
  dst_x = resource[offset]
2797
 
 
2798
 
  resource[offset] = dst_x \oplus src_x
 
2819
   Syntax: ``ATOMXOR dst, resource, offset, src``
 
2820
 
 
2821
   Example: ``ATOMXOR TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2822
 
 
2823
   The following operation is performed atomically:
 
2824
 
 
2825
   .. math::
 
2826
 
 
2827
      dst_x = resource[offset]
 
2828
 
 
2829
      resource[offset] = dst_x \oplus src_x
2799
2830
 
2800
2831
 
2801
2832
.. opcode:: ATOMUMIN - Atomic unsigned minimum
2802
2833
 
2803
 
  Syntax: ``ATOMUMIN dst, resource, offset, src``
2804
 
 
2805
 
  Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2806
 
 
2807
 
  The following operation is performed atomically:
2808
 
 
2809
 
.. math::
2810
 
 
2811
 
  dst_x = resource[offset]
2812
 
 
2813
 
  resource[offset] = (dst_x < src_x ? dst_x : src_x)
 
2834
   Syntax: ``ATOMUMIN dst, resource, offset, src``
 
2835
 
 
2836
   Example: ``ATOMUMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2837
 
 
2838
   The following operation is performed atomically:
 
2839
 
 
2840
   .. math::
 
2841
 
 
2842
      dst_x = resource[offset]
 
2843
 
 
2844
      resource[offset] = (dst_x < src_x ? dst_x : src_x)
2814
2845
 
2815
2846
 
2816
2847
.. opcode:: ATOMUMAX - Atomic unsigned maximum
2817
2848
 
2818
 
  Syntax: ``ATOMUMAX dst, resource, offset, src``
2819
 
 
2820
 
  Example: ``ATOMUMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2821
 
 
2822
 
  The following operation is performed atomically:
2823
 
 
2824
 
.. math::
2825
 
 
2826
 
  dst_x = resource[offset]
2827
 
 
2828
 
  resource[offset] = (dst_x > src_x ? dst_x : src_x)
 
2849
   Syntax: ``ATOMUMAX dst, resource, offset, src``
 
2850
 
 
2851
   Example: ``ATOMUMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2852
 
 
2853
   The following operation is performed atomically:
 
2854
 
 
2855
   .. math::
 
2856
 
 
2857
      dst_x = resource[offset]
 
2858
 
 
2859
      resource[offset] = (dst_x > src_x ? dst_x : src_x)
2829
2860
 
2830
2861
 
2831
2862
.. opcode:: ATOMIMIN - Atomic signed minimum
2832
2863
 
2833
 
  Syntax: ``ATOMIMIN dst, resource, offset, src``
2834
 
 
2835
 
  Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2836
 
 
2837
 
  The following operation is performed atomically:
2838
 
 
2839
 
.. math::
2840
 
 
2841
 
  dst_x = resource[offset]
2842
 
 
2843
 
  resource[offset] = (dst_x < src_x ? dst_x : src_x)
 
2864
   Syntax: ``ATOMIMIN dst, resource, offset, src``
 
2865
 
 
2866
   Example: ``ATOMIMIN TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2867
 
 
2868
   The following operation is performed atomically:
 
2869
 
 
2870
   .. math::
 
2871
 
 
2872
      dst_x = resource[offset]
 
2873
 
 
2874
      resource[offset] = (dst_x < src_x ? dst_x : src_x)
2844
2875
 
2845
2876
 
2846
2877
.. opcode:: ATOMIMAX - Atomic signed maximum
2847
2878
 
2848
 
  Syntax: ``ATOMIMAX dst, resource, offset, src``
2849
 
 
2850
 
  Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2851
 
 
2852
 
  The following operation is performed atomically:
2853
 
 
2854
 
.. math::
2855
 
 
2856
 
  dst_x = resource[offset]
2857
 
 
2858
 
  resource[offset] = (dst_x > src_x ? dst_x : src_x)
 
2879
   Syntax: ``ATOMIMAX dst, resource, offset, src``
 
2880
 
 
2881
   Example: ``ATOMIMAX TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2882
 
 
2883
   The following operation is performed atomically:
 
2884
 
 
2885
   .. math::
 
2886
 
 
2887
      dst_x = resource[offset]
 
2888
 
 
2889
      resource[offset] = (dst_x > src_x ? dst_x : src_x)
2859
2890
 
2860
2891
 
2861
2892
.. opcode:: ATOMINC_WRAP - Atomic increment + wrap around
2862
2893
 
2863
 
  Syntax: ``ATOMINC_WRAP dst, resource, offset, src``
2864
 
 
2865
 
  Example: ``ATOMINC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2866
 
 
2867
 
  The following operation is performed atomically:
2868
 
 
2869
 
.. math::
2870
 
 
2871
 
  dst_x = resource[offset] + 1
2872
 
 
2873
 
  resource[offset] = dst_x <= src_x ? dst_x : 0
 
2894
   Syntax: ``ATOMINC_WRAP dst, resource, offset, src``
 
2895
 
 
2896
   Example: ``ATOMINC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2897
 
 
2898
   The following operation is performed atomically:
 
2899
 
 
2900
   .. math::
 
2901
 
 
2902
      dst_x = resource[offset] + 1
 
2903
 
 
2904
      resource[offset] = dst_x <= src_x ? dst_x : 0
2874
2905
 
2875
2906
 
2876
2907
.. opcode:: ATOMDEC_WRAP - Atomic decrement + wrap around
2877
2908
 
2878
 
  Syntax: ``ATOMDEC_WRAP dst, resource, offset, src``
2879
 
 
2880
 
  Example: ``ATOMDEC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
2881
 
 
2882
 
  The following operation is performed atomically:
2883
 
 
2884
 
.. math::
2885
 
 
2886
 
  dst_x = resource[offset]
2887
 
 
2888
 
  resource[offset] = (dst_x > 0 && dst_x < src_x) ? dst_x - 1 : 0
2889
 
 
 
2909
   Syntax: ``ATOMDEC_WRAP dst, resource, offset, src``
 
2910
 
 
2911
   Example: ``ATOMDEC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
 
2912
 
 
2913
   The following operation is performed atomically:
 
2914
 
 
2915
   .. math::
 
2916
 
 
2917
      dst_x = resource[offset]
 
2918
 
 
2919
      resource[offset] =
 
2920
      \left\{
 
2921
      \begin{array}{ c l }
 
2922
         dst_x - 1 & \quad \textrm{if } dst_x \gt 0 \textrm{ and } dst_x \lt src_x \\
 
2923
         0         & \quad \textrm{otherwise}
 
2924
      \end{array}
 
2925
      \right.
2890
2926
 
2891
2927
.. _interlaneopcodes:
2892
2928
 
2900
2936
 
2901
2937
.. opcode:: VOTE_ANY - Value is set in any of the active invocations
2902
2938
 
2903
 
  Syntax: ``VOTE_ANY dst, value``
 
2939
   Syntax: ``VOTE_ANY dst, value``
2904
2940
 
2905
 
  Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
 
2941
   Example: ``VOTE_ANY TEMP[0].x, TEMP[1].x``
2906
2942
 
2907
2943
 
2908
2944
.. opcode:: VOTE_ALL - Value is set in all of the active invocations
2909
2945
 
2910
 
  Syntax: ``VOTE_ALL dst, value``
 
2946
   Syntax: ``VOTE_ALL dst, value``
2911
2947
 
2912
 
  Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
 
2948
   Example: ``VOTE_ALL TEMP[0].x, TEMP[1].x``
2913
2949
 
2914
2950
 
2915
2951
.. opcode:: VOTE_EQ - Value is the same in all of the active invocations
2916
2952
 
2917
 
  Syntax: ``VOTE_EQ dst, value``
 
2953
   Syntax: ``VOTE_EQ dst, value``
2918
2954
 
2919
 
  Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
 
2955
   Example: ``VOTE_EQ TEMP[0].x, TEMP[1].x``
2920
2956
 
2921
2957
 
2922
2958
.. opcode:: BALLOT - Lanemask of whether the value is set in each active
2923
2959
            invocation
2924
2960
 
2925
 
  Syntax: ``BALLOT dst, value``
2926
 
 
2927
 
  Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
2928
 
 
2929
 
  When the argument is a constant true, this produces a bitmask of active
2930
 
  invocations. In fragment shaders, this can include helper invocations
2931
 
  (invocations whose outputs and writes to memory are discarded, but which
2932
 
  are used to compute derivatives).
 
2961
   Syntax: ``BALLOT dst, value``
 
2962
 
 
2963
   Example: ``BALLOT TEMP[0].xy, TEMP[1].x``
 
2964
 
 
2965
   When the argument is a constant true, this produces a bitmask of active
 
2966
   invocations. In fragment shaders, this can include helper invocations
 
2967
   (invocations whose outputs and writes to memory are discarded, but which
 
2968
   are used to compute derivatives).
2933
2969
 
2934
2970
 
2935
2971
.. opcode:: READ_FIRST - Broadcast the value from the first active
2936
2972
            invocation to all active lanes
2937
2973
 
2938
 
  Syntax: ``READ_FIRST dst, value``
 
2974
   Syntax: ``READ_FIRST dst, value``
2939
2975
 
2940
 
  Example: ``READ_FIRST TEMP[0], TEMP[1]``
 
2976
   Example: ``READ_FIRST TEMP[0], TEMP[1]``
2941
2977
 
2942
2978
 
2943
2979
.. opcode:: READ_INVOC - Retrieve the value from the given invocation
2944
2980
            (need not be uniform)
2945
2981
 
2946
 
  Syntax: ``READ_INVOC dst, value, invocation``
2947
 
 
2948
 
  Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
2949
 
 
2950
 
  invocation.x controls the invocation number to read from for all channels.
2951
 
  The invocation number must be the same across all active invocations in a
2952
 
  sub-group; otherwise, the results are undefined.
 
2982
   Syntax: ``READ_INVOC dst, value, invocation``
 
2983
 
 
2984
   Example: ``READ_INVOC TEMP[0].xy, TEMP[1].xy, TEMP[2].x``
 
2985
 
 
2986
   invocation.x controls the invocation number to read from for all channels.
 
2987
   The invocation number must be the same across all active invocations in a
 
2988
   sub-group; otherwise, the results are undefined.
2953
2989
 
2954
2990
 
2955
2991
Explanation of symbols used
2960
2996
^^^^^^^^^^^^^^
2961
2997
 
2962
2998
 
2963
 
  :math:`|x|`       Absolute value of ``x``.
2964
 
 
2965
 
  :math:`\lceil x \rceil` Ceiling of ``x``.
2966
 
 
2967
 
  clamp(x,y,z)      Clamp x between y and z.
2968
 
                    (x < y) ? y : (x > z) ? z : x
2969
 
 
2970
 
  :math:`\lfloor x\rfloor` Floor of ``x``.
2971
 
 
2972
 
  :math:`\log_2{x}` Logarithm of ``x``, base 2.
2973
 
 
2974
 
  max(x,y)          Maximum of x and y.
2975
 
                    (x > y) ? x : y
2976
 
 
2977
 
  min(x,y)          Minimum of x and y.
2978
 
                    (x < y) ? x : y
2979
 
 
2980
 
  partialx(x)       Derivative of x relative to fragment's X.
2981
 
 
2982
 
  partialy(x)       Derivative of x relative to fragment's Y.
2983
 
 
2984
 
  pop()             Pop from stack.
2985
 
 
2986
 
  :math:`x^y`       ``x`` to the power ``y``.
2987
 
 
2988
 
  push(x)           Push x on stack.
2989
 
 
2990
 
  round(x)          Round x.
2991
 
 
2992
 
  trunc(x)          Truncate x, i.e. drop the fraction bits.
 
2999
   :math:`|x|`       Absolute value of ``x``.
 
3000
 
 
3001
   :math:`\lceil x \rceil` Ceiling of ``x``.
 
3002
 
 
3003
   clamp(x,y,z)      Clamp x between y and z.
 
3004
                     (x < y) ? y : (x > z) ? z : x
 
3005
 
 
3006
   :math:`\lfloor x\rfloor` Floor of ``x``.
 
3007
 
 
3008
   :math:`\log_2{x}` Logarithm of ``x``, base 2.
 
3009
 
 
3010
   max(x,y)          Maximum of x and y.
 
3011
                     (x > y) ? x : y
 
3012
 
 
3013
   min(x,y)          Minimum of x and y.
 
3014
                     (x < y) ? x : y
 
3015
 
 
3016
   partialx(x)       Derivative of x relative to fragment's X.
 
3017
 
 
3018
   partialy(x)       Derivative of x relative to fragment's Y.
 
3019
 
 
3020
   pop()             Pop from stack.
 
3021
 
 
3022
   :math:`x^y`       ``x`` to the power ``y``.
 
3023
 
 
3024
   push(x)           Push x on stack.
 
3025
 
 
3026
   round(x)          Round x.
 
3027
 
 
3028
   trunc(x)          Truncate x, i.e. drop the fraction bits.
2993
3029
 
2994
3030
 
2995
3031
Keywords
2996
3032
^^^^^^^^^^^^^
2997
3033
 
2998
3034
 
2999
 
  discard           Discard fragment.
3000
 
 
3001
 
  pc                Program counter.
3002
 
 
3003
 
  target            Label of target instruction.
 
3035
   discard           Discard fragment.
 
3036
 
 
3037
   pc                Program counter.
 
3038
 
 
3039
   target            Label of target instruction.
3004
3040
 
3005
3041
 
3006
3042
Other tokens
3720
3756
TES_PRIM_MODE
3721
3757
"""""""""""""
3722
3758
 
3723
 
This sets the tessellation primitive mode, one of ``PIPE_PRIM_TRIANGLES``,
3724
 
``PIPE_PRIM_QUADS``, or ``PIPE_PRIM_LINES``. (Unlike in GL, there is no
 
3759
This sets the tessellation primitive mode, one of ``MESA_PRIM_TRIANGLES``,
 
3760
``MESA_PRIM_QUADS``, or ``MESA_PRIM_LINES``. (Unlike in GL, there is no
3725
3761
separate isolines settings, the regular lines is assumed to mean isolines.)
3726
3762
 
3727
3763
TES_SPACING