revision 462:9add12452876
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 462:9add12452876 |
parent | 461:63d4de8dcec6 |
child | 463:0655796f9bb5 |
author | nkeynes |
date | Wed Oct 24 21:23:22 2007 +0000 (15 years ago) |
Fix long standing texcache management bug (invalidate palette was not placing
the invalidated entries on the free list).
the invalidated entries on the free list).
1.1 --- a/src/pvr2/texcache.c Tue Oct 23 10:48:24 2007 +00001.2 +++ b/src/pvr2/texcache.c Wed Oct 24 21:23:22 2007 +00001.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 OpenGL1.9 * textures.1.10 @@ -38,7 +38,7 @@1.11 */1.13 typedef signed short texcache_entry_index;1.14 -#define EMPTY_ENTRY 0xFF1.15 +#define EMPTY_ENTRY -11.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.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.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.64 /* Not found - check the free list */1.65 - int slot = 0;1.66 + texcache_entry_index slot = 0;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.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.90 /* Construct the GL texture */
.