i915_fpc.h File Reference

Include dependency graph for i915_fpc.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  i915_fp_compile
 Program translation state. More...

Defines

#define I915_PROGRAM_SIZE   192
#define UREG_TYPE_SHIFT   29
#define UREG_NR_SHIFT   24
#define UREG_CHANNEL_X_NEGATE_SHIFT   23
#define UREG_CHANNEL_X_SHIFT   20
#define UREG_CHANNEL_Y_NEGATE_SHIFT   19
#define UREG_CHANNEL_Y_SHIFT   16
#define UREG_CHANNEL_Z_NEGATE_SHIFT   15
#define UREG_CHANNEL_Z_SHIFT   12
#define UREG_CHANNEL_W_NEGATE_SHIFT   11
#define UREG_CHANNEL_W_SHIFT   8
#define UREG_CHANNEL_ZERO_NEGATE_MBZ   5
#define UREG_CHANNEL_ZERO_SHIFT   4
#define UREG_CHANNEL_ONE_NEGATE_MBZ   1
#define UREG_CHANNEL_ONE_SHIFT   0
#define UREG_BAD   0xffffffff
#define X   SRC_X
#define Y   SRC_Y
#define Z   SRC_Z
#define W   SRC_W
#define ZERO   SRC_ZERO
#define ONE   SRC_ONE
#define UREG(type, nr)
#define GET_CHANNEL_SRC(reg, channel)   ((reg<<(channel*4)) & (0xf<<20))
#define CHANNEL_SRC(src, channel)   (src>>(channel*4))
#define GET_UREG_TYPE(reg)   (((reg)>>UREG_TYPE_SHIFT)&REG_TYPE_MASK)
#define GET_UREG_NR(reg)   (((reg)>>UREG_NR_SHIFT)&REG_NR_MASK)
#define UREG_XYZW_CHANNEL_MASK   0x00ffff00

Functions

static int swizzle (int reg, uint x, uint y, uint z, uint w)
void i915_translate_fragment_program (struct i915_context *i915, struct i915_fragment_shader *fs)
uint i915_get_temp (struct i915_fp_compile *p)
uint i915_get_utemp (struct i915_fp_compile *p)
 Get unpreserved temporary, a temp whose value is not preserved between PS program phases.
void i915_release_utemps (struct i915_fp_compile *p)
uint i915_emit_texld (struct i915_fp_compile *p, uint dest, uint destmask, uint sampler, uint coord, uint op)
 Emit a texture load or texkill instruction.
uint i915_emit_arith (struct i915_fp_compile *p, uint op, uint dest, uint mask, uint saturate, uint src0, uint src1, uint src2)
uint i915_emit_decl (struct i915_fp_compile *p, uint type, uint nr, uint d0_flags)
uint i915_emit_const1f (struct i915_fp_compile *p, float c0)
uint i915_emit_const2f (struct i915_fp_compile *p, float c0, float c1)
uint i915_emit_const4fv (struct i915_fp_compile *p, const float *c)
uint i915_emit_const4f (struct i915_fp_compile *p, float c0, float c1, float c2, float c3)
void i915_disassemble_program (const uint *program, uint sz)
void i915_program_error (struct i915_fp_compile *p, const char *msg,...)


Define Documentation

#define CHANNEL_SRC ( src,
channel   )     (src>>(channel*4))

Definition at line 123 of file i915_fpc.h.

#define GET_CHANNEL_SRC ( reg,
channel   )     ((reg<<(channel*4)) & (0xf<<20))

Definition at line 122 of file i915_fpc.h.

#define GET_UREG_NR ( reg   )     (((reg)>>UREG_NR_SHIFT)&REG_NR_MASK)

Definition at line 126 of file i915_fpc.h.

#define GET_UREG_TYPE ( reg   )     (((reg)>>UREG_TYPE_SHIFT)&REG_TYPE_MASK)

Definition at line 125 of file i915_fpc.h.

#define I915_PROGRAM_SIZE   192

Definition at line 38 of file i915_fpc.h.

#define ONE   SRC_ONE

Definition at line 109 of file i915_fpc.h.

#define UREG ( type,
nr   ) 

Value:

Definition at line 113 of file i915_fpc.h.

#define UREG_BAD   0xffffffff

Definition at line 102 of file i915_fpc.h.

#define UREG_CHANNEL_ONE_NEGATE_MBZ   1

Definition at line 99 of file i915_fpc.h.

#define UREG_CHANNEL_ONE_SHIFT   0

Definition at line 100 of file i915_fpc.h.

#define UREG_CHANNEL_W_NEGATE_SHIFT   11

Definition at line 95 of file i915_fpc.h.

#define UREG_CHANNEL_W_SHIFT   8

Definition at line 96 of file i915_fpc.h.

#define UREG_CHANNEL_X_NEGATE_SHIFT   23

Definition at line 89 of file i915_fpc.h.

#define UREG_CHANNEL_X_SHIFT   20

Definition at line 90 of file i915_fpc.h.

#define UREG_CHANNEL_Y_NEGATE_SHIFT   19

Definition at line 91 of file i915_fpc.h.

#define UREG_CHANNEL_Y_SHIFT   16

Definition at line 92 of file i915_fpc.h.

#define UREG_CHANNEL_Z_NEGATE_SHIFT   15

Definition at line 93 of file i915_fpc.h.

#define UREG_CHANNEL_Z_SHIFT   12

Definition at line 94 of file i915_fpc.h.

#define UREG_CHANNEL_ZERO_NEGATE_MBZ   5

Definition at line 97 of file i915_fpc.h.

#define UREG_CHANNEL_ZERO_SHIFT   4

Definition at line 98 of file i915_fpc.h.

#define UREG_NR_SHIFT   24

Definition at line 88 of file i915_fpc.h.

#define UREG_TYPE_SHIFT   29

Definition at line 87 of file i915_fpc.h.

#define UREG_XYZW_CHANNEL_MASK   0x00ffff00

Definition at line 130 of file i915_fpc.h.

#define W   SRC_W

Definition at line 107 of file i915_fpc.h.

#define X   SRC_X

Definition at line 104 of file i915_fpc.h.

#define Y   SRC_Y

Definition at line 105 of file i915_fpc.h.

#define Z   SRC_Z

Definition at line 106 of file i915_fpc.h.

#define ZERO   SRC_ZERO

Definition at line 108 of file i915_fpc.h.


Function Documentation

void i915_disassemble_program ( const uint program,
uint  sz 
)

uint i915_emit_arith ( struct i915_fp_compile p,
uint  op,
uint  dest,
uint  mask,
uint  saturate,
uint  src0,
uint  src1,
uint  src2 
)

Definition at line 149 of file i915_fpc_emit.c.

00165                      {
00166       uint s[3], first, i, old_utemp_flag;
00167 
00168       s[0] = src0;
00169       s[1] = src1;
00170       s[2] = src2;
00171       old_utemp_flag = p->utemp_flag;
00172 
00173       first = GET_UREG_NR(s[c[0]]);
00174       for (i = 1; i < nr_const; i++) {
00175          if (GET_UREG_NR(s[c[i]]) != first) {
00176             uint tmp = i915_get_utemp(p);
00177 
00178             i915_emit_arith(p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0,
00179                             s[c[i]], 0, 0);
00180             s[c[i]] = tmp;
00181          }
00182       }
00183 
00184       src0 = s[0];
00185       src1 = s[1];
00186       src2 = s[2];
00187       p->utemp_flag = old_utemp_flag;   /* restore */
00188    }
00189 
00190    *(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0));
00191    *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1));
00192    *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2));
00193 
00194    p->nr_alu_insn++;
00195    return dest;
00196 }
00197 
00198 
00207 uint i915_emit_texld( struct i915_fp_compile *p,
00208                         uint dest,
00209                         uint destmask,
00210                         uint sampler,
00211                         uint coord,
00212                         uint opcode )
00213 {
00214    const uint k = UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord));
00215    int temp = -1;
00216 
00217    if (coord != k) {
00218       /* texcoord is swizzled or negated.  Need to allocate a new temporary
00219        * register (a utemp / unpreserved temp) won't do.
00220        */
00221       uint tempReg;
00222 
00223       temp = i915_get_temp(p);           /* get temp reg index */
00224       tempReg = UREG(REG_TYPE_R, temp);  /* make i915 register */
00225 
00226       i915_emit_arith( p, A0_MOV,
00227                        tempReg, A0_DEST_CHANNEL_ALL, /* dest reg, writemask */
00228                        0,                            /* saturate */
00229                        coord, 0, 0 );                /* src0, src1, src2 */

uint i915_emit_const1f ( struct i915_fp_compile p,
float  c0 
)

Definition at line 321 of file i915_fpc_emit.c.

References i915_fragment_shader::constant_flags, i915_fragment_shader::constants, i915_fragment_shader::num_constants, ONE, REG_TYPE_CONST, swizzle(), UREG, and ZERO.

00321                                                        {
00322             ifs->constants[reg][idx + 0] = c0;
00323             ifs->constants[reg][idx + 1] = c1;
00324             ifs->constant_flags[reg] |= 3 << idx;
00325             if (reg + 1 > ifs->num_constants)
00326                ifs->num_constants = reg + 1;
00327             return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO, ONE);
00328          }
00329       }
00330    }
00331 
00332    i915_program_error(p, "i915_emit_const2f: out of constants\n");
00333    return 0;
00334 }
00335 
00336 
00337 
00338 uint
00339 i915_emit_const4f(struct i915_fp_compile * p,
00340                   float c0, float c1, float c2, float c3)
00341 {
00342    struct i915_fragment_shader *ifs = p->shader;
00343    unsigned reg;
00344 
00345    for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
00346       if (ifs->constant_flags[reg] == 0xf &&
00347           ifs->constants[reg][0] == c0 &&
00348           ifs->constants[reg][1] == c1 &&
00349           ifs->constants[reg][2] == c2 &&
00350           ifs->constants[reg][3] == c3) {
00351          return UREG(REG_TYPE_CONST, reg);
00352       }
00353       else if (ifs->constant_flags[reg] == 0) {
00354 
00355          ifs->constants[reg][0] = c0;
00356          ifs->constants[reg][1] = c1;
00357          ifs->constants[reg][2] = c2;
00358          ifs->constants[reg][3] = c3;
00359          ifs->constant_flags[reg] = 0xf;
00360          if (reg + 1 > ifs->num_constants)
00361             ifs->num_constants = reg + 1;
00362          return UREG(REG_TYPE_CONST, reg);

uint i915_emit_const2f ( struct i915_fp_compile p,
float  c0,
float  c1 
)

Definition at line 365 of file i915_fpc_emit.c.

00366                                            : out of constants\n");
00367    return 0;
00368 }
00369 
00370 
00371 uint
00372 i915_emit_const4fv(struct i915_fp_compile * p, const float * c)
00373 {
00374    return i915_emit_const4f(p, c[0], c[1], c[2], c[3]);
00375 }
00376 }

uint i915_emit_const4f ( struct i915_fp_compile p,
float  c0,
float  c1,
float  c2,
float  c3 
)

Definition at line 409 of file i915_fpc_emit.c.

uint i915_emit_const4fv ( struct i915_fp_compile p,
const float *  c 
)

Definition at line 454 of file i915_fpc_emit.c.

uint i915_emit_decl ( struct i915_fp_compile p,
uint  type,
uint  nr,
uint  d0_flags 
)

Definition at line 111 of file i915_fpc_emit.c.

References D0_DCL, D0_DEST, D1_MBZ, D2_MBZ, i915_fp_compile::decl, i915_fp_compile::decl_s, i915_fp_compile::decl_t, i915_fp_compile::nr_decl_insn, REG_TYPE_S, REG_TYPE_T, and UREG.

00113 {
00114    uint reg = UREG(type, nr);
00115 
00116    if (type == REG_TYPE_T) {
00117       if (p->decl_t & (1 << nr))
00118          return reg;
00119 
00120       p->decl_t |= (1 << nr);
00121    }
00122    else if (type == REG_TYPE_S) {
00123       if (p->decl_s & (1 << nr))
00124          return reg;
00125 
00126       p->decl_s |= (1 << nr);
00127    }
00128    else
00129       return reg;
00130 
00131    *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
00132    *(p->decl++) = D1_MBZ;
00133    *(p->decl++) = D2_MBZ;
00134 
00135    p->nr_decl_insn++;
00136    return reg;
00137 }
00138 
00139 uint
00140 i915_emit_arith(struct i915_fp_compile * p,
00141                 uint op,
00142                 uint dest,
00143                 uint mask,
00144                 uint saturate, uint src0, uint src1, uint src2)
00145 {
00146    uint c[3];

uint i915_emit_texld ( struct i915_fp_compile p,
uint  dest,
uint  destmask,
uint  sampler,
uint  coord,
uint  opcode 
)

Emit a texture load or texkill instruction.

Parameters:
dest the dest i915 register
destmask the dest register writemask
sampler the i915 sampler register
coord the i915 source texcoord operand
opcode the instruction opcode

Definition at line 240 of file i915_fpc_emit.c.

00244         {
00245       assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
00246       assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
00247 
00248       /* is the sampler coord a texcoord input reg? */
00249       if (GET_UREG_TYPE(coord) != REG_TYPE_T) {
00250          p->nr_tex_indirect++;
00251       }
00252 
00253       *(p->csr++) = (opcode | 
00254                      T0_DEST( dest ) |
00255                      T0_SAMPLER( sampler ));
00256 
00257       *(p->csr++) = T1_ADDRESS_REG( coord );
00258       *(p->csr++) = T2_MBZ;
00259 
00260       p->nr_tex_insn++;
00261    }
00262 
00263    if (temp >= 0)
00264       i915_release_temp(p, temp);
00265 
00266    return dest;
00267 }
00268 
00269 
00270 uint
00271 i915_emit_const1f(struct i915_fp_compile * p, float c0)
00272 {
00273    struct i915_fragment_shader *ifs = p->shader;
00274    unsigned reg, idx;
00275 
00276    if (c0 == 0.0)
00277       return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO);
00278    if (c0 == 1.0)
00279       return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE);
00280 
00281    for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
00282       if (ifs->constant_flags[reg] == I915_CONSTFLAG_USER)
00283          continue;
00284       for (idx = 0; idx < 4; idx++) {
00285          if (!(ifs->constant_flags[reg] & (1 << idx)) ||
00286              ifs->constants[reg][idx] == c0) {
00287             ifs->constants[reg][idx] = c0;
00288             ifs->constant_flags[reg] |= 1 << idx;
00289             if (reg + 1 > ifs->num_constants)
00290                ifs->num_constants = reg + 1;
00291             return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE);
00292          }
00293       }
00294    }
00295 
00296    i915_program_error(p, "i915_emit_const1f: out of constants\n");
00297    return 0;
00298 }
00299 
00300 uint
00301 i915_emit_const2f(struct i915_fp_compile * p, float c0, float c1)
00302 {
00303    struct i915_fragment_shader *ifs = p->shader;
00304    unsigned reg, idx;
00305 
00306    if (c0 == 0.0)
00307       return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W);
00308    if (c0 == 1.0)
00309       return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W);
00310 
00311    if (c1 == 0.0)
00312       return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W);
00313    if (c1 == 1.0)
00314       return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
00315 
00316    for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
00317       if (ifs->constant_flags[reg] == 0xf ||

uint i915_get_temp ( struct i915_fp_compile p  ) 

Definition at line 66 of file i915_fpc_emit.c.

References i915_program_error(), and i915_fp_compile::temp_flag.

00067 {
00068    int bit = ffs(~p->temp_flag);
00069    if (!bit) {
00070       i915_program_error(p, "i915_get_temp: out of temporaries\n");
00071       return 0;
00072    }
00073 
00074    p->temp_flag |= 1 << (bit - 1);
00075    return bit - 1;
00076 }

uint i915_get_utemp ( struct i915_fp_compile p  ) 

Get unpreserved temporary, a temp whose value is not preserved between PS program phases.

Definition at line 91 of file i915_fpc_emit.c.

References i915_program_error(), REG_TYPE_U, UREG, and i915_fp_compile::utemp_flag.

00092 {
00093    int bit = ffs(~p->utemp_flag);
00094    if (!bit) {
00095       i915_program_error(p, "i915_get_utemp: out of temporaries\n");
00096       return 0;
00097    }
00098 
00099    p->utemp_flag |= 1 << (bit - 1);
00100    return UREG(REG_TYPE_U, (bit - 1));
00101 }

void i915_program_error ( struct i915_fp_compile p,
const char *  msg,
  ... 
)

Definition at line 137 of file i915_fpc_translate.c.

References tgsi_src_register::File, I915_MAX_TEMPORARY, i915_program_error(), tgsi_src_register::Index, REG_TYPE_R, tgsi_full_src_register::SrcRegister, TGSI_FILE_INPUT, TGSI_FILE_TEMPORARY, and UREG.

00145 {
00146    uint index = source->SrcRegister.Index;
00147    uint src, sem_name, sem_ind;
00148 
00149    switch (source->SrcRegister.File) {
00150    case TGSI_FILE_TEMPORARY:

void i915_release_utemps ( struct i915_fp_compile p  ) 

Definition at line 104 of file i915_fpc_emit.c.

References i915_fp_compile::utemp_flag.

00105 {
00106    p->utemp_flag = ~0x7;
00107 }

void i915_translate_fragment_program ( struct i915_context i915,
struct i915_fragment_shader fs 
)

Definition at line 1251 of file i915_fpc_translate.c.

static int swizzle ( int  reg,
uint  x,
uint  y,
uint  z,
uint  w 
) [static]

Definition at line 135 of file i915_fpc.h.

References assert, CHANNEL_SRC, GET_CHANNEL_SRC, SRC_ONE, and UREG_XYZW_CHANNEL_MASK.

00136 {
00137    assert(x <= SRC_ONE);
00138    assert(y <= SRC_ONE);
00139    assert(z <= SRC_ONE);
00140    assert(w <= SRC_ONE);
00141    return ((reg & ~UREG_XYZW_CHANNEL_MASK) |
00142            CHANNEL_SRC(GET_CHANNEL_SRC(reg, x), 0) |
00143            CHANNEL_SRC(GET_CHANNEL_SRC(reg, y), 1) |
00144            CHANNEL_SRC(GET_CHANNEL_SRC(reg, z), 2) |
00145            CHANNEL_SRC(GET_CHANNEL_SRC(reg, w), 3));
00146 }


Generated on Tue Sep 29 06:25:34 2009 for Gallium3D by  doxygen 1.5.4