Search
lxdream.org :: lxdream/src/pvr2/texcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/texcache.c
changeset 113:ce4eb7959d56
prev108:565de331ccec
next126:988003554ab5
author nkeynes
date Thu Mar 16 12:42:39 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Various fixes to make tatest work
file annotate diff log raw
1.1 --- a/src/pvr2/texcache.c Wed Mar 15 13:16:50 2006 +0000
1.2 +++ b/src/pvr2/texcache.c Thu Mar 16 12:42:39 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: texcache.c,v 1.3 2006-03-15 13:16:50 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $
1.7 *
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.9 * textures.
1.10 @@ -179,6 +179,21 @@
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 + char **in, uint32_t *out, uint32_t *pal) {
1.16 + if (size == 1) {
1.17 + out[y1 * totsize + x1] = pal[**in];
1.18 + (*in)++;
1.19 + } else {
1.20 + int ns = size>>1;
1.21 + detwiddle_pal8_to_24(x1, y1, ns, totsize, in, out, pal);
1.22 + detwiddle_pal8_to_24(x1, y1+ns, ns, totsize, in, out, pal);
1.23 + detwiddle_pal8_to_24(x1+ns, y1, ns, totsize, in, out, pal);
1.24 + detwiddle_pal8_to_24(x1+ns, y1+ns, ns, totsize, in, out, pal);
1.25 + }
1.26 +}
1.27 +
1.28 +
1.29 /**
1.30 * Load texture data from the given address and parameters into the currently
1.31 * bound OpenGL texture.
1.32 @@ -210,24 +225,29 @@
1.33 break;
1.34 case 3:
1.35 intFormat = GL_RGBA8;
1.36 - format = GL_RGBA;
1.37 - type = GL_UNSIGNED_INT_8_8_8_8;
1.38 + format = GL_BGRA;
1.39 + type = GL_UNSIGNED_INT_8_8_8_8_REV;
1.40 shift = 2;
1.41 break;
1.42 }
1.43
1.44 if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {
1.45 + unsigned char data[bytes<<shift];
1.46 int bank = (mode >> 25) &0x03;
1.47 - unsigned char data[bytes<<shift];
1.48 char *palette = mmio_region_PVR2PAL.mem + (bank * (256 << shift));
1.49 int i;
1.50 - pvr2_vram64_read( &data, texture_addr, bytes );
1.51 - for( i=bytes-1; i>=0; i-- ) {
1.52 - char ch = data[i];
1.53 - if( shift == 2 )
1.54 - ((uint32_t *)data)[i] = ((uint32_t *)palette)[ch];
1.55 - else
1.56 + if( shift == 2 ) {
1.57 + char tmp[bytes];
1.58 + char *p = tmp;
1.59 + pvr2_vram64_read( tmp, texture_addr, bytes );
1.60 + detwiddle_pal8_to_24( 0, 0, width, width, &p,
1.61 + (uint32_t *)data, (uint32_t *)palette );
1.62 + } else {
1.63 + pvr2_vram64_read( &data, texture_addr, bytes );
1.64 + for( i=bytes-1; i>=0; i-- ) {
1.65 + char ch = data[i];
1.66 ((uint16_t *)data)[i] = ((uint16_t *)palette)[ch];
1.67 + }
1.68 }
1.69 /* TODO: Detwiddle */
1.70 glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type,
.