# HG changeset patch # User gongo@gendarme.cr.ie.u-ryukyu.ac.jp # Date 1228787329 -32400 # Node ID 38cbb7aecc706415dafed6c372869c3d3454e072 # Parent e60e13967016be0ee0036fda05a89b5184ca83d9 TilePtr は SPE で計算した方がいいと判断して変更。 diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/Makefile.def --- a/TaskManager/Test/test_render/Makefile.def Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/Makefile.def Tue Dec 09 10:48:49 2008 +0900 @@ -3,10 +3,10 @@ # include/library path # ex: macosx #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium -#CERIUM = /Users/gongo/Source/hg/Cerium +CERIUM = /Users/gongo/Source/hg/Cerium # ex: linux/ps3 -CERIUM = /home/gongo/Cerium +#CERIUM = /home/gongo/Cerium #CERIUM = ../../.. diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/Span.h --- a/TaskManager/Test/test_render/Span.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/Span.h Tue Dec 09 10:48:49 2008 +0900 @@ -5,6 +5,10 @@ # include "Tapestry.h" #endif +#ifndef INCLUDED_TYPES +# include "types.h" +#endif + #define MAX_TILE_LIST 64 typedef struct tile { @@ -27,9 +31,9 @@ class Span { public: - long *tex_addr; - long tex_width; - long tex_height; + uint32 *tex_addr; + int tex_width; + int tex_height; int x; int y; int length_x; diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/polygon_pack.h --- a/TaskManager/Test/test_render/polygon_pack.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/polygon_pack.h Tue Dec 09 10:48:49 2008 +0900 @@ -1,6 +1,10 @@ #ifndef INCLUDED_POLYGON_PACK #define INCLUDED_POLYGON_PACK +#ifndef INCLUDED_TYPES +# include "types.h" +#endif + #define MAX_SIZE_TRIANGLE 128 typedef struct VertexPack { @@ -13,7 +17,8 @@ typedef struct TrianglePack { - long *tex_addr, tex_width, tex_height; + uint32 *tex_addr; + int tex_width, tex_height; VertexPack ver1; VertexPack ver2; VertexPack ver3; @@ -32,7 +37,7 @@ void init(void) { info.size = 0; - next = 0; + next = 0; } void clear(void) { diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/scene_graph_pack.h --- a/TaskManager/Test/test_render/scene_graph_pack.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/scene_graph_pack.h Tue Dec 09 10:48:49 2008 +0900 @@ -5,6 +5,10 @@ # include "SceneGraph.h" #endif +#ifndef INCLUDED_TYPES +# include "types.h" +#endif + #define MAX_NODE 16 #define MAX_POLYGON 36 @@ -15,7 +19,8 @@ float obj_pos[4]; float angle[4]; float translation[16]; - long *tex_addr, tex_width, tex_height; + uint32 *tex_addr; + int tex_width, tex_height; int id; int move, interaction; int pn; // parent number? diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/spe/CreateSpan.cpp --- 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); } } diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/spe/CreateSpan.h --- a/TaskManager/Test/test_render/spe/CreateSpan.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/spe/CreateSpan.h Tue Dec 09 10:48:49 2008 +0900 @@ -20,7 +20,7 @@ int run(void *rbuf, void *wbuf); void 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 *vMid1); void setTileInfoList(SpanPtr span); void setTileInfo(TileInfoPtr tile, int xpos, int ypos, diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/spe/DrawSpan.cpp --- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 09 10:48:49 2008 +0900 @@ -22,6 +22,65 @@ static TileListPtr tileList; +/** + * ƥϡTEXTURE_SPLIT_PIXEL^2 Υ֥åʬ䤹 + * + * +---+---+---+---+---+---+ + * | 0 | 1 | 2 | 3 | 4 | 5 | + * +---+---+---+---+---+---+ + * | | | | | |11 | + * +---+---+---+---+---+---+ + * | | | | | |17 | + * +---+---+---+---+---+---+ + * | | | | | |23 | + * +---+---+---+---+---+---+ + * | | | | | |29 | + * +---+---+---+---+---+---+ + * | | | | | |35 | + * +---+---+---+---+---+---+ + * + * դ TEXTURE_SPLIT Ȥ + * ƥ֥åο֥åIDȤʤ롣 + */ + +/** + * ƥκɸ顢 + * ƥΤɤΥ֥å + * + * @param[in] tx X coordinates of texture + * @param[in] tx Y coordinates of texture + * @param[in] twidth Width of texture + * @return block ID + */ +static inline int +get_tex_block(int tx, int ty, int twidth) +{ + int blockX, blockY; + + blockX = tx / TEXTURE_SPLIT_PIXEL; + blockY = ty / TEXTURE_SPLIT_PIXEL; + + return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY; +} + +/** + * block ID ȡƥ TOP address + * (tx,ty) ǻȤƥ Tile addres + * + * @param[in] tx X coordinates of texture + * @param[in] tx Y coordinates of texture + * @param[in] tw Width of texture + * @param[in] tex_addr_top (tx,ty) ǻȤƥƬaddress + * @return block ID + */ +static inline uint32* +getTile(int tx, int ty, int tw, uint32 *tex_addr_top) +{ + int block = get_tex_block(tx, ty, tw); + return tex_addr_top + block*TEXTURE_BLOCK_SIZE; +} + + static int hash(uint32 data) { @@ -153,6 +212,8 @@ + (blue & 0xff) + (alpha << 24); } + + int DrawSpan::run(void *rbuf, void *wbuf) { @@ -163,15 +224,9 @@ SpanPack *tmp_sp = NULL; Span *span; - TileInfoListPtr tilist = - (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); - TileInfoListPtr next_tilist = - (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); - tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); tileList->init(); - void *texture_image = global_get(TEXTURE_ID); int rangex_start = get_param(0); // Υô x ϰϤλ int rangex_end = get_param(1); // (start <= x <= end) int rangey = get_param(2); // y ϰ (render_y + rangey - 1) @@ -204,13 +259,20 @@ for (int t = 0; t < sp->info.size; t++) { span = &sp->span[t]; - smanager->dma_load(tilist, (uint32)span->tilelist, - sizeof(TileInfoList), TILE_INFO_LOAD); + Uint32 rgb = 0x00ff00; + float tex1 = span->tex_x1; + float tex2 = span->tex_x2; + float tey1 = span->tex_y1; + float tey2 = span->tex_y2; - Uint32 rgb = 0x00ff00; int tex_xpos; int tex_ypos; int tex_zpos; + + int tex_localx; + int tex_localy; + uint32 *tex_addr; + int x = span->x; int y = span->y; int x_len = span->length_x; @@ -221,98 +283,54 @@ int localx = getLocalX(x-1); int localy = getLocalY(y-1); - smanager->dma_wait(TILE_INFO_LOAD); - if (x_len == 1) { if (x < rangex_start || rangex_end < x) { continue; } - tex_xpos = tilist->tileinfo[0].tix; - tex_ypos = tilist->tileinfo[0].tiy; + tex_xpos = (int)((span->tex_width-1) * tex1); + tex_ypos = (int)((span->tex_height-1) * tey1); tex_zpos = (int)z; - texture_image = tilist->tileinfo[0].tile; if (zpos < zRow[localx + (rangex * localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); + zRow[localx + (rangex * localy)] = zpos; linebuf[localy][localx] = rgb; } } else { int js = (x < rangex_start) ? rangex_start - x : 0; int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; - - if (js > je) continue; - - int cur_x = 0; - int max_x = je; - int len = 0; + float tex_x, tex_y, tex_z; - /** - * Span ɽʤϰ([js..je]) TileInfoList - * äƤΤǡФ - */ - while (cur_x + MAX_TILE_LIST <= js) { - smanager->dma_load(next_tilist, (uint32)tilist->next, - sizeof(TileInfoList), TILE_INFO_LOAD); - smanager->dma_wait(TILE_INFO_LOAD); + for (int j = js; j <= je; j++) { + localx = getLocalX(x-1+j); - TileInfoListPtr tmp = tilist; - tilist = next_tilist; - next_tilist = tmp; - - cur_x += MAX_TILE_LIST; - } - - cur_x = js; + tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); - while (cur_x <= max_x) { - /** - * TileInfoList 30 ĤǶڤƤΤ - * cur_x TileInfoList 椫ϤޤäƤ - * MAX_TILE_LIST ˼ޤͤ - * (ex.) - * cur_x (=js) 0 Ϥޤä硢 - * cur_x = 0, len = 29 - * cur_x (=js) 15 Ϥޤä硢 - * cur_x = 15, len = 14 ˤʤ - */ - int cur_x_diff = MAX_TILE_LIST - (cur_x % MAX_TILE_LIST); - - if (cur_x + cur_x_diff - 1 < max_x) { - smanager->dma_load(next_tilist, (uint32)tilist->next, - sizeof(TileInfoList), - TILE_INFO_LOAD); - len = cur_x_diff - 1; - } else { - len = max_x - cur_x; - } + tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); + tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-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); + + if (tex_z < zRow[localx + (rangex*localy)]) { + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); - for (int j = cur_x; j <= cur_x + len; j++) { - TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; - float tex_z - = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); - - localx = getLocalX(x-1+j); - - tex_xpos = tinfo->tix; - tex_ypos = tinfo->tiy; - texture_image = tinfo->tile; - - if (tex_z < zRow[localx + (rangex*localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); - zRow[localx + (rangex*localy)] = tex_z; - linebuf[localy][localx] = rgb; - } + zRow[localx + (rangex*localy)] = tex_z; + linebuf[localy][localx] = rgb; } - - smanager->dma_wait(TILE_INFO_LOAD); - - TileInfoListPtr tmp = tilist; - tilist = next_tilist; - next_tilist = tmp; - - cur_x += cur_x_diff; } } } @@ -328,8 +346,6 @@ free(linebuf); free(zRow); free(tileList); - free(tilist); - free(next_tilist); return 0; } diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp --- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Tue Dec 09 10:48:49 2008 +0900 @@ -117,8 +117,8 @@ triangle->ver3.tex_x = sg->data[(i+2)*3 + sg->size*6]; triangle->ver3.tex_y = sg->data[(i+2)*3 + sg->size*6+1]; - triangle->tex_addr = (long*)sg->texture_info.pixels; - triangle->tex_width = sg->texture_info.t_w; + triangle->tex_addr = sg->texture_info.pixels; + triangle->tex_width = sg->texture_info.t_w; triangle->tex_height = sg->texture_info.t_h; } diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/task/CreateSpan.cpp --- a/TaskManager/Test/test_render/task/CreateSpan.cpp Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/task/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); } } diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/task/CreateSpan.h --- a/TaskManager/Test/test_render/task/CreateSpan.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/task/CreateSpan.h Tue Dec 09 10:48:49 2008 +0900 @@ -20,7 +20,7 @@ int run(void *rbuf, void *wbuf); void 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 *vMid1); void setTileInfoList(SpanPtr span); void setTileInfo(TileInfoPtr tile, int xpos, int ypos, diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/task/DrawSpan.cpp --- a/TaskManager/Test/test_render/task/DrawSpan.cpp Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cpp Tue Dec 09 10:48:49 2008 +0900 @@ -22,6 +22,65 @@ static TileListPtr tileList; +/** + * ƥϡTEXTURE_SPLIT_PIXEL^2 Υ֥åʬ䤹 + * + * +---+---+---+---+---+---+ + * | 0 | 1 | 2 | 3 | 4 | 5 | + * +---+---+---+---+---+---+ + * | | | | | |11 | + * +---+---+---+---+---+---+ + * | | | | | |17 | + * +---+---+---+---+---+---+ + * | | | | | |23 | + * +---+---+---+---+---+---+ + * | | | | | |29 | + * +---+---+---+---+---+---+ + * | | | | | |35 | + * +---+---+---+---+---+---+ + * + * դ TEXTURE_SPLIT Ȥ + * ƥ֥åο֥åIDȤʤ롣 + */ + +/** + * ƥκɸ顢 + * ƥΤɤΥ֥å + * + * @param[in] tx X coordinates of texture + * @param[in] tx Y coordinates of texture + * @param[in] twidth Width of texture + * @return block ID + */ +static inline int +get_tex_block(int tx, int ty, int twidth) +{ + int blockX, blockY; + + blockX = tx / TEXTURE_SPLIT_PIXEL; + blockY = ty / TEXTURE_SPLIT_PIXEL; + + return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY; +} + +/** + * block ID ȡƥ TOP address + * (tx,ty) ǻȤƥ Tile addres + * + * @param[in] tx X coordinates of texture + * @param[in] tx Y coordinates of texture + * @param[in] tw Width of texture + * @param[in] tex_addr_top (tx,ty) ǻȤƥƬaddress + * @return block ID + */ +static inline uint32* +getTile(int tx, int ty, int tw, uint32 *tex_addr_top) +{ + int block = get_tex_block(tx, ty, tw); + return tex_addr_top + block*TEXTURE_BLOCK_SIZE; +} + + static int hash(uint32 data) { @@ -153,6 +212,8 @@ + (blue & 0xff) + (alpha << 24); } + + int DrawSpan::run(void *rbuf, void *wbuf) { @@ -163,15 +224,9 @@ SpanPack *tmp_sp = NULL; Span *span; - TileInfoListPtr tilist = - (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); - TileInfoListPtr next_tilist = - (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); - tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); tileList->init(); - void *texture_image = global_get(TEXTURE_ID); int rangex_start = get_param(0); // Υô x ϰϤλ int rangex_end = get_param(1); // (start <= x <= end) int rangey = get_param(2); // y ϰ (render_y + rangey - 1) @@ -204,13 +259,20 @@ for (int t = 0; t < sp->info.size; t++) { span = &sp->span[t]; - smanager->dma_load(tilist, (uint32)span->tilelist, - sizeof(TileInfoList), TILE_INFO_LOAD); + Uint32 rgb = 0x00ff00; + float tex1 = span->tex_x1; + float tex2 = span->tex_x2; + float tey1 = span->tex_y1; + float tey2 = span->tex_y2; - Uint32 rgb = 0x00ff00; int tex_xpos; int tex_ypos; int tex_zpos; + + int tex_localx; + int tex_localy; + uint32 *tex_addr; + int x = span->x; int y = span->y; int x_len = span->length_x; @@ -221,98 +283,54 @@ int localx = getLocalX(x-1); int localy = getLocalY(y-1); - smanager->dma_wait(TILE_INFO_LOAD); - if (x_len == 1) { if (x < rangex_start || rangex_end < x) { continue; } - tex_xpos = tilist->tileinfo[0].tix; - tex_ypos = tilist->tileinfo[0].tiy; + tex_xpos = (int)((span->tex_width-1) * tex1); + tex_ypos = (int)((span->tex_height-1) * tey1); tex_zpos = (int)z; - texture_image = tilist->tileinfo[0].tile; if (zpos < zRow[localx + (rangex * localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); + zRow[localx + (rangex * localy)] = zpos; linebuf[localy][localx] = rgb; } } else { int js = (x < rangex_start) ? rangex_start - x : 0; int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; - - if (js > je) continue; - - int cur_x = 0; - int max_x = je; - int len = 0; + float tex_x, tex_y, tex_z; - /** - * Span ɽʤϰ([js..je]) TileInfoList - * äƤΤǡФ - */ - while (cur_x + MAX_TILE_LIST <= js) { - smanager->dma_load(next_tilist, (uint32)tilist->next, - sizeof(TileInfoList), TILE_INFO_LOAD); - smanager->dma_wait(TILE_INFO_LOAD); + for (int j = js; j <= je; j++) { + localx = getLocalX(x-1+j); - TileInfoListPtr tmp = tilist; - tilist = next_tilist; - next_tilist = tmp; - - cur_x += MAX_TILE_LIST; - } - - cur_x = js; + tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); - while (cur_x <= max_x) { - /** - * TileInfoList 30 ĤǶڤƤΤ - * cur_x TileInfoList 椫ϤޤäƤ - * MAX_TILE_LIST ˼ޤͤ - * (ex.) - * cur_x (=js) 0 Ϥޤä硢 - * cur_x = 0, len = 29 - * cur_x (=js) 15 Ϥޤä硢 - * cur_x = 15, len = 14 ˤʤ - */ - int cur_x_diff = MAX_TILE_LIST - (cur_x % MAX_TILE_LIST); - - if (cur_x + cur_x_diff - 1 < max_x) { - smanager->dma_load(next_tilist, (uint32)tilist->next, - sizeof(TileInfoList), - TILE_INFO_LOAD); - len = cur_x_diff - 1; - } else { - len = max_x - cur_x; - } + tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); + tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-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); + + if (tex_z < zRow[localx + (rangex*localy)]) { + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); - for (int j = cur_x; j <= cur_x + len; j++) { - TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; - float tex_z - = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); - - localx = getLocalX(x-1+j); - - tex_xpos = tinfo->tix; - tex_ypos = tinfo->tiy; - texture_image = tinfo->tile; - - if (tex_z < zRow[localx + (rangex*localy)]) { - rgb = get_rgb(tex_xpos, tex_ypos, texture_image); - zRow[localx + (rangex*localy)] = tex_z; - linebuf[localy][localx] = rgb; - } + zRow[localx + (rangex*localy)] = tex_z; + linebuf[localy][localx] = rgb; } - - smanager->dma_wait(TILE_INFO_LOAD); - - TileInfoListPtr tmp = tilist; - tilist = next_tilist; - next_tilist = tmp; - - cur_x += cur_x_diff; } } } @@ -328,8 +346,6 @@ free(linebuf); free(zRow); free(tileList); - free(tilist); - free(next_tilist); return 0; } diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/triangle.h --- a/TaskManager/Test/test_render/triangle.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/triangle.h Tue Dec 09 10:48:49 2008 +0900 @@ -4,10 +4,10 @@ #include "vertex.h" class Triangle { - public: - Vertex *vertex1,*vertex2,*vertex3; +public: + Vertex *vertex1,*vertex2,*vertex3; - Triangle(Vertex *tmp_vertex1,Vertex *tmp_vertex2,Vertex *tmp_vertex3); + Triangle(Vertex *tmp_vertex1,Vertex *tmp_vertex2,Vertex *tmp_vertex3); }; #endif diff -r e60e13967016 -r 38cbb7aecc70 TaskManager/Test/test_render/vertex.h --- a/TaskManager/Test/test_render/vertex.h Tue Dec 09 10:08:28 2008 +0900 +++ b/TaskManager/Test/test_render/vertex.h Tue Dec 09 10:48:49 2008 +0900 @@ -2,10 +2,10 @@ #define INCLUDE_VERTEX class Vertex { - public: - float x,y,z,tex_x,tex_y; - - Vertex(float tmp_x, float tmp_y, float tmp_z,float tmp_tex_x, float tmp_tex_y); +public: + float x,y,z,tex_x,tex_y; + + Vertex(float tmp_x, float tmp_y, float tmp_z,float tmp_tex_x, float tmp_tex_y); }; #endif