Search
lxdream.org :: lxdream :: r129:88e5ebc991e3
lxdream 0.9.1
released Jun 29
Download Now
changeset129:88e5ebc991e3
parent128:f98ce97cacdd
child130:279acbacc298
authornkeynes
dateThu Mar 30 11:25:42 2006 +0000 (14 years ago)
Fix up remaining (implemented) texture modes
src/pvr2/texcache.c
1.1 --- a/src/pvr2/texcache.c Thu Mar 23 13:19:55 2006 +0000
1.2 +++ b/src/pvr2/texcache.c Thu Mar 30 11:25:42 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: texcache.c,v 1.5 2006-03-23 13:18:51 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.6 2006-03-30 11:25:42 nkeynes Exp $
1.7 *
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.9 * textures.
1.10 @@ -179,17 +179,31 @@
1.11 return slot;
1.12 }
1.13
1.14 -static void detwiddle_pal8_to_24(int x1, int y1, int size, int totsize,
1.15 +static void detwiddle_pal8_to_32(int x1, int y1, int size, int totsize,
1.16 char **in, uint32_t *out, uint32_t *pal) {
1.17 if (size == 1) {
1.18 out[y1 * totsize + x1] = pal[**in];
1.19 (*in)++;
1.20 } else {
1.21 int ns = size>>1;
1.22 - detwiddle_pal8_to_24(x1, y1, ns, totsize, in, out, pal);
1.23 - detwiddle_pal8_to_24(x1, y1+ns, ns, totsize, in, out, pal);
1.24 - detwiddle_pal8_to_24(x1+ns, y1, ns, totsize, in, out, pal);
1.25 - detwiddle_pal8_to_24(x1+ns, y1+ns, ns, totsize, in, out, pal);
1.26 + detwiddle_pal8_to_32(x1, y1, ns, totsize, in, out, pal);
1.27 + detwiddle_pal8_to_32(x1, y1+ns, ns, totsize, in, out, pal);
1.28 + detwiddle_pal8_to_32(x1+ns, y1, ns, totsize, in, out, pal);
1.29 + detwiddle_pal8_to_32(x1+ns, y1+ns, ns, totsize, in, out, pal);
1.30 + }
1.31 +}
1.32 +
1.33 +static void detwiddle_pal8_to_16(int x1, int y1, int size, int totsize,
1.34 + char **in, uint16_t *out, uint16_t *pal) {
1.35 + if (size == 1) {
1.36 + out[y1 * totsize + x1] = pal[**in];
1.37 + (*in)++;
1.38 + } else {
1.39 + int ns = size>>1;
1.40 + detwiddle_pal8_to_16(x1, y1, ns, totsize, in, out, pal);
1.41 + detwiddle_pal8_to_16(x1, y1+ns, ns, totsize, in, out, pal);
1.42 + detwiddle_pal8_to_16(x1+ns, y1, ns, totsize, in, out, pal);
1.43 + detwiddle_pal8_to_16(x1+ns, y1+ns, ns, totsize, in, out, pal);
1.44 }
1.45 }
1.46
1.47 @@ -225,17 +239,17 @@
1.48 case 0: /* ARGB1555 */
1.49 intFormat = GL_RGB5_A1;
1.50 format = GL_RGBA;
1.51 - type = GL_UNSIGNED_SHORT_5_5_5_1;
1.52 + type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
1.53 break;
1.54 case 1:
1.55 intFormat = GL_RGB;
1.56 format = GL_RGB;
1.57 - type = GL_UNSIGNED_SHORT_5_6_5;
1.58 + type = GL_UNSIGNED_SHORT_5_6_5_REV;
1.59 break;
1.60 case 2:
1.61 intFormat = GL_RGBA4;
1.62 - format = GL_RGBA;
1.63 - type = GL_UNSIGNED_SHORT_4_4_4_4;
1.64 + format = GL_BGRA;
1.65 + type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
1.66 break;
1.67 case 3:
1.68 intFormat = GL_RGBA8;
1.69 @@ -254,15 +268,14 @@
1.70 char tmp[bytes];
1.71 char *p = tmp;
1.72 pvr2_vram64_read( tmp, texture_addr, bytes );
1.73 - detwiddle_pal8_to_24( 0, 0, width, width, &p,
1.74 + detwiddle_pal8_to_32( 0, 0, width, width, &p,
1.75 (uint32_t *)data, (uint32_t *)palette );
1.76 } else {
1.77 - pvr2_vram64_read( &data, texture_addr, bytes );
1.78 - for( i=bytes-1; i>=0; i-- ) {
1.79 - char ch = data[i];
1.80 - ((uint16_t *)data)[i] = ((uint16_t *)palette)[ch];
1.81 - }
1.82 - /* FIXME */
1.83 + char tmp[bytes];
1.84 + char *p = tmp;
1.85 + pvr2_vram64_read( tmp, texture_addr, bytes );
1.86 + detwiddle_pal8_to_16( 0, 0, width, width, &p,
1.87 + (uint16_t *)data, (uint16_t *)palette );
1.88 }
1.89 glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type,
1.90 data );
1.91 @@ -274,13 +287,13 @@
1.92 bytes <<= 1;
1.93 intFormat = GL_RGB5_A1;
1.94 format = GL_RGBA;
1.95 - type = GL_UNSIGNED_SHORT_5_5_5_1;
1.96 + type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
1.97 break;
1.98 case PVR2_TEX_FORMAT_RGB565:
1.99 bytes <<= 1;
1.100 - intFormat = GL_RGBA;
1.101 - format = GL_RGBA;
1.102 - type = GL_UNSIGNED_SHORT_5_6_5;
1.103 + intFormat = GL_RGB;
1.104 + format = GL_RGB;
1.105 + type = GL_UNSIGNED_SHORT_5_6_5_REV;
1.106 break;
1.107 case PVR2_TEX_FORMAT_ARGB4444:
1.108 bytes <<= 1;
1.109 @@ -310,7 +323,7 @@
1.110 break;
1.111 }
1.112
1.113 - unsigned char data[bytes];
1.114 + char data[bytes];
1.115 /* load data from image, detwiddling/uncompressing as required */
1.116 if( PVR2_TEX_IS_COMPRESSED(mode) ) {
1.117 ERROR( "VQ Compression not supported" );
.