changeset 371:f88744ee9350

change DrawSpan, #define USE_MEMLIST use MemList(LRU)
author aaa
date Wed, 29 Jul 2009 16:34:26 +0900
parents 4435c9990988
children 6ff4f651162b
files TaskManager/Test/test_render/Tapestry.h TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/spe/Load_Texture.cpp TaskManager/Test/test_render/task/DrawSpan.cpp TaskManager/Test/test_render/task/TileHash.cpp
diffstat 5 files changed, 66 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Tapestry.h	Wed Jul 29 15:09:36 2009 +0900
+++ b/TaskManager/Test/test_render/Tapestry.h	Wed Jul 29 16:34:26 2009 +0900
@@ -74,11 +74,15 @@
     
 };
 
+#ifdef USE_MEMLIST
+typedef MemorySegment Tile, *TilePtr;
+#else
 typedef struct {
-    uint32 pixel[TEXTURE_BLOCK_SIZE]; // 8*8
-    uint32 *texture_addr;
+    uint32 data[TEXTURE_BLOCK_SIZE]; // 8*8
+    uint32 *address;
     int pad[3];
 } Tile, *TilePtr;
+#endif
 
 #define MAX_TILE 128
 
@@ -87,6 +91,13 @@
  * これは汎用のサイズ別 freelist に置き換える
  * freelist は double linked list で、LRU をサポートする
 */
+#ifdef USE_MEMLIST
+class TileList : MemList {
+/*!
+  中身は同じ
+ */
+};
+#else
 class TileList {
 public:
     int curIndex;
@@ -120,6 +131,7 @@
 	curIndex = 0;
     }
 };
+#endif
 
 typedef TileList* TileListPtr;
 
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Wed Jul 29 15:09:36 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Wed Jul 29 16:34:26 2009 +0900
@@ -176,9 +176,15 @@
 {
     TilePtr tile;
 
+#ifdef USE_MEMLIST
+    tile = tileList->getLast();
+    tileList->remove(tile);
+#else
     tile = tileList->nextTile();
-    uint32 *old_addr = tile->texture_addr;
-    smanager->dma_load(tile->pixel, (uint32)addr,
+#endif
+
+    uint32 *old_addr = tile->address;
+    smanager->dma_load(tile->data, (uint32)addr,
                        sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
     /**
      * FIFO なので、もし前のが残っていれば削除
@@ -186,9 +192,9 @@
 
     hash->remove(old_addr);
 
-    tile->texture_addr = addr;
+    tile->address = addr;
 
-    hash->put(tile->texture_addr, tile);
+    hash->put(tile->address, tile);
 
     return tile;
 }
@@ -197,7 +203,7 @@
 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
 {
   
-    return tile->pixel[(TEXTURE_SPLIT_PIXEL)*ty+tx];
+    return tile->data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
 }
 
 /**
@@ -334,6 +340,11 @@
             smanager->dma_wait(wait_tag);
             //return startx;
         }
+#ifdef USE_MEMLIST
+	else {
+	    tileList->moveToFirst(tile);
+	} 
+#endif
 
         updateBuffer(zpos, rangex, localx, localy,
                      tex_localx, tex_localy, tile);	
@@ -424,7 +435,11 @@
                 tile = set_rgb(tex_addr, wait_tag);
                 smanager->dma_wait(wait_tag);
 	    }
-
+#ifdef USE_MEMLIST
+	    else {
+		tileList->moveToFirst(tile);
+	    } 
+#endif
 
             updateBuffer(tex_z, rangex, localx, localy,
 			 tex_localx, tex_localy, tile);
--- a/TaskManager/Test/test_render/spe/Load_Texture.cpp	Wed Jul 29 15:09:36 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Load_Texture.cpp	Wed Jul 29 16:34:26 2009 +0900
@@ -27,9 +27,14 @@
         = smanager->global_alloc(GLOBAL_TEXTURE_HASH, sizeof(TileHash));
     new(hash_tmp) TileHash;
 
+#ifdef USE_MEMLIST
+    void *tileList_tmp
+        = smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(MemList));
+    new(tileList_tmp) MemList;
+#else
     void *tileList_tmp
         = smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(TileList));
     new(tileList_tmp) TileList;
-
+#endif
     return 0;
 }
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp	Wed Jul 29 15:09:36 2009 +0900
+++ b/TaskManager/Test/test_render/task/DrawSpan.cpp	Wed Jul 29 16:34:26 2009 +0900
@@ -128,7 +128,7 @@
  */
 TilePtr
 DrawSpan::isAvailableTile(uint32 *addr)
-{
+{    
     return hash->get(addr);
 }
 
@@ -137,10 +137,15 @@
 {
     TilePtr tile;
 
-
+#ifdef USE_MEMLIST
+    tile = tileList->getLast();
+    tileList->remove(tile);
+#else
     tile = tileList->nextTile();
-    uint32 *old_addr = tile->texture_addr;
-    smanager->dma_load(tile->pixel, (uint32)addr,
+#endif
+
+    uint32 *old_addr = tile->address;
+    smanager->dma_load(tile->data, (uint32)addr,
 		       sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
     /**
      * FIFO なので、もし前のが残っていれば削除
@@ -148,9 +153,9 @@
 
     hash->remove(old_addr);
 
-    tile->texture_addr = addr;
+    tile->address = addr;
 
-    hash->put(tile->texture_addr, tile);
+    hash->put(tile->address, tile);
 
     return tile;
 }
@@ -158,7 +163,7 @@
 uint32
 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
 {
-    return tile->pixel[(TEXTURE_SPLIT_PIXEL)*ty+tx];
+    return tile->data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
 }
 
 /**
@@ -303,11 +308,16 @@
         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
 	TilePtr tile;
-        if (!(tile = isAvailableTile(tex_addr))) {
+        if (!(tile = isAvailableTile(tex_addr))) {	    
             tile = set_rgb(tex_addr, wait_tag);
             smanager->dma_wait(wait_tag);
             //return startx;
         }
+#ifdef USE_MEMLIST
+	else {
+	    tileList->moveToFirst(tile);
+	} 
+#endif
 
         updateBuffer(zpos, rangex, localx, localy,
                      tex_localx, tex_localy,
@@ -409,6 +419,11 @@
                 tile = set_rgb(tex_addr, wait_tag);
                 smanager->dma_wait(wait_tag);
             }
+#ifdef USE_MEMLIST
+	    else {
+		tileList->moveToFirst(tile);
+	    } 
+#endif
 
             updateBuffer(tex_z, rangex, localx, localy,
                          tex_localx, tex_localy,
--- a/TaskManager/Test/test_render/task/TileHash.cpp	Wed Jul 29 15:09:36 2009 +0900
+++ b/TaskManager/Test/test_render/task/TileHash.cpp	Wed Jul 29 16:34:26 2009 +0900
@@ -58,7 +58,7 @@
 	int index = (hashval + i*i)%hashSize;
 	
 	if (table[index] != NULL &&
-	    table[index]->texture_addr == key) {
+	    table[index]->address == key) {
 	    return table[index];
 	}
     }
@@ -75,7 +75,7 @@
 	int index = (hashval + i*i)%hashSize;
 	
 	if (table[index] != NULL &&
-	    table[index]->texture_addr == key) {
+	    table[index]->address == key) {
 	    table[index] = NULL;
 	}
     }