• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2008 VMware, Inc.
4  * Copyright 2009-2010 VMware, Inc.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28 
29 #ifndef P_SHADER_TOKENS_H
30 #define P_SHADER_TOKENS_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 
37 struct tgsi_header
38 {
39    unsigned HeaderSize : 8;
40    unsigned BodySize   : 24;
41 };
42 
43 #define TGSI_PROCESSOR_FRAGMENT  0
44 #define TGSI_PROCESSOR_VERTEX    1
45 #define TGSI_PROCESSOR_GEOMETRY  2
46 #define TGSI_PROCESSOR_TESS_CTRL 3
47 #define TGSI_PROCESSOR_TESS_EVAL 4
48 #define TGSI_PROCESSOR_COMPUTE   5
49 
50 struct tgsi_processor
51 {
52    unsigned Processor  : 4;  /* TGSI_PROCESSOR_ */
53    unsigned Padding    : 28;
54 };
55 
56 #define TGSI_TOKEN_TYPE_DECLARATION    0
57 #define TGSI_TOKEN_TYPE_IMMEDIATE      1
58 #define TGSI_TOKEN_TYPE_INSTRUCTION    2
59 #define TGSI_TOKEN_TYPE_PROPERTY       3
60 
61 struct tgsi_token
62 {
63    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_x */
64    unsigned NrTokens   : 8;  /**< UINT */
65    unsigned Padding    : 20;
66 };
67 
68 enum tgsi_file_type {
69    TGSI_FILE_NULL                =0,
70    TGSI_FILE_CONSTANT            =1,
71    TGSI_FILE_INPUT               =2,
72    TGSI_FILE_OUTPUT              =3,
73    TGSI_FILE_TEMPORARY           =4,
74    TGSI_FILE_SAMPLER             =5,
75    TGSI_FILE_ADDRESS             =6,
76    TGSI_FILE_IMMEDIATE           =7,
77    TGSI_FILE_PREDICATE           =8,
78    TGSI_FILE_SYSTEM_VALUE        =9,
79    TGSI_FILE_IMAGE               =10,
80    TGSI_FILE_SAMPLER_VIEW        =11,
81    TGSI_FILE_BUFFER,
82    TGSI_FILE_MEMORY,
83    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
84 };
85 
86 
87 #define TGSI_WRITEMASK_NONE     0x00
88 #define TGSI_WRITEMASK_X        0x01
89 #define TGSI_WRITEMASK_Y        0x02
90 #define TGSI_WRITEMASK_XY       0x03
91 #define TGSI_WRITEMASK_Z        0x04
92 #define TGSI_WRITEMASK_XZ       0x05
93 #define TGSI_WRITEMASK_YZ       0x06
94 #define TGSI_WRITEMASK_XYZ      0x07
95 #define TGSI_WRITEMASK_W        0x08
96 #define TGSI_WRITEMASK_XW       0x09
97 #define TGSI_WRITEMASK_YW       0x0A
98 #define TGSI_WRITEMASK_XYW      0x0B
99 #define TGSI_WRITEMASK_ZW       0x0C
100 #define TGSI_WRITEMASK_XZW      0x0D
101 #define TGSI_WRITEMASK_YZW      0x0E
102 #define TGSI_WRITEMASK_XYZW     0x0F
103 
104 #define TGSI_INTERPOLATE_CONSTANT      0
105 #define TGSI_INTERPOLATE_LINEAR        1
106 #define TGSI_INTERPOLATE_PERSPECTIVE   2
107 #define TGSI_INTERPOLATE_COLOR         3 /* special color case for smooth/flat */
108 #define TGSI_INTERPOLATE_COUNT         4
109 
110 #define TGSI_INTERPOLATE_LOC_CENTER    0
111 #define TGSI_INTERPOLATE_LOC_CENTROID  1
112 #define TGSI_INTERPOLATE_LOC_SAMPLE    2
113 #define TGSI_INTERPOLATE_LOC_COUNT     3
114 
115 #define TGSI_CYLINDRICAL_WRAP_X (1 << 0)
116 #define TGSI_CYLINDRICAL_WRAP_Y (1 << 1)
117 #define TGSI_CYLINDRICAL_WRAP_Z (1 << 2)
118 #define TGSI_CYLINDRICAL_WRAP_W (1 << 3)
119 
120 enum tgsi_memory_type {
121    TGSI_MEMORY_TYPE_GLOBAL,         /* OpenCL global              */
122    TGSI_MEMORY_TYPE_SHARED,         /* OpenCL local / GLSL shared */
123    TGSI_MEMORY_TYPE_PRIVATE,        /* OpenCL private             */
124    TGSI_MEMORY_TYPE_INPUT,          /* OpenCL kernel input params */
125    TGSI_MEMORY_TYPE_COUNT,
126 };
127 
128 struct tgsi_declaration
129 {
130    unsigned Type        : 4;  /**< TGSI_TOKEN_TYPE_DECLARATION */
131    unsigned NrTokens    : 8;  /**< UINT */
132    unsigned File        : 4;  /**< one of TGSI_FILE_x */
133    unsigned UsageMask   : 4;  /**< bitmask of TGSI_WRITEMASK_x flags */
134    unsigned Dimension   : 1;  /**< any extra dimension info? */
135    unsigned Semantic    : 1;  /**< BOOL, any semantic info? */
136    unsigned Interpolate : 1;  /**< any interpolation info? */
137    unsigned Invariant   : 1;  /**< invariant optimization? */
138    unsigned Local       : 1;  /**< optimize as subroutine local variable? */
139    unsigned Array       : 1;  /**< extra array info? */
140    unsigned Atomic      : 1;  /**< atomic only? for TGSI_FILE_BUFFER */
141    unsigned MemType     : 2;  /**< TGSI_MEMORY_TYPE_x for TGSI_FILE_MEMORY */
142    unsigned Padding     : 3;
143 };
144 
145 struct tgsi_declaration_range
146 {
147    unsigned First   : 16; /**< UINT */
148    unsigned Last    : 16; /**< UINT */
149 };
150 
151 struct tgsi_declaration_dimension
152 {
153    unsigned Index2D:16; /**< UINT */
154    unsigned Padding:16;
155 };
156 
157 struct tgsi_declaration_interp
158 {
159    unsigned Interpolate : 4;   /**< one of TGSI_INTERPOLATE_x */
160    unsigned Location    : 2;   /**< one of TGSI_INTERPOLATE_LOC_x */
161    unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
162    unsigned Padding     : 22;
163 };
164 
165 #define TGSI_SEMANTIC_POSITION   0
166 #define TGSI_SEMANTIC_COLOR      1
167 #define TGSI_SEMANTIC_BCOLOR     2  /**< back-face color */
168 #define TGSI_SEMANTIC_FOG        3
169 #define TGSI_SEMANTIC_PSIZE      4
170 #define TGSI_SEMANTIC_GENERIC    5
171 #define TGSI_SEMANTIC_NORMAL     6
172 #define TGSI_SEMANTIC_FACE       7
173 #define TGSI_SEMANTIC_EDGEFLAG   8
174 #define TGSI_SEMANTIC_PRIMID     9
175 #define TGSI_SEMANTIC_INSTANCEID 10 /**< doesn't include start_instance */
176 #define TGSI_SEMANTIC_VERTEXID   11
177 #define TGSI_SEMANTIC_STENCIL    12
178 #define TGSI_SEMANTIC_CLIPDIST   13
179 #define TGSI_SEMANTIC_CLIPVERTEX 14
180 #define TGSI_SEMANTIC_GRID_SIZE  15 /**< grid size in blocks */
181 #define TGSI_SEMANTIC_BLOCK_ID   16 /**< id of the current block */
182 #define TGSI_SEMANTIC_BLOCK_SIZE 17 /**< block size in threads */
183 #define TGSI_SEMANTIC_THREAD_ID  18 /**< block-relative id of the current thread */
184 #define TGSI_SEMANTIC_TEXCOORD   19 /**< texture or sprite coordinates */
185 #define TGSI_SEMANTIC_PCOORD     20 /**< point sprite coordinate */
186 #define TGSI_SEMANTIC_VIEWPORT_INDEX 21 /**< viewport index */
187 #define TGSI_SEMANTIC_LAYER      22 /**< layer (rendertarget index) */
188 #define TGSI_SEMANTIC_CULLDIST   23
189 #define TGSI_SEMANTIC_SAMPLEID   24
190 #define TGSI_SEMANTIC_SAMPLEPOS  25
191 #define TGSI_SEMANTIC_SAMPLEMASK 26
192 #define TGSI_SEMANTIC_INVOCATIONID 27
193 #define TGSI_SEMANTIC_VERTEXID_NOBASE 28
194 #define TGSI_SEMANTIC_BASEVERTEX 29
195 #define TGSI_SEMANTIC_PATCH      30 /**< generic per-patch semantic */
196 #define TGSI_SEMANTIC_TESSCOORD  31 /**< coordinate being processed by tess */
197 #define TGSI_SEMANTIC_TESSOUTER  32 /**< outer tessellation levels */
198 #define TGSI_SEMANTIC_TESSINNER  33 /**< inner tessellation levels */
199 #define TGSI_SEMANTIC_VERTICESIN 34 /**< number of input vertices */
200 #define TGSI_SEMANTIC_HELPER_INVOCATION 35 /**< current invocation is helper */
201 #define TGSI_SEMANTIC_COUNT      36 /**< number of semantic values */
202 
203 struct tgsi_declaration_semantic
204 {
205    unsigned Name           : 8;  /**< one of TGSI_SEMANTIC_x */
206    unsigned Index          : 16; /**< UINT */
207    unsigned StreamX        : 2; /**< vertex stream (for GS output) */
208    unsigned StreamY        : 2;
209    unsigned StreamZ        : 2;
210    unsigned StreamW        : 2;
211 };
212 
213 struct tgsi_declaration_image {
214    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
215    unsigned Raw         : 1;
216    unsigned Writable    : 1;
217    unsigned Format      : 10; /**< one of PIPE_FORMAT_ */
218    unsigned Padding     : 12;
219 };
220 
221 enum tgsi_return_type {
222    TGSI_RETURN_TYPE_UNORM = 0,
223    TGSI_RETURN_TYPE_SNORM,
224    TGSI_RETURN_TYPE_SINT,
225    TGSI_RETURN_TYPE_UINT,
226    TGSI_RETURN_TYPE_FLOAT,
227    TGSI_RETURN_TYPE_COUNT
228 };
229 
230 struct tgsi_declaration_sampler_view {
231    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
232    unsigned ReturnTypeX : 6; /**< one of enum tgsi_return_type */
233    unsigned ReturnTypeY : 6; /**< one of enum tgsi_return_type */
234    unsigned ReturnTypeZ : 6; /**< one of enum tgsi_return_type */
235    unsigned ReturnTypeW : 6; /**< one of enum tgsi_return_type */
236 };
237 
238 struct tgsi_declaration_array {
239    unsigned ArrayID : 10;
240    unsigned Padding : 22;
241 };
242 
243 /*
244  * Special resources that don't need to be declared.  They map to the
245  * GLOBAL/LOCAL/PRIVATE/INPUT compute memory spaces.
246  */
247 #define TGSI_RESOURCE_GLOBAL	0x7fff
248 #define TGSI_RESOURCE_LOCAL	0x7ffe
249 #define TGSI_RESOURCE_PRIVATE	0x7ffd
250 #define TGSI_RESOURCE_INPUT	0x7ffc
251 
252 #define TGSI_IMM_FLOAT32   0
253 #define TGSI_IMM_UINT32    1
254 #define TGSI_IMM_INT32     2
255 #define TGSI_IMM_FLOAT64   3
256 
257 struct tgsi_immediate
258 {
259    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_IMMEDIATE */
260    unsigned NrTokens   : 14; /**< UINT */
261    unsigned DataType   : 4;  /**< one of TGSI_IMM_x */
262    unsigned Padding    : 10;
263 };
264 
265 union tgsi_immediate_data
266 {
267    float Float;
268    unsigned Uint;
269    int Int;
270 };
271 
272 #define TGSI_PROPERTY_GS_INPUT_PRIM          0
273 #define TGSI_PROPERTY_GS_OUTPUT_PRIM         1
274 #define TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES 2
275 #define TGSI_PROPERTY_FS_COORD_ORIGIN        3
276 #define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER  4
277 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5
278 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
279 #define TGSI_PROPERTY_VS_PROHIBIT_UCPS       7
280 #define TGSI_PROPERTY_GS_INVOCATIONS         8
281 #define TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION 9
282 #define TGSI_PROPERTY_TCS_VERTICES_OUT       10
283 #define TGSI_PROPERTY_TES_PRIM_MODE          11
284 #define TGSI_PROPERTY_TES_SPACING            12
285 #define TGSI_PROPERTY_TES_VERTEX_ORDER_CW    13
286 #define TGSI_PROPERTY_TES_POINT_MODE         14
287 #define TGSI_PROPERTY_NUM_CLIPDIST_ENABLED   15
288 #define TGSI_PROPERTY_NUM_CULLDIST_ENABLED   16
289 #define TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL 17
290 #define TGSI_PROPERTY_FS_POST_DEPTH_COVERAGE 18
291 #define TGSI_PROPERTY_NEXT_SHADER            19
292 #define TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH   20
293 #define TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT  21
294 #define TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH   22
295 #define TGSI_PROPERTY_MUL_ZERO_WINS          23
296 #define TGSI_PROPERTY_COUNT                  24
297 
298 struct tgsi_property {
299    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
300    unsigned NrTokens     : 8;  /**< UINT */
301    unsigned PropertyName : 8;  /**< one of TGSI_PROPERTY */
302    unsigned Padding      : 12;
303 };
304 
305 #define TGSI_FS_COORD_ORIGIN_UPPER_LEFT 0
306 #define TGSI_FS_COORD_ORIGIN_LOWER_LEFT 1
307 
308 #define TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 0
309 #define TGSI_FS_COORD_PIXEL_CENTER_INTEGER 1
310 
311 #define TGSI_FS_DEPTH_LAYOUT_NONE         0
312 #define TGSI_FS_DEPTH_LAYOUT_ANY          1
313 #define TGSI_FS_DEPTH_LAYOUT_GREATER      2
314 #define TGSI_FS_DEPTH_LAYOUT_LESS         3
315 #define TGSI_FS_DEPTH_LAYOUT_UNCHANGED    4
316 
317 
318 struct tgsi_property_data {
319    unsigned Data;
320 };
321 
322 /* TGSI opcodes.
323  *
324  * For more information on semantics of opcodes and
325  * which APIs are known to use which opcodes, see
326  * gallium/docs/source/tgsi.rst
327  */
328 /* VIRGLRENDERER specific - DON'T SYNC WITH MESA
329  * OR REMOVE OPCODES - FILL in and REWRITE tgsi_info
330  * accordingly.
331  */
332 #define TGSI_OPCODE_ARL                 0
333 #define TGSI_OPCODE_MOV                 1
334 #define TGSI_OPCODE_LIT                 2
335 #define TGSI_OPCODE_RCP                 3
336 #define TGSI_OPCODE_RSQ                 4
337 #define TGSI_OPCODE_EXP                 5
338 #define TGSI_OPCODE_LOG                 6
339 #define TGSI_OPCODE_MUL                 7
340 #define TGSI_OPCODE_ADD                 8
341 #define TGSI_OPCODE_DP3                 9
342 #define TGSI_OPCODE_DP4                 10
343 #define TGSI_OPCODE_DST                 11
344 #define TGSI_OPCODE_MIN                 12
345 #define TGSI_OPCODE_MAX                 13
346 #define TGSI_OPCODE_SLT                 14
347 #define TGSI_OPCODE_SGE                 15
348 #define TGSI_OPCODE_MAD                 16
349 #define TGSI_OPCODE_SUB                 17
350 #define TGSI_OPCODE_LRP                 18
351 #define TGSI_OPCODE_FMA                 19
352 #define TGSI_OPCODE_SQRT                20
353 #define TGSI_OPCODE_DP2A                21
354                                 /* gap */
355 #define TGSI_OPCODE_FRC                 24
356 #define TGSI_OPCODE_CLAMP               25
357 #define TGSI_OPCODE_FLR                 26
358 #define TGSI_OPCODE_ROUND               27
359 #define TGSI_OPCODE_EX2                 28
360 #define TGSI_OPCODE_LG2                 29
361 #define TGSI_OPCODE_POW                 30
362 #define TGSI_OPCODE_XPD                 31
363                                 /* gap */
364 #define TGSI_OPCODE_ABS                 33
365                                 /* gap */
366 #define TGSI_OPCODE_DPH                 35
367 #define TGSI_OPCODE_COS                 36
368 #define TGSI_OPCODE_DDX                 37
369 #define TGSI_OPCODE_DDY                 38
370 #define TGSI_OPCODE_KILL                39 /* unconditional */
371 #define TGSI_OPCODE_PK2H                40
372 #define TGSI_OPCODE_PK2US               41
373 #define TGSI_OPCODE_PK4B                42
374 #define TGSI_OPCODE_PK4UB               43
375                                 /* gap */
376 #define TGSI_OPCODE_SEQ                 45
377                                 /* gap */
378 #define TGSI_OPCODE_SGT                 47
379 #define TGSI_OPCODE_SIN                 48
380 #define TGSI_OPCODE_SLE                 49
381 #define TGSI_OPCODE_SNE                 50
382                                 /* gap */
383 #define TGSI_OPCODE_TEX                 52
384 #define TGSI_OPCODE_TXD                 53
385 #define TGSI_OPCODE_TXP                 54
386 #define TGSI_OPCODE_UP2H                55
387 #define TGSI_OPCODE_UP2US               56
388 #define TGSI_OPCODE_UP4B                57
389 #define TGSI_OPCODE_UP4UB               58
390                                 /* gap */
391 #define TGSI_OPCODE_ARR                 61
392                                 /* gap */
393 #define TGSI_OPCODE_CAL                 63
394 #define TGSI_OPCODE_RET                 64
395 #define TGSI_OPCODE_SSG                 65 /* SGN */
396 #define TGSI_OPCODE_CMP                 66
397 #define TGSI_OPCODE_SCS                 67
398 #define TGSI_OPCODE_TXB                 68
399 #define TGSI_OPCODE_FBFETCH             69
400 #define TGSI_OPCODE_DIV                 70
401 #define TGSI_OPCODE_DP2                 71
402 #define TGSI_OPCODE_TXL                 72
403 #define TGSI_OPCODE_BRK                 73
404 #define TGSI_OPCODE_IF                  74
405 #define TGSI_OPCODE_UIF                 75
406 #define TGSI_OPCODE_ELSE                77
407 #define TGSI_OPCODE_ENDIF               78
408 
409 #define TGSI_OPCODE_DDX_FINE            79
410 #define TGSI_OPCODE_DDY_FINE            80
411 
412 #define TGSI_OPCODE_PUSHA               81
413 #define TGSI_OPCODE_POPA                82
414 #define TGSI_OPCODE_CEIL                83
415 #define TGSI_OPCODE_I2F                 84
416 #define TGSI_OPCODE_NOT                 85
417 #define TGSI_OPCODE_TRUNC               86
418 #define TGSI_OPCODE_SHL                 87
419                                 /* gap */
420 #define TGSI_OPCODE_AND                 89
421 #define TGSI_OPCODE_OR                  90
422 #define TGSI_OPCODE_MOD                 91
423 #define TGSI_OPCODE_XOR                 92
424 #define TGSI_OPCODE_SAD                 93
425 #define TGSI_OPCODE_TXF                 94
426 #define TGSI_OPCODE_TXQ                 95
427 #define TGSI_OPCODE_CONT                96
428 #define TGSI_OPCODE_EMIT                97
429 #define TGSI_OPCODE_ENDPRIM             98
430 #define TGSI_OPCODE_BGNLOOP             99
431 #define TGSI_OPCODE_BGNSUB              100
432 #define TGSI_OPCODE_ENDLOOP             101
433 #define TGSI_OPCODE_ENDSUB              102
434 #define TGSI_OPCODE_TXQ_LZ              103 /* TXQ for mipmap level 0 */
435 #define TGSI_OPCODE_TXQS                104
436 #define TGSI_OPCODE_RESQ                105
437                                 /* gap */
438 #define TGSI_OPCODE_NOP                 107
439 
440 #define TGSI_OPCODE_FSEQ                108
441 #define TGSI_OPCODE_FSGE                109
442 #define TGSI_OPCODE_FSLT                110
443 #define TGSI_OPCODE_FSNE                111
444 
445 #define TGSI_OPCODE_MEMBAR              112
446 #define TGSI_OPCODE_CALLNZ              113
447                                 /* gap */
448 #define TGSI_OPCODE_BREAKC              115
449 #define TGSI_OPCODE_KILL_IF             116  /* conditional kill */
450 #define TGSI_OPCODE_END                 117  /* aka HALT */
451 #define TGSI_OPCODE_DFMA                118
452 #define TGSI_OPCODE_F2I                 119
453 #define TGSI_OPCODE_IDIV                120
454 #define TGSI_OPCODE_IMAX                121
455 #define TGSI_OPCODE_IMIN                122
456 #define TGSI_OPCODE_INEG                123
457 #define TGSI_OPCODE_ISGE                124
458 #define TGSI_OPCODE_ISHR                125
459 #define TGSI_OPCODE_ISLT                126
460 #define TGSI_OPCODE_F2U                 127
461 #define TGSI_OPCODE_U2F                 128
462 #define TGSI_OPCODE_UADD                129
463 #define TGSI_OPCODE_UDIV                130
464 #define TGSI_OPCODE_UMAD                131
465 #define TGSI_OPCODE_UMAX                132
466 #define TGSI_OPCODE_UMIN                133
467 #define TGSI_OPCODE_UMOD                134
468 #define TGSI_OPCODE_UMUL                135
469 #define TGSI_OPCODE_USEQ                136
470 #define TGSI_OPCODE_USGE                137
471 #define TGSI_OPCODE_USHR                138
472 #define TGSI_OPCODE_USLT                139
473 #define TGSI_OPCODE_USNE                140
474 #define TGSI_OPCODE_SWITCH              141
475 #define TGSI_OPCODE_CASE                142
476 #define TGSI_OPCODE_DEFAULT             143
477 #define TGSI_OPCODE_ENDSWITCH           144
478 
479 /* resource related opcodes */
480 #define TGSI_OPCODE_SAMPLE              145
481 #define TGSI_OPCODE_SAMPLE_I            146
482 #define TGSI_OPCODE_SAMPLE_I_MS         147
483 #define TGSI_OPCODE_SAMPLE_B            148
484 #define TGSI_OPCODE_SAMPLE_C            149
485 #define TGSI_OPCODE_SAMPLE_C_LZ         150
486 #define TGSI_OPCODE_SAMPLE_D            151
487 #define TGSI_OPCODE_SAMPLE_L            152
488 #define TGSI_OPCODE_GATHER4             153
489 #define TGSI_OPCODE_SVIEWINFO           154
490 #define TGSI_OPCODE_SAMPLE_POS          155
491 #define TGSI_OPCODE_SAMPLE_INFO         156
492 
493 #define TGSI_OPCODE_UARL                157
494 #define TGSI_OPCODE_UCMP                158
495 #define TGSI_OPCODE_IABS                159
496 #define TGSI_OPCODE_ISSG                160
497 
498 #define TGSI_OPCODE_LOAD                161
499 #define TGSI_OPCODE_STORE               162
500 
501 #define TGSI_OPCODE_MFENCE              163
502 #define TGSI_OPCODE_LFENCE              164
503 #define TGSI_OPCODE_SFENCE              165
504 #define TGSI_OPCODE_BARRIER             166
505 
506 #define TGSI_OPCODE_ATOMUADD            167
507 #define TGSI_OPCODE_ATOMXCHG            168
508 #define TGSI_OPCODE_ATOMCAS             169
509 #define TGSI_OPCODE_ATOMAND             170
510 #define TGSI_OPCODE_ATOMOR              171
511 #define TGSI_OPCODE_ATOMXOR             172
512 #define TGSI_OPCODE_ATOMUMIN            173
513 #define TGSI_OPCODE_ATOMUMAX            174
514 #define TGSI_OPCODE_ATOMIMIN            175
515 #define TGSI_OPCODE_ATOMIMAX            176
516 
517 /* to be used for shadow cube map compares */
518 #define TGSI_OPCODE_TEX2                177
519 #define TGSI_OPCODE_TXB2                178
520 #define TGSI_OPCODE_TXL2                179
521 
522 #define TGSI_OPCODE_IMUL_HI             180
523 #define TGSI_OPCODE_UMUL_HI             181
524 
525 #define TGSI_OPCODE_TG4                 182
526 
527 #define TGSI_OPCODE_LODQ                183
528 
529 #define TGSI_OPCODE_IBFE                184
530 #define TGSI_OPCODE_UBFE                185
531 #define TGSI_OPCODE_BFI                 186
532 #define TGSI_OPCODE_BREV                187
533 #define TGSI_OPCODE_POPC                188
534 #define TGSI_OPCODE_LSB                 189
535 #define TGSI_OPCODE_IMSB                190
536 #define TGSI_OPCODE_UMSB                191
537 
538 #define TGSI_OPCODE_INTERP_CENTROID     192
539 #define TGSI_OPCODE_INTERP_SAMPLE       193
540 #define TGSI_OPCODE_INTERP_OFFSET       194
541 
542 /* sm5 marked opcodes are supported in D3D11 optionally - also DMOV, DMOVC */
543 #define TGSI_OPCODE_F2D                 195 /* SM5 */
544 #define TGSI_OPCODE_D2F                 196
545 #define TGSI_OPCODE_DABS                197
546 #define TGSI_OPCODE_DNEG                198 /* SM5 */
547 #define TGSI_OPCODE_DADD                199 /* SM5 */
548 #define TGSI_OPCODE_DMUL                200 /* SM5 */
549 #define TGSI_OPCODE_DMAX                201 /* SM5 */
550 #define TGSI_OPCODE_DMIN                202 /* SM5 */
551 #define TGSI_OPCODE_DSLT                203 /* SM5 */
552 #define TGSI_OPCODE_DSGE                204 /* SM5 */
553 #define TGSI_OPCODE_DSEQ                205 /* SM5 */
554 #define TGSI_OPCODE_DSNE                206 /* SM5 */
555 #define TGSI_OPCODE_DRCP                207 /* eg, cayman */
556 #define TGSI_OPCODE_DSQRT               208 /* eg, cayman also has DRSQ */
557 #define TGSI_OPCODE_DMAD                209
558 #define TGSI_OPCODE_DFRAC               210 /* eg, cayman */
559 #define TGSI_OPCODE_DLDEXP              211 /* eg, cayman */
560 #define TGSI_OPCODE_DFRACEXP            212 /* eg, cayman */
561 #define TGSI_OPCODE_D2I                 213
562 #define TGSI_OPCODE_I2D                 214
563 #define TGSI_OPCODE_D2U                 215
564 #define TGSI_OPCODE_U2D                 216
565 #define TGSI_OPCODE_DRSQ                217 /* eg, cayman also has DRSQ */
566 #define TGSI_OPCODE_DTRUNC              218 /* nvc0 */
567 #define TGSI_OPCODE_DCEIL               219 /* nvc0 */
568 #define TGSI_OPCODE_DFLR                220 /* nvc0 */
569 #define TGSI_OPCODE_DROUND              221 /* nvc0 */
570 #define TGSI_OPCODE_DSSG                222
571 #define TGSI_OPCODE_DDIV                223
572 #define TGSI_OPCODE_CLOCK               224
573 #define TGSI_OPCODE_LAST                225
574 
575 /**
576  * Opcode is the operation code to execute. A given operation defines the
577  * semantics how the source registers (if any) are interpreted and what is
578  * written to the destination registers (if any) as a result of execution.
579  *
580  * NumDstRegs and NumSrcRegs is the number of destination and source registers,
581  * respectively. For a given operation code, those numbers are fixed and are
582  * present here only for convenience.
583  *
584  * Saturate controls how are final results in destination registers modified.
585  */
586 
587 /*
588  * VIRGLRENDERER specific -
589  * we no long keep this in sync with mesa, we had to increase the NrTokens
590  * as mesa can remove old opcodes, but the renderer cannot.
591  */
592 struct tgsi_instruction
593 {
594    unsigned Type       : 4;  /* TGSI_TOKEN_TYPE_INSTRUCTION */
595    unsigned NrTokens   : 9;  /* UINT */
596    unsigned Opcode     : 8;  /* TGSI_OPCODE_ */
597    unsigned Saturate   : 1;  /* BOOL */
598    unsigned NumDstRegs : 2;  /* UINT */
599    unsigned NumSrcRegs : 4;  /* UINT */
600    unsigned Label      : 1;
601    unsigned Texture    : 1;
602    unsigned Memory     : 1;
603    unsigned Precise    : 1;
604 };
605 
606 /*
607  * If tgsi_instruction::Label is TRUE, tgsi_instruction_label follows.
608  *
609  * If tgsi_instruction::Texture is TRUE, tgsi_instruction_texture follows.
610  *   if texture instruction has a number of offsets,
611  *   then tgsi_instruction::Texture::NumOffset of tgsi_texture_offset follow.
612  *
613  * Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
614  *
615  * Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
616  *
617  * tgsi_instruction::NrTokens contains the total number of words that make the
618  * instruction, including the instruction word.
619  */
620 
621 #define TGSI_SWIZZLE_X      0
622 #define TGSI_SWIZZLE_Y      1
623 #define TGSI_SWIZZLE_Z      2
624 #define TGSI_SWIZZLE_W      3
625 
626 struct tgsi_instruction_label
627 {
628    unsigned Label    : 24;   /* UINT */
629    unsigned Padding  : 8;
630 };
631 
632 #define TGSI_TEXTURE_BUFFER         0
633 #define TGSI_TEXTURE_1D             1
634 #define TGSI_TEXTURE_2D             2
635 #define TGSI_TEXTURE_3D             3
636 #define TGSI_TEXTURE_CUBE           4
637 #define TGSI_TEXTURE_RECT           5
638 #define TGSI_TEXTURE_SHADOW1D       6
639 #define TGSI_TEXTURE_SHADOW2D       7
640 #define TGSI_TEXTURE_SHADOWRECT     8
641 #define TGSI_TEXTURE_1D_ARRAY       9
642 #define TGSI_TEXTURE_2D_ARRAY       10
643 #define TGSI_TEXTURE_SHADOW1D_ARRAY 11
644 #define TGSI_TEXTURE_SHADOW2D_ARRAY 12
645 #define TGSI_TEXTURE_SHADOWCUBE     13
646 #define TGSI_TEXTURE_2D_MSAA        14
647 #define TGSI_TEXTURE_2D_ARRAY_MSAA  15
648 #define TGSI_TEXTURE_CUBE_ARRAY     16
649 #define TGSI_TEXTURE_SHADOWCUBE_ARRAY 17
650 #define TGSI_TEXTURE_UNKNOWN        18
651 #define TGSI_TEXTURE_COUNT          19
652 
653 struct tgsi_instruction_texture
654 {
655    unsigned Texture  : 8;    /* TGSI_TEXTURE_ */
656    unsigned NumOffsets : 4;
657    unsigned Padding : 20;
658 };
659 
660 /* for texture offsets in GLSL and DirectX.
661  * Generally these always come from TGSI_FILE_IMMEDIATE,
662  * however DX11 appears to have the capability to do
663  * non-constant texture offsets.
664  */
665 struct tgsi_texture_offset
666 {
667    int      Index    : 16;
668    unsigned File     : 4;  /**< one of TGSI_FILE_x */
669    unsigned SwizzleX : 2;  /* TGSI_SWIZZLE_x */
670    unsigned SwizzleY : 2;  /* TGSI_SWIZZLE_x */
671    unsigned SwizzleZ : 2;  /* TGSI_SWIZZLE_x */
672    unsigned Padding  : 6;
673 };
674 
675 /**
676  * File specifies the register array to access.
677  *
678  * Index specifies the element number of a register in the register file.
679  *
680  * If Indirect is TRUE, Index should be offset by the X component of the indirect
681  * register that follows. The register can be now fetched into local storage
682  * for further processing.
683  *
684  * If Negate is TRUE, all components of the fetched register are negated.
685  *
686  * The fetched register components are swizzled according to SwizzleX, SwizzleY,
687  * SwizzleZ and SwizzleW.
688  *
689  */
690 
691 struct tgsi_src_register
692 {
693    unsigned File        : 4;  /* TGSI_FILE_ */
694    unsigned Indirect    : 1;  /* BOOL */
695    unsigned Dimension   : 1;  /* BOOL */
696    int      Index       : 16; /* SINT */
697    unsigned SwizzleX    : 2;  /* TGSI_SWIZZLE_ */
698    unsigned SwizzleY    : 2;  /* TGSI_SWIZZLE_ */
699    unsigned SwizzleZ    : 2;  /* TGSI_SWIZZLE_ */
700    unsigned SwizzleW    : 2;  /* TGSI_SWIZZLE_ */
701    unsigned Absolute    : 1;    /* BOOL */
702    unsigned Negate      : 1;    /* BOOL */
703 };
704 
705 /**
706  * If tgsi_src_register::Indirect is TRUE, tgsi_ind_register follows.
707  *
708  * File, Index and Swizzle are handled the same as in tgsi_src_register.
709  *
710  * If ArrayID is zero the whole register file might be indirectly addressed,
711  * if not only the Declaration with this ArrayID is accessed by this operand.
712  *
713  */
714 
715 struct tgsi_ind_register
716 {
717    unsigned File    : 4;  /* TGSI_FILE_ */
718    int      Index   : 16; /* SINT */
719    unsigned Swizzle : 2;  /* TGSI_SWIZZLE_ */
720    unsigned ArrayID : 10; /* UINT */
721 };
722 
723 /**
724  * If tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
725  */
726 
727 struct tgsi_dimension
728 {
729    unsigned Indirect    : 1;  /* BOOL */
730    unsigned Dimension   : 1;  /* BOOL */
731    unsigned Padding     : 14;
732    int      Index       : 16; /* SINT */
733 };
734 
735 struct tgsi_dst_register
736 {
737    unsigned File        : 4;  /* TGSI_FILE_ */
738    unsigned WriteMask   : 4;  /* TGSI_WRITEMASK_ */
739    unsigned Indirect    : 1;  /* BOOL */
740    unsigned Dimension   : 1;  /* BOOL */
741    int      Index       : 16; /* SINT */
742    unsigned Padding     : 6;
743 };
744 
745 #define TGSI_MEMORY_COHERENT (1 << 0)
746 #define TGSI_MEMORY_RESTRICT (1 << 1)
747 #define TGSI_MEMORY_VOLATILE (1 << 2)
748 
749 /**
750  * Specifies the type of memory access to do for the LOAD/STORE instruction.
751  */
752 struct tgsi_instruction_memory
753 {
754    unsigned Qualifier : 3;  /* TGSI_MEMORY_ */
755    unsigned Texture   : 8;  /* only for images: TGSI_TEXTURE_ */
756    unsigned Format    : 10; /* only for images: PIPE_FORMAT_ */
757    unsigned Padding   : 11;
758 };
759 
760 #define TGSI_MEMBAR_SHADER_BUFFER (1 << 0)
761 #define TGSI_MEMBAR_ATOMIC_BUFFER (1 << 1)
762 #define TGSI_MEMBAR_SHADER_IMAGE  (1 << 2)
763 #define TGSI_MEMBAR_SHARED        (1 << 3)
764 #define TGSI_MEMBAR_THREAD_GROUP  (1 << 4)
765 
766 #ifdef __cplusplus
767 }
768 #endif
769 
770 #endif /* P_SHADER_TOKENS_H */
771