1 /**************************************************************************
2  *
3  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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_COMPUTE   3
47 
48 struct tgsi_processor
49 {
50    unsigned Processor  : 4;  /* TGSI_PROCESSOR_ */
51    unsigned Padding    : 28;
52 };
53 
54 #define TGSI_TOKEN_TYPE_DECLARATION    0
55 #define TGSI_TOKEN_TYPE_IMMEDIATE      1
56 #define TGSI_TOKEN_TYPE_INSTRUCTION    2
57 #define TGSI_TOKEN_TYPE_PROPERTY       3
58 
59 struct tgsi_token
60 {
61    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_x */
62    unsigned NrTokens   : 8;  /**< UINT */
63    unsigned Padding    : 20;
64 };
65 
66 enum tgsi_file_type {
67    TGSI_FILE_NULL                =0,
68    TGSI_FILE_CONSTANT            =1,
69    TGSI_FILE_INPUT               =2,
70    TGSI_FILE_OUTPUT              =3,
71    TGSI_FILE_TEMPORARY           =4,
72    TGSI_FILE_SAMPLER             =5,
73    TGSI_FILE_ADDRESS             =6,
74    TGSI_FILE_IMMEDIATE           =7,
75    TGSI_FILE_PREDICATE           =8,
76    TGSI_FILE_SYSTEM_VALUE        =9,
77    TGSI_FILE_IMMEDIATE_ARRAY     =10,
78    TGSI_FILE_TEMPORARY_ARRAY     =11,
79    TGSI_FILE_RESOURCE            =12,
80    TGSI_FILE_SAMPLER_VIEW        =13,
81    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
82 };
83 
84 
85 #define TGSI_WRITEMASK_NONE     0x00
86 #define TGSI_WRITEMASK_X        0x01
87 #define TGSI_WRITEMASK_Y        0x02
88 #define TGSI_WRITEMASK_XY       0x03
89 #define TGSI_WRITEMASK_Z        0x04
90 #define TGSI_WRITEMASK_XZ       0x05
91 #define TGSI_WRITEMASK_YZ       0x06
92 #define TGSI_WRITEMASK_XYZ      0x07
93 #define TGSI_WRITEMASK_W        0x08
94 #define TGSI_WRITEMASK_XW       0x09
95 #define TGSI_WRITEMASK_YW       0x0A
96 #define TGSI_WRITEMASK_XYW      0x0B
97 #define TGSI_WRITEMASK_ZW       0x0C
98 #define TGSI_WRITEMASK_XZW      0x0D
99 #define TGSI_WRITEMASK_YZW      0x0E
100 #define TGSI_WRITEMASK_XYZW     0x0F
101 
102 #define TGSI_INTERPOLATE_CONSTANT      0
103 #define TGSI_INTERPOLATE_LINEAR        1
104 #define TGSI_INTERPOLATE_PERSPECTIVE   2
105 #define TGSI_INTERPOLATE_COLOR         3 /* special color case for smooth/flat */
106 #define TGSI_INTERPOLATE_COUNT         4
107 
108 #define TGSI_CYLINDRICAL_WRAP_X (1 << 0)
109 #define TGSI_CYLINDRICAL_WRAP_Y (1 << 1)
110 #define TGSI_CYLINDRICAL_WRAP_Z (1 << 2)
111 #define TGSI_CYLINDRICAL_WRAP_W (1 << 3)
112 
113 struct tgsi_declaration
114 {
115    unsigned Type        : 4;  /**< TGSI_TOKEN_TYPE_DECLARATION */
116    unsigned NrTokens    : 8;  /**< UINT */
117    unsigned File        : 4;  /**< one of TGSI_FILE_x */
118    unsigned UsageMask   : 4;  /**< bitmask of TGSI_WRITEMASK_x flags */
119    unsigned Dimension   : 1;  /**< any extra dimension info? */
120    unsigned Semantic    : 1;  /**< BOOL, any semantic info? */
121    unsigned Interpolate : 1;  /**< any interpolation info? */
122    unsigned Invariant   : 1;  /**< invariant optimization? */
123    unsigned Local       : 1;  /**< optimize as subroutine local variable? */
124    unsigned Padding     : 7;
125 };
126 
127 struct tgsi_declaration_range
128 {
129    unsigned First   : 16; /**< UINT */
130    unsigned Last    : 16; /**< UINT */
131 };
132 
133 struct tgsi_declaration_dimension
134 {
135    unsigned Index2D:16; /**< UINT */
136    unsigned Padding:16;
137 };
138 
139 struct tgsi_declaration_interp
140 {
141    unsigned Interpolate : 4;   /**< one of TGSI_INTERPOLATE_x */
142    unsigned Centroid    : 1;   /**< centroid sampling? */
143    unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
144    unsigned Padding     : 23;
145 };
146 
147 #define TGSI_SEMANTIC_POSITION   0
148 #define TGSI_SEMANTIC_COLOR      1
149 #define TGSI_SEMANTIC_BCOLOR     2  /**< back-face color */
150 #define TGSI_SEMANTIC_FOG        3
151 #define TGSI_SEMANTIC_PSIZE      4
152 #define TGSI_SEMANTIC_GENERIC    5
153 #define TGSI_SEMANTIC_NORMAL     6
154 #define TGSI_SEMANTIC_FACE       7
155 #define TGSI_SEMANTIC_EDGEFLAG   8
156 #define TGSI_SEMANTIC_PRIMID     9
157 #define TGSI_SEMANTIC_INSTANCEID 10
158 #define TGSI_SEMANTIC_VERTEXID   11
159 #define TGSI_SEMANTIC_STENCIL    12
160 #define TGSI_SEMANTIC_CLIPDIST   13
161 #define TGSI_SEMANTIC_CLIPVERTEX 14
162 #define TGSI_SEMANTIC_GRID_SIZE  15 /**< grid size in blocks */
163 #define TGSI_SEMANTIC_BLOCK_ID   16 /**< id of the current block */
164 #define TGSI_SEMANTIC_BLOCK_SIZE 17 /**< block size in threads */
165 #define TGSI_SEMANTIC_THREAD_ID  18 /**< block-relative id of the current thread */
166 #define TGSI_SEMANTIC_COUNT      19 /**< number of semantic values */
167 
168 struct tgsi_declaration_semantic
169 {
170    unsigned Name           : 8;  /**< one of TGSI_SEMANTIC_x */
171    unsigned Index          : 16; /**< UINT */
172    unsigned Padding        : 8;
173 };
174 
175 struct tgsi_declaration_resource {
176    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
177    unsigned Raw         : 1;
178    unsigned Writable    : 1;
179    unsigned Padding     : 22;
180 };
181 
182 struct tgsi_declaration_sampler_view {
183    unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
184    unsigned ReturnTypeX : 6; /**< one of enum pipe_type */
185    unsigned ReturnTypeY : 6; /**< one of enum pipe_type */
186    unsigned ReturnTypeZ : 6; /**< one of enum pipe_type */
187    unsigned ReturnTypeW : 6; /**< one of enum pipe_type */
188 };
189 
190 /*
191  * Special resources that don't need to be declared.  They map to the
192  * GLOBAL/LOCAL/PRIVATE/INPUT compute memory spaces.
193  */
194 #define TGSI_RESOURCE_GLOBAL	0x7fff
195 #define TGSI_RESOURCE_LOCAL	0x7ffe
196 #define TGSI_RESOURCE_PRIVATE	0x7ffd
197 #define TGSI_RESOURCE_INPUT	0x7ffc
198 
199 #define TGSI_IMM_FLOAT32   0
200 #define TGSI_IMM_UINT32    1
201 #define TGSI_IMM_INT32     2
202 
203 struct tgsi_immediate
204 {
205    unsigned Type       : 4;  /**< TGSI_TOKEN_TYPE_IMMEDIATE */
206    unsigned NrTokens   : 14; /**< UINT */
207    unsigned DataType   : 4;  /**< one of TGSI_IMM_x */
208    unsigned Padding    : 10;
209 };
210 
211 union tgsi_immediate_data
212 {
213    float Float;
214    unsigned Uint;
215    int Int;
216 };
217 
218 #define TGSI_PROPERTY_GS_INPUT_PRIM          0
219 #define TGSI_PROPERTY_GS_OUTPUT_PRIM         1
220 #define TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES 2
221 #define TGSI_PROPERTY_FS_COORD_ORIGIN        3
222 #define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER  4
223 #define TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS 5
224 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
225 #define TGSI_PROPERTY_VS_PROHIBIT_UCPS       7
226 #define TGSI_PROPERTY_COUNT                  8
227 
228 struct tgsi_property {
229    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */
230    unsigned NrTokens     : 8;  /**< UINT */
231    unsigned PropertyName : 8;  /**< one of TGSI_PROPERTY */
232    unsigned Padding      : 12;
233 };
234 
235 #define TGSI_FS_COORD_ORIGIN_UPPER_LEFT 0
236 #define TGSI_FS_COORD_ORIGIN_LOWER_LEFT 1
237 
238 #define TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 0
239 #define TGSI_FS_COORD_PIXEL_CENTER_INTEGER 1
240 
241 #define TGSI_FS_DEPTH_LAYOUT_NONE         0
242 #define TGSI_FS_DEPTH_LAYOUT_ANY          1
243 #define TGSI_FS_DEPTH_LAYOUT_GREATER      2
244 #define TGSI_FS_DEPTH_LAYOUT_LESS         3
245 #define TGSI_FS_DEPTH_LAYOUT_UNCHANGED    4
246 
247 
248 struct tgsi_property_data {
249    unsigned Data;
250 };
251 
252 /* TGSI opcodes.
253  *
254  * For more information on semantics of opcodes and
255  * which APIs are known to use which opcodes, see
256  * gallium/docs/source/tgsi.rst
257  */
258 #define TGSI_OPCODE_ARL                 0
259 #define TGSI_OPCODE_MOV                 1
260 #define TGSI_OPCODE_LIT                 2
261 #define TGSI_OPCODE_RCP                 3
262 #define TGSI_OPCODE_RSQ                 4
263 #define TGSI_OPCODE_EXP                 5
264 #define TGSI_OPCODE_LOG                 6
265 #define TGSI_OPCODE_MUL                 7
266 #define TGSI_OPCODE_ADD                 8
267 #define TGSI_OPCODE_DP3                 9
268 #define TGSI_OPCODE_DP4                 10
269 #define TGSI_OPCODE_DST                 11
270 #define TGSI_OPCODE_MIN                 12
271 #define TGSI_OPCODE_MAX                 13
272 #define TGSI_OPCODE_SLT                 14
273 #define TGSI_OPCODE_SGE                 15
274 #define TGSI_OPCODE_MAD                 16
275 #define TGSI_OPCODE_SUB                 17
276 #define TGSI_OPCODE_LRP                 18
277 #define TGSI_OPCODE_CND                 19
278                                 /* gap */
279 #define TGSI_OPCODE_DP2A                21
280                                 /* gap */
281 #define TGSI_OPCODE_FRC                 24
282 #define TGSI_OPCODE_CLAMP               25
283 #define TGSI_OPCODE_FLR                 26
284 #define TGSI_OPCODE_ROUND               27
285 #define TGSI_OPCODE_EX2                 28
286 #define TGSI_OPCODE_LG2                 29
287 #define TGSI_OPCODE_POW                 30
288 #define TGSI_OPCODE_XPD                 31
289                                 /* gap */
290 #define TGSI_OPCODE_ABS                 33
291 #define TGSI_OPCODE_RCC                 34
292 #define TGSI_OPCODE_DPH                 35
293 #define TGSI_OPCODE_COS                 36
294 #define TGSI_OPCODE_DDX                 37
295 #define TGSI_OPCODE_DDY                 38
296 #define TGSI_OPCODE_KILP                39  /* predicated kill */
297 #define TGSI_OPCODE_PK2H                40
298 #define TGSI_OPCODE_PK2US               41
299 #define TGSI_OPCODE_PK4B                42
300 #define TGSI_OPCODE_PK4UB               43
301 #define TGSI_OPCODE_RFL                 44
302 #define TGSI_OPCODE_SEQ                 45
303 #define TGSI_OPCODE_SFL                 46
304 #define TGSI_OPCODE_SGT                 47
305 #define TGSI_OPCODE_SIN                 48
306 #define TGSI_OPCODE_SLE                 49
307 #define TGSI_OPCODE_SNE                 50
308 #define TGSI_OPCODE_STR                 51
309 #define TGSI_OPCODE_TEX                 52
310 #define TGSI_OPCODE_TXD                 53
311 #define TGSI_OPCODE_TXP                 54
312 #define TGSI_OPCODE_UP2H                55
313 #define TGSI_OPCODE_UP2US               56
314 #define TGSI_OPCODE_UP4B                57
315 #define TGSI_OPCODE_UP4UB               58
316 #define TGSI_OPCODE_X2D                 59
317 #define TGSI_OPCODE_ARA                 60
318 #define TGSI_OPCODE_ARR                 61
319 #define TGSI_OPCODE_BRA                 62
320 #define TGSI_OPCODE_CAL                 63
321 #define TGSI_OPCODE_RET                 64
322 #define TGSI_OPCODE_SSG                 65 /* SGN */
323 #define TGSI_OPCODE_CMP                 66
324 #define TGSI_OPCODE_SCS                 67
325 #define TGSI_OPCODE_TXB                 68
326 #define TGSI_OPCODE_NRM                 69
327 #define TGSI_OPCODE_DIV                 70
328 #define TGSI_OPCODE_DP2                 71
329 #define TGSI_OPCODE_TXL                 72
330 #define TGSI_OPCODE_BRK                 73
331 #define TGSI_OPCODE_IF                  74
332                                 /* gap */
333 #define TGSI_OPCODE_ELSE                77
334 #define TGSI_OPCODE_ENDIF               78
335                                 /* gap */
336 #define TGSI_OPCODE_PUSHA               81
337 #define TGSI_OPCODE_POPA                82
338 #define TGSI_OPCODE_CEIL                83
339 #define TGSI_OPCODE_I2F                 84
340 #define TGSI_OPCODE_NOT                 85
341 #define TGSI_OPCODE_TRUNC               86
342 #define TGSI_OPCODE_SHL                 87
343                                 /* gap */
344 #define TGSI_OPCODE_AND                 89
345 #define TGSI_OPCODE_OR                  90
346 #define TGSI_OPCODE_MOD                 91
347 #define TGSI_OPCODE_XOR                 92
348 #define TGSI_OPCODE_SAD                 93
349 #define TGSI_OPCODE_TXF                 94
350 #define TGSI_OPCODE_TXQ                 95
351 #define TGSI_OPCODE_CONT                96
352 #define TGSI_OPCODE_EMIT                97
353 #define TGSI_OPCODE_ENDPRIM             98
354 #define TGSI_OPCODE_BGNLOOP             99
355 #define TGSI_OPCODE_BGNSUB              100
356 #define TGSI_OPCODE_ENDLOOP             101
357 #define TGSI_OPCODE_ENDSUB              102
358 #define TGSI_OPCODE_TXQ_LZ              103 /* TXQ for mipmap level 0 */
359                                 /* gap */
360 #define TGSI_OPCODE_NOP                 107
361                                 /* gap */
362 #define TGSI_OPCODE_NRM4                112
363 #define TGSI_OPCODE_CALLNZ              113
364 #define TGSI_OPCODE_IFC                 114
365 #define TGSI_OPCODE_BREAKC              115
366 #define TGSI_OPCODE_KIL                 116  /* conditional kill */
367 #define TGSI_OPCODE_END                 117  /* aka HALT */
368                                 /* gap */
369 #define TGSI_OPCODE_F2I                 119
370 #define TGSI_OPCODE_IDIV                120
371 #define TGSI_OPCODE_IMAX                121
372 #define TGSI_OPCODE_IMIN                122
373 #define TGSI_OPCODE_INEG                123
374 #define TGSI_OPCODE_ISGE                124
375 #define TGSI_OPCODE_ISHR                125
376 #define TGSI_OPCODE_ISLT                126
377 #define TGSI_OPCODE_F2U                 127
378 #define TGSI_OPCODE_U2F                 128
379 #define TGSI_OPCODE_UADD                129
380 #define TGSI_OPCODE_UDIV                130
381 #define TGSI_OPCODE_UMAD                131
382 #define TGSI_OPCODE_UMAX                132
383 #define TGSI_OPCODE_UMIN                133
384 #define TGSI_OPCODE_UMOD                134
385 #define TGSI_OPCODE_UMUL                135
386 #define TGSI_OPCODE_USEQ                136
387 #define TGSI_OPCODE_USGE                137
388 #define TGSI_OPCODE_USHR                138
389 #define TGSI_OPCODE_USLT                139
390 #define TGSI_OPCODE_USNE                140
391 #define TGSI_OPCODE_SWITCH              141
392 #define TGSI_OPCODE_CASE                142
393 #define TGSI_OPCODE_DEFAULT             143
394 #define TGSI_OPCODE_ENDSWITCH           144
395 
396 /* resource related opcodes */
397 #define TGSI_OPCODE_SAMPLE              145
398 #define TGSI_OPCODE_SAMPLE_I            146
399 #define TGSI_OPCODE_SAMPLE_I_MS         147
400 #define TGSI_OPCODE_SAMPLE_B            148
401 #define TGSI_OPCODE_SAMPLE_C            149
402 #define TGSI_OPCODE_SAMPLE_C_LZ         150
403 #define TGSI_OPCODE_SAMPLE_D            151
404 #define TGSI_OPCODE_SAMPLE_L            152
405 #define TGSI_OPCODE_GATHER4             153
406 #define TGSI_OPCODE_SVIEWINFO           154
407 #define TGSI_OPCODE_SAMPLE_POS          155
408 #define TGSI_OPCODE_SAMPLE_INFO         156
409 
410 #define TGSI_OPCODE_UARL                157
411 #define TGSI_OPCODE_UCMP                158
412 #define TGSI_OPCODE_IABS                159
413 #define TGSI_OPCODE_ISSG                160
414 
415 #define TGSI_OPCODE_LOAD                161
416 #define TGSI_OPCODE_STORE               162
417 
418 #define TGSI_OPCODE_MFENCE              163
419 #define TGSI_OPCODE_LFENCE              164
420 #define TGSI_OPCODE_SFENCE              165
421 #define TGSI_OPCODE_BARRIER             166
422 
423 #define TGSI_OPCODE_ATOMUADD            167
424 #define TGSI_OPCODE_ATOMXCHG            168
425 #define TGSI_OPCODE_ATOMCAS             169
426 #define TGSI_OPCODE_ATOMAND             170
427 #define TGSI_OPCODE_ATOMOR              171
428 #define TGSI_OPCODE_ATOMXOR             172
429 #define TGSI_OPCODE_ATOMUMIN            173
430 #define TGSI_OPCODE_ATOMUMAX            174
431 #define TGSI_OPCODE_ATOMIMIN            175
432 #define TGSI_OPCODE_ATOMIMAX            176
433 
434 #define TGSI_OPCODE_LAST                177
435 
436 #define TGSI_SAT_NONE            0  /* do not saturate */
437 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
438 #define TGSI_SAT_MINUS_PLUS_ONE  2  /* clamp to [-1,1] */
439 
440 /**
441  * Opcode is the operation code to execute. A given operation defines the
442  * semantics how the source registers (if any) are interpreted and what is
443  * written to the destination registers (if any) as a result of execution.
444  *
445  * NumDstRegs and NumSrcRegs is the number of destination and source registers,
446  * respectively. For a given operation code, those numbers are fixed and are
447  * present here only for convenience.
448  *
449  * If Predicate is TRUE, tgsi_instruction_predicate token immediately follows.
450  *
451  * Saturate controls how are final results in destination registers modified.
452  */
453 
454 struct tgsi_instruction
455 {
456    unsigned Type       : 4;  /* TGSI_TOKEN_TYPE_INSTRUCTION */
457    unsigned NrTokens   : 8;  /* UINT */
458    unsigned Opcode     : 8;  /* TGSI_OPCODE_ */
459    unsigned Saturate   : 2;  /* TGSI_SAT_ */
460    unsigned NumDstRegs : 2;  /* UINT */
461    unsigned NumSrcRegs : 4;  /* UINT */
462    unsigned Predicate  : 1;  /* BOOL */
463    unsigned Label      : 1;
464    unsigned Texture    : 1;
465    unsigned Padding    : 1;
466 };
467 
468 /*
469  * If tgsi_instruction::Label is TRUE, tgsi_instruction_label follows.
470  *
471  * If tgsi_instruction::Texture is TRUE, tgsi_instruction_texture follows.
472  *   if texture instruction has a number of offsets,
473  *   then tgsi_instruction::Texture::NumOffset of tgsi_texture_offset follow.
474  *
475  * Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
476  *
477  * Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
478  *
479  * tgsi_instruction::NrTokens contains the total number of words that make the
480  * instruction, including the instruction word.
481  */
482 
483 #define TGSI_SWIZZLE_X      0
484 #define TGSI_SWIZZLE_Y      1
485 #define TGSI_SWIZZLE_Z      2
486 #define TGSI_SWIZZLE_W      3
487 
488 struct tgsi_instruction_label
489 {
490    unsigned Label    : 24;   /* UINT */
491    unsigned Padding  : 8;
492 };
493 
494 #define TGSI_TEXTURE_BUFFER         0
495 #define TGSI_TEXTURE_1D             1
496 #define TGSI_TEXTURE_2D             2
497 #define TGSI_TEXTURE_3D             3
498 #define TGSI_TEXTURE_CUBE           4
499 #define TGSI_TEXTURE_RECT           5
500 #define TGSI_TEXTURE_SHADOW1D       6
501 #define TGSI_TEXTURE_SHADOW2D       7
502 #define TGSI_TEXTURE_SHADOWRECT     8
503 #define TGSI_TEXTURE_1D_ARRAY       9
504 #define TGSI_TEXTURE_2D_ARRAY       10
505 #define TGSI_TEXTURE_SHADOW1D_ARRAY 11
506 #define TGSI_TEXTURE_SHADOW2D_ARRAY 12
507 #define TGSI_TEXTURE_SHADOWCUBE     13
508 #define TGSI_TEXTURE_2D_MSAA        14
509 #define TGSI_TEXTURE_2D_ARRAY_MSAA  15
510 #define TGSI_TEXTURE_UNKNOWN        16
511 #define TGSI_TEXTURE_COUNT          17
512 
513 struct tgsi_instruction_texture
514 {
515    unsigned Texture  : 8;    /* TGSI_TEXTURE_ */
516    unsigned NumOffsets : 4;
517    unsigned Padding : 20;
518 };
519 
520 /* for texture offsets in GLSL and DirectX.
521  * Generally these always come from TGSI_FILE_IMMEDIATE,
522  * however DX11 appears to have the capability to do
523  * non-constant texture offsets.
524  */
525 struct tgsi_texture_offset
526 {
527    int      Index    : 16;
528    unsigned File     : 4;  /**< one of TGSI_FILE_x */
529    unsigned SwizzleX : 2;  /* TGSI_SWIZZLE_x */
530    unsigned SwizzleY : 2;  /* TGSI_SWIZZLE_x */
531    unsigned SwizzleZ : 2;  /* TGSI_SWIZZLE_x */
532    unsigned Padding  : 6;
533 };
534 
535 /*
536  * For SM3, the following constraint applies.
537  *   - Swizzle is either set to identity or replicate.
538  */
539 struct tgsi_instruction_predicate
540 {
541    int      Index    : 16; /* SINT */
542    unsigned SwizzleX : 2;  /* TGSI_SWIZZLE_x */
543    unsigned SwizzleY : 2;  /* TGSI_SWIZZLE_x */
544    unsigned SwizzleZ : 2;  /* TGSI_SWIZZLE_x */
545    unsigned SwizzleW : 2;  /* TGSI_SWIZZLE_x */
546    unsigned Negate   : 1;  /* BOOL */
547    unsigned Padding  : 7;
548 };
549 
550 /**
551  * File specifies the register array to access.
552  *
553  * Index specifies the element number of a register in the register file.
554  *
555  * If Indirect is TRUE, Index should be offset by the X component of a source
556  * register that follows. The register can be now fetched into local storage
557  * for further processing.
558  *
559  * If Negate is TRUE, all components of the fetched register are negated.
560  *
561  * The fetched register components are swizzled according to SwizzleX, SwizzleY,
562  * SwizzleZ and SwizzleW.
563  *
564  */
565 
566 struct tgsi_src_register
567 {
568    unsigned File        : 4;  /* TGSI_FILE_ */
569    unsigned Indirect    : 1;  /* BOOL */
570    unsigned Dimension   : 1;  /* BOOL */
571    int      Index       : 16; /* SINT */
572    unsigned SwizzleX    : 2;  /* TGSI_SWIZZLE_ */
573    unsigned SwizzleY    : 2;  /* TGSI_SWIZZLE_ */
574    unsigned SwizzleZ    : 2;  /* TGSI_SWIZZLE_ */
575    unsigned SwizzleW    : 2;  /* TGSI_SWIZZLE_ */
576    unsigned Absolute    : 1;    /* BOOL */
577    unsigned Negate      : 1;    /* BOOL */
578 };
579 
580 /**
581  * If tgsi_src_register::Modifier is TRUE, tgsi_src_register_modifier follows.
582  *
583  * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
584  * follows.
585  *
586  * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
587  */
588 
589 
590 struct tgsi_dimension
591 {
592    unsigned Indirect    : 1;  /* BOOL */
593    unsigned Dimension   : 1;  /* BOOL */
594    unsigned Padding     : 14;
595    int      Index       : 16; /* SINT */
596 };
597 
598 struct tgsi_dst_register
599 {
600    unsigned File        : 4;  /* TGSI_FILE_ */
601    unsigned WriteMask   : 4;  /* TGSI_WRITEMASK_ */
602    unsigned Indirect    : 1;  /* BOOL */
603    unsigned Dimension   : 1;  /* BOOL */
604    int      Index       : 16; /* SINT */
605    unsigned Padding     : 6;
606 };
607 
608 
609 #ifdef __cplusplus
610 }
611 #endif
612 
613 #endif /* P_SHADER_TOKENS_H */
614