diff TaskManager/Test/test_render/spe/CreateSpan.cpp @ 164:38cbb7aecc70

TilePtr は SPE で計算した方がいいと判断して変更。
author gongo@gendarme.cr.ie.u-ryukyu.ac.jp
date Tue, 09 Dec 2008 10:48:49 +0900
parents 1f4c3f3238e6
children cd1c289f952d
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/CreateSpan.cpp	Tue Dec 09 10:08:28 2008 +0900
+++ b/TaskManager/Test/test_render/spe/CreateSpan.cpp	Tue Dec 09 10:48:49 2008 +0900
@@ -1,12 +1,12 @@
 #include "CreateSpan.h"
 #include "viewer_types.h"
 
-static const int SPAN_PACK_LOAD    = 5;
-static const int SPAN_PACK_STORE   = 6;
-static const int POLYGON_PACK_LOAD = 7;
-static const int TILE_ALLOCATE  = 8;
-static const int TILE_LOAD  = 9;
-static const int TILE_STORE = 10;
+static const int SPAN_PACK_LOAD    =  5;
+static const int SPAN_PACK_STORE   =  6;
+static const int POLYGON_PACK_LOAD =  7;
+static const int TILE_ALLOCATE     =  8;
+static const int TILE_LOAD         =  9;
+static const int TILE_STORE        = 10;
 
 static SpanPackPtr spack = NULL;
 static SpanPackPtr send_spack = NULL;
@@ -123,138 +123,6 @@
      return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
 }
 
-void
-CreateSpan::setTileInfo(TileInfoPtr tile, int xpos, int ypos,
-			int tex_width, uint32* tex_addr_top)
-{
-     /*
-      * テクスチャの座標 (tex_xpos, tex_ypos) の
-      * 分割したブロック内での座標
-      * 例:
-      *  (450, 318) -> 分割されたブロックの (2, 6) になる
-      */
-     tile->tix = xpos % TEXTURE_SPLIT_PIXEL;
-     tile->tiy = ypos % TEXTURE_SPLIT_PIXEL;
-     
-     /**
-      * ブロックIDから、あらかじめ分割したテクスチャの
-      * 先頭addressの addr からの距離を求める。
-      * それがこの 1 pixel が使うテクスチャのブロックになる
-      */
-     int block = get_tex_block(xpos, ypos, tex_width);
-     tile->tile = (void*)(tex_addr_top + block*TEXTURE_BLOCK_SIZE);
-}
-
-/**
- * Span の1ドットずつ、必要なテクスチャのブロック(Tile)を求めていく
- */
-void
-CreateSpan::setTileInfoList(SpanPtr span)
-{
-    TileInfoListPtr tilelist =
-	(TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
-    TileInfoListPtr send_tilelist =
-	(TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
-    TileInfoListPtr tilelist_addr;
-    TileInfoListPtr send_tilelist_addr;
-    TileInfoPtr tile;
-
-    int cur_x = 0;
-    int len = 0;
-
-    smanager->mainMem_wait();
-    tilelist_addr = (TileInfoListPtr)smanager->mainMem_get(TILE_ALLOCATE);
-    span->tilelist = tilelist_addr;
-
-    float tex1 = span->tex_x1;
-    float tex2 = span->tex_x2;
-    float tey1 = span->tex_y1;
-    float tey2 = span->tex_y2;
-    int tex_xpos;
-    int tex_ypos;
-    int end = span->length_x;
-
-    if (span->length_x == 1) {
-	tilelist->init();
-
-	tex_xpos = (int)((span->tex_width-1) * tex1);
-	tex_ypos = (int)((span->tex_height-1) * tey1);
-
-	tile = &tilelist->tileinfo[tilelist->size++];
-	setTileInfo(tile, tex_xpos, tex_ypos, span->tex_width,
-		    (uint32*)span->tex_addr);
-    } else {    
-	while (cur_x <= span->length_x) {
-	    if (cur_x + MAX_TILE_LIST - 1 < span->length_x) {
-		len = MAX_TILE_LIST - 1;
-		smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList));
-	    } else {
-		len = span->length_x - cur_x;
-	    }
-
-	    float tex_x, tex_y;
-
-	    tilelist->init();
-
-	    for (int i = cur_x; i <= cur_x + len; i++) {
-		tex_x = tex1*(end-1-i)/(end-1) + tex2*i/(end-1);
-		tex_y = tey1*(end-1-i)/(end-1) + tey2*i/(end-1);
-		if (tex_x > 1) tex_x = 1;
-		if (tex_y > 1) tex_y = 1;
-		tex_xpos = (int)((span->tex_width-1) * tex_x);
-		tex_ypos = (int)((span->tex_height-1) * tex_y);
-
-		/**
-		 * 座標が [0..MAX-1] を超えない様に
-		 * なんかもっと良い書き方ありそうだけど
-		 */
-		if (tex_xpos < 0) tex_xpos = 0;
-		if (span->tex_width - 1 < tex_xpos) {
-		     tex_xpos = span->tex_width - 1;
-		}
-		if (tex_ypos < 0) tex_ypos = 0;
-		if (span->tex_height - 1 < tex_ypos) {
-		     tex_ypos = span->tex_height - 1;
-		}
-
-		tile = &tilelist->tileinfo[tilelist->size++];
-		setTileInfo(tile, tex_xpos, tex_ypos, span->tex_width,
-			    (uint32*)span->tex_addr);
-	    }
-	
-	    if (cur_x + MAX_TILE_LIST - 1 < span->length_x) {
-		TileInfoListPtr tmp = tilelist;
-		tilelist = send_tilelist;
-		send_tilelist = tmp;
-
-		send_tilelist_addr = tilelist_addr;
-
-		smanager->mainMem_wait();
-		tilelist_addr =
-		    (TileInfoListPtr)smanager->mainMem_get(TILE_ALLOCATE);
-		
-		send_tilelist->next = tilelist_addr;
-		
-		smanager->dma_wait(TILE_STORE);
-		smanager->dma_store(send_tilelist, (uint32)send_tilelist_addr,
-				    sizeof(TileInfoList), TILE_STORE);
-	    }
-	    
-	    cur_x += MAX_TILE_LIST;
-	}
-    }
-
-    smanager->dma_wait(TILE_STORE);
-    tilelist->next = NULL;
-    smanager->dma_store(tilelist, (uint32)tilelist_addr,
-			sizeof(TileInfoList), TILE_STORE);
-    free(send_tilelist);
-
-    smanager->dma_wait(TILE_STORE);
-
-    free(tilelist);
-}
-
 /**
  * x軸に水平な辺を持つ三角形ポリゴンから、
  * Span を抜き出す
@@ -262,7 +130,7 @@
 void
 CreateSpan::half_triangle(SpanPackPtr *spackList,
 			  int charge_y_top, int charge_y_end,
-			  long *tex_addr, long tex_width, long tex_height, 
+			  uint32 *tex_addr, int tex_width, int tex_height, 
 			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10)
 {
     float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
@@ -332,7 +200,7 @@
 	if (charge_y_top <= y && y <= charge_y_end) {
 	    // 1..8 を index0, 9..16 を index1 にするために y を -1
 	    int index = (y-1) / split_screen_h;
-	    //if (index != 0) continue;
+
 	    /**
 	     * 違う SpanPack を扱う場合、
 	     * 現在の SpanPack をメインメモリに送り、
@@ -400,13 +268,6 @@
 	    continue;
 	}
 
-	/**
-	 * メインメモリに、Tile 用の領域確保をここで指定しておく
-	 */
-	// ちと仕様変更によりここでは使わない
-	// 予めやっておいて、その間に処理、だとちょっと動作が怪しいらしい
-	smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList));
-
 	tmp_tex1 =((i/(div_y)) * vMid10->tex_x) +
 	    ( ((div_y - i)/(div_y)) * vMin->tex_x);
 	tmp_tex2 =( (i/(div_y)) * vMid->tex_x) +
@@ -458,10 +319,6 @@
 	span->tex_x2     = end_tex_x;
 	span->tex_y1     = start_tex_y;
 	span->tex_y2     = end_tex_y;
-
-	// TilePtr の計算
-	// tix, tiy (Tile 内での x, y)
-	setTileInfoList(span);
     }
 }