tgsi_ureg.h revision 4a49301e
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
35extern "C" {
36#endif
37
38struct 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 */
43struct 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 */
64struct 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
81struct pipe_context;
82
83struct ureg_program *
84ureg_create( unsigned processor );
85
86const struct tgsi_token *
87ureg_finalize( struct ureg_program * );
88
89/* Create and return a shader:
90 */
91void *
92ureg_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 */
99const struct tgsi_token *
100ureg_get_tokens( struct ureg_program *ureg,
101                 unsigned *nr_tokens );
102
103
104void
105ureg_destroy( struct ureg_program * );
106
107
108/***********************************************************************
109 * Convenience routine:
110 */
111static INLINE void *
112ureg_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
126struct ureg_src
127ureg_DECL_fs_input( struct ureg_program *,
128                    unsigned semantic_name,
129                    unsigned semantic_index,
130                    unsigned interp_mode );
131
132struct ureg_src
133ureg_DECL_vs_input( struct ureg_program *,
134                    unsigned index );
135
136struct ureg_dst
137ureg_DECL_output( struct ureg_program *,
138                  unsigned semantic_name,
139                  unsigned semantic_index );
140
141struct ureg_src
142ureg_DECL_immediate( struct ureg_program *,
143                     const float *v,
144                     unsigned nr );
145
146struct ureg_src
147ureg_DECL_constant( struct ureg_program *,
148                    unsigned index );
149
150struct ureg_dst
151ureg_DECL_temporary( struct ureg_program * );
152
153void
154ureg_release_temporary( struct ureg_program *ureg,
155                        struct ureg_dst tmp );
156
157struct ureg_dst
158ureg_DECL_address( struct ureg_program * );
159
160struct ureg_dst
161ureg_DECL_predicate(struct ureg_program *);
162
163/* Supply an index to the sampler declaration as this is the hook to
164 * the external pipe_sampler state.  Users of this function probably
165 * don't want just any sampler, but a specific one which they've set
166 * up state for in the context.
167 */
168struct ureg_src
169ureg_DECL_sampler( struct ureg_program *,
170                   unsigned index );
171
172
173static INLINE struct ureg_src
174ureg_imm4f( struct ureg_program *ureg,
175                       float a, float b,
176                       float c, float d)
177{
178   float v[4];
179   v[0] = a;
180   v[1] = b;
181   v[2] = c;
182   v[3] = d;
183   return ureg_DECL_immediate( ureg, v, 4 );
184}
185
186static INLINE struct ureg_src
187ureg_imm3f( struct ureg_program *ureg,
188                       float a, float b,
189                       float c)
190{
191   float v[3];
192   v[0] = a;
193   v[1] = b;
194   v[2] = c;
195   return ureg_DECL_immediate( ureg, v, 3 );
196}
197
198static INLINE struct ureg_src
199ureg_imm2f( struct ureg_program *ureg,
200                       float a, float b)
201{
202   float v[2];
203   v[0] = a;
204   v[1] = b;
205   return ureg_DECL_immediate( ureg, v, 2 );
206}
207
208static INLINE struct ureg_src
209ureg_imm1f( struct ureg_program *ureg,
210                       float a)
211{
212   float v[1];
213   v[0] = a;
214   return ureg_DECL_immediate( ureg, v, 1 );
215}
216
217/***********************************************************************
218 * Functions for patching up labels
219 */
220
221
222/* Will return a number which can be used in a label to point to the
223 * next instruction to be emitted.
224 */
225unsigned
226ureg_get_instruction_number( struct ureg_program *ureg );
227
228
229/* Patch a given label (expressed as a token number) to point to a
230 * given instruction (expressed as an instruction number).
231 *
232 * Labels are obtained from instruction emitters, eg ureg_CAL().
233 * Instruction numbers are obtained from ureg_get_instruction_number(),
234 * above.
235 */
236void
237ureg_fixup_label(struct ureg_program *ureg,
238                 unsigned label_token,
239                 unsigned instruction_number );
240
241
242/* Generic instruction emitter.  Use if you need to pass the opcode as
243 * a parameter, rather than using the emit_OP() varients below.
244 */
245void
246ureg_insn(struct ureg_program *ureg,
247          unsigned opcode,
248          const struct ureg_dst *dst,
249          unsigned nr_dst,
250          const struct ureg_src *src,
251          unsigned nr_src );
252
253
254void
255ureg_tex_insn(struct ureg_program *ureg,
256              unsigned opcode,
257              const struct ureg_dst *dst,
258              unsigned nr_dst,
259              unsigned target,
260              const struct ureg_src *src,
261              unsigned nr_src );
262
263
264void
265ureg_label_insn(struct ureg_program *ureg,
266                unsigned opcode,
267                const struct ureg_src *src,
268                unsigned nr_src,
269                unsigned *label);
270
271
272/***********************************************************************
273 * Internal instruction helpers, don't call these directly:
274 */
275
276struct ureg_emit_insn_result {
277   unsigned insn_token;       /*< Used to fixup insn size. */
278   unsigned extended_token;   /*< Used to set the Extended bit, usually the same as insn_token. */
279};
280
281struct ureg_emit_insn_result
282ureg_emit_insn(struct ureg_program *ureg,
283               unsigned opcode,
284               boolean saturate,
285               boolean predicate,
286               boolean pred_negate,
287               unsigned pred_swizzle_x,
288               unsigned pred_swizzle_y,
289               unsigned pred_swizzle_z,
290               unsigned pred_swizzle_w,
291               unsigned num_dst,
292               unsigned num_src );
293
294void
295ureg_emit_label(struct ureg_program *ureg,
296                unsigned insn_token,
297                unsigned *label_token );
298
299void
300ureg_emit_texture(struct ureg_program *ureg,
301                  unsigned insn_token,
302                  unsigned target );
303
304void
305ureg_emit_dst( struct ureg_program *ureg,
306               struct ureg_dst dst );
307
308void
309ureg_emit_src( struct ureg_program *ureg,
310               struct ureg_src src );
311
312void
313ureg_fixup_insn_size(struct ureg_program *ureg,
314                     unsigned insn );
315
316
317#define OP00( op )                                              \
318static INLINE void ureg_##op( struct ureg_program *ureg )       \
319{                                                               \
320   unsigned opcode = TGSI_OPCODE_##op;                          \
321   unsigned insn = ureg_emit_insn(ureg,                         \
322                                  opcode,                       \
323                                  FALSE,                        \
324                                  FALSE,                        \
325                                  FALSE,                        \
326                                  TGSI_SWIZZLE_X,               \
327                                  TGSI_SWIZZLE_Y,               \
328                                  TGSI_SWIZZLE_Z,               \
329                                  TGSI_SWIZZLE_W,               \
330                                  0,                            \
331                                  0).insn_token;                \
332   ureg_fixup_insn_size( ureg, insn );                          \
333}
334
335#define OP01( op )                                              \
336static INLINE void ureg_##op( struct ureg_program *ureg,        \
337                              struct ureg_src src )             \
338{                                                               \
339   unsigned opcode = TGSI_OPCODE_##op;                          \
340   unsigned insn = ureg_emit_insn(ureg,                         \
341                                  opcode,                       \
342                                  FALSE,                        \
343                                  FALSE,                        \
344                                  FALSE,                        \
345                                  TGSI_SWIZZLE_X,               \
346                                  TGSI_SWIZZLE_Y,               \
347                                  TGSI_SWIZZLE_Z,               \
348                                  TGSI_SWIZZLE_W,               \
349                                  0,                            \
350                                  1).insn_token;                \
351   ureg_emit_src( ureg, src );                                  \
352   ureg_fixup_insn_size( ureg, insn );                          \
353}
354
355#define OP00_LBL( op )                                          \
356static INLINE void ureg_##op( struct ureg_program *ureg,        \
357                              unsigned *label_token )           \
358{                                                               \
359   unsigned opcode = TGSI_OPCODE_##op;                          \
360   struct ureg_emit_insn_result insn;                           \
361   insn = ureg_emit_insn(ureg,                                  \
362                         opcode,                                \
363                         FALSE,                                 \
364                         FALSE,                                 \
365                         FALSE,                                 \
366                         TGSI_SWIZZLE_X,                        \
367                         TGSI_SWIZZLE_Y,                        \
368                         TGSI_SWIZZLE_Z,                        \
369                         TGSI_SWIZZLE_W,                        \
370                         0,                                     \
371                         0);                                    \
372   ureg_emit_label( ureg, insn.extended_token, label_token );   \
373   ureg_fixup_insn_size( ureg, insn.insn_token );               \
374}
375
376#define OP01_LBL( op )                                          \
377static INLINE void ureg_##op( struct ureg_program *ureg,        \
378                              struct ureg_src src,              \
379                              unsigned *label_token )          \
380{                                                               \
381   unsigned opcode = TGSI_OPCODE_##op;                          \
382   struct ureg_emit_insn_result insn;                           \
383   insn = ureg_emit_insn(ureg,                                  \
384                         opcode,                                \
385                         FALSE,                                 \
386                         FALSE,                                 \
387                         FALSE,                                 \
388                         TGSI_SWIZZLE_X,                        \
389                         TGSI_SWIZZLE_Y,                        \
390                         TGSI_SWIZZLE_Z,                        \
391                         TGSI_SWIZZLE_W,                        \
392                         0,                                     \
393                         1);                                    \
394   ureg_emit_label( ureg, insn.extended_token, label_token );   \
395   ureg_emit_src( ureg, src );                                  \
396   ureg_fixup_insn_size( ureg, insn.insn_token );               \
397}
398
399#define OP10( op )                                                      \
400static INLINE void ureg_##op( struct ureg_program *ureg,                \
401                              struct ureg_dst dst )                     \
402{                                                                       \
403   unsigned opcode = TGSI_OPCODE_##op;                                  \
404   unsigned insn = ureg_emit_insn(ureg,                                 \
405                                  opcode,                               \
406                                  dst.Saturate,                         \
407                                  dst.Predicate,                        \
408                                  dst.PredNegate,                       \
409                                  dst.PredSwizzleX,                     \
410                                  dst.PredSwizzleY,                     \
411                                  dst.PredSwizzleZ,                     \
412                                  dst.PredSwizzleW,                     \
413                                  1,                                    \
414                                  0).insn_token;                        \
415   ureg_emit_dst( ureg, dst );                                          \
416   ureg_fixup_insn_size( ureg, insn );                                  \
417}
418
419
420#define OP11( op )                                                      \
421static INLINE void ureg_##op( struct ureg_program *ureg,                \
422                              struct ureg_dst dst,                      \
423                              struct ureg_src src )                     \
424{                                                                       \
425   unsigned opcode = TGSI_OPCODE_##op;                                  \
426   unsigned insn = ureg_emit_insn(ureg,                                 \
427                                  opcode,                               \
428                                  dst.Saturate,                         \
429                                  dst.Predicate,                        \
430                                  dst.PredNegate,                       \
431                                  dst.PredSwizzleX,                     \
432                                  dst.PredSwizzleY,                     \
433                                  dst.PredSwizzleZ,                     \
434                                  dst.PredSwizzleW,                     \
435                                  1,                                    \
436                                  1).insn_token;                        \
437   ureg_emit_dst( ureg, dst );                                          \
438   ureg_emit_src( ureg, src );                                          \
439   ureg_fixup_insn_size( ureg, insn );                                  \
440}
441
442#define OP12( op )                                                      \
443static INLINE void ureg_##op( struct ureg_program *ureg,                \
444                              struct ureg_dst dst,                      \
445                              struct ureg_src src0,                     \
446                              struct ureg_src src1 )                    \
447{                                                                       \
448   unsigned opcode = TGSI_OPCODE_##op;                                  \
449   unsigned insn = ureg_emit_insn(ureg,                                 \
450                                  opcode,                               \
451                                  dst.Saturate,                         \
452                                  dst.Predicate,                        \
453                                  dst.PredNegate,                       \
454                                  dst.PredSwizzleX,                     \
455                                  dst.PredSwizzleY,                     \
456                                  dst.PredSwizzleZ,                     \
457                                  dst.PredSwizzleW,                     \
458                                  1,                                    \
459                                  2).insn_token;                        \
460   ureg_emit_dst( ureg, dst );                                          \
461   ureg_emit_src( ureg, src0 );                                         \
462   ureg_emit_src( ureg, src1 );                                         \
463   ureg_fixup_insn_size( ureg, insn );                                  \
464}
465
466#define OP12_TEX( op )                                                  \
467static INLINE void ureg_##op( struct ureg_program *ureg,                \
468                              struct ureg_dst dst,                      \
469                              unsigned target,                          \
470                              struct ureg_src src0,                     \
471                              struct ureg_src src1 )                    \
472{                                                                       \
473   unsigned opcode = TGSI_OPCODE_##op;                                  \
474   struct ureg_emit_insn_result insn;                                   \
475   insn = ureg_emit_insn(ureg,                                          \
476                         opcode,                                        \
477                         dst.Saturate,                                  \
478                         dst.Predicate,                                 \
479                         dst.PredNegate,                                \
480                         dst.PredSwizzleX,                              \
481                         dst.PredSwizzleY,                              \
482                         dst.PredSwizzleZ,                              \
483                         dst.PredSwizzleW,                              \
484                         1,                                             \
485                         2);                                            \
486   ureg_emit_texture( ureg, insn.extended_token, target );              \
487   ureg_emit_dst( ureg, dst );                                          \
488   ureg_emit_src( ureg, src0 );                                         \
489   ureg_emit_src( ureg, src1 );                                         \
490   ureg_fixup_insn_size( ureg, insn.insn_token );                       \
491}
492
493#define OP13( op )                                                      \
494static INLINE void ureg_##op( struct ureg_program *ureg,                \
495                              struct ureg_dst dst,                      \
496                              struct ureg_src src0,                     \
497                              struct ureg_src src1,                     \
498                              struct ureg_src src2 )                    \
499{                                                                       \
500   unsigned opcode = TGSI_OPCODE_##op;                                  \
501   unsigned insn = ureg_emit_insn(ureg,                                 \
502                                  opcode,                               \
503                                  dst.Saturate,                         \
504                                  dst.Predicate,                        \
505                                  dst.PredNegate,                       \
506                                  dst.PredSwizzleX,                     \
507                                  dst.PredSwizzleY,                     \
508                                  dst.PredSwizzleZ,                     \
509                                  dst.PredSwizzleW,                     \
510                                  1,                                    \
511                                  3).insn_token;                        \
512   ureg_emit_dst( ureg, dst );                                          \
513   ureg_emit_src( ureg, src0 );                                         \
514   ureg_emit_src( ureg, src1 );                                         \
515   ureg_emit_src( ureg, src2 );                                         \
516   ureg_fixup_insn_size( ureg, insn );                                  \
517}
518
519#define OP14_TEX( op )                                                  \
520static INLINE void ureg_##op( struct ureg_program *ureg,                \
521                              struct ureg_dst dst,                      \
522                              unsigned target,                          \
523                              struct ureg_src src0,                     \
524                              struct ureg_src src1,                     \
525                              struct ureg_src src2,                     \
526                              struct ureg_src src3 )                    \
527{                                                                       \
528   unsigned opcode = TGSI_OPCODE_##op;                                  \
529   struct ureg_emit_insn_result insn;                                   \
530   insn = ureg_emit_insn(ureg,                                          \
531                         opcode,                                        \
532                         dst.Saturate,                                  \
533                         dst.Predicate,                                 \
534                         dst.PredNegate,                                \
535                         dst.PredSwizzleX,                              \
536                         dst.PredSwizzleY,                              \
537                         dst.PredSwizzleZ,                              \
538                         dst.PredSwizzleW,                              \
539                         1,                                             \
540                         4);                                            \
541   ureg_emit_texture( ureg, insn.extended_token, target );              \
542   ureg_emit_dst( ureg, dst );                                          \
543   ureg_emit_src( ureg, src0 );                                         \
544   ureg_emit_src( ureg, src1 );                                         \
545   ureg_emit_src( ureg, src2 );                                         \
546   ureg_emit_src( ureg, src3 );                                         \
547   ureg_fixup_insn_size( ureg, insn.insn_token );                       \
548}
549
550
551/* Use a template include to generate a correctly-typed ureg_OP()
552 * function for each TGSI opcode:
553 */
554#include "tgsi_opcode_tmp.h"
555
556
557/***********************************************************************
558 * Inline helpers for manipulating register structs:
559 */
560static INLINE struct ureg_src
561ureg_negate( struct ureg_src reg )
562{
563   assert(reg.File != TGSI_FILE_NULL);
564   reg.Negate ^= 1;
565   return reg;
566}
567
568static INLINE struct ureg_src
569ureg_abs( struct ureg_src reg )
570{
571   assert(reg.File != TGSI_FILE_NULL);
572   reg.Absolute = 1;
573   reg.Negate = 0;
574   return reg;
575}
576
577static INLINE struct ureg_src
578ureg_swizzle( struct ureg_src reg,
579              int x, int y, int z, int w )
580{
581   unsigned swz = ( (reg.SwizzleX << 0) |
582                    (reg.SwizzleY << 2) |
583                    (reg.SwizzleZ << 4) |
584                    (reg.SwizzleW << 6));
585
586   assert(reg.File != TGSI_FILE_NULL);
587   assert(x < 4);
588   assert(y < 4);
589   assert(z < 4);
590   assert(w < 4);
591
592   reg.SwizzleX = (swz >> (x*2)) & 0x3;
593   reg.SwizzleY = (swz >> (y*2)) & 0x3;
594   reg.SwizzleZ = (swz >> (z*2)) & 0x3;
595   reg.SwizzleW = (swz >> (w*2)) & 0x3;
596   return reg;
597}
598
599static INLINE struct ureg_src
600ureg_scalar( struct ureg_src reg, int x )
601{
602   return ureg_swizzle(reg, x, x, x, x);
603}
604
605static INLINE struct ureg_dst
606ureg_writemask( struct ureg_dst reg,
607                unsigned writemask )
608{
609   assert(reg.File != TGSI_FILE_NULL);
610   reg.WriteMask &= writemask;
611   return reg;
612}
613
614static INLINE struct ureg_dst
615ureg_saturate( struct ureg_dst reg )
616{
617   assert(reg.File != TGSI_FILE_NULL);
618   reg.Saturate = 1;
619   return reg;
620}
621
622static INLINE struct ureg_dst
623ureg_predicate(struct ureg_dst reg,
624               boolean negate,
625               unsigned swizzle_x,
626               unsigned swizzle_y,
627               unsigned swizzle_z,
628               unsigned swizzle_w)
629{
630   assert(reg.File != TGSI_FILE_NULL);
631   reg.Predicate = 1;
632   reg.PredNegate = negate;
633   reg.PredSwizzleX = swizzle_x;
634   reg.PredSwizzleY = swizzle_y;
635   reg.PredSwizzleZ = swizzle_z;
636   reg.PredSwizzleW = swizzle_w;
637   return reg;
638}
639
640static INLINE struct ureg_dst
641ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
642{
643   assert(reg.File != TGSI_FILE_NULL);
644   assert(addr.File == TGSI_FILE_ADDRESS);
645   reg.Indirect = 1;
646   reg.IndirectIndex = addr.Index;
647   reg.IndirectSwizzle = addr.SwizzleX;
648   return reg;
649}
650
651static INLINE struct ureg_src
652ureg_src_indirect( struct ureg_src reg, struct ureg_src addr )
653{
654   assert(reg.File != TGSI_FILE_NULL);
655   assert(addr.File == TGSI_FILE_ADDRESS);
656   reg.Indirect = 1;
657   reg.IndirectIndex = addr.Index;
658   reg.IndirectSwizzle = addr.SwizzleX;
659   return reg;
660}
661
662static INLINE struct ureg_dst
663ureg_dst( struct ureg_src src )
664{
665   struct ureg_dst dst;
666
667   dst.File      = src.File;
668   dst.WriteMask = TGSI_WRITEMASK_XYZW;
669   dst.Indirect  = src.Indirect;
670   dst.IndirectIndex = src.IndirectIndex;
671   dst.IndirectSwizzle = src.IndirectSwizzle;
672   dst.Saturate  = 0;
673   dst.Predicate = 0;
674   dst.PredNegate = 0;
675   dst.PredSwizzleX = TGSI_SWIZZLE_X;
676   dst.PredSwizzleY = TGSI_SWIZZLE_Y;
677   dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
678   dst.PredSwizzleW = TGSI_SWIZZLE_W;
679   dst.Index     = src.Index;
680
681   return dst;
682}
683
684static INLINE struct ureg_src
685ureg_src( struct ureg_dst dst )
686{
687   struct ureg_src src;
688
689   src.File      = dst.File;
690   src.SwizzleX  = TGSI_SWIZZLE_X;
691   src.SwizzleY  = TGSI_SWIZZLE_Y;
692   src.SwizzleZ  = TGSI_SWIZZLE_Z;
693   src.SwizzleW  = TGSI_SWIZZLE_W;
694   src.Pad       = 0;
695   src.Indirect  = dst.Indirect;
696   src.IndirectIndex = dst.IndirectIndex;
697   src.IndirectSwizzle = dst.IndirectSwizzle;
698   src.Absolute  = 0;
699   src.Index     = dst.Index;
700   src.Negate    = 0;
701
702   return src;
703}
704
705
706
707static INLINE struct ureg_dst
708ureg_dst_undef( void )
709{
710   struct ureg_dst dst;
711
712   dst.File      = TGSI_FILE_NULL;
713   dst.WriteMask = 0;
714   dst.Indirect  = 0;
715   dst.IndirectIndex = 0;
716   dst.IndirectSwizzle = 0;
717   dst.Saturate  = 0;
718   dst.Predicate = 0;
719   dst.PredNegate = 0;
720   dst.PredSwizzleX = TGSI_SWIZZLE_X;
721   dst.PredSwizzleY = TGSI_SWIZZLE_Y;
722   dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
723   dst.PredSwizzleW = TGSI_SWIZZLE_W;
724   dst.Index     = 0;
725
726   return dst;
727}
728
729static INLINE struct ureg_src
730ureg_src_undef( void )
731{
732   struct ureg_src src;
733
734   src.File      = TGSI_FILE_NULL;
735   src.SwizzleX  = 0;
736   src.SwizzleY  = 0;
737   src.SwizzleZ  = 0;
738   src.SwizzleW  = 0;
739   src.Pad       = 0;
740   src.Indirect  = 0;
741   src.IndirectIndex = 0;
742   src.IndirectSwizzle = 0;
743   src.Absolute  = 0;
744   src.Index     = 0;
745   src.Negate    = 0;
746
747   return src;
748}
749
750static INLINE boolean
751ureg_src_is_undef( struct ureg_src src )
752{
753   return src.File == TGSI_FILE_NULL;
754}
755
756static INLINE boolean
757ureg_dst_is_undef( struct ureg_dst dst )
758{
759   return dst.File == TGSI_FILE_NULL;
760}
761
762
763#ifdef __cplusplus
764}
765#endif
766
767#endif
768