changeset 173:56be4a6e5513

add scale
author gongo@localhost.localdomain
date Thu, 11 Dec 2008 20:17:01 +0900
parents dc68bc5c9e41
children 559b48b69b76
files TaskManager/Test/test_render/SceneGraph.cpp TaskManager/Test/test_render/Tapestry.h TaskManager/Test/test_render/spe/CreateSpan.cpp TaskManager/Test/test_render/spe/CreateSpan.h TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/spe/Load_Texture.cpp TaskManager/Test/test_render/spe/TileHash.cpp TaskManager/Test/test_render/spe/TileHash.h TaskManager/Test/test_render/task/CreateSpan.cpp TaskManager/Test/test_render/task/CreateSpan.h TaskManager/Test/test_render/task/DrawSpan.cpp TaskManager/Test/test_render/task/Load_Texture.cpp TaskManager/Test/test_render/task/TileHash.cpp TaskManager/Test/test_render/task/TileHash.h
diffstat 14 files changed, 288 insertions(+), 145 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/SceneGraph.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/SceneGraph.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -323,86 +323,76 @@
 		    texture_image = converted;
 		}
 
-		int image_tmp = texture_image->w*texture_image->h*4;
-		int tile_size = image_tmp + image_tmp/2 + image_tmp/4 + image_tmp/8 + image_tmp/16;
-		//uint32 *tex_dest = (uint32*)manager->malloc(texture_image->w*texture_image->h*4);
-		uint32 *tex_dest = (uint32*)manager->malloc(tile_size);
-
+		uint32 *tex_dest;
 
 		{
 		    int t = 0;
-		    int tex_width = texture_image->w;
-		    int tex_height = texture_image->h;
+		    int tex_w = texture_image->w;
+		    int tex_h = texture_image->h;
 		    Uint32 *tex_src = (Uint32*)texture_image->pixels;
-		    
-		    for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL) {
-			for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL) {
-			    for (int j = 0; j < TEXTURE_SPLIT_PIXEL; j++) {
-				for (int i = 0; i < TEXTURE_SPLIT_PIXEL; i++) {
-				    tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
+		    int scale = 1;
+		    int scale_cnt;
+		    int cur_w = tex_w;
+		    int cur_h = tex_h;
+		    int all_pixel_num = 0;
+
+		    /**
+		     * テクスチャの w or h が 8 pixel で分割できる間、
+		     * 1/2 の縮小画像を作る。
+		     * ここでは、最大の scale (1/scale) を見つける
+		     *
+		     * (ex)
+		     *  (128,128) => 64,64 : 32,32: 16,16 : 8,8
+		     *     scale = 16
+		     *  (128, 64) => 64,32 : 32,16: 16,8
+		     *     scale = 8
+		     */
+		    while (cur_w % TEXTURE_SPLIT_PIXEL == 0 && 
+			   cur_h % TEXTURE_SPLIT_PIXEL == 0) {
+			printf("(%3d, %3d) = %4d\n", cur_w, cur_h, cur_w*cur_h);
+			all_pixel_num += cur_w*cur_h;
+			cur_w >>= 1;
+			cur_h >>= 1;
+			scale <<= 1;
+		    }
+
+		    scale >>= 1;
+		    scale_cnt = scale;
+		    tex_dest
+			= (uint32*)manager->malloc(sizeof(int)*all_pixel_num);
+
+		    printf("scale = %d, all = %d\n", scale, all_pixel_num);
+
+		    int diff = TEXTURE_SPLIT_PIXEL;
+		    int p_diff = 1;
+		    while (scale_cnt) {
+			for (int y = 0; y < tex_h; y += diff) {
+			    for (int x = 0; x < tex_w; x += diff) {
+				for (int j = 0; j < diff; j += p_diff) {
+				    for (int i = 0; i < diff; i += p_diff) {
+					tex_dest[t++]
+					    = tex_src[(x+i) + tex_w*(y+j)];
+				    }
 				}
 			    }
 			}
+
+			diff <<= 1;
+			p_diff <<= 1;
+			scale_cnt >>= 1;
 		    }
-		    
-		    // 1 / 2
-		    for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*2) {
-		      for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*2) {
-			for (int j = 0; j < TEXTURE_SPLIT_PIXEL*2; j+=2) {
-			  for (int i = 0; i < TEXTURE_SPLIT_PIXEL*2; i+=2) {
-			    tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
-			  }
-			}
-		      }
-                    }
-		    
-		    // 1 / 4
-		    for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*4) {
-		      for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*4) {
-			for (int j = 0; j < TEXTURE_SPLIT_PIXEL*4; j+=4) {
-			  for (int i = 0; i < TEXTURE_SPLIT_PIXEL*4; i+=4) {
-			    tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
-			  }
-			}
-		      }
-                    }
-		    
-		    // 1 / 8
-                    for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*8) {
-                      for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*8) {
-                        for (int j = 0; j < TEXTURE_SPLIT_PIXEL*8; j+=8) {
-                          for (int i = 0; i < TEXTURE_SPLIT_PIXEL*8; i+=8) {
-                            tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
-                          }
-                        }
-                      }
-                    }
-
-                    // 1 / 16
-                    for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL*16) {
-                      for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL*16) {
-                        for (int j = 0; j < TEXTURE_SPLIT_PIXEL*16; j+=16) {
-                          for (int i = 0; i < TEXTURE_SPLIT_PIXEL*16; i+=16) {
-                            tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)];
-                          }
-                        }
-                      }
-                    }
-		    
 		}
 
-		list[id_count-1].t_w = texture_image->w/2;
-		list[id_count-1].t_h = texture_image->h/2;
+		list[id_count-1].t_w = texture_image->w;
+		list[id_count-1].t_h = texture_image->h;
 		list[id_count-1].pixels_orig = (Uint32*)texture_image->pixels;
-		list[id_count-1].pixels = tex_dest + image_tmp/4;
+		list[id_count-1].pixels = tex_dest;
 
 		texture_id = id_count-1;
-		texture_info.t_w = texture_image->w/2;
-		texture_info.t_h = texture_image->h/2;
+		texture_info.t_w = texture_image->w;
+		texture_info.t_h = texture_image->h;
 		texture_info.pixels_orig = (Uint32*)texture_image->pixels;
-		texture_info.pixels = tex_dest + image_tmp/4;
-
-		printf("[%s] %p\n", filename, tex_dest);
+		texture_info.pixels = tex_dest;
 
 		if(unlink(image_name))
 		{
--- a/TaskManager/Test/test_render/Tapestry.h	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/Tapestry.h	Thu Dec 11 20:17:01 2008 +0900
@@ -88,14 +88,31 @@
 
 #define MAX_TILE 100
 
-typedef struct {
-    int size;
+class TileList {
+public:
+    int curIndex;
     int pad[3];
     Tile tile[MAX_TILE];
 
-    void init(void) {
-	size = 0;
+    TileList(void) {
+	curIndex = 0;
     }
-} TileList, *TileListPtr;
+
+    /**
+     * tile[] をリングバスっぽく扱うことで
+     * FIFO を実現することに。
+     */
+    TilePtr nextTile(void) {
+	TilePtr t = &tile[curIndex];
+	curIndex = (curIndex + 1) % MAX_TILE;
+	return t;
+    }
+
+    void clear(void) {
+	curIndex = 0;
+    }
+};
+
+typedef TileList* TileListPtr;
 
 #endif
--- a/TaskManager/Test/test_render/spe/CreateSpan.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/CreateSpan.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -123,17 +123,40 @@
      return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
 }
 
-#if 0
+/**
+ * span の width,height と texture の width,height を比べて
+ * span を描画する際に使う texture の比率を求める
+ *
+ * @param width      Width of span
+ * @param height     Height of span
+ * @param tex_width  Width of 1/1 texture that span use
+ * @param tex_height Height of 1/1 texture that span use
+ * @return 描画に使う texture の比率
+ *         width と height は 1/scale の画像を使う
+ *
+ * @todo scale_max を設定するべき
+ *       縮小は 1/8 までしかやってなくて、scale が 16 になる場合もある
+ */
 static int
-getScale(SpanPtr span)
+getScale(int width, int height, int tex_width, int tex_height)
 {
-    int tex_width = span->texture_width;
-    int tex_height = span->texture_height;
-    int width = span->length_x;
+    int base, tex_base;
     int scale = 1;
-    
-    if (tex_width > width) {
-	int t_scale = tex_width/width;
+
+    /**
+     * width と height で、長い方を基準に、
+     * texture の scale を決める
+     */
+    if (width > height) {
+	base = width;
+	tex_base = tex_width;
+    } else {
+	base = height;
+	tex_base = tex_height;
+    }
+
+    if (tex_base > base) {
+	int t_scale = tex_base/base;
 
 	while (t_scale >>= 1) {
 	    scale <<= 1;
@@ -142,17 +165,29 @@
 
     return scale;
 }
-#endif
 
 /**
  * x軸に水平な辺を持つ三角形ポリゴンから、
  * Span を抜き出す
+ *
+ * @param spackList    triangle から生成された span を格納する List
+ * @param charge_y_top 担当する y の範囲開始地点
+ * @param charge_y_end 担当する y の範囲終了地点
+ * @param tex_addr     triangle が参照するテクスチャの先頭アドレス
+ * @param tex_width    テクスチャの width
+ * @param tex_height   テクスチャの height
+ * @param vMin         triangle の座標
+ * @param vMid         triangle の座標。triangle を二つに分けて出来た新しい座標
+ * @param vMid10       triangle の座標
+ * @param y_length     分割する前の Triangle の y の長さ
+ *
  */
 void
 CreateSpan::half_triangle(SpanPackPtr *spackList,
 			  int charge_y_top, int charge_y_end,
 			  uint32 *tex_addr, int tex_width, int tex_height, 
-			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10)
+			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10,
+			  int y_length)
 {
     float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
     float tmp_xpos,tmp_end,tmp_zpos;
@@ -178,7 +213,6 @@
     /**
      * 三角形ポリゴンをx軸に水平に二つに分けようとして
      * ある一辺がすでに水平だった場合、つまり
-     * (環境によっては、back slash が 円マークかも)
      *
      * |\
      * | \
@@ -299,16 +333,9 @@
 	tmp_tey2 =( (i/(div_y)) * vMid->tex_y) +
 	    ( ((div_y - i)/(div_y)) * vMin->tex_y);
 
-	
-
-
 	if (tmp_xpos > tmp_end) {
 	    x = (int)tmp_end;
-	    /**
-	     * +1 は要らない気がする・・・
-	     */ 
-	    //length = (int)(tmp_xpos)-(int)(tmp_end)+1;
-	    length = (int)(tmp_xpos)-(int)(tmp_end);
+	    length = (int)(tmp_xpos)-(int)(tmp_end)+1;
 	    start_z = tmp_zpos;
 	    end_z = tmp_z;
 	    start_tex_x = tmp_tex2;
@@ -317,8 +344,7 @@
 	    end_tex_y = tmp_tey1;
 	} else {
 	    x = (int)tmp_xpos;
-	    //length = (int)(tmp_end)-(int)(tmp_xpos)+1;
-	    length = (int)(tmp_end)-(int)(tmp_xpos);
+	    length = (int)(tmp_end)-(int)(tmp_xpos)+1;
 	    start_z = tmp_z;
 	    end_z = tmp_zpos;
 	    start_tex_x = tmp_tex1;
@@ -343,6 +369,9 @@
 	span->tex_x2     = end_tex_x;
 	span->tex_y1     = start_tex_y;
 	span->tex_y2     = end_tex_y;
+
+	int scale = getScale(span->length_x, y_length,
+			     span->tex_width, span->tex_height);
     }
 }
 
@@ -422,13 +451,31 @@
 	    /**
 	     * ポリゴンを、x軸に水平に分割して二つの三角形を作り、
 	     * それぞれから Span を求める
+	     *
+	     *      vMax
+	     *        |\
+	     *        | \
+	     *        |  \
+	     *        |   \
+	     * vMid10 ------ vMid
+	     *        |   /
+	     *        |  /
+	     *        | /
+	     *        |/
+	     *      vMin
+	     *
+	     * (vMax, vMid, vMin) という triangle を
+	     * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という
+	     * 二つの Triangle に分けている
 	     */
 	    half_triangle(spackList, charge_y_top, charge_y_end,
 			  triPack->tex_addr, triPack->tex_width,
-			  triPack->tex_height, vMin, vMid, vMid10);
+			  triPack->tex_height, vMin, vMid, vMid10,
+			  (int)(vMax->y - vMin->y));
 	    half_triangle(spackList, charge_y_top, charge_y_end,
 			  pp->tri[0].tex_addr, pp->tri[0].tex_width,
-			  pp->tri[0].tex_height, vMax, vMid, vMid10);
+			  pp->tri[0].tex_height, vMax, vMid, vMid10,
+			  (int)(vMax->y - vMin->y));
 	}
 
 	smanager->dma_wait(POLYGON_PACK_LOAD);	
--- a/TaskManager/Test/test_render/spe/CreateSpan.h	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/CreateSpan.h	Thu Dec 11 20:17:01 2008 +0900
@@ -21,7 +21,8 @@
     void half_triangle(SpanPackPtr *spackList,
 		       int charge_y_top, int charge_y_end,
 		       uint32 *tex_addr, int tex_width, int tex_height,
-		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1);
+		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1,
+		       int y_length);
     void setTileInfoList(SpanPtr span);
     void setTileInfo(TileInfoPtr tile, int xpos, int ypos,
 		     int tex_width, uint32* tex_addr_top);
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -105,12 +105,13 @@
 
     tile = hash->get(addr);
     if (tile == NULL) {
-	if (tileList->size >= MAX_TILE) {
-	    tileList->init();
-	    hash->clear();
-	}
+	tile = tileList->nextTile();
 
-	tile = &tileList->tile[tileList->size];
+	/**
+	 * FIFO ʤΤǡ⤷ΤĤäƤк
+	 */
+	hash->remove(tile->texture_addr);
+
 	tile->texture_addr = addr;
 
 	smanager->dma_load(tile->pixel, (uint32)addr,
@@ -128,8 +129,6 @@
 	    return 0xff0000;
 	}
 
-	tileList->size++;
-
 	smanager->dma_wait(TEX_LOAD);
     }
 
--- a/TaskManager/Test/test_render/spe/Load_Texture.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/Load_Texture.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -18,14 +18,13 @@
      * 現在 global_alloc() では new をサポートしてないので
      * コンストラクタ呼ぶために placement new してます。
      */
-    void *hash_tmp = smanager->global_alloc(GLOBAL_TEXTURE_HASH,
-					    sizeof(TileHash));
+    void *hash_tmp
+	= smanager->global_alloc(GLOBAL_TEXTURE_HASH, sizeof(TileHash));
     TileHashPtr hashtable = new(hash_tmp) TileHash;
 
-    TileListPtr tileList
-	= (TileListPtr)smanager->global_alloc(GLOBAL_TILE_LIST,
-					      sizeof(TileList));
-    tileList->init();
+    void *tileList_tmp
+	= smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(TileList));
+    TileListPtr tileList = new(tileList_tmp) TileList;
 
     return 0;
 }
--- a/TaskManager/Test/test_render/spe/TileHash.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/TileHash.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -66,6 +66,21 @@
 }
 
 void
+TileHash::remove(uint32 *key)
+{
+    int hashval = hash((uint32)key);
+
+    for (int i = 0; i < hashSize/2; i++) {
+	int index = (hashval + i*i)%hashSize;
+	
+	if (table[index] != NULL &&
+	    table[index]->texture_addr == key) {
+	    table[index] = NULL;
+	}
+    }
+}
+
+void
 TileHash::clear(void)
 {
     bzero(table, tableSize);
--- a/TaskManager/Test/test_render/spe/TileHash.h	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/spe/TileHash.h	Thu Dec 11 20:17:01 2008 +0900
@@ -19,12 +19,7 @@
     int hash(uint32 data);
     int put(uint32 *addr, TilePtr tile);
     TilePtr get(uint32 *addr);
-
-    /**
-     * 未実装
-     * 
-     * void remove(uint32 *addr);
-     */
+    void remove(uint32 *addr);
 };
 
 typedef TileHash* TileHashPtr;
--- a/TaskManager/Test/test_render/task/CreateSpan.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/CreateSpan.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -124,14 +124,70 @@
 }
 
 /**
+ * span の width,height と texture の width,height を比べて
+ * span を描画する際に使う texture の比率を求める
+ *
+ * @param width      Width of span
+ * @param height     Height of span
+ * @param tex_width  Width of 1/1 texture that span use
+ * @param tex_height Height of 1/1 texture that span use
+ * @return 描画に使う texture の比率
+ *         width と height は 1/scale の画像を使う
+ *
+ * @todo scale_max を設定するべき
+ *       縮小は 1/8 までしかやってなくて、scale が 16 になる場合もある
+ */
+static int
+getScale(int width, int height, int tex_width, int tex_height)
+{
+    int base, tex_base;
+    int scale = 1;
+
+    /**
+     * width と height で、長い方を基準に、
+     * texture の scale を決める
+     */
+    if (width > height) {
+	base = width;
+	tex_base = tex_width;
+    } else {
+	base = height;
+	tex_base = tex_height;
+    }
+
+    if (tex_base > base) {
+	int t_scale = tex_base/base;
+
+	while (t_scale >>= 1) {
+	    scale <<= 1;
+	}
+    }
+
+    return scale;
+}
+
+/**
  * x軸に水平な辺を持つ三角形ポリゴンから、
  * Span を抜き出す
+ *
+ * @param spackList    triangle から生成された span を格納する List
+ * @param charge_y_top 担当する y の範囲開始地点
+ * @param charge_y_end 担当する y の範囲終了地点
+ * @param tex_addr     triangle が参照するテクスチャの先頭アドレス
+ * @param tex_width    テクスチャの width
+ * @param tex_height   テクスチャの height
+ * @param vMin         triangle の座標
+ * @param vMid         triangle の座標。triangle を二つに分けて出来た新しい座標
+ * @param vMid10       triangle の座標
+ * @param y_length     分割する前の Triangle の y の長さ
+ *
  */
 void
 CreateSpan::half_triangle(SpanPackPtr *spackList,
 			  int charge_y_top, int charge_y_end,
 			  uint32 *tex_addr, int tex_width, int tex_height, 
-			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10)
+			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10,
+			  int y_length)
 {
     float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
     float tmp_xpos,tmp_end,tmp_zpos;
@@ -157,7 +213,6 @@
     /**
      * 三角形ポリゴンをx軸に水平に二つに分けようとして
      * ある一辺がすでに水平だった場合、つまり
-     * (環境によっては、back slash が 円マークかも)
      *
      * |\
      * | \
@@ -280,11 +335,7 @@
 
 	if (tmp_xpos > tmp_end) {
 	    x = (int)tmp_end;
-	    /**
-	     * +1 は要らない気がする・・・
-	     */ 
-	    //length = (int)(tmp_xpos)-(int)(tmp_end)+1;
-	    length = (int)(tmp_xpos)-(int)(tmp_end);
+	    length = (int)(tmp_xpos)-(int)(tmp_end)+1;
 	    start_z = tmp_zpos;
 	    end_z = tmp_z;
 	    start_tex_x = tmp_tex2;
@@ -293,8 +344,7 @@
 	    end_tex_y = tmp_tey1;
 	} else {
 	    x = (int)tmp_xpos;
-	    //length = (int)(tmp_end)-(int)(tmp_xpos)+1;
-	    length = (int)(tmp_end)-(int)(tmp_xpos);
+	    length = (int)(tmp_end)-(int)(tmp_xpos)+1;
 	    start_z = tmp_z;
 	    end_z = tmp_zpos;
 	    start_tex_x = tmp_tex1;
@@ -319,6 +369,9 @@
 	span->tex_x2     = end_tex_x;
 	span->tex_y1     = start_tex_y;
 	span->tex_y2     = end_tex_y;
+
+	int scale = getScale(span->length_x, y_length,
+			     span->tex_width, span->tex_height);
     }
 }
 
@@ -398,13 +451,31 @@
 	    /**
 	     * ポリゴンを、x軸に水平に分割して二つの三角形を作り、
 	     * それぞれから Span を求める
+	     *
+	     *      vMax
+	     *        |\
+	     *        | \
+	     *        |  \
+	     *        |   \
+	     * vMid10 ------ vMid
+	     *        |   /
+	     *        |  /
+	     *        | /
+	     *        |/
+	     *      vMin
+	     *
+	     * (vMax, vMid, vMin) という triangle を
+	     * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という
+	     * 二つの Triangle に分けている
 	     */
 	    half_triangle(spackList, charge_y_top, charge_y_end,
 			  triPack->tex_addr, triPack->tex_width,
-			  triPack->tex_height, vMin, vMid, vMid10);
+			  triPack->tex_height, vMin, vMid, vMid10,
+			  (int)(vMax->y - vMin->y));
 	    half_triangle(spackList, charge_y_top, charge_y_end,
 			  pp->tri[0].tex_addr, pp->tri[0].tex_width,
-			  pp->tri[0].tex_height, vMax, vMid, vMid10);
+			  pp->tri[0].tex_height, vMax, vMid, vMid10,
+			  (int)(vMax->y - vMin->y));
 	}
 
 	smanager->dma_wait(POLYGON_PACK_LOAD);	
--- a/TaskManager/Test/test_render/task/CreateSpan.h	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/CreateSpan.h	Thu Dec 11 20:17:01 2008 +0900
@@ -21,7 +21,8 @@
     void half_triangle(SpanPackPtr *spackList,
 		       int charge_y_top, int charge_y_end,
 		       uint32 *tex_addr, int tex_width, int tex_height,
-		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1);
+		       VertexPack *vMin,VertexPack *vMid,VertexPack *vMid1,
+		       int y_length);
     void setTileInfoList(SpanPtr span);
     void setTileInfo(TileInfoPtr tile, int xpos, int ypos,
 		     int tex_width, uint32* tex_addr_top);
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/DrawSpan.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -105,12 +105,13 @@
 
     tile = hash->get(addr);
     if (tile == NULL) {
-	if (tileList->size >= MAX_TILE) {
-	    tileList->init();
-	    hash->clear();
-	}
+	tile = tileList->nextTile();
 
-	tile = &tileList->tile[tileList->size];
+	/**
+	 * FIFO ʤΤǡ⤷ΤĤäƤк
+	 */
+	hash->remove(tile->texture_addr);
+
 	tile->texture_addr = addr;
 
 	smanager->dma_load(tile->pixel, (uint32)addr,
@@ -128,8 +129,6 @@
 	    return 0xff0000;
 	}
 
-	tileList->size++;
-
 	smanager->dma_wait(TEX_LOAD);
     }
 
--- a/TaskManager/Test/test_render/task/Load_Texture.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/Load_Texture.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -18,14 +18,13 @@
      * 現在 global_alloc() では new をサポートしてないので
      * コンストラクタ呼ぶために placement new してます。
      */
-    void *hash_tmp = smanager->global_alloc(GLOBAL_TEXTURE_HASH,
-					    sizeof(TileHash));
+    void *hash_tmp
+	= smanager->global_alloc(GLOBAL_TEXTURE_HASH, sizeof(TileHash));
     TileHashPtr hashtable = new(hash_tmp) TileHash;
 
-    TileListPtr tileList
-	= (TileListPtr)smanager->global_alloc(GLOBAL_TILE_LIST,
-					      sizeof(TileList));
-    tileList->init();
+    void *tileList_tmp
+	= smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(TileList));
+    TileListPtr tileList = new(tileList_tmp) TileList;
 
     return 0;
 }
--- a/TaskManager/Test/test_render/task/TileHash.cpp	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/TileHash.cpp	Thu Dec 11 20:17:01 2008 +0900
@@ -66,6 +66,21 @@
 }
 
 void
+TileHash::remove(uint32 *key)
+{
+    int hashval = hash((uint32)key);
+
+    for (int i = 0; i < hashSize/2; i++) {
+	int index = (hashval + i*i)%hashSize;
+	
+	if (table[index] != NULL &&
+	    table[index]->texture_addr == key) {
+	    table[index] = NULL;
+	}
+    }
+}
+
+void
 TileHash::clear(void)
 {
     bzero(table, tableSize);
--- a/TaskManager/Test/test_render/task/TileHash.h	Thu Dec 11 16:33:39 2008 +0900
+++ b/TaskManager/Test/test_render/task/TileHash.h	Thu Dec 11 20:17:01 2008 +0900
@@ -19,12 +19,7 @@
     int hash(uint32 data);
     int put(uint32 *addr, TilePtr tile);
     TilePtr get(uint32 *addr);
-
-    /**
-     * 未実装
-     * 
-     * void remove(uint32 *addr);
-     */
+    void remove(uint32 *addr);
 };
 
 typedef TileHash* TileHashPtr;