Mercurial > hg > Game > Cerium
changeset 146:a98dbb81db5c draft
TileList の生成の修正
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 02 Dec 2008 14:12:01 +0900 |
parents | a5138d6e8996 |
children | 4636153abc9f |
files | TaskManager/Test/test_render/Makefile.def TaskManager/Test/test_render/Span.h TaskManager/Test/test_render/SpanPack.h TaskManager/Test/test_render/spe/CreatePolygon.cpp TaskManager/Test/test_render/spe/CreateSpan.cpp TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp TaskManager/Test/test_render/task/CreateSpan.cpp |
diffstat | 7 files changed, 77 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Makefile.def Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/Makefile.def Tue Dec 02 14:12:01 2008 +0900 @@ -11,7 +11,7 @@ #CERIUM = ../../.. CC = g++ -CFLAGS = -O9 -g -Wall# -DDEBUG +CFLAGS = -O0 -g -Wall# -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I. LIBS = -L$(CERIUM)/TaskManager
--- a/TaskManager/Test/test_render/Span.h Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/Span.h Tue Dec 02 14:12:01 2008 +0900 @@ -42,6 +42,23 @@ TileInfoListPtr tilelist; int pad[3]; + + void init(void) { + tilelist = 0; + } + + void reinit(void) { + TileInfoListPtr tlist = this->tilelist; + TileInfoListPtr t; + + while (tlist) { + t = tlist->next; + free(tlist); + tlist = t; + } + + tilelist = 0; + } }; typedef Span* SpanPtr;
--- a/TaskManager/Test/test_render/SpanPack.h Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/SpanPack.h Tue Dec 02 14:12:01 2008 +0900 @@ -40,30 +40,15 @@ p1 = p->next; for (int i = 0; i < p->info.size; i++) { Span* span = &p->span[i]; - TileInfoListPtr tlist = span->tilelist; - TileInfoListPtr t; - - while (tlist) { - t = tlist->next; - free(tlist); - tlist = t; - } + span->reinit(); } - free(p); p = p1; } for (int i = 0; i < this->info.size; i++) { Span* span = &this->span[i]; - TileInfoListPtr tlist = span->tilelist; - TileInfoListPtr t; - - while (tlist) { - t = tlist->next; - free(tlist); - tlist = t; - } + span->reinit(); } this->info.size = 0;
--- a/TaskManager/Test/test_render/spe/CreatePolygon.cpp Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/spe/CreatePolygon.cpp Tue Dec 02 14:12:01 2008 +0900 @@ -146,7 +146,7 @@ triangle->ver3.tex_x = node->texture[nt+4]; triangle->ver3.tex_y = node->texture[nt+4+1]; -#if 0 +#if 1 triangle->tex_addr = node->tex_addr; triangle->tex_width = node->tex_width; triangle->tex_height = node->tex_height;
--- a/TaskManager/Test/test_render/spe/CreateSpan.cpp Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/spe/CreateSpan.cpp Tue Dec 02 14:12:01 2008 +0900 @@ -68,9 +68,11 @@ make_vMid10(VertexPack *v, VertexPack *vMin, VertexPack *vMid, VertexPack *vMax) { - int d, d1; - - d = (int)(vMax->y - vMin->y); + //int d, d1; + float d; + int d1; + + d = vMax->y - vMin->y; d1 = (int)(vMid->y - vMin->y); v->tex_x = calc(vMax->tex_x - vMin->tex_x, d, d1, vMin->tex_x); @@ -122,14 +124,17 @@ tile->tiy = tex_ypos; } else { while (cur_x < span->length_x) { - len = (cur_x + MAX_TILE_LIST < span->length_x) ? - MAX_TILE_LIST : span->length_x - cur_x; + if (cur_x + MAX_TILE_LIST < span->length_x) { + len = MAX_TILE_LIST; + } else { + len = span->length_x - cur_x; + } float tex_x, tex_y; tilelist->init(); - for (int i = cur_x; i < end; i++) { + for (int i = cur_x; i < cur_x + len; i++) { tile = &tilelist->tileinfo[tilelist->size++]; tex_x = tex1*(end-1-i)/(end-1) + tex2*i/(end-1); @@ -147,6 +152,7 @@ TileInfoListPtr tmp = tilelist; tilelist = send_tilelist; send_tilelist = tmp; + send_tilelist_addr = tilelist_addr; smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); @@ -159,6 +165,8 @@ smanager->dma_wait(TILE_STORE); smanager->dma_store(send_tilelist, (uint32)send_tilelist_addr, sizeof(TileInfoList), TILE_STORE); + + tilelist->init(); } cur_x += MAX_TILE_LIST; @@ -169,7 +177,6 @@ tilelist->next = 0; // ? smanager->dma_store(tilelist, (uint32)tilelist_addr, sizeof(TileInfoList), TILE_STORE); - free(send_tilelist); smanager->dma_wait(TILE_STORE); @@ -310,18 +317,25 @@ */ continue; } + + tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + + length = (tmp_xpos > tmp_end) + ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; + if (length == 0) { + continue; + } /** * メインメモリに、Tile 用の領域確保をここで指定しておく */ // ちと仕様変更によりここでは使わない // 予めやっておいて、その間に処理、だとちょっと動作が怪しいらしい - //smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); - - tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); - tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); - tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); - tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); + tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + ( ((div_y - i)/(div_y)) * vMin->tex_x); @@ -378,8 +392,8 @@ // TilePtr の計算 // tix, tiy (Tile 内での x, y) // - //smanager->mainMem_wait(); - //setTile(span); + smanager->mainMem_wait(); + setTile(span); } }
--- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Tue Dec 02 14:12:01 2008 +0900 @@ -117,9 +117,9 @@ 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 = sg->texture_image->pixels; - triangle->tex_width = sg->texture_image->w; - triangle->tex_height = sg->texture_image->h; + triangle->tex_addr = (long*)sg->texture_info.pixels; + triangle->tex_width = sg->texture_info.t_w; + triangle->tex_height = sg->texture_info.t_h; }
--- a/TaskManager/Test/test_render/task/CreateSpan.cpp Tue Dec 02 12:46:54 2008 +0900 +++ b/TaskManager/Test/test_render/task/CreateSpan.cpp Tue Dec 02 14:12:01 2008 +0900 @@ -124,14 +124,17 @@ tile->tiy = tex_ypos; } else { while (cur_x < span->length_x) { - len = (cur_x + MAX_TILE_LIST < span->length_x) ? - MAX_TILE_LIST : span->length_x - cur_x; + if (cur_x + MAX_TILE_LIST < span->length_x) { + len = MAX_TILE_LIST; + } else { + len = span->length_x - cur_x; + } float tex_x, tex_y; tilelist->init(); - for (int i = cur_x; i < end; i++) { + for (int i = cur_x; i < cur_x + len; i++) { tile = &tilelist->tileinfo[tilelist->size++]; tex_x = tex1*(end-1-i)/(end-1) + tex2*i/(end-1); @@ -149,6 +152,7 @@ TileInfoListPtr tmp = tilelist; tilelist = send_tilelist; send_tilelist = tmp; + send_tilelist_addr = tilelist_addr; smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); @@ -161,6 +165,8 @@ smanager->dma_wait(TILE_STORE); smanager->dma_store(send_tilelist, (uint32)send_tilelist_addr, sizeof(TileInfoList), TILE_STORE); + + tilelist->init(); } cur_x += MAX_TILE_LIST; @@ -171,7 +177,6 @@ tilelist->next = 0; // ? smanager->dma_store(tilelist, (uint32)tilelist_addr, sizeof(TileInfoList), TILE_STORE); - free(send_tilelist); smanager->dma_wait(TILE_STORE); @@ -312,18 +317,25 @@ */ continue; } + + tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + + length = (tmp_xpos > tmp_end) + ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; + if (length == 0) { + continue; + } /** * メインメモリに、Tile 用の領域確保をここで指定しておく */ // ちと仕様変更によりここでは使わない // 予めやっておいて、その間に処理、だとちょっと動作が怪しいらしい - //smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); - - tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); - tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); - tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); - tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); + tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + ( ((div_y - i)/(div_y)) * vMin->tex_x); @@ -380,8 +392,8 @@ // TilePtr の計算 // tix, tiy (Tile 内での x, y) // - //smanager->mainMem_wait(); - //setTile(span); + smanager->mainMem_wait(); + setTile(span); } }