filename | src/pvr2/texcache.c |
changeset | 315:2d8ba198d62c |
prev | 314:2a1f3b3d8708 |
next | 321:7036e3692165 |
author | nkeynes |
date | Tue Jan 23 11:19:32 2007 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Refactor render buffer read/write to pvr2mem.c Implement 4-bit indexed textures (tentatively) Fix RGB24 support |
file | annotate | diff | log | raw |
1.1 --- a/src/pvr2/texcache.c Tue Jan 23 09:30:59 2007 +00001.2 +++ b/src/pvr2/texcache.c Tue Jan 23 11:19:32 2007 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: texcache.c,v 1.18 2007-01-23 09:30:59 nkeynes Exp $1.6 + * $Id: texcache.c,v 1.19 2007-01-23 11:19:32 nkeynes Exp $1.7 *1.8 * Texture cache. Responsible for maintaining a working set of OpenGL1.9 * textures.1.10 @@ -195,6 +195,27 @@1.11 }1.12 }1.14 +static void decode_pal4_to_32( uint32_t *out, uint8_t *in, int inbytes, uint32_t *pal )1.15 +{1.16 + int i;1.17 + for( i=0; i<inbytes; i++ ) {1.18 + *out++ = pal[*in & 0x0F];1.19 + *out++ = pal[(*in >> 4)];1.20 + in++;1.21 + }1.22 +}1.23 +1.24 +1.25 +static void decode_pal4_to_16( uint16_t *out, uint8_t *in, int inbytes, uint16_t *pal )1.26 +{1.27 + int i;1.28 + for( i=0; i<inbytes; i++ ) {1.29 + *out++ = pal[*in & 0x0F];1.30 + *out++ = pal[(*in >> 4)];1.31 + in++;1.32 + }1.33 +}1.34 +1.35 #define VQ_CODEBOOK_SIZE 2048 /* 256 entries * 4 pixels per quad * 2 byte pixels */1.37 struct vq_codebook {1.38 @@ -283,7 +304,6 @@1.39 /* Decode the format parameters */1.40 switch( tex_format ) {1.41 case PVR2_TEX_FORMAT_IDX4:1.42 - ERROR( "4-bit indexed textures not supported" );1.43 case PVR2_TEX_FORMAT_IDX8:1.44 /* For indexed-colour modes, we need to lookup the palette control1.45 * word to determine the de-indexed texture format.1.46 @@ -385,13 +405,23 @@1.47 int bank = (mode >> 25) &0x03;1.48 char *palette = mmio_region_PVR2PAL.mem + (bank * (256 << bpp_shift));1.49 char tmp[inputlength];1.50 - char *p = tmp;1.51 pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );1.52 if( bpp_shift == 2 ) {1.53 decode_pal8_to_32( (uint32_t *)data, tmp, inputlength, (uint32_t*)palette );1.54 } else {1.55 decode_pal8_to_16( (uint16_t *)data, tmp, inputlength, (uint16_t*)palette );1.56 }1.57 + } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {1.58 + int inputlength = (mip_width * mip_height) >> 1;1.59 + int bank = (mode >>21 ) & 0x3F;1.60 + char *palette = mmio_region_PVR2PAL.mem + (bank * (16 << bpp_shift));1.61 + char tmp[inputlength];1.62 + pvr2_vram64_read_twiddled_4( tmp, texture_addr, mip_width, mip_height );1.63 + if( bpp_shift == 2 ) {1.64 + decode_pal4_to_32( (uint32_t *)data, tmp, inputlength, (uint32_t*)palette );1.65 + } else {1.66 + decode_pal4_to_16( (uint16_t *)data, tmp, inputlength, (uint16_t*)palette );1.67 + }1.68 } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {1.69 int inputlength = ((mip_width*mip_height)<<1);1.70 char tmp[inputlength];
.