filename | src/pvr2/texcache.c |
changeset | 635:76c63aac3590 |
prev | 561:533f6b478071 |
next | 645:a7392098299c |
author | nkeynes |
date | Thu Feb 14 13:54:11 2008 +0000 (16 years ago) |
branch | lxdream-render |
permissions | -rw-r--r-- |
last change | Commit render work in progress. Main changes: * Preliminary OSMesa support * Move the generic gl code out to pvr2/ * Implement scene data structure + reader * Remove the 1/z adjustments |
file | annotate | diff | log | raw |
1.1 --- a/src/pvr2/texcache.c Tue Jan 01 05:08:38 2008 +00001.2 +++ b/src/pvr2/texcache.c Thu Feb 14 13:54:11 2008 +00001.3 @@ -67,6 +67,7 @@1.4 for( i=0; i<MAX_TEXTURES; i++ ) {1.5 texcache_free_list[i] = i;1.6 texcache_active_list[i].texture_addr = -1;1.7 + texcache_active_list[i].next = EMPTY_ENTRY;1.8 }1.9 texcache_free_ptr = 0;1.10 texcache_ref_counter = 0;1.11 @@ -99,6 +100,7 @@1.12 }1.13 for( i=0; i<MAX_TEXTURES; i++ ) {1.14 texcache_free_list[i] = i;1.15 + texcache_active_list[i].next = EMPTY_ENTRY;1.16 }1.17 texcache_free_ptr = 0;1.18 texcache_ref_counter = 0;1.19 @@ -526,6 +528,7 @@1.20 idx = entry->next;1.21 }1.23 +1.24 /* Not found - check the free list */1.25 texcache_entry_index slot = 0;1.27 @@ -561,6 +564,45 @@1.28 /* Construct the GL texture */1.29 glBindTexture( GL_TEXTURE_2D, texcache_active_list[slot].texture_id );1.30 texcache_load_texture( texture_addr, width, height, mode );1.31 -1.32 +1.33 + texcache_integrity_check();1.34 return texcache_active_list[slot].texture_id;1.35 }1.36 +1.37 +/**1.38 + * Check the integrity of the texcache. Verifies that every cache slot1.39 + * appears exactly once on either the free list or one page list. For1.40 + * active slots, the texture address must also match the page it appears on.1.41 + *1.42 + */1.43 +void texcache_integrity_check()1.44 +{1.45 + int i;1.46 + int slot_found[MAX_TEXTURES];1.47 +1.48 + memset( slot_found, 0, sizeof(slot_found) );1.49 +1.50 + /* Check entries on the free list */1.51 + for( i= texcache_free_ptr; i< MAX_TEXTURES; i++ ) {1.52 + int slot = texcache_free_list[i];1.53 + assert( slot_found[slot] == 0 );1.54 + assert( texcache_active_list[slot].next == EMPTY_ENTRY );1.55 + slot_found[slot] = 1;1.56 + }1.57 +1.58 + /* Check entries on the active lists */1.59 + for( i=0; i< PVR2_RAM_PAGES; i++ ) {1.60 + int slot = texcache_page_lookup[i];1.61 + while( slot != EMPTY_ENTRY ) {1.62 + assert( slot_found[slot] == 0 );1.63 + assert( (texcache_active_list[slot].texture_addr >> 12) == i );1.64 + slot_found[slot] = 2;1.65 + slot = texcache_active_list[slot].next;1.66 + }1.67 + }1.68 +1.69 + /* Make sure we didn't miss any entries */1.70 + for( i=0; i<MAX_TEXTURES; i++ ) {1.71 + assert( slot_found[i] != 0 );1.72 + }1.73 +}
.