fix typo
[mesa.git] / src / mesa / pipe / p_shader_tokens.h
1 #if !defined TGSI_TOKEN_H
2 #define TGSI_TOKEN_H
3
4 #if defined __cplusplus
5 extern "C" {
6 #endif // defined __cplusplus
7
8 struct tgsi_version
9 {
10 unsigned MajorVersion : 8;
11 unsigned MinorVersion : 8;
12 unsigned Padding : 16;
13 };
14
15 struct tgsi_header
16 {
17 unsigned HeaderSize : 8;
18 unsigned BodySize : 24;
19 };
20
21 #define TGSI_PROCESSOR_FRAGMENT 0
22 #define TGSI_PROCESSOR_VERTEX 1
23 #define TGSI_PROCESSOR_GEOMETRY 2
24
25 struct tgsi_processor
26 {
27 unsigned Processor : 4; /* TGSI_PROCESSOR_ */
28 unsigned Padding : 28;
29 };
30
31 #define TGSI_TOKEN_TYPE_DECLARATION 0
32 #define TGSI_TOKEN_TYPE_IMMEDIATE 1
33 #define TGSI_TOKEN_TYPE_INSTRUCTION 2
34
35 struct tgsi_token
36 {
37 unsigned Type : 4; /* TGSI_TOKEN_TYPE_ */
38 unsigned Size : 8; /* UINT */
39 unsigned Padding : 19;
40 unsigned Extended : 1; /* BOOL */
41 };
42
43 #define TGSI_FILE_NULL 0
44 #define TGSI_FILE_CONSTANT 1
45 #define TGSI_FILE_INPUT 2
46 #define TGSI_FILE_OUTPUT 3
47 #define TGSI_FILE_TEMPORARY 4
48 #define TGSI_FILE_SAMPLER 5
49 #define TGSI_FILE_ADDRESS 6
50 #define TGSI_FILE_IMMEDIATE 7
51
52 #define TGSI_DECLARE_RANGE 0
53 #define TGSI_DECLARE_MASK 1
54
55 #define TGSI_WRITEMASK_NONE 0x00
56 #define TGSI_WRITEMASK_X 0x01
57 #define TGSI_WRITEMASK_Y 0x02
58 #define TGSI_WRITEMASK_XY 0x03
59 #define TGSI_WRITEMASK_Z 0x04
60 #define TGSI_WRITEMASK_XZ 0x05
61 #define TGSI_WRITEMASK_YZ 0x06
62 #define TGSI_WRITEMASK_XYZ 0x07
63 #define TGSI_WRITEMASK_W 0x08
64 #define TGSI_WRITEMASK_XW 0x09
65 #define TGSI_WRITEMASK_YW 0x0A
66 #define TGSI_WRITEMASK_XYW 0x0B
67 #define TGSI_WRITEMASK_ZW 0x0C
68 #define TGSI_WRITEMASK_XZW 0x0D
69 #define TGSI_WRITEMASK_YZW 0x0E
70 #define TGSI_WRITEMASK_XYZW 0x0F
71
72 struct tgsi_declaration
73 {
74 unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */
75 unsigned Size : 8; /* UINT */
76 unsigned File : 4; /* one of TGSI_FILE_x */
77 unsigned Declare : 4; /* one of TGSI_DECLARE_x */
78 unsigned UsageMask : 4; /* bitmask of TGSI_WRITEMASK_x flags */
79 unsigned Interpolate : 1; /* BOOL, any interpolation info? */
80 unsigned Semantic : 1; /* BOOL, any semantic info? */
81 unsigned Padding : 5;
82 unsigned Extended : 1; /* BOOL */
83 };
84
85 struct tgsi_declaration_range
86 {
87 unsigned First : 16; /* UINT */
88 unsigned Last : 16; /* UINT */
89 };
90
91 struct tgsi_declaration_mask
92 {
93 unsigned Mask : 32; /* UINT */
94 };
95
96 #define TGSI_INTERPOLATE_CONSTANT 0
97 #define TGSI_INTERPOLATE_LINEAR 1
98 #define TGSI_INTERPOLATE_PERSPECTIVE 2
99
100 struct tgsi_declaration_interpolation
101 {
102 unsigned Interpolate : 4; /* TGSI_INTERPOLATE_ */
103 unsigned Padding : 28;
104 };
105
106 #define TGSI_SEMANTIC_POSITION 0
107 #define TGSI_SEMANTIC_COLOR 1
108 #define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */
109 #define TGSI_SEMANTIC_FOG 3
110 #define TGSI_SEMANTIC_PSIZE 4
111 #define TGSI_SEMANTIC_GENERIC 5
112 #define TGSI_SEMANTIC_NORMAL 6
113 #define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */
114
115 struct tgsi_declaration_semantic
116 {
117 unsigned SemanticName : 8; /* one of TGSI_SEMANTIC_ */
118 unsigned SemanticIndex : 16; /* UINT */
119 unsigned Padding : 8;
120 };
121
122 #define TGSI_IMM_FLOAT32 0
123
124 struct tgsi_immediate
125 {
126 unsigned Type : 4; /* TGSI_TOKEN_TYPE_IMMEDIATE */
127 unsigned Size : 8; /* UINT */
128 unsigned DataType : 4; /* TGSI_IMM_ */
129 unsigned Padding : 15;
130 unsigned Extended : 1; /* BOOL */
131 };
132
133 struct tgsi_immediate_float32
134 {
135 float Float;
136 };
137
138 /*
139 * GL_NV_vertex_program
140 */
141 #define TGSI_OPCODE_ARL 0
142 #define TGSI_OPCODE_MOV 1
143 #define TGSI_OPCODE_LIT 2
144 #define TGSI_OPCODE_RCP 3
145 #define TGSI_OPCODE_RSQ 4
146 #define TGSI_OPCODE_EXP 5
147 #define TGSI_OPCODE_LOG 6
148 #define TGSI_OPCODE_MUL 7
149 #define TGSI_OPCODE_ADD 8
150 #define TGSI_OPCODE_DP3 9
151 #define TGSI_OPCODE_DP4 10
152 #define TGSI_OPCODE_DST 11
153 #define TGSI_OPCODE_MIN 12
154 #define TGSI_OPCODE_MAX 13
155 #define TGSI_OPCODE_SLT 14
156 #define TGSI_OPCODE_SGE 15
157 #define TGSI_OPCODE_MAD 16
158
159 /*
160 * GL_ATI_fragment_shader
161 */
162 #define TGSI_OPCODE_SUB 17
163 #define TGSI_OPCODE_DOT3 TGSI_OPCODE_DP3
164 #define TGSI_OPCODE_DOT4 TGSI_OPCODE_DP4
165 #define TGSI_OPCODE_LERP 18
166 #define TGSI_OPCODE_CND 19
167 #define TGSI_OPCODE_CND0 20
168 #define TGSI_OPCODE_DOT2ADD 21
169
170 /*
171 * GL_EXT_vertex_shader
172 */
173 #define TGSI_OPCODE_INDEX 22
174 #define TGSI_OPCODE_NEGATE 23
175 #define TGSI_OPCODE_MADD TGSI_OPCODE_MAD
176 #define TGSI_OPCODE_FRAC 24
177 #define TGSI_OPCODE_SETGE TGSI_OPCODE_SGE
178 #define TGSI_OPCODE_SETLT TGSI_OPCODE_SLT
179 #define TGSI_OPCODE_CLAMP 25
180 #define TGSI_OPCODE_FLOOR 26
181 #define TGSI_OPCODE_ROUND 27
182 #define TGSI_OPCODE_EXPBASE2 28
183 #define TGSI_OPCODE_LOGBASE2 29
184 #define TGSI_OPCODE_POWER 30
185 #define TGSI_OPCODE_RECIP TGSI_OPCODE_RCP
186 #define TGSI_OPCODE_RECIPSQRT TGSI_OPCODE_RSQ
187 #define TGSI_OPCODE_CROSSPRODUCT 31
188 #define TGSI_OPCODE_MULTIPLYMATRIX 32
189
190 /*
191 * GL_NV_vertex_program1_1
192 */
193 #define TGSI_OPCODE_ABS 33
194 #define TGSI_OPCODE_RCC 34
195 #define TGSI_OPCODE_DPH 35
196
197 /*
198 * GL_NV_fragment_program
199 */
200 #define TGSI_OPCODE_COS 36
201 #define TGSI_OPCODE_DDX 37
202 #define TGSI_OPCODE_DDY 38
203 #define TGSI_OPCODE_EX2 TGSI_OPCODE_EXPBASE2
204 #define TGSI_OPCODE_FLR TGSI_OPCODE_FLOOR
205 #define TGSI_OPCODE_FRC TGSI_OPCODE_FRAC
206 #define TGSI_OPCODE_KILP 39 /* predicated kill */
207 #define TGSI_OPCODE_LG2 TGSI_OPCODE_LOGBASE2
208 #define TGSI_OPCODE_LRP TGSI_OPCODE_LERP
209 #define TGSI_OPCODE_PK2H 40
210 #define TGSI_OPCODE_PK2US 41
211 #define TGSI_OPCODE_PK4B 42
212 #define TGSI_OPCODE_PK4UB 43
213 #define TGSI_OPCODE_POW TGSI_OPCODE_POWER
214 #define TGSI_OPCODE_RFL 44
215 #define TGSI_OPCODE_SEQ 45
216 #define TGSI_OPCODE_SFL 46
217 #define TGSI_OPCODE_SGT 47
218 #define TGSI_OPCODE_SIN 48
219 #define TGSI_OPCODE_SLE 49
220 #define TGSI_OPCODE_SNE 50
221 #define TGSI_OPCODE_STR 51
222 #define TGSI_OPCODE_TEX 52
223 #define TGSI_OPCODE_TXD 53
224 #define TGSI_OPCODE_UP2H 54
225 #define TGSI_OPCODE_UP2US 55
226 #define TGSI_OPCODE_UP4B 56
227 #define TGSI_OPCODE_UP4UB 57
228 #define TGSI_OPCODE_X2D 58
229
230 /*
231 * GL_NV_vertex_program2
232 */
233 #define TGSI_OPCODE_ARA 59
234 #define TGSI_OPCODE_ARR 60
235 #define TGSI_OPCODE_BRA 61
236 #define TGSI_OPCODE_CAL 62
237 #define TGSI_OPCODE_RET 63
238 #define TGSI_OPCODE_SSG 64
239
240 /*
241 * GL_ARB_vertex_program
242 */
243 #define TGSI_OPCODE_SWZ TGSI_OPCODE_MOV
244 #define TGSI_OPCODE_XPD TGSI_OPCODE_CROSSPRODUCT
245
246 /*
247 * GL_ARB_fragment_program
248 */
249 #define TGSI_OPCODE_CMP 65
250 #define TGSI_OPCODE_SCS 66
251 #define TGSI_OPCODE_TXB 67
252
253 /*
254 * GL_NV_fragment_program_option
255 */
256 /* No new opcode */
257
258 /*
259 * GL_NV_fragment_program2
260 */
261 #define TGSI_OPCODE_NRM 68
262 #define TGSI_OPCODE_DIV 69
263 #define TGSI_OPCODE_DP2 70
264 #define TGSI_OPCODE_DP2A TGSI_OPCODE_DOT2ADD
265 #define TGSI_OPCODE_TXL 71
266 #define TGSI_OPCODE_BRK 72
267 #define TGSI_OPCODE_IF 73
268 #define TGSI_OPCODE_LOOP 74
269 #define TGSI_OPCODE_REP 75
270 #define TGSI_OPCODE_ELSE 76
271 #define TGSI_OPCODE_ENDIF 77
272 #define TGSI_OPCODE_ENDLOOP 78
273 #define TGSI_OPCODE_ENDREP 79
274
275 /*
276 * GL_NV_vertex_program2_option
277 */
278
279 /*
280 * GL_NV_vertex_program3
281 */
282 #define TGSI_OPCODE_PUSHA 80
283 #define TGSI_OPCODE_POPA 81
284
285 /*
286 * GL_NV_gpu_program4
287 */
288 #define TGSI_OPCODE_CEIL 82
289 #define TGSI_OPCODE_I2F 83
290 #define TGSI_OPCODE_NOT 84
291 #define TGSI_OPCODE_TRUNC 85
292 #define TGSI_OPCODE_SHL 86
293 #define TGSI_OPCODE_SHR 87
294 #define TGSI_OPCODE_AND 88
295 #define TGSI_OPCODE_OR 89
296 #define TGSI_OPCODE_MOD 90
297 #define TGSI_OPCODE_XOR 91
298 #define TGSI_OPCODE_SAD 92
299 #define TGSI_OPCODE_TXF 93
300 #define TGSI_OPCODE_TXQ 94
301 #define TGSI_OPCODE_CONT 95
302
303 /*
304 * GL_NV_vertex_program4
305 */
306 /* Same as GL_NV_gpu_program4 */
307
308 /*
309 * GL_NV_fragment_program4
310 */
311 /* Same as GL_NV_gpu_program4 */
312
313 /*
314 * GL_NV_geometry_program4
315 */
316 /* Same as GL_NV_gpu_program4 */
317 #define TGSI_OPCODE_EMIT 96
318 #define TGSI_OPCODE_ENDPRIM 97
319
320 /*
321 * GLSL
322 */
323 #define TGSI_OPCODE_BGNLOOP2 98
324 #define TGSI_OPCODE_BGNSUB 99
325 #define TGSI_OPCODE_ENDLOOP2 100
326 #define TGSI_OPCODE_ENDSUB 101
327 #define TGSI_OPCODE_INT TGSI_OPCODE_TRUNC
328 #define TGSI_OPCODE_NOISE1 102
329 #define TGSI_OPCODE_NOISE2 103
330 #define TGSI_OPCODE_NOISE3 104
331 #define TGSI_OPCODE_NOISE4 105
332 #define TGSI_OPCODE_NOP 106
333
334 /*
335 * ps_1_1
336 */
337 #define TGSI_OPCODE_TEXCOORD TGSI_OPCODE_NOP
338 #define TGSI_OPCODE_TEXKILL TGSI_OPCODE_KIL
339 #define TGSI_OPCODE_TEXBEM 107
340 #define TGSI_OPCODE_TEXBEML 108
341 #define TGSI_OPCODE_TEXREG2AR 109
342 #define TGSI_OPCODE_TEXM3X2PAD 110
343 #define TGSI_OPCODE_TEXM3X2TEX 111
344 #define TGSI_OPCODE_TEXM3X3PAD 112
345 #define TGSI_OPCODE_TEXM3X3TEX 113
346 #define TGSI_OPCODE_TEXM3X3SPEC 114
347 #define TGSI_OPCODE_TEXM3X3VSPEC 115
348
349 /*
350 * ps_1_2
351 */
352 #define TGSI_OPCODE_TEXREG2GB 116
353 #define TGSI_OPCODE_TEXREG2RGB 117
354 #define TGSI_OPCODE_TEXDP3TEX 118
355 #define TGSI_OPCODE_TEXDP3 119
356 #define TGSI_OPCODE_TEXM3X3 120
357 /* CMP - use TGSI_OPCODE_CND0 */
358
359 /*
360 * ps_1_3
361 */
362 #define TGSI_OPCODE_TEXM3X2DEPTH 121
363 /* CMP - use TGSI_OPCODE_CND0 */
364
365 /*
366 * ps_1_4
367 */
368 #define TGSI_OPCODE_TEXCRD TGSI_OPCODE_TEXCOORD
369 #define TGSI_OPCODE_TEXLD TGSI_OPCODE_TEX
370 #define TGSI_OPCODE_TEXDEPTH 122
371 #define TGSI_OPCODE_BEM 123
372
373 /*
374 * ps_2_0
375 */
376 #define TGSI_OPCODE_M4X4 TGSI_OPCODE_MULTIPLYMATRIX
377 #define TGSI_OPCODE_M4X3 124
378 #define TGSI_OPCODE_M3X4 125
379 #define TGSI_OPCODE_M3X3 126
380 #define TGSI_OPCODE_M3X2 127
381 #define TGSI_OPCODE_CRS TGSI_OPCODE_XPD
382 #define TGSI_OPCODE_NRM4 128
383 #define TGSI_OPCODE_SINCOS TGSI_OPCODE_SCS
384 #define TGSI_OPCODE_TEXLDB TGSI_OPCODE_TXB
385 #define TGSI_OPCODE_DP2ADD TGSI_OPCODE_DP2A
386
387 /*
388 * ps_2_x
389 */
390 #define TGSI_OPCODE_CALL TGSI_OPCODE_CAL
391 #define TGSI_OPCODE_CALLNZ 129
392 #define TGSI_OPCODE_IFC 130
393 #define TGSI_OPCODE_BREAK TGSI_OPCODE_BRK
394 #define TGSI_OPCODE_BREAKC 131
395 #define TGSI_OPCODE_DSX TGSI_OPCODE_DDX
396 #define TGSI_OPCODE_DSY TGSI_OPCODE_DDY
397 #define TGSI_OPCODE_TEXLDD TGSI_OPCODE_TXD
398
399 /*
400 * vs_1_1
401 */
402 #define TGSI_OPCODE_EXPP TGSI_OPCODE_EXP
403 #define TGSI_OPCODE_LOGP TGSI_OPCODE_LG2
404
405 /*
406 * vs_2_0
407 */
408 #define TGSI_OPCODE_SGN TGSI_OPCODE_SSG
409 #define TGSI_OPCODE_MOVA TGSI_OPCODE_ARR
410
411 /*
412 * vs_2_x
413 */
414
415 #define TGSI_OPCODE_KIL 132 /* unpredicated kill */
416 #define TGSI_OPCODE_END 133 /* aka HALT */
417
418 #define TGSI_OPCODE_LAST 134
419
420 #define TGSI_SAT_NONE 0 /* do not saturate */
421 #define TGSI_SAT_ZERO_ONE 1 /* clamp to [0,1] */
422 #define TGSI_SAT_MINUS_PLUS_ONE 2 /* clamp to [-1,1] */
423
424 /*
425 * Opcode is the operation code to execute. A given operation defines the
426 * semantics how the source registers (if any) are interpreted and what is
427 * written to the destination registers (if any) as a result of execution.
428 *
429 * NumDstRegs and NumSrcRegs is the number of destination and source registers,
430 * respectively. For a given operation code, those numbers are fixed and are
431 * present here only for convenience.
432 *
433 * If Extended is TRUE, it is now executed.
434 *
435 * Saturate controls how are final results in destination registers modified.
436 */
437
438 struct tgsi_instruction
439 {
440 unsigned Type : 4; /* TGSI_TOKEN_TYPE_INSTRUCTION */
441 unsigned Size : 8; /* UINT */
442 unsigned Opcode : 8; /* TGSI_OPCODE_ */
443 unsigned Saturate : 2; /* TGSI_SAT_ */
444 unsigned NumDstRegs : 2; /* UINT */
445 unsigned NumSrcRegs : 4; /* UINT */
446 unsigned Padding : 3;
447 unsigned Extended : 1; /* BOOL */
448 };
449
450 /*
451 * If tgsi_instruction::Extended is TRUE, tgsi_instruction_ext follows.
452 *
453 * Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
454 *
455 * Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
456 *
457 * tgsi_instruction::Size contains the total number of words that make the
458 * instruction, including the instruction word.
459 */
460
461 #define TGSI_INSTRUCTION_EXT_TYPE_NV 0
462 #define TGSI_INSTRUCTION_EXT_TYPE_LABEL 1
463 #define TGSI_INSTRUCTION_EXT_TYPE_TEXTURE 2
464 #define TGSI_INSTRUCTION_EXT_TYPE_PREDICATE 3
465
466 struct tgsi_instruction_ext
467 {
468 unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_ */
469 unsigned Padding : 27;
470 unsigned Extended : 1; /* BOOL */
471 };
472
473 /*
474 * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_NV, it should
475 * be cast to tgsi_instruction_ext_nv.
476 *
477 * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_LABEL, it
478 * should be cast to tgsi_instruction_ext_label.
479 *
480 * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_TEXTURE, it
481 * should be cast to tgsi_instruction_ext_texture.
482 *
483 * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_PREDICATE, it
484 * should be cast to tgsi_instruction_ext_predicate.
485 *
486 * If tgsi_instruction_ext::Extended is TRUE, another tgsi_instruction_ext
487 * follows.
488 */
489
490 #define TGSI_PRECISION_DEFAULT 0
491 #define TGSI_PRECISION_FLOAT32 1
492 #define TGSI_PRECISION_FLOAT16 2
493 #define TGSI_PRECISION_FIXED12 3
494
495 #define TGSI_CC_GT 0
496 #define TGSI_CC_EQ 1
497 #define TGSI_CC_LT 2
498 #define TGSI_CC_UN 3
499 #define TGSI_CC_GE 4
500 #define TGSI_CC_LE 5
501 #define TGSI_CC_NE 6
502 #define TGSI_CC_TR 7
503 #define TGSI_CC_FL 8
504
505 #define TGSI_SWIZZLE_X 0
506 #define TGSI_SWIZZLE_Y 1
507 #define TGSI_SWIZZLE_Z 2
508 #define TGSI_SWIZZLE_W 3
509
510 /*
511 * Precision controls the precision at which the operation should be executed.
512 *
513 * CondDstUpdate enables condition code register writes. When this field is
514 * TRUE, CondDstIndex specifies the index of the condition code register to
515 * update.
516 *
517 * CondFlowEnable enables conditional execution of the operation. When this
518 * field is TRUE, CondFlowIndex specifies the index of the condition code
519 * register to test against CondMask with component swizzle controled by
520 * CondSwizzleX, CondSwizzleY, CondSwizzleZ and CondSwizzleW. If the test fails,
521 * the operation is not executed.
522 */
523
524 struct tgsi_instruction_ext_nv
525 {
526 unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_NV */
527 unsigned Precision : 4; /* TGSI_PRECISION_ */
528 unsigned CondDstIndex : 4; /* UINT */
529 unsigned CondFlowIndex : 4; /* UINT */
530 unsigned CondMask : 4; /* TGSI_CC_ */
531 unsigned CondSwizzleX : 2; /* TGSI_SWIZZLE_ */
532 unsigned CondSwizzleY : 2; /* TGSI_SWIZZLE_ */
533 unsigned CondSwizzleZ : 2; /* TGSI_SWIZZLE_ */
534 unsigned CondSwizzleW : 2; /* TGSI_SWIZZLE_ */
535 unsigned CondDstUpdate : 1; /* BOOL */
536 unsigned CondFlowEnable : 1; /* BOOL */
537 unsigned Padding : 1;
538 unsigned Extended : 1; /* BOOL */
539 };
540
541 struct tgsi_instruction_ext_label
542 {
543 unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_LABEL */
544 unsigned Label : 24; /* UINT */
545 unsigned Padding : 3;
546 unsigned Extended : 1; /* BOOL */
547 };
548
549 #define TGSI_TEXTURE_UNKNOWN 0
550 #define TGSI_TEXTURE_1D 1
551 #define TGSI_TEXTURE_2D 2
552 #define TGSI_TEXTURE_3D 3
553 #define TGSI_TEXTURE_CUBE 4
554 #define TGSI_TEXTURE_RECT 5
555 #define TGSI_TEXTURE_SHADOW1D 6
556 #define TGSI_TEXTURE_SHADOW2D 7
557 #define TGSI_TEXTURE_SHADOWRECT 8
558
559 struct tgsi_instruction_ext_texture
560 {
561 unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_TEXTURE */
562 unsigned Texture : 8; /* TGSI_TEXTURE_ */
563 unsigned Padding : 19;
564 unsigned Extended : 1; /* BOOL */
565 };
566
567 struct tgsi_instruction_ext_predicate
568 {
569 unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_PREDICATE */
570 unsigned PredDstIndex : 4; /* UINT */
571 unsigned PredWriteMask : 4; /* TGSI_WRITEMASK_ */
572 unsigned Padding : 19;
573 unsigned Extended : 1; /* BOOL */
574 };
575
576 /*
577 * File specifies the register array to access.
578 *
579 * Index specifies the element number of a register in the register file.
580 *
581 * If Indirect is TRUE, Index should be offset by the X component of a source
582 * register that follows. The register can be now fetched into local storage
583 * for further processing.
584 *
585 * If Negate is TRUE, all components of the fetched register are negated.
586 *
587 * The fetched register components are swizzled according to SwizzleX, SwizzleY,
588 * SwizzleZ and SwizzleW.
589 *
590 * If Extended is TRUE, any further modifications to the source register are
591 * made to this temporary storage.
592 */
593
594 struct tgsi_src_register
595 {
596 unsigned File : 4; /* TGSI_FILE_ */
597 unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */
598 unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
599 unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
600 unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
601 unsigned Negate : 1; /* BOOL */
602 unsigned Indirect : 1; /* BOOL */
603 unsigned Dimension : 1; /* BOOL */
604 int Index : 16; /* SINT */
605 unsigned Extended : 1; /* BOOL */
606 };
607
608 /*
609 * If tgsi_src_register::Extended is TRUE, tgsi_src_register_ext follows.
610 *
611 * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
612 * follows.
613 *
614 * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
615 */
616
617 #define TGSI_SRC_REGISTER_EXT_TYPE_SWZ 0
618 #define TGSI_SRC_REGISTER_EXT_TYPE_MOD 1
619
620 struct tgsi_src_register_ext
621 {
622 unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_ */
623 unsigned Padding : 27;
624 unsigned Extended : 1; /* BOOL */
625 };
626
627 /*
628 * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_SWZ,
629 * it should be cast to tgsi_src_register_ext_swz.
630 *
631 * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_MOD,
632 * it should be cast to tgsi_src_register_ext_mod.
633 *
634 * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
635 * follows.
636 */
637
638 #define TGSI_EXTSWIZZLE_X TGSI_SWIZZLE_X
639 #define TGSI_EXTSWIZZLE_Y TGSI_SWIZZLE_Y
640 #define TGSI_EXTSWIZZLE_Z TGSI_SWIZZLE_Z
641 #define TGSI_EXTSWIZZLE_W TGSI_SWIZZLE_W
642 #define TGSI_EXTSWIZZLE_ZERO 4
643 #define TGSI_EXTSWIZZLE_ONE 5
644
645 /*
646 * ExtSwizzleX, ExtSwizzleY, ExtSwizzleZ and ExtSwizzleW swizzle the source
647 * register in an extended manner.
648 *
649 * NegateX, NegateY, NegateZ and NegateW negate individual components of the
650 * source register.
651 *
652 * ExtDivide specifies which component is used to divide all components of the
653 * source register.
654 */
655
656 struct tgsi_src_register_ext_swz
657 {
658 unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_SWZ */
659 unsigned ExtSwizzleX : 4; /* TGSI_EXTSWIZZLE_ */
660 unsigned ExtSwizzleY : 4; /* TGSI_EXTSWIZZLE_ */
661 unsigned ExtSwizzleZ : 4; /* TGSI_EXTSWIZZLE_ */
662 unsigned ExtSwizzleW : 4; /* TGSI_EXTSWIZZLE_ */
663 unsigned NegateX : 1; /* BOOL */
664 unsigned NegateY : 1; /* BOOL */
665 unsigned NegateZ : 1; /* BOOL */
666 unsigned NegateW : 1; /* BOOL */
667 unsigned ExtDivide : 4; /* TGSI_EXTSWIZZLE_ */
668 unsigned Padding : 3;
669 unsigned Extended : 1; /* BOOL */
670 };
671
672 /**
673 * Extra src register modifiers
674 *
675 * If Complement is TRUE, the source register is modified by subtracting it
676 * from 1.0.
677 *
678 * If Bias is TRUE, the source register is modified by subtracting 0.5 from it.
679 *
680 * If Scale2X is TRUE, the source register is modified by multiplying it by 2.0.
681 *
682 * If Absolute is TRUE, the source register is modified by removing the sign.
683 *
684 * If Negate is TRUE, the source register is modified by negating it.
685 */
686
687 struct tgsi_src_register_ext_mod
688 {
689 unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_MOD */
690 unsigned Complement : 1; /* BOOL */
691 unsigned Bias : 1; /* BOOL */
692 unsigned Scale2X : 1; /* BOOL */
693 unsigned Absolute : 1; /* BOOL */
694 unsigned Negate : 1; /* BOOL */
695 unsigned Padding : 22;
696 unsigned Extended : 1; /* BOOL */
697 };
698
699 struct tgsi_dimension
700 {
701 unsigned Indirect : 1; /* BOOL */
702 unsigned Dimension : 1; /* BOOL */
703 unsigned Padding : 13;
704 int Index : 16; /* SINT */
705 unsigned Extended : 1; /* BOOL */
706 };
707
708 struct tgsi_dst_register
709 {
710 unsigned File : 4; /* TGSI_FILE_ */
711 unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
712 unsigned Indirect : 1; /* BOOL */
713 unsigned Dimension : 1; /* BOOL */
714 int Index : 16; /* SINT */
715 unsigned Padding : 5;
716 unsigned Extended : 1; /* BOOL */
717 };
718
719 /*
720 * If tgsi_dst_register::Extended is TRUE, tgsi_dst_register_ext follows.
721 *
722 * Then, if tgsi_dst_register::Indirect is TRUE, tgsi_src_register follows.
723 */
724
725 #define TGSI_DST_REGISTER_EXT_TYPE_CONDCODE 0
726 #define TGSI_DST_REGISTER_EXT_TYPE_MODULATE 1
727 #define TGSI_DST_REGISTER_EXT_TYPE_PREDICATE 2
728
729 struct tgsi_dst_register_ext
730 {
731 unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_ */
732 unsigned Padding : 27;
733 unsigned Extended : 1; /* BOOL */
734 };
735
736 /**
737 * Extra destination register modifiers
738 *
739 * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_CONDCODE,
740 * it should be cast to tgsi_dst_register_ext_condcode.
741 *
742 * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_MODULATE,
743 * it should be cast to tgsi_dst_register_ext_modulate.
744 *
745 * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_PREDICATE,
746 * it should be cast to tgsi_dst_register_ext_predicate.
747 *
748 * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
749 * follows.
750 */
751 struct tgsi_dst_register_ext_concode
752 {
753 unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_CONDCODE */
754 unsigned CondMask : 4; /* TGSI_CC_ */
755 unsigned CondSwizzleX : 2; /* TGSI_SWIZZLE_ */
756 unsigned CondSwizzleY : 2; /* TGSI_SWIZZLE_ */
757 unsigned CondSwizzleZ : 2; /* TGSI_SWIZZLE_ */
758 unsigned CondSwizzleW : 2; /* TGSI_SWIZZLE_ */
759 unsigned CondSrcIndex : 4; /* UINT */
760 unsigned Padding : 11;
761 unsigned Extended : 1; /* BOOL */
762 };
763
764 #define TGSI_MODULATE_1X 0
765 #define TGSI_MODULATE_2X 1
766 #define TGSI_MODULATE_4X 2
767 #define TGSI_MODULATE_8X 3
768 #define TGSI_MODULATE_HALF 4
769 #define TGSI_MODULATE_QUARTER 5
770 #define TGSI_MODULATE_EIGHTH 6
771
772 struct tgsi_dst_register_ext_modulate
773 {
774 unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_MODULATE */
775 unsigned Modulate : 4; /* TGSI_MODULATE_ */
776 unsigned Padding : 23;
777 unsigned Extended : 1; /* BOOL */
778 };
779
780 /*
781 * Currently, the following constraints apply.
782 *
783 * - PredSwizzleXYZW is either set to identity or replicate.
784 * - PredSrcIndex is 0.
785 */
786
787 struct tgsi_dst_register_ext_predicate
788 {
789 unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_PREDICATE */
790 unsigned PredSwizzleX : 2; /* TGSI_SWIZZLE_ */
791 unsigned PredSwizzleY : 2; /* TGSI_SWIZZLE_ */
792 unsigned PredSwizzleZ : 2; /* TGSI_SWIZZLE_ */
793 unsigned PredSwizzleW : 2; /* TGSI_SWIZZLE_ */
794 unsigned PredSrcIndex : 4; /* UINT */
795 unsigned Negate : 1; /* BOOL */
796 unsigned Padding : 14;
797 unsigned Extended : 1; /* BOOL */
798 };
799
800
801 #if defined __cplusplus
802 } // extern "C"
803 #endif // defined __cplusplus
804
805 #endif // !defined TGSI_TOKEN_H
806