revision 313:7e4bd1629268
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 313:7e4bd1629268 |
parent | 312:2c34bdc36cbd |
child | 314:2a1f3b3d8708 |
author | nkeynes |
date | Tue Jan 23 08:18:05 2007 +0000 (16 years ago) |
Tweak mip-map support
1.1 --- a/src/pvr2/texcache.c Tue Jan 23 08:17:06 2007 +00001.2 +++ b/src/pvr2/texcache.c Tue Jan 23 08:18:05 2007 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: texcache.c,v 1.16 2007-01-22 21:26:39 nkeynes Exp $1.6 + * $Id: texcache.c,v 1.17 2007-01-23 08:18:05 nkeynes Exp $1.7 *1.8 * Texture cache. Responsible for maintaining a working set of OpenGL1.9 * textures.1.10 @@ -222,7 +222,7 @@1.11 uint8_t *c = (uint8_t *)input;1.12 for( j=0; j<height; j+=2 ) {1.13 for( i=0; i<width; i+=2 ) {1.14 - uint8_t code = *c;1.15 + uint8_t code = *c++;1.16 output[i + j*width] = codebook->quad[code][0];1.17 output[i + 1 + j*width] = codebook->quad[code][1];1.18 output[i + (j+1)*width] = codebook->quad[code][2];1.19 @@ -364,8 +364,8 @@1.20 int i;1.21 for( i=0; 1<<i < width; i++ );1.22 last_level = i;1.23 - mip_width = 1;1.24 - mip_height= 1;1.25 + mip_width = 2;1.26 + mip_height= 2;1.27 filter = GL_LINEAR_MIPMAP_LINEAR;1.28 }1.29 mip_bytes = (mip_width * mip_height) << bpp_shift;1.30 @@ -396,12 +396,13 @@1.31 int inputlength = ((mip_width*mip_height)<<1);1.32 char tmp[inputlength];1.33 pvr2_vram64_read( tmp, texture_addr, inputlength );1.34 + ERROR( "Twiddled YUV not supported" );1.35 yuv_decode( (uint32_t *)data, (uint32_t *)tmp, mip_width, mip_height );1.36 } else if( PVR2_TEX_IS_COMPRESSED(mode) ) {1.37 int inputlength = ((mip_width*mip_height) >> 2);1.38 char tmp[inputlength];1.39 if( PVR2_TEX_IS_TWIDDLED(mode) ) {1.40 - pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );1.41 + pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width>>1, mip_height>>1 );1.42 } else {1.43 pvr2_vram64_read( tmp, texture_addr, inputlength );1.44 }1.45 @@ -411,14 +412,19 @@1.46 } else {1.47 pvr2_vram64_read( data, texture_addr, mip_bytes );1.48 }1.49 -1.50 +1.51 /* Pass to GL */1.52 - glTexImage2D( GL_TEXTURE_2D, level, intFormat, mip_width, mip_height, 0, format, type,1.53 - data );1.54 - texture_addr += mip_bytes;1.55 - mip_width <<= 1;1.56 - mip_height <<= 1;1.57 - mip_bytes <<= 2;1.58 + if( level == last_level && level != 0 ) { /* 1x1 stored within a 2x2 */1.59 + glTexImage2D( GL_TEXTURE_2D, level, intFormat, 1, 1, 0, format, type,1.60 + data + (3 << bpp_shift) );1.61 + } else {1.62 + glTexImage2D( GL_TEXTURE_2D, level, intFormat, mip_width, mip_height, 0, format, type,1.63 + data );1.64 + texture_addr += mip_bytes;1.65 + mip_width <<= 1;1.66 + mip_height <<= 1;1.67 + mip_bytes <<= 2;1.68 + }1.69 }1.71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
.