Mercurial > hg > Members > kono > Cerium
diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 167:c8b868871dce
DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
author | gongo@localhost.localdomain |
---|---|
date | Tue, 09 Dec 2008 15:07:31 +0900 |
parents | e297ecaf2b4d |
children | cf2aa37d2fe7 |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 09 11:53:51 2008 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 09 15:07:31 2008 +0900 @@ -5,20 +5,14 @@ #include "SpanPack.h" #include "texture.h" #include "viewer_types.h" +#include "TileHash.h" #define SPAN_PACK_LOAD 0 #define TEX_LOAD 1 SchedDefineTask(DrawSpan); -static const int hashsize = 263; - -static TilePtr hash_table[hashsize] = {0}; - -unsigned short PRIME[8] = { - 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd, -}; - +static TileHashPtr hash; static TileListPtr tileList; /** @@ -79,57 +73,6 @@ return tex_addr_top + block*TEXTURE_BLOCK_SIZE; } - -static int -hash(uint32 data) -{ - int value = 0; - int n = 0; - int key; - - for (int i = 0; i < 8; i ++) { - key = data & 0xf; - value += key * PRIME[n++]; - data >>= 4; - } - - return value % hashsize; -} - -static int -put(void *key, TilePtr data) -{ - int hashval = hash((uint32)key); - - for (int i = 0; i < hashsize/2; i++) { - int index = (hashval + i*i)%hashsize; - - if (hash_table[index] == 0) { - hash_table[index] = data; - return index; - } - } - - return -1; -} - -static TilePtr -get(void *key) -{ - int hashval = hash((uint32)key); - - for (int i = 0; i < hashsize/2; i++) { - int index = (hashval + i*i)%hashsize; - - if (hash_table[index] != NULL && - hash_table[index]->texture_addr == key) { - return hash_table[index]; - } - } - - return NULL; -} - void DrawSpan::linebuf_init(int *buf, int x, int rgb) { @@ -170,11 +113,11 @@ /** * get,put ϥ֥(HashȤ)äƥ뤫 */ - tile = get(addr); + tile = hash->get(addr); if (tile == NULL) { if (tileList->size >= MAX_TILE) { tileList->init(); - bzero(hash_table, sizeof(TilePtr)*hashsize); + hash->clear(); } tile = &tileList->tile[tileList->size]; @@ -183,7 +126,7 @@ smanager->dma_load(tile->pixel, (uint32)addr, sizeof(uint32)*TEXTURE_BLOCK_SIZE, TEX_LOAD); - int index = put(tile->texture_addr, tile); + int index = hash->put(tile->texture_addr, tile); /** * TODO: @@ -223,8 +166,8 @@ SpanPack *tmp_sp = NULL; Span *span; - tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); - tileList->init(); + hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH); + tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); int rangex_start = get_param(0); // Υô x ϰϤλ int rangex_end = get_param(1); // (start <= x <= end) @@ -232,7 +175,6 @@ int rangex = rangex_end - rangex_start + 1; float *zRow = zRow_init(rangex, rangey); - int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); for (int i = 0; i < rangey; i++) { @@ -240,8 +182,6 @@ linebuf_init(linebuf[i], rangex, 0xffffff); } - bzero(hash_table, sizeof(TilePtr)*hashsize); - do { /** * SpanPack->next ¸ߤ硢 @@ -355,7 +295,6 @@ free(free_sp); free(linebuf); free(zRow); - free(tileList); return 0; }