tgsi: Support signed/unsigned integer immediate types.
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_ureg.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE, INC AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef TGSI_UREG_H
29 #define TGSI_UREG_H
30
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_shader_tokens.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 struct ureg_program;
39
40 /* Almost a tgsi_src_register, but we need to pull in the Absolute
41 * flag from the _ext token. Indirect flag always implies ADDR[0].
42 */
43 struct ureg_src
44 {
45 unsigned File : 4; /* TGSI_FILE_ */
46 unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */
47 unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
48 unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
49 unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
50 unsigned Pad : 1; /* BOOL */
51 unsigned Indirect : 1; /* BOOL */
52 unsigned Absolute : 1; /* BOOL */
53 int Index : 16; /* SINT */
54 unsigned Negate : 1; /* BOOL */
55 int IndirectIndex : 16; /* SINT */
56 int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
57 };
58
59 /* Very similar to a tgsi_dst_register, removing unsupported fields
60 * and adding a Saturate flag. It's easier to push saturate into the
61 * destination register than to try and create a _SAT varient of each
62 * instruction function.
63 */
64 struct ureg_dst
65 {
66 unsigned File : 4; /* TGSI_FILE_ */
67 unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
68 unsigned Indirect : 1; /* BOOL */
69 unsigned Saturate : 1; /* BOOL */
70 unsigned Predicate : 1;
71 unsigned PredNegate : 1; /* BOOL */
72 unsigned PredSwizzleX: 2; /* TGSI_SWIZZLE_ */
73 unsigned PredSwizzleY: 2; /* TGSI_SWIZZLE_ */
74 unsigned PredSwizzleZ: 2; /* TGSI_SWIZZLE_ */
75 unsigned PredSwizzleW: 2; /* TGSI_SWIZZLE_ */
76 int Index : 16; /* SINT */
77 int IndirectIndex : 16; /* SINT */
78 int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
79 };
80
81 struct pipe_context;
82
83 struct ureg_program *
84 ureg_create( unsigned processor );
85
86 const struct tgsi_token *
87 ureg_finalize( struct ureg_program * );
88
89 /* Create and return a shader:
90 */
91 void *
92 ureg_create_shader( struct ureg_program *,
93 struct pipe_context *pipe );
94
95
96 /* Alternately, return the built token stream and hand ownership of
97 * that memory to the caller:
98 */
99 const struct tgsi_token *
100 ureg_get_tokens( struct ureg_program *ureg,
101 unsigned *nr_tokens );
102
103
104 void
105 ureg_destroy( struct ureg_program * );
106
107
108 /***********************************************************************
109 * Convenience routine:
110 */
111 static INLINE void *
112 ureg_create_shader_and_destroy( struct ureg_program *p,
113 struct pipe_context *pipe )
114 {
115 void *result = ureg_create_shader( p, pipe );
116 ureg_destroy( p );
117 return result;
118 }
119
120
121
122 /***********************************************************************
123 * Build shader declarations:
124 */
125
126 struct ureg_src
127 ureg_DECL_fs_input( struct ureg_program *,
128 unsigned semantic_name,
129 unsigned semantic_index,
130 unsigned interp_mode );
131
132 struct ureg_src
133 ureg_DECL_vs_input( struct ureg_program *,
134 unsigned index );
135
136 struct ureg_src
137 ureg_DECL_gs_input(struct ureg_program *,
138 unsigned index);
139
140 struct ureg_dst
141 ureg_DECL_output( struct ureg_program *,
142 unsigned semantic_name,
143 unsigned semantic_index );
144
145 struct ureg_src
146 ureg_DECL_immediate( struct ureg_program *,
147 const float *v,
148 unsigned nr );
149
150 struct ureg_src
151 ureg_DECL_immediate_uint( struct ureg_program *,
152 const unsigned *v,
153 unsigned nr );
154
155 struct ureg_src
156 ureg_DECL_immediate_int( struct ureg_program *,
157 const int *v,
158 unsigned nr );
159
160 struct ureg_src
161 ureg_DECL_constant( struct ureg_program *,
162 unsigned index );
163
164 struct ureg_dst
165 ureg_DECL_temporary( struct ureg_program * );
166
167 void
168 ureg_release_temporary( struct ureg_program *ureg,
169 struct ureg_dst tmp );
170
171 struct ureg_dst
172 ureg_DECL_address( struct ureg_program * );
173
174 struct ureg_dst
175 ureg_DECL_loop( struct ureg_program * );
176
177 struct ureg_dst
178 ureg_DECL_predicate(struct ureg_program *);
179
180 /* Supply an index to the sampler declaration as this is the hook to
181 * the external pipe_sampler state. Users of this function probably
182 * don't want just any sampler, but a specific one which they've set
183 * up state for in the context.
184 */
185 struct ureg_src
186 ureg_DECL_sampler( struct ureg_program *,
187 unsigned index );
188
189
190 static INLINE struct ureg_src
191 ureg_imm4f( struct ureg_program *ureg,
192 float a, float b,
193 float c, float d)
194 {
195 float v[4];
196 v[0] = a;
197 v[1] = b;
198 v[2] = c;
199 v[3] = d;
200 return ureg_DECL_immediate( ureg, v, 4 );
201 }
202
203 static INLINE struct ureg_src
204 ureg_imm3f( struct ureg_program *ureg,
205 float a, float b,
206 float c)
207 {
208 float v[3];
209 v[0] = a;
210 v[1] = b;
211 v[2] = c;
212 return ureg_DECL_immediate( ureg, v, 3 );
213 }
214
215 static INLINE struct ureg_src
216 ureg_imm2f( struct ureg_program *ureg,
217 float a, float b)
218 {
219 float v[2];
220 v[0] = a;
221 v[1] = b;
222 return ureg_DECL_immediate( ureg, v, 2 );
223 }
224
225 static INLINE struct ureg_src
226 ureg_imm1f( struct ureg_program *ureg,
227 float a)
228 {
229 float v[1];
230 v[0] = a;
231 return ureg_DECL_immediate( ureg, v, 1 );
232 }
233
234 static INLINE struct ureg_src
235 ureg_imm4u( struct ureg_program *ureg,
236 unsigned a, unsigned b,
237 unsigned c, unsigned d)
238 {
239 unsigned v[4];
240 v[0] = a;
241 v[1] = b;
242 v[2] = c;
243 v[3] = d;
244 return ureg_DECL_immediate_uint( ureg, v, 4 );
245 }
246
247 static INLINE struct ureg_src
248 ureg_imm3u( struct ureg_program *ureg,
249 unsigned a, unsigned b,
250 unsigned c)
251 {
252 unsigned v[3];
253 v[0] = a;
254 v[1] = b;
255 v[2] = c;
256 return ureg_DECL_immediate_uint( ureg, v, 3 );
257 }
258
259 static INLINE struct ureg_src
260 ureg_imm2u( struct ureg_program *ureg,
261 unsigned a, unsigned b)
262 {
263 unsigned v[2];
264 v[0] = a;
265 v[1] = b;
266 return ureg_DECL_immediate_uint( ureg, v, 2 );
267 }
268
269 static INLINE struct ureg_src
270 ureg_imm1u( struct ureg_program *ureg,
271 unsigned a)
272 {
273 return ureg_DECL_immediate_uint( ureg, &a, 1 );
274 }
275
276 static INLINE struct ureg_src
277 ureg_imm4i( struct ureg_program *ureg,
278 int a, int b,
279 int c, int d)
280 {
281 int v[4];
282 v[0] = a;
283 v[1] = b;
284 v[2] = c;
285 v[3] = d;
286 return ureg_DECL_immediate_int( ureg, v, 4 );
287 }
288
289 static INLINE struct ureg_src
290 ureg_imm3i( struct ureg_program *ureg,
291 int a, int b,
292 int c)
293 {
294 int v[3];
295 v[0] = a;
296 v[1] = b;
297 v[2] = c;
298 return ureg_DECL_immediate_int( ureg, v, 3 );
299 }
300
301 static INLINE struct ureg_src
302 ureg_imm2i( struct ureg_program *ureg,
303 int a, int b)
304 {
305 int v[2];
306 v[0] = a;
307 v[1] = b;
308 return ureg_DECL_immediate_int( ureg, v, 2 );
309 }
310
311 static INLINE struct ureg_src
312 ureg_imm1i( struct ureg_program *ureg,
313 int a)
314 {
315 return ureg_DECL_immediate_int( ureg, &a, 1 );
316 }
317
318 /***********************************************************************
319 * Functions for patching up labels
320 */
321
322
323 /* Will return a number which can be used in a label to point to the
324 * next instruction to be emitted.
325 */
326 unsigned
327 ureg_get_instruction_number( struct ureg_program *ureg );
328
329
330 /* Patch a given label (expressed as a token number) to point to a
331 * given instruction (expressed as an instruction number).
332 *
333 * Labels are obtained from instruction emitters, eg ureg_CAL().
334 * Instruction numbers are obtained from ureg_get_instruction_number(),
335 * above.
336 */
337 void
338 ureg_fixup_label(struct ureg_program *ureg,
339 unsigned label_token,
340 unsigned instruction_number );
341
342
343 /* Generic instruction emitter. Use if you need to pass the opcode as
344 * a parameter, rather than using the emit_OP() varients below.
345 */
346 void
347 ureg_insn(struct ureg_program *ureg,
348 unsigned opcode,
349 const struct ureg_dst *dst,
350 unsigned nr_dst,
351 const struct ureg_src *src,
352 unsigned nr_src );
353
354
355 void
356 ureg_tex_insn(struct ureg_program *ureg,
357 unsigned opcode,
358 const struct ureg_dst *dst,
359 unsigned nr_dst,
360 unsigned target,
361 const struct ureg_src *src,
362 unsigned nr_src );
363
364
365 void
366 ureg_label_insn(struct ureg_program *ureg,
367 unsigned opcode,
368 const struct ureg_src *src,
369 unsigned nr_src,
370 unsigned *label);
371
372
373 /***********************************************************************
374 * Internal instruction helpers, don't call these directly:
375 */
376
377 struct ureg_emit_insn_result {
378 unsigned insn_token; /*< Used to fixup insn size. */
379 unsigned extended_token; /*< Used to set the Extended bit, usually the same as insn_token. */
380 };
381
382 struct ureg_emit_insn_result
383 ureg_emit_insn(struct ureg_program *ureg,
384 unsigned opcode,
385 boolean saturate,
386 boolean predicate,
387 boolean pred_negate,
388 unsigned pred_swizzle_x,
389 unsigned pred_swizzle_y,
390 unsigned pred_swizzle_z,
391 unsigned pred_swizzle_w,
392 unsigned num_dst,
393 unsigned num_src );
394
395 void
396 ureg_emit_label(struct ureg_program *ureg,
397 unsigned insn_token,
398 unsigned *label_token );
399
400 void
401 ureg_emit_texture(struct ureg_program *ureg,
402 unsigned insn_token,
403 unsigned target );
404
405 void
406 ureg_emit_dst( struct ureg_program *ureg,
407 struct ureg_dst dst );
408
409 void
410 ureg_emit_src( struct ureg_program *ureg,
411 struct ureg_src src );
412
413 void
414 ureg_fixup_insn_size(struct ureg_program *ureg,
415 unsigned insn );
416
417
418 #define OP00( op ) \
419 static INLINE void ureg_##op( struct ureg_program *ureg ) \
420 { \
421 unsigned opcode = TGSI_OPCODE_##op; \
422 unsigned insn = ureg_emit_insn(ureg, \
423 opcode, \
424 FALSE, \
425 FALSE, \
426 FALSE, \
427 TGSI_SWIZZLE_X, \
428 TGSI_SWIZZLE_Y, \
429 TGSI_SWIZZLE_Z, \
430 TGSI_SWIZZLE_W, \
431 0, \
432 0).insn_token; \
433 ureg_fixup_insn_size( ureg, insn ); \
434 }
435
436 #define OP01( op ) \
437 static INLINE void ureg_##op( struct ureg_program *ureg, \
438 struct ureg_src src ) \
439 { \
440 unsigned opcode = TGSI_OPCODE_##op; \
441 unsigned insn = ureg_emit_insn(ureg, \
442 opcode, \
443 FALSE, \
444 FALSE, \
445 FALSE, \
446 TGSI_SWIZZLE_X, \
447 TGSI_SWIZZLE_Y, \
448 TGSI_SWIZZLE_Z, \
449 TGSI_SWIZZLE_W, \
450 0, \
451 1).insn_token; \
452 ureg_emit_src( ureg, src ); \
453 ureg_fixup_insn_size( ureg, insn ); \
454 }
455
456 #define OP00_LBL( op ) \
457 static INLINE void ureg_##op( struct ureg_program *ureg, \
458 unsigned *label_token ) \
459 { \
460 unsigned opcode = TGSI_OPCODE_##op; \
461 struct ureg_emit_insn_result insn; \
462 insn = ureg_emit_insn(ureg, \
463 opcode, \
464 FALSE, \
465 FALSE, \
466 FALSE, \
467 TGSI_SWIZZLE_X, \
468 TGSI_SWIZZLE_Y, \
469 TGSI_SWIZZLE_Z, \
470 TGSI_SWIZZLE_W, \
471 0, \
472 0); \
473 ureg_emit_label( ureg, insn.extended_token, label_token ); \
474 ureg_fixup_insn_size( ureg, insn.insn_token ); \
475 }
476
477 #define OP01_LBL( op ) \
478 static INLINE void ureg_##op( struct ureg_program *ureg, \
479 struct ureg_src src, \
480 unsigned *label_token ) \
481 { \
482 unsigned opcode = TGSI_OPCODE_##op; \
483 struct ureg_emit_insn_result insn; \
484 insn = ureg_emit_insn(ureg, \
485 opcode, \
486 FALSE, \
487 FALSE, \
488 FALSE, \
489 TGSI_SWIZZLE_X, \
490 TGSI_SWIZZLE_Y, \
491 TGSI_SWIZZLE_Z, \
492 TGSI_SWIZZLE_W, \
493 0, \
494 1); \
495 ureg_emit_label( ureg, insn.extended_token, label_token ); \
496 ureg_emit_src( ureg, src ); \
497 ureg_fixup_insn_size( ureg, insn.insn_token ); \
498 }
499
500 #define OP10( op ) \
501 static INLINE void ureg_##op( struct ureg_program *ureg, \
502 struct ureg_dst dst ) \
503 { \
504 unsigned opcode = TGSI_OPCODE_##op; \
505 unsigned insn = ureg_emit_insn(ureg, \
506 opcode, \
507 dst.Saturate, \
508 dst.Predicate, \
509 dst.PredNegate, \
510 dst.PredSwizzleX, \
511 dst.PredSwizzleY, \
512 dst.PredSwizzleZ, \
513 dst.PredSwizzleW, \
514 1, \
515 0).insn_token; \
516 ureg_emit_dst( ureg, dst ); \
517 ureg_fixup_insn_size( ureg, insn ); \
518 }
519
520
521 #define OP11( op ) \
522 static INLINE void ureg_##op( struct ureg_program *ureg, \
523 struct ureg_dst dst, \
524 struct ureg_src src ) \
525 { \
526 unsigned opcode = TGSI_OPCODE_##op; \
527 unsigned insn = ureg_emit_insn(ureg, \
528 opcode, \
529 dst.Saturate, \
530 dst.Predicate, \
531 dst.PredNegate, \
532 dst.PredSwizzleX, \
533 dst.PredSwizzleY, \
534 dst.PredSwizzleZ, \
535 dst.PredSwizzleW, \
536 1, \
537 1).insn_token; \
538 ureg_emit_dst( ureg, dst ); \
539 ureg_emit_src( ureg, src ); \
540 ureg_fixup_insn_size( ureg, insn ); \
541 }
542
543 #define OP12( op ) \
544 static INLINE void ureg_##op( struct ureg_program *ureg, \
545 struct ureg_dst dst, \
546 struct ureg_src src0, \
547 struct ureg_src src1 ) \
548 { \
549 unsigned opcode = TGSI_OPCODE_##op; \
550 unsigned insn = ureg_emit_insn(ureg, \
551 opcode, \
552 dst.Saturate, \
553 dst.Predicate, \
554 dst.PredNegate, \
555 dst.PredSwizzleX, \
556 dst.PredSwizzleY, \
557 dst.PredSwizzleZ, \
558 dst.PredSwizzleW, \
559 1, \
560 2).insn_token; \
561 ureg_emit_dst( ureg, dst ); \
562 ureg_emit_src( ureg, src0 ); \
563 ureg_emit_src( ureg, src1 ); \
564 ureg_fixup_insn_size( ureg, insn ); \
565 }
566
567 #define OP12_TEX( op ) \
568 static INLINE void ureg_##op( struct ureg_program *ureg, \
569 struct ureg_dst dst, \
570 unsigned target, \
571 struct ureg_src src0, \
572 struct ureg_src src1 ) \
573 { \
574 unsigned opcode = TGSI_OPCODE_##op; \
575 struct ureg_emit_insn_result insn; \
576 insn = ureg_emit_insn(ureg, \
577 opcode, \
578 dst.Saturate, \
579 dst.Predicate, \
580 dst.PredNegate, \
581 dst.PredSwizzleX, \
582 dst.PredSwizzleY, \
583 dst.PredSwizzleZ, \
584 dst.PredSwizzleW, \
585 1, \
586 2); \
587 ureg_emit_texture( ureg, insn.extended_token, target ); \
588 ureg_emit_dst( ureg, dst ); \
589 ureg_emit_src( ureg, src0 ); \
590 ureg_emit_src( ureg, src1 ); \
591 ureg_fixup_insn_size( ureg, insn.insn_token ); \
592 }
593
594 #define OP13( op ) \
595 static INLINE void ureg_##op( struct ureg_program *ureg, \
596 struct ureg_dst dst, \
597 struct ureg_src src0, \
598 struct ureg_src src1, \
599 struct ureg_src src2 ) \
600 { \
601 unsigned opcode = TGSI_OPCODE_##op; \
602 unsigned insn = ureg_emit_insn(ureg, \
603 opcode, \
604 dst.Saturate, \
605 dst.Predicate, \
606 dst.PredNegate, \
607 dst.PredSwizzleX, \
608 dst.PredSwizzleY, \
609 dst.PredSwizzleZ, \
610 dst.PredSwizzleW, \
611 1, \
612 3).insn_token; \
613 ureg_emit_dst( ureg, dst ); \
614 ureg_emit_src( ureg, src0 ); \
615 ureg_emit_src( ureg, src1 ); \
616 ureg_emit_src( ureg, src2 ); \
617 ureg_fixup_insn_size( ureg, insn ); \
618 }
619
620 #define OP14_TEX( op ) \
621 static INLINE void ureg_##op( struct ureg_program *ureg, \
622 struct ureg_dst dst, \
623 unsigned target, \
624 struct ureg_src src0, \
625 struct ureg_src src1, \
626 struct ureg_src src2, \
627 struct ureg_src src3 ) \
628 { \
629 unsigned opcode = TGSI_OPCODE_##op; \
630 struct ureg_emit_insn_result insn; \
631 insn = ureg_emit_insn(ureg, \
632 opcode, \
633 dst.Saturate, \
634 dst.Predicate, \
635 dst.PredNegate, \
636 dst.PredSwizzleX, \
637 dst.PredSwizzleY, \
638 dst.PredSwizzleZ, \
639 dst.PredSwizzleW, \
640 1, \
641 4); \
642 ureg_emit_texture( ureg, insn.extended_token, target ); \
643 ureg_emit_dst( ureg, dst ); \
644 ureg_emit_src( ureg, src0 ); \
645 ureg_emit_src( ureg, src1 ); \
646 ureg_emit_src( ureg, src2 ); \
647 ureg_emit_src( ureg, src3 ); \
648 ureg_fixup_insn_size( ureg, insn.insn_token ); \
649 }
650
651
652 /* Use a template include to generate a correctly-typed ureg_OP()
653 * function for each TGSI opcode:
654 */
655 #include "tgsi_opcode_tmp.h"
656
657
658 /***********************************************************************
659 * Inline helpers for manipulating register structs:
660 */
661 static INLINE struct ureg_src
662 ureg_negate( struct ureg_src reg )
663 {
664 assert(reg.File != TGSI_FILE_NULL);
665 reg.Negate ^= 1;
666 return reg;
667 }
668
669 static INLINE struct ureg_src
670 ureg_abs( struct ureg_src reg )
671 {
672 assert(reg.File != TGSI_FILE_NULL);
673 reg.Absolute = 1;
674 reg.Negate = 0;
675 return reg;
676 }
677
678 static INLINE struct ureg_src
679 ureg_swizzle( struct ureg_src reg,
680 int x, int y, int z, int w )
681 {
682 unsigned swz = ( (reg.SwizzleX << 0) |
683 (reg.SwizzleY << 2) |
684 (reg.SwizzleZ << 4) |
685 (reg.SwizzleW << 6));
686
687 assert(reg.File != TGSI_FILE_NULL);
688 assert(x < 4);
689 assert(y < 4);
690 assert(z < 4);
691 assert(w < 4);
692
693 reg.SwizzleX = (swz >> (x*2)) & 0x3;
694 reg.SwizzleY = (swz >> (y*2)) & 0x3;
695 reg.SwizzleZ = (swz >> (z*2)) & 0x3;
696 reg.SwizzleW = (swz >> (w*2)) & 0x3;
697 return reg;
698 }
699
700 static INLINE struct ureg_src
701 ureg_scalar( struct ureg_src reg, int x )
702 {
703 return ureg_swizzle(reg, x, x, x, x);
704 }
705
706 static INLINE struct ureg_dst
707 ureg_writemask( struct ureg_dst reg,
708 unsigned writemask )
709 {
710 assert(reg.File != TGSI_FILE_NULL);
711 reg.WriteMask &= writemask;
712 return reg;
713 }
714
715 static INLINE struct ureg_dst
716 ureg_saturate( struct ureg_dst reg )
717 {
718 assert(reg.File != TGSI_FILE_NULL);
719 reg.Saturate = 1;
720 return reg;
721 }
722
723 static INLINE struct ureg_dst
724 ureg_predicate(struct ureg_dst reg,
725 boolean negate,
726 unsigned swizzle_x,
727 unsigned swizzle_y,
728 unsigned swizzle_z,
729 unsigned swizzle_w)
730 {
731 assert(reg.File != TGSI_FILE_NULL);
732 reg.Predicate = 1;
733 reg.PredNegate = negate;
734 reg.PredSwizzleX = swizzle_x;
735 reg.PredSwizzleY = swizzle_y;
736 reg.PredSwizzleZ = swizzle_z;
737 reg.PredSwizzleW = swizzle_w;
738 return reg;
739 }
740
741 static INLINE struct ureg_dst
742 ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
743 {
744 assert(reg.File != TGSI_FILE_NULL);
745 assert(addr.File == TGSI_FILE_ADDRESS);
746 reg.Indirect = 1;
747 reg.IndirectIndex = addr.Index;
748 reg.IndirectSwizzle = addr.SwizzleX;
749 return reg;
750 }
751
752 static INLINE struct ureg_src
753 ureg_src_indirect( struct ureg_src reg, struct ureg_src addr )
754 {
755 assert(reg.File != TGSI_FILE_NULL);
756 assert(addr.File == TGSI_FILE_ADDRESS);
757 reg.Indirect = 1;
758 reg.IndirectIndex = addr.Index;
759 reg.IndirectSwizzle = addr.SwizzleX;
760 return reg;
761 }
762
763 static INLINE struct ureg_dst
764 ureg_dst( struct ureg_src src )
765 {
766 struct ureg_dst dst;
767
768 dst.File = src.File;
769 dst.WriteMask = TGSI_WRITEMASK_XYZW;
770 dst.Indirect = src.Indirect;
771 dst.IndirectIndex = src.IndirectIndex;
772 dst.IndirectSwizzle = src.IndirectSwizzle;
773 dst.Saturate = 0;
774 dst.Predicate = 0;
775 dst.PredNegate = 0;
776 dst.PredSwizzleX = TGSI_SWIZZLE_X;
777 dst.PredSwizzleY = TGSI_SWIZZLE_Y;
778 dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
779 dst.PredSwizzleW = TGSI_SWIZZLE_W;
780 dst.Index = src.Index;
781
782 return dst;
783 }
784
785 static INLINE struct ureg_src
786 ureg_src( struct ureg_dst dst )
787 {
788 struct ureg_src src;
789
790 src.File = dst.File;
791 src.SwizzleX = TGSI_SWIZZLE_X;
792 src.SwizzleY = TGSI_SWIZZLE_Y;
793 src.SwizzleZ = TGSI_SWIZZLE_Z;
794 src.SwizzleW = TGSI_SWIZZLE_W;
795 src.Pad = 0;
796 src.Indirect = dst.Indirect;
797 src.IndirectIndex = dst.IndirectIndex;
798 src.IndirectSwizzle = dst.IndirectSwizzle;
799 src.Absolute = 0;
800 src.Index = dst.Index;
801 src.Negate = 0;
802
803 return src;
804 }
805
806
807
808 static INLINE struct ureg_dst
809 ureg_dst_undef( void )
810 {
811 struct ureg_dst dst;
812
813 dst.File = TGSI_FILE_NULL;
814 dst.WriteMask = 0;
815 dst.Indirect = 0;
816 dst.IndirectIndex = 0;
817 dst.IndirectSwizzle = 0;
818 dst.Saturate = 0;
819 dst.Predicate = 0;
820 dst.PredNegate = 0;
821 dst.PredSwizzleX = TGSI_SWIZZLE_X;
822 dst.PredSwizzleY = TGSI_SWIZZLE_Y;
823 dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
824 dst.PredSwizzleW = TGSI_SWIZZLE_W;
825 dst.Index = 0;
826
827 return dst;
828 }
829
830 static INLINE struct ureg_src
831 ureg_src_undef( void )
832 {
833 struct ureg_src src;
834
835 src.File = TGSI_FILE_NULL;
836 src.SwizzleX = 0;
837 src.SwizzleY = 0;
838 src.SwizzleZ = 0;
839 src.SwizzleW = 0;
840 src.Pad = 0;
841 src.Indirect = 0;
842 src.IndirectIndex = 0;
843 src.IndirectSwizzle = 0;
844 src.Absolute = 0;
845 src.Index = 0;
846 src.Negate = 0;
847
848 return src;
849 }
850
851 static INLINE boolean
852 ureg_src_is_undef( struct ureg_src src )
853 {
854 return src.File == TGSI_FILE_NULL;
855 }
856
857 static INLINE boolean
858 ureg_dst_is_undef( struct ureg_dst dst )
859 {
860 return dst.File == TGSI_FILE_NULL;
861 }
862
863
864 #ifdef __cplusplus
865 }
866 #endif
867
868 #endif