Author : Olivier Langlois The MemoryHeap class is an attempt to enhance the Memory pool service algorithm used by the texture cache. To interface this new class with the TextureCache class, modify the following functions: void TextureCache::init_pool () void TextureCache::destroy_pool () void dump_pool() void* TextureCache::alloc_pool () void TextureCache::free_pool () with void TextureCache::init_pool () { destroy_pool (); cache_size = (cache_size+7)&~7; // Round to higher multiple of 8 CHK (memory = new MemoryHeap(cache_size)); } void TextureCache::destroy_pool () { if (memory) { CHK (delete memory); memory = NULL; } } void dump_pool( MemoryHeap *h ) { ULong totsize = sizeof(heap); ULong cur; CsPrintf( MSG_STDOUT,"\nStart : %-8d\n", ((heap *)h->memory)->start ); CsPrintf( MSG_STDOUT, "First free : %-8d\n", ((heap *)h->memory)->first_free ); CsPrintf( MSG_STDOUT, "End : %-8d\n", ((heap *)h->memory)->end ); CsPrintf( MSG_STDOUT, "Size : %d\n", h->cache_size ); CsPrintf( MSG_STDOUT, "\nSTATE SIZE OFFSET ADDRESS\n" ); for( cur = ((heap *)h->memory)->start; cur <= ((heap *)h->memory)->end; cur = (ULong)(cur + ((bufhd *)(h->memory + (ULong)(cur)))->size) ) { CsPrintf( MSG_STDOUT, "%-6d %-6d %-6d %-8X\n", ((bufhd *)(h->memory + (ULong)(cur)))->full, ((bufhd *)(h->memory + (ULong)(cur)))->size, cur, ((char *)h->memory + (ULong)(cur) + sizeof(bufhd)) ); totsize += ((bufhd *)(h->memory + (ULong)(cur)))->size; if( !((bufhd *)(h->memory + (ULong)(cur)))->size ) break; } CsPrintf( MSG_STDOUT, "\nTotal size : %d\n", totsize ); CsPrintf( MSG_STDOUT, "Missing : %d\n", h->cache_size-totsize ); } void* TextureCache::alloc_pool (int size) { return memory->alloc(size); } void TextureCache::free_pool (void* mem, int dummy ) { memory->free(mem); }