Search
lxdream.org :: lxdream :: r462:9add12452876
lxdream 0.9.1
released Jun 29
Download Now
changeset462:9add12452876
parent461:63d4de8dcec6
child463:0655796f9bb5
authornkeynes
dateWed Oct 24 21:23:22 2007 +0000 (16 years ago)
Fix long standing texcache management bug (invalidate palette was not placing
the invalidated entries on the free list).
src/pvr2/texcache.c
1.1 --- a/src/pvr2/texcache.c Tue Oct 23 10:48:24 2007 +0000
1.2 +++ b/src/pvr2/texcache.c Wed Oct 24 21:23:22 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: texcache.c,v 1.27 2007-10-08 11:52:13 nkeynes Exp $
1.6 + * $Id: texcache.c,v 1.28 2007-10-24 21:23:22 nkeynes Exp $
1.7 *
1.8 * Texture cache. Responsible for maintaining a working set of OpenGL
1.9 * textures.
1.10 @@ -38,7 +38,7 @@
1.11 */
1.12
1.13 typedef signed short texcache_entry_index;
1.14 -#define EMPTY_ENTRY 0xFF
1.15 +#define EMPTY_ENTRY -1
1.16
1.17 static texcache_entry_index texcache_free_ptr = 0;
1.18 static GLuint texcache_free_list[MAX_TEXTURES];
1.19 @@ -51,7 +51,7 @@
1.20 uint32_t lru_count;
1.21 } *texcache_entry_t;
1.22
1.23 -static uint8_t texcache_page_lookup[PVR2_RAM_PAGES];
1.24 +static texcache_entry_index texcache_page_lookup[PVR2_RAM_PAGES];
1.25 static uint32_t texcache_ref_counter;
1.26 static struct texcache_entry texcache_active_list[MAX_TEXTURES];
1.27
1.28 @@ -124,6 +124,7 @@
1.29 static void texcache_evict( int slot )
1.30 {
1.31 /* Remove the selected slot from the lookup table */
1.32 + assert( texcache_active_list[slot].texture_addr != -1 );
1.33 uint32_t evict_page = texcache_active_list[slot].texture_addr >> 12;
1.34 texcache_entry_index replace_next = texcache_active_list[slot].next;
1.35 texcache_active_list[slot].texture_addr = -1;
1.36 @@ -136,6 +137,7 @@
1.37 do {
1.38 next = texcache_active_list[idx].next;
1.39 if( next == slot ) {
1.40 + assert( idx != replace_next );
1.41 texcache_active_list[idx].next = replace_next;
1.42 break;
1.43 }
1.44 @@ -200,6 +202,8 @@
1.45 if( texcache_active_list[i].texture_addr != -1 &&
1.46 PVR2_TEX_IS_PALETTE(texcache_active_list[i].mode) ) {
1.47 texcache_evict( i );
1.48 + texcache_free_ptr--;
1.49 + texcache_free_list[texcache_free_ptr] = i;
1.50 }
1.51 }
1.52 }
1.53 @@ -507,6 +511,7 @@
1.54 int mode )
1.55 {
1.56 uint32_t texture_page = texture_addr >> 12;
1.57 + texcache_entry_index next;
1.58 texcache_entry_index idx = texcache_page_lookup[texture_page];
1.59 while( idx != EMPTY_ENTRY ) {
1.60 texcache_entry_t entry = &texcache_active_list[idx];
1.61 @@ -522,7 +527,7 @@
1.62 }
1.63
1.64 /* Not found - check the free list */
1.65 - int slot = 0;
1.66 + texcache_entry_index slot = 0;
1.67
1.68 if( texcache_free_ptr < MAX_TEXTURES ) {
1.69 slot = texcache_free_list[texcache_free_ptr++];
1.70 @@ -538,7 +543,19 @@
1.71 texcache_active_list[slot].lru_count = texcache_ref_counter++;
1.72
1.73 /* Add entry to the lookup table */
1.74 - texcache_active_list[slot].next = texcache_page_lookup[texture_page];
1.75 + next = texcache_page_lookup[texture_page];
1.76 + if( next == slot ) {
1.77 + int i;
1.78 + fprintf( stderr, "Active list: " );
1.79 + for( i=0; i<MAX_TEXTURES; i++ ) {
1.80 + fprintf( stderr, "%d, ", texcache_active_list[i].next );
1.81 + }
1.82 + fprintf( stderr, "\n" );
1.83 + assert( next != slot );
1.84 +
1.85 + }
1.86 + assert( next != slot );
1.87 + texcache_active_list[slot].next = next;
1.88 texcache_page_lookup[texture_page] = slot;
1.89
1.90 /* Construct the GL texture */
.