Search
lxdream.org :: lxdream :: r321:7036e3692165
lxdream 0.9.1
released Jun 29
Download Now
changeset321:7036e3692165
parent320:660b15095115
child322:354407942957
authornkeynes
dateThu Jan 25 08:16:02 2007 +0000 (12 years ago)
Fix 16-bit palettes
Up texture count to 128
src/pvr2/texcache.c
1.1 --- a/src/pvr2/texcache.c Wed Jan 24 08:13:18 2007 +0000
1.2 +++ b/src/pvr2/texcache.c Thu Jan 25 08:16:02 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: texcache.c,v 1.19 2007-01-23 11:19:32 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.20 2007-01-25 08:16:02 nkeynes Exp $
1.7 *
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.9 * textures.
1.10 @@ -25,7 +25,7 @@
1.11 * textures we're willing to have open at a time. If more are
1.12 * needed, textures will be evicted in LRU order.
1.13 */
1.14 -#define MAX_TEXTURES 64
1.15 +#define MAX_TEXTURES 128
1.16
1.17 /**
1.18 * Data structure:
1.19 @@ -187,11 +187,11 @@
1.20 }
1.21 }
1.22
1.23 -static void decode_pal8_to_16( uint16_t *out, uint8_t *in, int inbytes, uint16_t *pal )
1.24 +static void decode_pal8_to_16( uint16_t *out, uint8_t *in, int inbytes, uint32_t *pal )
1.25 {
1.26 int i;
1.27 for( i=0; i<inbytes; i++ ) {
1.28 - *out++ = pal[*in++];
1.29 + *out++ = (uint16_t)pal[*in++];
1.30 }
1.31 }
1.32
1.33 @@ -206,12 +206,12 @@
1.34 }
1.35
1.36
1.37 -static void decode_pal4_to_16( uint16_t *out, uint8_t *in, int inbytes, uint16_t *pal )
1.38 +static void decode_pal4_to_16( uint16_t *out, uint8_t *in, int inbytes, uint32_t *pal )
1.39 {
1.40 int i;
1.41 for( i=0; i<inbytes; i++ ) {
1.42 - *out++ = pal[*in & 0x0F];
1.43 - *out++ = pal[(*in >> 4)];
1.44 + *out++ = (uint16_t)pal[*in & 0x0F];
1.45 + *out++ = (uint16_t)pal[(*in >> 4)];
1.46 in++;
1.47 }
1.48 }
1.49 @@ -362,7 +362,8 @@
1.50 break;
1.51 }
1.52
1.53 - if( PVR2_TEX_IS_STRIDE(mode) ) {
1.54 + if( PVR2_TEX_IS_STRIDE(mode) && tex_format != PVR2_TEX_FORMAT_IDX4 &&
1.55 + tex_format != PVR2_TEX_FORMAT_IDX8 ) {
1.56 /* Stride textures cannot be mip-mapped, compressed, indexed or twiddled */
1.57 uint32_t stride = (MMIO_READ( PVR2, RENDER_TEXSIZE ) & 0x003F) << 5;
1.58 char data[(width*height) << bpp_shift];
1.59 @@ -403,24 +404,24 @@
1.60 if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {
1.61 int inputlength = mip_bytes >> bpp_shift;
1.62 int bank = (mode >> 25) &0x03;
1.63 - char *palette = mmio_region_PVR2PAL.mem + (bank * (256 << bpp_shift));
1.64 + uint32_t *palette = (uint32_t *)(mmio_region_PVR2PAL.mem + (bank * (256 << bpp_shift)));
1.65 char tmp[inputlength];
1.66 pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );
1.67 if( bpp_shift == 2 ) {
1.68 - decode_pal8_to_32( (uint32_t *)data, tmp, inputlength, (uint32_t*)palette );
1.69 + decode_pal8_to_32( (uint32_t *)data, tmp, inputlength, palette );
1.70 } else {
1.71 - decode_pal8_to_16( (uint16_t *)data, tmp, inputlength, (uint16_t*)palette );
1.72 + decode_pal8_to_16( (uint16_t *)data, tmp, inputlength, palette );
1.73 }
1.74 } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {
1.75 int inputlength = (mip_width * mip_height) >> 1;
1.76 int bank = (mode >>21 ) & 0x3F;
1.77 - char *palette = mmio_region_PVR2PAL.mem + (bank * (16 << bpp_shift));
1.78 + uint32_t *palette = (uint32_t *)(mmio_region_PVR2PAL.mem + (bank * (16 << bpp_shift)));
1.79 char tmp[inputlength];
1.80 pvr2_vram64_read_twiddled_4( tmp, texture_addr, mip_width, mip_height );
1.81 if( bpp_shift == 2 ) {
1.82 - decode_pal4_to_32( (uint32_t *)data, tmp, inputlength, (uint32_t*)palette );
1.83 + decode_pal4_to_32( (uint32_t *)data, tmp, inputlength, palette );
1.84 } else {
1.85 - decode_pal4_to_16( (uint16_t *)data, tmp, inputlength, (uint16_t*)palette );
1.86 + decode_pal4_to_16( (uint16_t *)data, tmp, inputlength, palette );
1.87 }
1.88 } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {
1.89 int inputlength = ((mip_width*mip_height)<<1);
.