tgsi_util.c File Reference

Include dependency graph for tgsi_util.c:

Go to the source code of this file.

Data Structures

union  pointer_hack

Functions

void * tgsi_align_128bit (void *unaligned)
unsigned tgsi_util_get_src_register_swizzle (const struct tgsi_src_register *reg, unsigned component)
unsigned tgsi_util_get_src_register_extswizzle (const struct tgsi_src_register_ext_swz *reg, unsigned component)
unsigned tgsi_util_get_full_src_register_extswizzle (const struct tgsi_full_src_register *reg, unsigned component)
void tgsi_util_set_src_register_swizzle (struct tgsi_src_register *reg, unsigned swizzle, unsigned component)
void tgsi_util_set_src_register_extswizzle (struct tgsi_src_register_ext_swz *reg, unsigned swizzle, unsigned component)
unsigned tgsi_util_get_src_register_extnegate (const struct tgsi_src_register_ext_swz *reg, unsigned component)
void tgsi_util_set_src_register_extnegate (struct tgsi_src_register_ext_swz *reg, unsigned negate, unsigned component)
unsigned tgsi_util_get_full_src_register_sign_mode (const struct tgsi_full_src_register *reg, unsigned component)
void tgsi_util_set_full_src_register_sign_mode (struct tgsi_full_src_register *reg, unsigned sign_mode)


Function Documentation

void* tgsi_align_128bit ( void *  unaligned  ) 

Definition at line 41 of file tgsi_util.c.

References pointer_hack::pointer, and pointer_hack::uint64.

00043 {
00044    union pointer_hack ph;
00045 
00046    ph.uint64 = 0;
00047    ph.pointer = unaligned;
00048    ph.uint64 = (ph.uint64 + 15) & ~15;
00049    return ph.pointer;
00050 }

unsigned tgsi_util_get_full_src_register_extswizzle ( const struct tgsi_full_src_register reg,
unsigned  component 
)

Definition at line 93 of file tgsi_util.c.

00096 {
00097    unsigned swizzle;
00098 
00099    /*
00100     * First, calculate  the   extended swizzle for a given channel. This will give
00101     * us either a channel index into the simple swizzle or  a constant 1 or   0.
00102     */
00103    swizzle = tgsi_util_get_src_register_extswizzle(
00104       &reg->SrcRegisterExtSwz,
00105       component );
00106 
00107    assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
00108    assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
00109    assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
00110    assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
00111    assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
00112    assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
00113 
00114    /*
00115     * Second, calculate the simple  swizzle  for   the   unswizzled channel index.
00116     * Leave the constants intact, they are   not   affected by the   simple swizzle.
00117     */
00118    if( swizzle <= TGSI_SWIZZLE_W ) {
00119       swizzle = tgsi_util_get_src_register_swizzle(
00120          &reg->SrcRegister,
00121          swizzle );
00122    }
00123 
00124    return swizzle;
00125 }

unsigned tgsi_util_get_full_src_register_sign_mode ( const struct tgsi_full_src_register reg,
unsigned  component 
)

Definition at line 220 of file tgsi_util.c.

00223 {
00224    unsigned sign_mode;
00225 
00226    if( reg->SrcRegisterExtMod.Absolute ) {
00227       /* Consider only the post-abs negation. */
00228 
00229       if( reg->SrcRegisterExtMod.Negate ) {
00230          sign_mode = TGSI_UTIL_SIGN_SET;
00231       }
00232       else {
00233          sign_mode = TGSI_UTIL_SIGN_CLEAR;
00234       }
00235    }
00236    else {
00237       /* Accumulate the three negations. */
00238 
00239       unsigned negate;
00240 
00241       negate = reg->SrcRegister.Negate;
00242       if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
00243          negate = !negate;
00244       }
00245       if( reg->SrcRegisterExtMod.Negate ) {
00246          negate = !negate;
00247       }
00248 
00249       if( negate ) {
00250          sign_mode = TGSI_UTIL_SIGN_TOGGLE;
00251       }
00252       else {
00253          sign_mode = TGSI_UTIL_SIGN_KEEP;
00254       }
00255    }
00256 
00257    return sign_mode;
00258 }

unsigned tgsi_util_get_src_register_extnegate ( const struct tgsi_src_register_ext_swz reg,
unsigned  component 
)

Definition at line 176 of file tgsi_util.c.

00179 {
00180    switch( component ) {
00181    case 0:
00182       return reg->NegateX;
00183    case 1:
00184       return reg->NegateY;
00185    case 2:
00186       return reg->NegateZ;
00187    case 3:
00188       return reg->NegateW;
00189    default:
00190       assert( 0 );
00191    }
00192    return 0;
00193 }

unsigned tgsi_util_get_src_register_extswizzle ( const struct tgsi_src_register_ext_swz reg,
unsigned  component 
)

Definition at line 73 of file tgsi_util.c.

00076 {
00077    switch( component ) {
00078    case 0:
00079       return reg->ExtSwizzleX;
00080    case 1:
00081       return reg->ExtSwizzleY;
00082    case 2:
00083       return reg->ExtSwizzleZ;
00084    case 3:
00085       return reg->ExtSwizzleW;
00086    default:
00087       assert( 0 );
00088    }
00089    return 0;
00090 }

unsigned tgsi_util_get_src_register_swizzle ( const struct tgsi_src_register reg,
unsigned  component 
)

Definition at line 53 of file tgsi_util.c.

00056 {
00057    switch( component ) {
00058    case 0:
00059       return reg->SwizzleX;
00060    case 1:
00061       return reg->SwizzleY;
00062    case 2:
00063       return reg->SwizzleZ;
00064    case 3:
00065       return reg->SwizzleW;
00066    default:
00067       assert( 0 );
00068    }
00069    return 0;
00070 }

void tgsi_util_set_full_src_register_sign_mode ( struct tgsi_full_src_register reg,
unsigned  sign_mode 
)

Definition at line 261 of file tgsi_util.c.

References tgsi_src_register_ext_mod::Absolute, assert, tgsi_src_register_ext_mod::Negate, tgsi_src_register::Negate, tgsi_src_register_ext_swz::NegateW, tgsi_src_register_ext_swz::NegateX, tgsi_src_register_ext_swz::NegateY, tgsi_src_register_ext_swz::NegateZ, tgsi_full_src_register::SrcRegister, tgsi_full_src_register::SrcRegisterExtMod, tgsi_full_src_register::SrcRegisterExtSwz, TGSI_UTIL_SIGN_CLEAR, TGSI_UTIL_SIGN_KEEP, TGSI_UTIL_SIGN_SET, and TGSI_UTIL_SIGN_TOGGLE.

00264 {
00265    reg->SrcRegisterExtSwz.NegateX = 0;
00266    reg->SrcRegisterExtSwz.NegateY = 0;
00267    reg->SrcRegisterExtSwz.NegateZ = 0;
00268    reg->SrcRegisterExtSwz.NegateW = 0;
00269 
00270    switch (sign_mode)
00271    {
00272    case TGSI_UTIL_SIGN_CLEAR:
00273       reg->SrcRegister.Negate = 0;
00274       reg->SrcRegisterExtMod.Absolute = 1;
00275       reg->SrcRegisterExtMod.Negate = 0;
00276       break;
00277 
00278    case TGSI_UTIL_SIGN_SET:
00279       reg->SrcRegister.Negate = 0;
00280       reg->SrcRegisterExtMod.Absolute = 1;
00281       reg->SrcRegisterExtMod.Negate = 1;
00282       break;
00283 
00284    case TGSI_UTIL_SIGN_TOGGLE:
00285       reg->SrcRegister.Negate = 1;
00286       reg->SrcRegisterExtMod.Absolute = 0;
00287       reg->SrcRegisterExtMod.Negate = 0;
00288       break;
00289 
00290    case TGSI_UTIL_SIGN_KEEP:
00291       reg->SrcRegister.Negate = 0;
00292       reg->SrcRegisterExtMod.Absolute = 0;
00293       reg->SrcRegisterExtMod.Negate = 0;
00294       break;
00295 
00296    default:
00297       assert( 0 );
00298    }
00299 }

void tgsi_util_set_src_register_extnegate ( struct tgsi_src_register_ext_swz reg,
unsigned  negate,
unsigned  component 
)

Definition at line 196 of file tgsi_util.c.

00200 {
00201    switch( component ) {
00202    case 0:
00203       reg->NegateX = negate;
00204       break;
00205    case 1:
00206       reg->NegateY = negate;
00207       break;
00208    case 2:
00209       reg->NegateZ = negate;
00210       break;
00211    case 3:
00212       reg->NegateW = negate;
00213       break;
00214    default:
00215       assert( 0 );
00216    }
00217 }

void tgsi_util_set_src_register_extswizzle ( struct tgsi_src_register_ext_swz reg,
unsigned  swizzle,
unsigned  component 
)

Definition at line 152 of file tgsi_util.c.

References assert, tgsi_src_register_ext_swz::ExtSwizzleW, tgsi_src_register_ext_swz::ExtSwizzleX, tgsi_src_register_ext_swz::ExtSwizzleY, and tgsi_src_register_ext_swz::ExtSwizzleZ.

00156 {
00157    switch( component ) {
00158    case 0:
00159       reg->ExtSwizzleX = swizzle;
00160       break;
00161    case 1:
00162       reg->ExtSwizzleY = swizzle;
00163       break;
00164    case 2:
00165       reg->ExtSwizzleZ = swizzle;
00166       break;
00167    case 3:
00168       reg->ExtSwizzleW = swizzle;
00169       break;
00170    default:
00171       assert( 0 );
00172    }
00173 }

void tgsi_util_set_src_register_swizzle ( struct tgsi_src_register reg,
unsigned  swizzle,
unsigned  component 
)

Definition at line 128 of file tgsi_util.c.

References assert, tgsi_src_register::SwizzleW, tgsi_src_register::SwizzleX, tgsi_src_register::SwizzleY, and tgsi_src_register::SwizzleZ.

00132 {
00133    switch( component ) {
00134    case 0:
00135       reg->SwizzleX = swizzle;
00136       break;
00137    case 1:
00138       reg->SwizzleY = swizzle;
00139       break;
00140    case 2:
00141       reg->SwizzleZ = swizzle;
00142       break;
00143    case 3:
00144       reg->SwizzleW = swizzle;
00145       break;
00146    default:
00147       assert( 0 );
00148    }
00149 }


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