Search
lxdream.org :: lxdream/src/pvr2/texcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/texcache.c
changeset 429:e581b90c3fb3
prev352:f0df7a6d4703
next462:9add12452876
author nkeynes
date Mon Oct 08 11:52:13 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Fix compilation warnings
file annotate diff log raw
1.1 --- a/src/pvr2/texcache.c Sun Feb 11 10:09:32 2007 +0000
1.2 +++ b/src/pvr2/texcache.c Mon Oct 08 11:52:13 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: texcache.c,v 1.26 2007-02-11 10:09:32 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.27 2007-10-08 11:52:13 nkeynes Exp $
1.7 *
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.9 * textures.
1.10 @@ -261,7 +261,7 @@
1.11 }
1.12 }
1.13
1.14 -static void vq_decode( uint16_t *output, char *input, int width, int height,
1.15 +static void vq_decode( uint16_t *output, unsigned char *input, int width, int height,
1.16 struct vq_codebook *codebook ) {
1.17 int i,j;
1.18
1.19 @@ -318,7 +318,7 @@
1.20 * Load texture data from the given address and parameters into the currently
1.21 * bound OpenGL texture.
1.22 */
1.23 -static texcache_load_texture( uint32_t texture_addr, int width, int height,
1.24 +static void texcache_load_texture( uint32_t texture_addr, int width, int height,
1.25 int mode ) {
1.26 int bpp_shift = 1; /* bytes per (output) pixel as a power of 2 */
1.27 GLint intFormat = GL_RGBA, format, type;
1.28 @@ -353,6 +353,8 @@
1.29 type = GL_UNSIGNED_INT_8_8_8_8_REV;
1.30 bpp_shift = 2;
1.31 break;
1.32 + default:
1.33 + return; /* Can't happen, but it makes gcc stop complaining */
1.34 }
1.35 break;
1.36
1.37 @@ -379,16 +381,19 @@
1.38 break;
1.39 case PVR2_TEX_FORMAT_BUMPMAP:
1.40 ERROR( "Bumpmap not supported" );
1.41 - break;
1.42 + return;
1.43 + default:
1.44 + ERROR( "Undefined texture format" );
1.45 + return;
1.46 }
1.47
1.48 if( PVR2_TEX_IS_STRIDE(mode) && tex_format != PVR2_TEX_FORMAT_IDX4 &&
1.49 tex_format != PVR2_TEX_FORMAT_IDX8 ) {
1.50 /* Stride textures cannot be mip-mapped, compressed, indexed or twiddled */
1.51 uint32_t stride = (MMIO_READ( PVR2, RENDER_TEXSIZE ) & 0x003F) << 5;
1.52 - char data[(width*height) << bpp_shift];
1.53 + unsigned char data[(width*height) << bpp_shift];
1.54 if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {
1.55 - char tmp[(width*height)<<1];
1.56 + unsigned char tmp[(width*height)<<1];
1.57 pvr2_vram64_read_stride( tmp, width<<1, texture_addr, stride<<1, height );
1.58 yuv_decode( (uint32_t *)data, (uint32_t *)tmp, width, height );
1.59 } else {
1.60 @@ -414,19 +419,19 @@
1.61
1.62 if( PVR2_TEX_IS_COMPRESSED(mode) ) {
1.63 uint16_t tmp[VQ_CODEBOOK_SIZE];
1.64 - pvr2_vram64_read( (char *)tmp, texture_addr, VQ_CODEBOOK_SIZE );
1.65 + pvr2_vram64_read( (unsigned char *)tmp, texture_addr, VQ_CODEBOOK_SIZE );
1.66 texture_addr += VQ_CODEBOOK_SIZE;
1.67 vq_get_codebook( &codebook, tmp );
1.68 }
1.69
1.70 for( level=last_level; level>= 0; level-- ) {
1.71 - char data[dest_bytes];
1.72 + unsigned char data[dest_bytes];
1.73 /* load data from image, detwiddling/uncompressing as required */
1.74 if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {
1.75 src_bytes = (mip_width * mip_height);
1.76 int bank = (mode >> 25) &0x03;
1.77 uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<8);
1.78 - char tmp[src_bytes];
1.79 + unsigned char tmp[src_bytes];
1.80 pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );
1.81 if( bpp_shift == 2 ) {
1.82 decode_pal8_to_32( (uint32_t *)data, tmp, src_bytes, palette );
1.83 @@ -437,7 +442,7 @@
1.84 src_bytes = (mip_width * mip_height) >> 1;
1.85 int bank = (mode >>21 ) & 0x3F;
1.86 uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<4);
1.87 - char tmp[src_bytes];
1.88 + unsigned char tmp[src_bytes];
1.89 pvr2_vram64_read_twiddled_4( tmp, texture_addr, mip_width, mip_height );
1.90 if( bpp_shift == 2 ) {
1.91 decode_pal4_to_32( (uint32_t *)data, tmp, src_bytes, palette );
1.92 @@ -446,7 +451,7 @@
1.93 }
1.94 } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {
1.95 src_bytes = ((mip_width*mip_height)<<1);
1.96 - char tmp[src_bytes];
1.97 + unsigned char tmp[src_bytes];
1.98 if( PVR2_TEX_IS_TWIDDLED(mode) ) {
1.99 pvr2_vram64_read_twiddled_16( tmp, texture_addr, mip_width, mip_height );
1.100 } else {
1.101 @@ -455,7 +460,7 @@
1.102 yuv_decode( (uint32_t *)data, (uint32_t *)tmp, mip_width, mip_height );
1.103 } else if( PVR2_TEX_IS_COMPRESSED(mode) ) {
1.104 src_bytes = ((mip_width*mip_height) >> 2);
1.105 - char tmp[src_bytes];
1.106 + unsigned char tmp[src_bytes];
1.107 if( PVR2_TEX_IS_TWIDDLED(mode) ) {
1.108 pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width>>1, mip_height>>1 );
1.109 } else {
.