Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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. #include "util/u_debug.h"
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.    
  39. struct ureg_program;
  40. struct pipe_stream_output_info;
  41.  
  42. /* Almost a tgsi_src_register, but we need to pull in the Absolute
  43.  * flag from the _ext token.  Indirect flag always implies ADDR[0].
  44.  */
  45. struct ureg_src
  46. {
  47.    unsigned File             : 4;  /* TGSI_FILE_ */
  48.    unsigned SwizzleX         : 2;  /* TGSI_SWIZZLE_ */
  49.    unsigned SwizzleY         : 2;  /* TGSI_SWIZZLE_ */
  50.    unsigned SwizzleZ         : 2;  /* TGSI_SWIZZLE_ */
  51.    unsigned SwizzleW         : 2;  /* TGSI_SWIZZLE_ */
  52.    unsigned Indirect         : 1;  /* BOOL */
  53.    unsigned DimIndirect      : 1;  /* BOOL */
  54.    unsigned Dimension        : 1;  /* BOOL */
  55.    unsigned Absolute         : 1;  /* BOOL */
  56.    unsigned Negate           : 1;  /* BOOL */
  57.    unsigned IndirectFile     : 4;  /* TGSI_FILE_ */
  58.    unsigned IndirectSwizzle  : 2;  /* TGSI_SWIZZLE_ */
  59.    unsigned DimIndFile       : 4;  /* TGSI_FILE_ */
  60.    unsigned DimIndSwizzle    : 2;  /* TGSI_SWIZZLE_ */
  61.    int      Index            : 16; /* SINT */
  62.    int      IndirectIndex    : 16; /* SINT */
  63.    int      DimensionIndex   : 16; /* SINT */
  64.    int      DimIndIndex      : 16; /* SINT */
  65.    unsigned ArrayID          : 10; /* UINT */
  66. };
  67.  
  68. /* Very similar to a tgsi_dst_register, removing unsupported fields
  69.  * and adding a Saturate flag.  It's easier to push saturate into the
  70.  * destination register than to try and create a _SAT variant of each
  71.  * instruction function.
  72.  */
  73. struct ureg_dst
  74. {
  75.    unsigned File            : 4;  /* TGSI_FILE_ */
  76.    unsigned WriteMask       : 4;  /* TGSI_WRITEMASK_ */
  77.    unsigned Indirect        : 1;  /* BOOL */
  78.    unsigned DimIndirect     : 1;  /* BOOL */
  79.    unsigned Dimension       : 1;  /* BOOL */
  80.    unsigned Saturate        : 1;  /* BOOL */
  81.    unsigned Predicate       : 1;
  82.    unsigned PredNegate      : 1;  /* BOOL */
  83.    unsigned PredSwizzleX    : 2;  /* TGSI_SWIZZLE_ */
  84.    unsigned PredSwizzleY    : 2;  /* TGSI_SWIZZLE_ */
  85.    unsigned PredSwizzleZ    : 2;  /* TGSI_SWIZZLE_ */
  86.    unsigned PredSwizzleW    : 2;  /* TGSI_SWIZZLE_ */
  87.    int      Index           : 16; /* SINT */
  88.    int      IndirectIndex   : 16; /* SINT */
  89.    unsigned IndirectFile    : 4;  /* TGSI_FILE_ */
  90.    int      IndirectSwizzle : 2;  /* TGSI_SWIZZLE_ */
  91.    unsigned DimIndFile      : 4;  /* TGSI_FILE_ */
  92.    unsigned DimIndSwizzle   : 2;  /* TGSI_SWIZZLE_ */
  93.    int      DimensionIndex  : 16; /* SINT */
  94.    int      DimIndIndex     : 16; /* SINT */
  95.    unsigned ArrayID         : 10; /* UINT */
  96. };
  97.  
  98. struct pipe_context;
  99.  
  100. struct ureg_program *
  101. ureg_create( unsigned processor );
  102.  
  103. const struct tgsi_token *
  104. ureg_finalize( struct ureg_program * );
  105.  
  106. /* Create and return a shader:
  107.  */
  108. void *
  109. ureg_create_shader( struct ureg_program *,
  110.                     struct pipe_context *pipe,
  111.                     const struct pipe_stream_output_info *so );
  112.  
  113.  
  114. /* Alternately, return the built token stream and hand ownership of
  115.  * that memory to the caller:
  116.  */
  117. const struct tgsi_token *
  118. ureg_get_tokens( struct ureg_program *ureg,
  119.                  unsigned *nr_tokens );
  120.  
  121. /*
  122.  * Returns the number of currently declared outputs.
  123.  */
  124. unsigned
  125. ureg_get_nr_outputs( const struct ureg_program *ureg );
  126.  
  127.  
  128. /* Free the tokens created by ureg_get_tokens() */
  129. void ureg_free_tokens( const struct tgsi_token *tokens );
  130.  
  131.  
  132. void
  133. ureg_destroy( struct ureg_program * );
  134.  
  135.  
  136. /***********************************************************************
  137.  * Convenience routine:
  138.  */
  139. static INLINE void *
  140. ureg_create_shader_with_so_and_destroy( struct ureg_program *p,
  141.                         struct pipe_context *pipe,
  142.                         const struct pipe_stream_output_info *so )
  143. {
  144.    void *result = ureg_create_shader( p, pipe, so );
  145.    ureg_destroy( p );
  146.    return result;
  147. }
  148.  
  149. static INLINE void *
  150. ureg_create_shader_and_destroy( struct ureg_program *p,
  151.                                 struct pipe_context *pipe )
  152. {
  153.    return ureg_create_shader_with_so_and_destroy(p, pipe, NULL);
  154. }
  155.  
  156.  
  157. /***********************************************************************
  158.  * Build shader properties:
  159.  */
  160.  
  161. void
  162. ureg_property(struct ureg_program *ureg, unsigned name, unsigned value);
  163.  
  164.  
  165. /***********************************************************************
  166.  * Build shader declarations:
  167.  */
  168.  
  169. struct ureg_src
  170. ureg_DECL_fs_input_cyl_centroid(struct ureg_program *,
  171.                        unsigned semantic_name,
  172.                        unsigned semantic_index,
  173.                        unsigned interp_mode,
  174.                        unsigned cylindrical_wrap,
  175.                        unsigned interp_location);
  176.  
  177. static INLINE struct ureg_src
  178. ureg_DECL_fs_input_cyl(struct ureg_program *ureg,
  179.                        unsigned semantic_name,
  180.                        unsigned semantic_index,
  181.                        unsigned interp_mode,
  182.                        unsigned cylindrical_wrap)
  183. {
  184.    return ureg_DECL_fs_input_cyl_centroid(ureg,
  185.                                  semantic_name,
  186.                                  semantic_index,
  187.                                  interp_mode,
  188.                                  cylindrical_wrap,
  189.                                  0);
  190. }
  191.  
  192. static INLINE struct ureg_src
  193. ureg_DECL_fs_input(struct ureg_program *ureg,
  194.                    unsigned semantic_name,
  195.                    unsigned semantic_index,
  196.                    unsigned interp_mode)
  197. {
  198.    return ureg_DECL_fs_input_cyl_centroid(ureg,
  199.                                  semantic_name,
  200.                                  semantic_index,
  201.                                  interp_mode,
  202.                                  0, 0);
  203. }
  204.  
  205. struct ureg_src
  206. ureg_DECL_vs_input( struct ureg_program *,
  207.                     unsigned index );
  208.  
  209. struct ureg_src
  210. ureg_DECL_gs_input(struct ureg_program *,
  211.                    unsigned index,
  212.                    unsigned semantic_name,
  213.                    unsigned semantic_index);
  214.  
  215. struct ureg_src
  216. ureg_DECL_system_value(struct ureg_program *,
  217.                        unsigned index,
  218.                        unsigned semantic_name,
  219.                        unsigned semantic_index);
  220.  
  221. struct ureg_dst
  222. ureg_DECL_output_masked( struct ureg_program *,
  223.                          unsigned semantic_name,
  224.                          unsigned semantic_index,
  225.                          unsigned usage_mask );
  226.  
  227. struct ureg_dst
  228. ureg_DECL_output( struct ureg_program *,
  229.                   unsigned semantic_name,
  230.                   unsigned semantic_index );
  231.  
  232. struct ureg_src
  233. ureg_DECL_immediate( struct ureg_program *,
  234.                      const float *v,
  235.                      unsigned nr );
  236.  
  237. struct ureg_src
  238. ureg_DECL_immediate_f64( struct ureg_program *,
  239.                          const double *v,
  240.                          unsigned nr );
  241.  
  242. struct ureg_src
  243. ureg_DECL_immediate_uint( struct ureg_program *,
  244.                           const unsigned *v,
  245.                           unsigned nr );
  246.  
  247. struct ureg_src
  248. ureg_DECL_immediate_block_uint( struct ureg_program *,
  249.                                 const unsigned *v,
  250.                                 unsigned nr );
  251.  
  252. struct ureg_src
  253. ureg_DECL_immediate_int( struct ureg_program *,
  254.                          const int *v,
  255.                          unsigned nr );
  256.  
  257. void
  258. ureg_DECL_constant2D(struct ureg_program *ureg,
  259.                      unsigned first,
  260.                      unsigned last,
  261.                      unsigned index2D);
  262.  
  263. struct ureg_src
  264. ureg_DECL_constant( struct ureg_program *,
  265.                     unsigned index );
  266.  
  267. struct ureg_dst
  268. ureg_DECL_temporary( struct ureg_program * );
  269.  
  270. /**
  271.  * Emit a temporary with the LOCAL declaration flag set.  For use when
  272.  * the register value is not required to be preserved across
  273.  * subroutine boundaries.
  274.  */
  275. struct ureg_dst
  276. ureg_DECL_local_temporary( struct ureg_program * );
  277.  
  278. /**
  279.  * Declare "size" continuous temporary registers.
  280.  */
  281. struct ureg_dst
  282. ureg_DECL_array_temporary( struct ureg_program *,
  283.                            unsigned size,
  284.                            boolean local );
  285.  
  286. void
  287. ureg_release_temporary( struct ureg_program *ureg,
  288.                         struct ureg_dst tmp );
  289.  
  290. struct ureg_dst
  291. ureg_DECL_address( struct ureg_program * );
  292.  
  293. struct ureg_dst
  294. ureg_DECL_predicate(struct ureg_program *);
  295.  
  296. /* Supply an index to the sampler declaration as this is the hook to
  297.  * the external pipe_sampler state.  Users of this function probably
  298.  * don't want just any sampler, but a specific one which they've set
  299.  * up state for in the context.
  300.  */
  301. struct ureg_src
  302. ureg_DECL_sampler( struct ureg_program *,
  303.                    unsigned index );
  304.  
  305. struct ureg_src
  306. ureg_DECL_sampler_view(struct ureg_program *,
  307.                        unsigned index,
  308.                        unsigned target,
  309.                        unsigned return_type_x,
  310.                        unsigned return_type_y,
  311.                        unsigned return_type_z,
  312.                        unsigned return_type_w );
  313.  
  314.  
  315. static INLINE struct ureg_src
  316. ureg_imm4f( struct ureg_program *ureg,
  317.                        float a, float b,
  318.                        float c, float d)
  319. {
  320.    float v[4];
  321.    v[0] = a;
  322.    v[1] = b;
  323.    v[2] = c;
  324.    v[3] = d;
  325.    return ureg_DECL_immediate( ureg, v, 4 );
  326. }
  327.  
  328. static INLINE struct ureg_src
  329. ureg_imm3f( struct ureg_program *ureg,
  330.                        float a, float b,
  331.                        float c)
  332. {
  333.    float v[3];
  334.    v[0] = a;
  335.    v[1] = b;
  336.    v[2] = c;
  337.    return ureg_DECL_immediate( ureg, v, 3 );
  338. }
  339.  
  340. static INLINE struct ureg_src
  341. ureg_imm2f( struct ureg_program *ureg,
  342.                        float a, float b)
  343. {
  344.    float v[2];
  345.    v[0] = a;
  346.    v[1] = b;
  347.    return ureg_DECL_immediate( ureg, v, 2 );
  348. }
  349.  
  350. static INLINE struct ureg_src
  351. ureg_imm1f( struct ureg_program *ureg,
  352.                        float a)
  353. {
  354.    float v[1];
  355.    v[0] = a;
  356.    return ureg_DECL_immediate( ureg, v, 1 );
  357. }
  358.  
  359. static INLINE struct ureg_src
  360. ureg_imm4u( struct ureg_program *ureg,
  361.             unsigned a, unsigned b,
  362.             unsigned c, unsigned d)
  363. {
  364.    unsigned v[4];
  365.    v[0] = a;
  366.    v[1] = b;
  367.    v[2] = c;
  368.    v[3] = d;
  369.    return ureg_DECL_immediate_uint( ureg, v, 4 );
  370. }
  371.  
  372. static INLINE struct ureg_src
  373. ureg_imm3u( struct ureg_program *ureg,
  374.             unsigned a, unsigned b,
  375.             unsigned c)
  376. {
  377.    unsigned v[3];
  378.    v[0] = a;
  379.    v[1] = b;
  380.    v[2] = c;
  381.    return ureg_DECL_immediate_uint( ureg, v, 3 );
  382. }
  383.  
  384. static INLINE struct ureg_src
  385. ureg_imm2u( struct ureg_program *ureg,
  386.             unsigned a, unsigned b)
  387. {
  388.    unsigned v[2];
  389.    v[0] = a;
  390.    v[1] = b;
  391.    return ureg_DECL_immediate_uint( ureg, v, 2 );
  392. }
  393.  
  394. static INLINE struct ureg_src
  395. ureg_imm1u( struct ureg_program *ureg,
  396.             unsigned a)
  397. {
  398.    return ureg_DECL_immediate_uint( ureg, &a, 1 );
  399. }
  400.  
  401. static INLINE struct ureg_src
  402. ureg_imm4i( struct ureg_program *ureg,
  403.             int a, int b,
  404.             int c, int d)
  405. {
  406.    int v[4];
  407.    v[0] = a;
  408.    v[1] = b;
  409.    v[2] = c;
  410.    v[3] = d;
  411.    return ureg_DECL_immediate_int( ureg, v, 4 );
  412. }
  413.  
  414. static INLINE struct ureg_src
  415. ureg_imm3i( struct ureg_program *ureg,
  416.             int a, int b,
  417.             int c)
  418. {
  419.    int v[3];
  420.    v[0] = a;
  421.    v[1] = b;
  422.    v[2] = c;
  423.    return ureg_DECL_immediate_int( ureg, v, 3 );
  424. }
  425.  
  426. static INLINE struct ureg_src
  427. ureg_imm2i( struct ureg_program *ureg,
  428.             int a, int b)
  429. {
  430.    int v[2];
  431.    v[0] = a;
  432.    v[1] = b;
  433.    return ureg_DECL_immediate_int( ureg, v, 2 );
  434. }
  435.  
  436. static INLINE struct ureg_src
  437. ureg_imm1i( struct ureg_program *ureg,
  438.             int a)
  439. {
  440.    return ureg_DECL_immediate_int( ureg, &a, 1 );
  441. }
  442.  
  443. /* Where the destination register has a valid file, but an empty
  444.  * writemask.
  445.  */
  446. static INLINE boolean
  447. ureg_dst_is_empty( struct ureg_dst dst )
  448. {
  449.    return dst.File != TGSI_FILE_NULL &&
  450.           dst.WriteMask == 0;
  451. }
  452.  
  453. /***********************************************************************
  454.  * Functions for patching up labels
  455.  */
  456.  
  457.  
  458. /* Will return a number which can be used in a label to point to the
  459.  * next instruction to be emitted.
  460.  */
  461. unsigned
  462. ureg_get_instruction_number( struct ureg_program *ureg );
  463.  
  464.  
  465. /* Patch a given label (expressed as a token number) to point to a
  466.  * given instruction (expressed as an instruction number).
  467.  *
  468.  * Labels are obtained from instruction emitters, eg ureg_CAL().
  469.  * Instruction numbers are obtained from ureg_get_instruction_number(),
  470.  * above.
  471.  */
  472. void
  473. ureg_fixup_label(struct ureg_program *ureg,
  474.                  unsigned label_token,
  475.                  unsigned instruction_number );
  476.  
  477.  
  478. /* Generic instruction emitter.  Use if you need to pass the opcode as
  479.  * a parameter, rather than using the emit_OP() variants below.
  480.  */
  481. void
  482. ureg_insn(struct ureg_program *ureg,
  483.           unsigned opcode,
  484.           const struct ureg_dst *dst,
  485.           unsigned nr_dst,
  486.           const struct ureg_src *src,
  487.           unsigned nr_src );
  488.  
  489.  
  490. void
  491. ureg_tex_insn(struct ureg_program *ureg,
  492.               unsigned opcode,
  493.               const struct ureg_dst *dst,
  494.               unsigned nr_dst,
  495.               unsigned target,
  496.               const struct tgsi_texture_offset *texoffsets,
  497.               unsigned nr_offset,
  498.               const struct ureg_src *src,
  499.               unsigned nr_src );
  500.  
  501.  
  502. void
  503. ureg_label_insn(struct ureg_program *ureg,
  504.                 unsigned opcode,
  505.                 const struct ureg_src *src,
  506.                 unsigned nr_src,
  507.                 unsigned *label);
  508.  
  509.  
  510. /***********************************************************************
  511.  * Internal instruction helpers, don't call these directly:
  512.  */
  513.  
  514. struct ureg_emit_insn_result {
  515.    unsigned insn_token;       /*< Used to fixup insn size. */
  516.    unsigned extended_token;   /*< Used to set the Extended bit, usually the same as insn_token. */
  517. };
  518.  
  519. struct ureg_emit_insn_result
  520. ureg_emit_insn(struct ureg_program *ureg,
  521.                unsigned opcode,
  522.                boolean saturate,
  523.                boolean predicate,
  524.                boolean pred_negate,
  525.                unsigned pred_swizzle_x,
  526.                unsigned pred_swizzle_y,
  527.                unsigned pred_swizzle_z,
  528.                unsigned pred_swizzle_w,
  529.                unsigned num_dst,
  530.                unsigned num_src );
  531.  
  532. void
  533. ureg_emit_label(struct ureg_program *ureg,
  534.                 unsigned insn_token,
  535.                 unsigned *label_token );
  536.  
  537. void
  538. ureg_emit_texture(struct ureg_program *ureg,
  539.                   unsigned insn_token,
  540.                   unsigned target, unsigned num_offsets);
  541.  
  542. void
  543. ureg_emit_texture_offset(struct ureg_program *ureg,
  544.                          const struct tgsi_texture_offset *offset);
  545.  
  546. void
  547. ureg_emit_dst( struct ureg_program *ureg,
  548.                struct ureg_dst dst );
  549.  
  550. void
  551. ureg_emit_src( struct ureg_program *ureg,
  552.                struct ureg_src src );
  553.  
  554. void
  555. ureg_fixup_insn_size(struct ureg_program *ureg,
  556.                      unsigned insn );
  557.  
  558.  
  559. #define OP00( op )                                              \
  560. static INLINE void ureg_##op( struct ureg_program *ureg )       \
  561. {                                                               \
  562.    unsigned opcode = TGSI_OPCODE_##op;                          \
  563.    struct ureg_emit_insn_result insn;                           \
  564.    insn = ureg_emit_insn(ureg,                                  \
  565.                          opcode,                                \
  566.                          FALSE,                                 \
  567.                          FALSE,                                 \
  568.                          FALSE,                                 \
  569.                          TGSI_SWIZZLE_X,                        \
  570.                          TGSI_SWIZZLE_Y,                        \
  571.                          TGSI_SWIZZLE_Z,                        \
  572.                          TGSI_SWIZZLE_W,                        \
  573.                          0,                                     \
  574.                          0);                                    \
  575.    ureg_fixup_insn_size( ureg, insn.insn_token );               \
  576. }
  577.  
  578. #define OP01( op )                                              \
  579. static INLINE void ureg_##op( struct ureg_program *ureg,        \
  580.                               struct ureg_src src )             \
  581. {                                                               \
  582.    unsigned opcode = TGSI_OPCODE_##op;                          \
  583.    struct ureg_emit_insn_result insn;                           \
  584.    insn = ureg_emit_insn(ureg,                                  \
  585.                          opcode,                                \
  586.                          FALSE,                                 \
  587.                          FALSE,                                 \
  588.                          FALSE,                                 \
  589.                          TGSI_SWIZZLE_X,                        \
  590.                          TGSI_SWIZZLE_Y,                        \
  591.                          TGSI_SWIZZLE_Z,                        \
  592.                          TGSI_SWIZZLE_W,                        \
  593.                          0,                                     \
  594.                          1);                                    \
  595.    ureg_emit_src( ureg, src );                                  \
  596.    ureg_fixup_insn_size( ureg, insn.insn_token );               \
  597. }
  598.  
  599. #define OP00_LBL( op )                                          \
  600. static INLINE void ureg_##op( struct ureg_program *ureg,        \
  601.                               unsigned *label_token )           \
  602. {                                                               \
  603.    unsigned opcode = TGSI_OPCODE_##op;                          \
  604.    struct ureg_emit_insn_result insn;                           \
  605.    insn = ureg_emit_insn(ureg,                                  \
  606.                          opcode,                                \
  607.                          FALSE,                                 \
  608.                          FALSE,                                 \
  609.                          FALSE,                                 \
  610.                          TGSI_SWIZZLE_X,                        \
  611.                          TGSI_SWIZZLE_Y,                        \
  612.                          TGSI_SWIZZLE_Z,                        \
  613.                          TGSI_SWIZZLE_W,                        \
  614.                          0,                                     \
  615.                          0);                                    \
  616.    ureg_emit_label( ureg, insn.extended_token, label_token );   \
  617.    ureg_fixup_insn_size( ureg, insn.insn_token );               \
  618. }
  619.  
  620. #define OP01_LBL( op )                                          \
  621. static INLINE void ureg_##op( struct ureg_program *ureg,        \
  622.                               struct ureg_src src,              \
  623.                               unsigned *label_token )          \
  624. {                                                               \
  625.    unsigned opcode = TGSI_OPCODE_##op;                          \
  626.    struct ureg_emit_insn_result insn;                           \
  627.    insn = ureg_emit_insn(ureg,                                  \
  628.                          opcode,                                \
  629.                          FALSE,                                 \
  630.                          FALSE,                                 \
  631.                          FALSE,                                 \
  632.                          TGSI_SWIZZLE_X,                        \
  633.                          TGSI_SWIZZLE_Y,                        \
  634.                          TGSI_SWIZZLE_Z,                        \
  635.                          TGSI_SWIZZLE_W,                        \
  636.                          0,                                     \
  637.                          1);                                    \
  638.    ureg_emit_label( ureg, insn.extended_token, label_token );   \
  639.    ureg_emit_src( ureg, src );                                  \
  640.    ureg_fixup_insn_size( ureg, insn.insn_token );               \
  641. }
  642.  
  643. #define OP10( op )                                                      \
  644. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  645.                               struct ureg_dst dst )                     \
  646. {                                                                       \
  647.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  648.    struct ureg_emit_insn_result insn;                                   \
  649.    if (ureg_dst_is_empty(dst))                                          \
  650.       return;                                                           \
  651.    insn = ureg_emit_insn(ureg,                                          \
  652.                          opcode,                                        \
  653.                          dst.Saturate,                                  \
  654.                          dst.Predicate,                                 \
  655.                          dst.PredNegate,                                \
  656.                          dst.PredSwizzleX,                              \
  657.                          dst.PredSwizzleY,                              \
  658.                          dst.PredSwizzleZ,                              \
  659.                          dst.PredSwizzleW,                              \
  660.                          1,                                             \
  661.                          0);                                            \
  662.    ureg_emit_dst( ureg, dst );                                          \
  663.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  664. }
  665.  
  666.  
  667. #define OP11( op )                                                      \
  668. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  669.                               struct ureg_dst dst,                      \
  670.                               struct ureg_src src )                     \
  671. {                                                                       \
  672.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  673.    struct ureg_emit_insn_result insn;                                   \
  674.    if (ureg_dst_is_empty(dst))                                          \
  675.       return;                                                           \
  676.    insn = ureg_emit_insn(ureg,                                          \
  677.                          opcode,                                        \
  678.                          dst.Saturate,                                  \
  679.                          dst.Predicate,                                 \
  680.                          dst.PredNegate,                                \
  681.                          dst.PredSwizzleX,                              \
  682.                          dst.PredSwizzleY,                              \
  683.                          dst.PredSwizzleZ,                              \
  684.                          dst.PredSwizzleW,                              \
  685.                          1,                                             \
  686.                          1);                                            \
  687.    ureg_emit_dst( ureg, dst );                                          \
  688.    ureg_emit_src( ureg, src );                                          \
  689.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  690. }
  691.  
  692. #define OP12( op )                                                      \
  693. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  694.                               struct ureg_dst dst,                      \
  695.                               struct ureg_src src0,                     \
  696.                               struct ureg_src src1 )                    \
  697. {                                                                       \
  698.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  699.    struct ureg_emit_insn_result insn;                                   \
  700.    if (ureg_dst_is_empty(dst))                                          \
  701.       return;                                                           \
  702.    insn = ureg_emit_insn(ureg,                                          \
  703.                          opcode,                                        \
  704.                          dst.Saturate,                                  \
  705.                          dst.Predicate,                                 \
  706.                          dst.PredNegate,                                \
  707.                          dst.PredSwizzleX,                              \
  708.                          dst.PredSwizzleY,                              \
  709.                          dst.PredSwizzleZ,                              \
  710.                          dst.PredSwizzleW,                              \
  711.                          1,                                             \
  712.                          2);                                            \
  713.    ureg_emit_dst( ureg, dst );                                          \
  714.    ureg_emit_src( ureg, src0 );                                         \
  715.    ureg_emit_src( ureg, src1 );                                         \
  716.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  717. }
  718.  
  719. #define OP12_TEX( op )                                                  \
  720. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  721.                               struct ureg_dst dst,                      \
  722.                               unsigned target,                          \
  723.                               struct ureg_src src0,                     \
  724.                               struct ureg_src src1 )                    \
  725. {                                                                       \
  726.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  727.    struct ureg_emit_insn_result insn;                                   \
  728.    if (ureg_dst_is_empty(dst))                                          \
  729.       return;                                                           \
  730.    insn = ureg_emit_insn(ureg,                                          \
  731.                          opcode,                                        \
  732.                          dst.Saturate,                                  \
  733.                          dst.Predicate,                                 \
  734.                          dst.PredNegate,                                \
  735.                          dst.PredSwizzleX,                              \
  736.                          dst.PredSwizzleY,                              \
  737.                          dst.PredSwizzleZ,                              \
  738.                          dst.PredSwizzleW,                              \
  739.                          1,                                             \
  740.                          2);                                            \
  741.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  742.    ureg_emit_dst( ureg, dst );                                          \
  743.    ureg_emit_src( ureg, src0 );                                         \
  744.    ureg_emit_src( ureg, src1 );                                         \
  745.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  746. }
  747.  
  748. #define OP12_SAMPLE( op )                                               \
  749. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  750.                               struct ureg_dst dst,                      \
  751.                               struct ureg_src src0,                     \
  752.                               struct ureg_src src1 )                    \
  753. {                                                                       \
  754.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  755.    unsigned target = TGSI_TEXTURE_UNKNOWN;                              \
  756.    struct ureg_emit_insn_result insn;                                   \
  757.    if (ureg_dst_is_empty(dst))                                          \
  758.       return;                                                           \
  759.    insn = ureg_emit_insn(ureg,                                          \
  760.                          opcode,                                        \
  761.                          dst.Saturate,                                  \
  762.                          dst.Predicate,                                 \
  763.                          dst.PredNegate,                                \
  764.                          dst.PredSwizzleX,                              \
  765.                          dst.PredSwizzleY,                              \
  766.                          dst.PredSwizzleZ,                              \
  767.                          dst.PredSwizzleW,                              \
  768.                          1,                                             \
  769.                          2);                                            \
  770.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  771.    ureg_emit_dst( ureg, dst );                                          \
  772.    ureg_emit_src( ureg, src0 );                                         \
  773.    ureg_emit_src( ureg, src1 );                                         \
  774.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  775. }
  776.  
  777. #define OP13( op )                                                      \
  778. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  779.                               struct ureg_dst dst,                      \
  780.                               struct ureg_src src0,                     \
  781.                               struct ureg_src src1,                     \
  782.                               struct ureg_src src2 )                    \
  783. {                                                                       \
  784.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  785.    struct ureg_emit_insn_result insn;                                   \
  786.    if (ureg_dst_is_empty(dst))                                          \
  787.       return;                                                           \
  788.    insn = ureg_emit_insn(ureg,                                          \
  789.                          opcode,                                        \
  790.                          dst.Saturate,                                  \
  791.                          dst.Predicate,                                 \
  792.                          dst.PredNegate,                                \
  793.                          dst.PredSwizzleX,                              \
  794.                          dst.PredSwizzleY,                              \
  795.                          dst.PredSwizzleZ,                              \
  796.                          dst.PredSwizzleW,                              \
  797.                          1,                                             \
  798.                          3);                                            \
  799.    ureg_emit_dst( ureg, dst );                                          \
  800.    ureg_emit_src( ureg, src0 );                                         \
  801.    ureg_emit_src( ureg, src1 );                                         \
  802.    ureg_emit_src( ureg, src2 );                                         \
  803.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  804. }
  805.  
  806. #define OP13_SAMPLE( op )                                               \
  807. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  808.                               struct ureg_dst dst,                      \
  809.                               struct ureg_src src0,                     \
  810.                               struct ureg_src src1,                     \
  811.                               struct ureg_src src2 )                    \
  812. {                                                                       \
  813.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  814.    unsigned target = TGSI_TEXTURE_UNKNOWN;                              \
  815.    struct ureg_emit_insn_result insn;                                   \
  816.    if (ureg_dst_is_empty(dst))                                          \
  817.       return;                                                           \
  818.    insn = ureg_emit_insn(ureg,                                          \
  819.                          opcode,                                        \
  820.                          dst.Saturate,                                  \
  821.                          dst.Predicate,                                 \
  822.                          dst.PredNegate,                                \
  823.                          dst.PredSwizzleX,                              \
  824.                          dst.PredSwizzleY,                              \
  825.                          dst.PredSwizzleZ,                              \
  826.                          dst.PredSwizzleW,                              \
  827.                          1,                                             \
  828.                          3);                                            \
  829.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  830.    ureg_emit_dst( ureg, dst );                                          \
  831.    ureg_emit_src( ureg, src0 );                                         \
  832.    ureg_emit_src( ureg, src1 );                                         \
  833.    ureg_emit_src( ureg, src2 );                                         \
  834.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  835. }
  836.  
  837. #define OP14_TEX( op )                                                  \
  838. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  839.                               struct ureg_dst dst,                      \
  840.                               unsigned target,                          \
  841.                               struct ureg_src src0,                     \
  842.                               struct ureg_src src1,                     \
  843.                               struct ureg_src src2,                     \
  844.                               struct ureg_src src3 )                    \
  845. {                                                                       \
  846.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  847.    struct ureg_emit_insn_result insn;                                   \
  848.    if (ureg_dst_is_empty(dst))                                          \
  849.       return;                                                           \
  850.    insn = ureg_emit_insn(ureg,                                          \
  851.                          opcode,                                        \
  852.                          dst.Saturate,                                  \
  853.                          dst.Predicate,                                 \
  854.                          dst.PredNegate,                                \
  855.                          dst.PredSwizzleX,                              \
  856.                          dst.PredSwizzleY,                              \
  857.                          dst.PredSwizzleZ,                              \
  858.                          dst.PredSwizzleW,                              \
  859.                          1,                                             \
  860.                          4);                                            \
  861.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  862.    ureg_emit_dst( ureg, dst );                                          \
  863.    ureg_emit_src( ureg, src0 );                                         \
  864.    ureg_emit_src( ureg, src1 );                                         \
  865.    ureg_emit_src( ureg, src2 );                                         \
  866.    ureg_emit_src( ureg, src3 );                                         \
  867.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  868. }
  869.  
  870. #define OP14_SAMPLE( op )                                               \
  871. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  872.                               struct ureg_dst dst,                      \
  873.                               struct ureg_src src0,                     \
  874.                               struct ureg_src src1,                     \
  875.                               struct ureg_src src2,                     \
  876.                               struct ureg_src src3 )                    \
  877. {                                                                       \
  878.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  879.    unsigned target = TGSI_TEXTURE_UNKNOWN;                              \
  880.    struct ureg_emit_insn_result insn;                                   \
  881.    if (ureg_dst_is_empty(dst))                                          \
  882.       return;                                                           \
  883.    insn = ureg_emit_insn(ureg,                                          \
  884.                          opcode,                                        \
  885.                          dst.Saturate,                                  \
  886.                          dst.Predicate,                                 \
  887.                          dst.PredNegate,                                \
  888.                          dst.PredSwizzleX,                              \
  889.                          dst.PredSwizzleY,                              \
  890.                          dst.PredSwizzleZ,                              \
  891.                          dst.PredSwizzleW,                              \
  892.                          1,                                             \
  893.                          4);                                            \
  894.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  895.    ureg_emit_dst( ureg, dst );                                          \
  896.    ureg_emit_src( ureg, src0 );                                         \
  897.    ureg_emit_src( ureg, src1 );                                         \
  898.    ureg_emit_src( ureg, src2 );                                         \
  899.    ureg_emit_src( ureg, src3 );                                         \
  900.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  901. }
  902.  
  903.  
  904. #define OP14( op )                                                      \
  905. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  906.                               struct ureg_dst dst,                      \
  907.                               struct ureg_src src0,                     \
  908.                               struct ureg_src src1,                     \
  909.                               struct ureg_src src2,                     \
  910.                               struct ureg_src src3 )                    \
  911. {                                                                       \
  912.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  913.    struct ureg_emit_insn_result insn;                                   \
  914.    if (ureg_dst_is_empty(dst))                                          \
  915.       return;                                                           \
  916.    insn = ureg_emit_insn(ureg,                                          \
  917.                          opcode,                                        \
  918.                          dst.Saturate,                                  \
  919.                          dst.Predicate,                                 \
  920.                          dst.PredNegate,                                \
  921.                          dst.PredSwizzleX,                              \
  922.                          dst.PredSwizzleY,                              \
  923.                          dst.PredSwizzleZ,                              \
  924.                          dst.PredSwizzleW,                              \
  925.                          1,                                             \
  926.                          4);                                            \
  927.    ureg_emit_dst( ureg, dst );                                          \
  928.    ureg_emit_src( ureg, src0 );                                         \
  929.    ureg_emit_src( ureg, src1 );                                         \
  930.    ureg_emit_src( ureg, src2 );                                         \
  931.    ureg_emit_src( ureg, src3 );                                         \
  932.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  933. }
  934.  
  935.  
  936. #define OP15( op )                                                      \
  937. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  938.                               struct ureg_dst dst,                      \
  939.                               struct ureg_src src0,                     \
  940.                               struct ureg_src src1,                     \
  941.                               struct ureg_src src2,                     \
  942.                               struct ureg_src src3,                     \
  943.                               struct ureg_src src4 )                    \
  944. {                                                                       \
  945.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  946.    struct ureg_emit_insn_result insn;                                   \
  947.    if (ureg_dst_is_empty(dst))                                          \
  948.       return;                                                           \
  949.    insn = ureg_emit_insn(ureg,                                          \
  950.                          opcode,                                        \
  951.                          dst.Saturate,                                  \
  952.                          dst.Predicate,                                 \
  953.                          dst.PredNegate,                                \
  954.                          dst.PredSwizzleX,                              \
  955.                          dst.PredSwizzleY,                              \
  956.                          dst.PredSwizzleZ,                              \
  957.                          dst.PredSwizzleW,                              \
  958.                          1,                                             \
  959.                          5);                                            \
  960.    ureg_emit_dst( ureg, dst );                                          \
  961.    ureg_emit_src( ureg, src0 );                                         \
  962.    ureg_emit_src( ureg, src1 );                                         \
  963.    ureg_emit_src( ureg, src2 );                                         \
  964.    ureg_emit_src( ureg, src3 );                                         \
  965.    ureg_emit_src( ureg, src4 );                                         \
  966.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  967. }
  968.  
  969. #define OP15_SAMPLE( op )                                               \
  970. static INLINE void ureg_##op( struct ureg_program *ureg,                \
  971.                               struct ureg_dst dst,                      \
  972.                               struct ureg_src src0,                     \
  973.                               struct ureg_src src1,                     \
  974.                               struct ureg_src src2,                     \
  975.                               struct ureg_src src3,                     \
  976.                               struct ureg_src src4 )                    \
  977. {                                                                       \
  978.    unsigned opcode = TGSI_OPCODE_##op;                                  \
  979.    unsigned target = TGSI_TEXTURE_UNKNOWN;                              \
  980.    struct ureg_emit_insn_result insn;                                   \
  981.    if (ureg_dst_is_empty(dst))                                          \
  982.       return;                                                           \
  983.    insn = ureg_emit_insn(ureg,                                          \
  984.                          opcode,                                        \
  985.                          dst.Saturate,                                  \
  986.                          dst.Predicate,                                 \
  987.                          dst.PredNegate,                                \
  988.                          dst.PredSwizzleX,                              \
  989.                          dst.PredSwizzleY,                              \
  990.                          dst.PredSwizzleZ,                              \
  991.                          dst.PredSwizzleW,                              \
  992.                          1,                                             \
  993.                          5);                                            \
  994.    ureg_emit_texture( ureg, insn.extended_token, target, 0 );           \
  995.    ureg_emit_dst( ureg, dst );                                          \
  996.    ureg_emit_src( ureg, src0 );                                         \
  997.    ureg_emit_src( ureg, src1 );                                         \
  998.    ureg_emit_src( ureg, src2 );                                         \
  999.    ureg_emit_src( ureg, src3 );                                         \
  1000.    ureg_emit_src( ureg, src4 );                                         \
  1001.    ureg_fixup_insn_size( ureg, insn.insn_token );                       \
  1002. }
  1003.  
  1004. /* Use a template include to generate a correctly-typed ureg_OP()
  1005.  * function for each TGSI opcode:
  1006.  */
  1007. #include "tgsi_opcode_tmp.h"
  1008.  
  1009.  
  1010. /***********************************************************************
  1011.  * Inline helpers for manipulating register structs:
  1012.  */
  1013. static INLINE struct ureg_src
  1014. ureg_negate( struct ureg_src reg )
  1015. {
  1016.    assert(reg.File != TGSI_FILE_NULL);
  1017.    reg.Negate ^= 1;
  1018.    return reg;
  1019. }
  1020.  
  1021. static INLINE struct ureg_src
  1022. ureg_abs( struct ureg_src reg )
  1023. {
  1024.    assert(reg.File != TGSI_FILE_NULL);
  1025.    reg.Absolute = 1;
  1026.    reg.Negate = 0;
  1027.    return reg;
  1028. }
  1029.  
  1030. static INLINE struct ureg_src
  1031. ureg_swizzle( struct ureg_src reg,
  1032.               int x, int y, int z, int w )
  1033. {
  1034.    unsigned swz = ( (reg.SwizzleX << 0) |
  1035.                     (reg.SwizzleY << 2) |
  1036.                     (reg.SwizzleZ << 4) |
  1037.                     (reg.SwizzleW << 6));
  1038.  
  1039.    assert(reg.File != TGSI_FILE_NULL);
  1040.    assert(x < 4);
  1041.    assert(y < 4);
  1042.    assert(z < 4);
  1043.    assert(w < 4);
  1044.  
  1045.    reg.SwizzleX = (swz >> (x*2)) & 0x3;
  1046.    reg.SwizzleY = (swz >> (y*2)) & 0x3;
  1047.    reg.SwizzleZ = (swz >> (z*2)) & 0x3;
  1048.    reg.SwizzleW = (swz >> (w*2)) & 0x3;
  1049.    return reg;
  1050. }
  1051.  
  1052. static INLINE struct ureg_src
  1053. ureg_scalar( struct ureg_src reg, int x )
  1054. {
  1055.    return ureg_swizzle(reg, x, x, x, x);
  1056. }
  1057.  
  1058. static INLINE struct ureg_dst
  1059. ureg_writemask( struct ureg_dst reg,
  1060.                 unsigned writemask )
  1061. {
  1062.    assert(reg.File != TGSI_FILE_NULL);
  1063.    reg.WriteMask &= writemask;
  1064.    return reg;
  1065. }
  1066.  
  1067. static INLINE struct ureg_dst
  1068. ureg_saturate( struct ureg_dst reg )
  1069. {
  1070.    assert(reg.File != TGSI_FILE_NULL);
  1071.    reg.Saturate = 1;
  1072.    return reg;
  1073. }
  1074.  
  1075. static INLINE struct ureg_dst
  1076. ureg_predicate(struct ureg_dst reg,
  1077.                boolean negate,
  1078.                unsigned swizzle_x,
  1079.                unsigned swizzle_y,
  1080.                unsigned swizzle_z,
  1081.                unsigned swizzle_w)
  1082. {
  1083.    assert(reg.File != TGSI_FILE_NULL);
  1084.    reg.Predicate = 1;
  1085.    reg.PredNegate = negate;
  1086.    reg.PredSwizzleX = swizzle_x;
  1087.    reg.PredSwizzleY = swizzle_y;
  1088.    reg.PredSwizzleZ = swizzle_z;
  1089.    reg.PredSwizzleW = swizzle_w;
  1090.    return reg;
  1091. }
  1092.  
  1093. static INLINE struct ureg_dst
  1094. ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr )
  1095. {
  1096.    assert(reg.File != TGSI_FILE_NULL);
  1097.    assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY);
  1098.    reg.Indirect = 1;
  1099.    reg.IndirectFile = addr.File;
  1100.    reg.IndirectIndex = addr.Index;
  1101.    reg.IndirectSwizzle = addr.SwizzleX;
  1102.    return reg;
  1103. }
  1104.  
  1105. static INLINE struct ureg_src
  1106. ureg_src_indirect( struct ureg_src reg, struct ureg_src addr )
  1107. {
  1108.    assert(reg.File != TGSI_FILE_NULL);
  1109.    assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY);
  1110.    reg.Indirect = 1;
  1111.    reg.IndirectFile = addr.File;
  1112.    reg.IndirectIndex = addr.Index;
  1113.    reg.IndirectSwizzle = addr.SwizzleX;
  1114.    return reg;
  1115. }
  1116.  
  1117. static INLINE struct ureg_dst
  1118. ureg_dst_dimension( struct ureg_dst reg, int index )
  1119. {
  1120.    assert(reg.File != TGSI_FILE_NULL);
  1121.    reg.Dimension = 1;
  1122.    reg.DimIndirect = 0;
  1123.    reg.DimensionIndex = index;
  1124.    return reg;
  1125. }
  1126.  
  1127. static INLINE struct ureg_src
  1128. ureg_src_dimension( struct ureg_src reg, int index )
  1129. {
  1130.    assert(reg.File != TGSI_FILE_NULL);
  1131.    reg.Dimension = 1;
  1132.    reg.DimIndirect = 0;
  1133.    reg.DimensionIndex = index;
  1134.    return reg;
  1135. }
  1136.  
  1137. static INLINE struct ureg_dst
  1138. ureg_dst_dimension_indirect( struct ureg_dst reg, struct ureg_src addr,
  1139.                              int index )
  1140. {
  1141.    assert(reg.File != TGSI_FILE_NULL);
  1142.    reg.Dimension = 1;
  1143.    reg.DimIndirect = 1;
  1144.    reg.DimensionIndex = index;
  1145.    reg.DimIndFile = addr.File;
  1146.    reg.DimIndIndex = addr.Index;
  1147.    reg.DimIndSwizzle = addr.SwizzleX;
  1148.    return reg;
  1149. }
  1150.  
  1151. static INLINE struct ureg_src
  1152. ureg_src_dimension_indirect( struct ureg_src reg, struct ureg_src addr,
  1153.                              int index )
  1154. {
  1155.    assert(reg.File != TGSI_FILE_NULL);
  1156.    reg.Dimension = 1;
  1157.    reg.DimIndirect = 1;
  1158.    reg.DimensionIndex = index;
  1159.    reg.DimIndFile = addr.File;
  1160.    reg.DimIndIndex = addr.Index;
  1161.    reg.DimIndSwizzle = addr.SwizzleX;
  1162.    return reg;
  1163. }
  1164.  
  1165. static INLINE struct ureg_dst
  1166. ureg_dst_array_offset( struct ureg_dst reg, int offset )
  1167. {
  1168.    assert(reg.File == TGSI_FILE_TEMPORARY);
  1169.    reg.Index += offset;
  1170.    return reg;
  1171. }
  1172.  
  1173. static INLINE struct ureg_dst
  1174. ureg_dst_register( unsigned file,
  1175.                    unsigned index )
  1176. {
  1177.    struct ureg_dst dst;
  1178.  
  1179.    dst.File      = file;
  1180.    dst.WriteMask = TGSI_WRITEMASK_XYZW;
  1181.    dst.Indirect  = 0;
  1182.    dst.IndirectFile = TGSI_FILE_NULL;
  1183.    dst.IndirectIndex = 0;
  1184.    dst.IndirectSwizzle = 0;
  1185.    dst.Saturate  = 0;
  1186.    dst.Predicate = 0;
  1187.    dst.PredNegate = 0;
  1188.    dst.PredSwizzleX = TGSI_SWIZZLE_X;
  1189.    dst.PredSwizzleY = TGSI_SWIZZLE_Y;
  1190.    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
  1191.    dst.PredSwizzleW = TGSI_SWIZZLE_W;
  1192.    dst.Index     = index;
  1193.    dst.Dimension = 0;
  1194.    dst.DimensionIndex = 0;
  1195.    dst.DimIndirect = 0;
  1196.    dst.DimIndFile = TGSI_FILE_NULL;
  1197.    dst.DimIndIndex = 0;
  1198.    dst.DimIndSwizzle = 0;
  1199.    dst.ArrayID = 0;
  1200.  
  1201.    return dst;
  1202. }
  1203.  
  1204. static INLINE struct ureg_dst
  1205. ureg_dst( struct ureg_src src )
  1206. {
  1207.    struct ureg_dst dst;
  1208.  
  1209.    assert(!src.Indirect ||
  1210.           (src.IndirectFile == TGSI_FILE_ADDRESS ||
  1211.            src.IndirectFile == TGSI_FILE_TEMPORARY));
  1212.  
  1213.    dst.File      = src.File;
  1214.    dst.WriteMask = TGSI_WRITEMASK_XYZW;
  1215.    dst.IndirectFile = src.IndirectFile;
  1216.    dst.Indirect  = src.Indirect;
  1217.    dst.IndirectIndex = src.IndirectIndex;
  1218.    dst.IndirectSwizzle = src.IndirectSwizzle;
  1219.    dst.Saturate  = 0;
  1220.    dst.Predicate = 0;
  1221.    dst.PredNegate = 0;
  1222.    dst.PredSwizzleX = TGSI_SWIZZLE_X;
  1223.    dst.PredSwizzleY = TGSI_SWIZZLE_Y;
  1224.    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
  1225.    dst.PredSwizzleW = TGSI_SWIZZLE_W;
  1226.    dst.Index     = src.Index;
  1227.    dst.Dimension = src.Dimension;
  1228.    dst.DimensionIndex = src.DimensionIndex;
  1229.    dst.DimIndirect = src.DimIndirect;
  1230.    dst.DimIndFile = src.DimIndFile;
  1231.    dst.DimIndIndex = src.DimIndIndex;
  1232.    dst.DimIndSwizzle = src.DimIndSwizzle;
  1233.    dst.ArrayID = src.ArrayID;
  1234.  
  1235.    return dst;
  1236. }
  1237.  
  1238. static INLINE struct ureg_src
  1239. ureg_src_register(unsigned file,
  1240.                   unsigned index)
  1241. {
  1242.    struct ureg_src src;
  1243.  
  1244.    src.File = file;
  1245.    src.SwizzleX = TGSI_SWIZZLE_X;
  1246.    src.SwizzleY = TGSI_SWIZZLE_Y;
  1247.    src.SwizzleZ = TGSI_SWIZZLE_Z;
  1248.    src.SwizzleW = TGSI_SWIZZLE_W;
  1249.    src.Indirect = 0;
  1250.    src.IndirectFile = TGSI_FILE_NULL;
  1251.    src.IndirectIndex = 0;
  1252.    src.IndirectSwizzle = 0;
  1253.    src.Absolute = 0;
  1254.    src.Index = index;
  1255.    src.Negate = 0;
  1256.    src.Dimension = 0;
  1257.    src.DimensionIndex = 0;
  1258.    src.DimIndirect = 0;
  1259.    src.DimIndFile = TGSI_FILE_NULL;
  1260.    src.DimIndIndex = 0;
  1261.    src.DimIndSwizzle = 0;
  1262.    src.ArrayID = 0;
  1263.  
  1264.    return src;
  1265. }
  1266.  
  1267. static INLINE struct ureg_src
  1268. ureg_src( struct ureg_dst dst )
  1269. {
  1270.    struct ureg_src src;
  1271.  
  1272.    src.File      = dst.File;
  1273.    src.SwizzleX  = TGSI_SWIZZLE_X;
  1274.    src.SwizzleY  = TGSI_SWIZZLE_Y;
  1275.    src.SwizzleZ  = TGSI_SWIZZLE_Z;
  1276.    src.SwizzleW  = TGSI_SWIZZLE_W;
  1277.    src.Indirect  = dst.Indirect;
  1278.    src.IndirectFile = dst.IndirectFile;
  1279.    src.IndirectIndex = dst.IndirectIndex;
  1280.    src.IndirectSwizzle = dst.IndirectSwizzle;
  1281.    src.Absolute  = 0;
  1282.    src.Index     = dst.Index;
  1283.    src.Negate    = 0;
  1284.    src.Dimension = dst.Dimension;
  1285.    src.DimensionIndex = dst.DimensionIndex;
  1286.    src.DimIndirect = dst.DimIndirect;
  1287.    src.DimIndFile = dst.DimIndFile;
  1288.    src.DimIndIndex = dst.DimIndIndex;
  1289.    src.DimIndSwizzle = dst.DimIndSwizzle;
  1290.    src.ArrayID = dst.ArrayID;
  1291.  
  1292.    return src;
  1293. }
  1294.  
  1295.  
  1296.  
  1297. static INLINE struct ureg_dst
  1298. ureg_dst_undef( void )
  1299. {
  1300.    struct ureg_dst dst;
  1301.  
  1302.    dst.File      = TGSI_FILE_NULL;
  1303.    dst.WriteMask = 0;
  1304.    dst.Indirect  = 0;
  1305.    dst.IndirectFile = TGSI_FILE_NULL;
  1306.    dst.IndirectIndex = 0;
  1307.    dst.IndirectSwizzle = 0;
  1308.    dst.Saturate  = 0;
  1309.    dst.Predicate = 0;
  1310.    dst.PredNegate = 0;
  1311.    dst.PredSwizzleX = TGSI_SWIZZLE_X;
  1312.    dst.PredSwizzleY = TGSI_SWIZZLE_Y;
  1313.    dst.PredSwizzleZ = TGSI_SWIZZLE_Z;
  1314.    dst.PredSwizzleW = TGSI_SWIZZLE_W;
  1315.    dst.Index     = 0;
  1316.    dst.Dimension = 0;
  1317.    dst.DimensionIndex = 0;
  1318.    dst.DimIndirect = 0;
  1319.    dst.DimIndFile = TGSI_FILE_NULL;
  1320.    dst.DimIndIndex = 0;
  1321.    dst.DimIndSwizzle = 0;
  1322.    dst.ArrayID = 0;
  1323.  
  1324.    return dst;
  1325. }
  1326.  
  1327. static INLINE struct ureg_src
  1328. ureg_src_undef( void )
  1329. {
  1330.    struct ureg_src src;
  1331.  
  1332.    src.File      = TGSI_FILE_NULL;
  1333.    src.SwizzleX  = 0;
  1334.    src.SwizzleY  = 0;
  1335.    src.SwizzleZ  = 0;
  1336.    src.SwizzleW  = 0;
  1337.    src.Indirect  = 0;
  1338.    src.IndirectFile = TGSI_FILE_NULL;
  1339.    src.IndirectIndex = 0;
  1340.    src.IndirectSwizzle = 0;
  1341.    src.Absolute  = 0;
  1342.    src.Index     = 0;
  1343.    src.Negate    = 0;
  1344.    src.Dimension = 0;
  1345.    src.DimensionIndex = 0;
  1346.    src.DimIndirect = 0;
  1347.    src.DimIndFile = TGSI_FILE_NULL;
  1348.    src.DimIndIndex = 0;
  1349.    src.DimIndSwizzle = 0;
  1350.    src.ArrayID = 0;
  1351.  
  1352.    return src;
  1353. }
  1354.  
  1355. static INLINE boolean
  1356. ureg_src_is_undef( struct ureg_src src )
  1357. {
  1358.    return src.File == TGSI_FILE_NULL;
  1359. }
  1360.  
  1361. static INLINE boolean
  1362. ureg_dst_is_undef( struct ureg_dst dst )
  1363. {
  1364.    return dst.File == TGSI_FILE_NULL;
  1365. }
  1366.  
  1367.  
  1368. #ifdef __cplusplus
  1369. }
  1370. #endif
  1371.  
  1372. #endif
  1373.