Mercurial > hg > Game > Cerium
changeset 472:f979728101e7 draft
fix spe test_render
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Oct 2009 23:20:25 +0900 |
parents | e95d1047d15c (current diff) 15e4ff86aa3e (diff) |
children | 16f0abb574b7 |
files | TaskManager/Test/test_render/spe/ChainInit.cc TaskManager/Test/test_render/spe/CreateSpan.cc TaskManager/Test/test_render/spe/DrawBack.cc TaskManager/Test/test_render/spe/DrawSpan.cc TaskManager/Test/test_render/spe/DrawSpan.h TaskManager/Test/test_render/spe/Load_Texture.cc TaskManager/Test/test_render/spe/TileHash.h TaskManager/Test/test_render/spe/spe-main.cc TaskManager/Test/test_render/task/DrawSpan.h TaskManager/Test/test_render/task/InitKey.cc TaskManager/Test/test_render/task/UpdateKey.h |
diffstat | 24 files changed, 233 insertions(+), 153 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/ChangeLog Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/ChangeLog Fri Oct 02 23:20:25 2009 +0900 @@ -1,3 +1,27 @@ +2009-10-02 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + DrawSpan で、~DrawSpan() で、allocate したデータを DMA_WAIT + して、free しているが、これは、抽象化違反。Task で明示的に + DMAするのは禁止。Task 内で、add_outData 出来れば良い。 + + renew が正しいような気がするが... + + Task 内で大域変数は使えない。なので、smanager からallocateする + 必要がある。Task の解放のタイミングではなくて、パイプラインの + タイミングでDMA waitとfreeを行なう必要がある。DrawSpan の場合は、 + add_outData で良いが、内部で allocate/free は行なう必要がある。 + put_segement がパイプライン動作するべきなのか? + + 固定のDMA tagが邪魔。 + + DrawSpan は全般的にダメだな〜 + + でも、その変更は大きいので、とりあえず動くようにしたい。 + + memset 0 は、7.7.3 SL1 Data Cache Range Set to Zero コマンド + つかうべき。SPE側でやっても良い。でも、本来は全面埋まるのが + 普通なのでどうでも良いけど。 + 2009-08-06 Shinji KONO <kono@ie.u-ryukyu.ac.jp> で、MemList/MemHash が TaskManager 側に移ったので、
--- a/TaskManager/Test/test_render/Func.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/Func.h Fri Oct 02 23:20:25 2009 +0900 @@ -16,7 +16,7 @@ TASK_CS_START, TASK_CS_RUN, TASK_DRAW_SPAN, -// TASK_DRAW_SPAN2, + TASK_DRAW_SPAN_END, TASK_DRAW_BACK, TASK_SET_TEXTURE, TASK_MOVE,
--- a/TaskManager/Test/test_render/spe/ChainCal.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainCal.cc Fri Oct 02 23:20:25 2009 +0900 @@ -27,8 +27,8 @@ //int parent; } ChainProperty, *ChainPropertyPtr; -int -ChainCal::run(SchedTask *s,void *rbuf, void *wbuf) +static int +run(SchedTask *s,void *rbuf, void *wbuf) { ChainPropertyPtr property = (ChainPropertyPtr)s->get_input(rbuf, 0); ChainPropertyPtr update_property = (ChainPropertyPtr)s->get_output(wbuf, 0);
--- a/TaskManager/Test/test_render/spe/ChainInit.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainInit.cc Fri Oct 02 23:20:25 2009 +0900 @@ -25,7 +25,7 @@ uint32 chain_len = s->get_param(0); // property は spe 上で allocate している(global) - CHAIN_VARS *property = (CHAIN_VARS*)global_alloc(DATA_ID, sizeof(CHAIN_VARS)*chain_len); + CHAIN_VARS *property = (CHAIN_VARS*)s->global_alloc(DATA_ID, sizeof(CHAIN_VARS)*chain_len); memcpy(property, idata, sizeof(CHAIN_VARS)*chain_len); return 0;
--- a/TaskManager/Test/test_render/spe/CreateSpan.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/CreateSpan.cc Fri Oct 02 23:20:25 2009 +0900 @@ -11,10 +11,10 @@ static const int TILE_LOAD = 9; static const int TILE_STORE = 10; -static struct g { +typedef struct g { SpanPackPtr spack ; SpanPackPtr send_spack ; - int prev_index = ; + int prev_index ; } G, *Gptr; SchedDefineTask(CreateSpan); @@ -193,8 +193,8 @@ * @param[in] tex_y_len 分割する前の Triangle に貼られている Texture の * 長さの割合 (0 ... 1) */ -void -CreateSpan::half_triangle(SchedTask *smanager, SpanPackPtr *spackList, +static void +half_triangle(SchedTask *smanager, Gptr g, SpanPackPtr *spackList, int charge_y_top, int charge_y_end, TriangleTexInfoPtr tex_info, VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10, @@ -272,18 +272,18 @@ * 現在の SpanPack をメインメモリに送り、 * 新しい SpanPack を取ってくる */ - if (index != prev_index) { - tmp_spack = spack; - spack = send_spack; - send_spack = tmp_spack; + if (index != g->prev_index) { + tmp_spack = g->spack; + g->spack = g->send_spack; + g->send_spack = tmp_spack; smanager->dma_wait(SPAN_PACK_STORE); - smanager->dma_store(send_spack, (uint32)spackList[prev_index], + smanager->dma_store(g->send_spack, (uint32)spackList[g->prev_index], sizeof(SpanPack), SPAN_PACK_STORE); - smanager->dma_load(spack, (uint32)spackList[index], + smanager->dma_load(g->spack, (uint32)spackList[index], sizeof(SpanPack), SPAN_PACK_LOAD); - prev_index = index; + g->prev_index = index; smanager->dma_wait(SPAN_PACK_LOAD); } @@ -292,7 +292,7 @@ * メインメモリで allocate した領域 (next) を持ってきて * 現在の spack->next につなぎ、next を次の spack とする。 */ - if (spack->info.size >= MAX_SIZE_SPAN) { + if (g->spack->info.size >= MAX_SIZE_SPAN) { SpanPackPtr next; __debug_spe("CreateSpan mainMem_alloc 0x%x\n", (unsigned int)sizeof(SpanPack)); @@ -301,22 +301,22 @@ next = (SpanPackPtr)smanager->mainMem_get(0); __debug_spe("CreateSpan mainMem_allocated 0x%x\n", (unsigned int)next); - spack->next = next; // この部分は TaskManager でやる + g->spack->next = next; // この部分は TaskManager でやる - tmp_spack = spack; - spack = send_spack; - send_spack = tmp_spack; + tmp_spack = g->spack; + g->spack = g->send_spack; + g->send_spack = tmp_spack; smanager->dma_wait(SPAN_PACK_STORE); - smanager->dma_store(send_spack, (uint32)spackList[index], + smanager->dma_store(g->send_spack, (uint32)spackList[index], sizeof(SpanPack), SPAN_PACK_STORE); spackList[index] = next; - smanager->dma_load(spack, (uint32)spackList[index], + smanager->dma_load(g->spack, (uint32)spackList[index], sizeof(SpanPack), SPAN_PACK_LOAD); smanager->dma_wait(SPAN_PACK_LOAD); - spack->init((index+1)*split_screen_h); + g->spack->init((index+1)*split_screen_h); } } else { /** @@ -368,7 +368,7 @@ smanager->dma_wait(SPAN_PACK_LOAD); - Span *span = &spack->span[spack->info.size++]; + Span *span = &g->spack->span[g->spack->info.size++]; span->x = x; span->y = y; @@ -414,7 +414,9 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { - smanager->__debug_spe("CreateSpan\n"); + __debug_spe("CreateSpan\n"); + Gptr g = (Gptr)smanager->allocate(sizeof(G)); + g->prev_index = 0; PolygonPack *pp = (PolygonPack*)smanager->get_input(0); PolygonPack *next_pp = @@ -428,19 +430,19 @@ = (VertexPackPtr)smanager->allocate(sizeof(VertexPack)); SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(1); - spack = (SpanPackPtr)smanager->get_input(2); - send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); - prev_index = get_param(0); + g->spack = (SpanPackPtr)smanager->get_input(2); + g->send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); + g->prev_index = (int)smanager->get_param(0); // spack と send_spack は swap しながら DMA を繰り返すので // 自分で allocate した send_spack を覚えてないといけない - SpanPackPtr free_spack = send_spack; + SpanPackPtr free_spack = g->send_spack; - int charge_y_top = get_param(1); - int charge_y_end = get_param(2); + int charge_y_top = smanager->get_param(1); + int charge_y_end = smanager->get_param(2); do { - smanager->__debug_spe("CreateSpan allocated 0x%x\n",(uint32)next_pp); + __debug_spe("CreateSpan allocated 0x%x\n",(uint32)next_pp); if (pp->next != NULL) { smanager->dma_load(next_pp, (uint32)pp->next, @@ -477,10 +479,10 @@ * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という * 二つの Triangle に分けている */ - half_triangle(smanager, spackList, charge_y_top, charge_y_end, + half_triangle(smanager, g, spackList, charge_y_top, charge_y_end, tri_tex_info, vMin, vMid, vMid10, (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y); - half_triangle(smanager, spackList, charge_y_top, charge_y_end, + half_triangle(smanager, g, spackList, charge_y_top, charge_y_end, tri_tex_info, vMax, vMid, vMid10, (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y); } @@ -493,15 +495,16 @@ } while (pp); smanager->dma_wait(SPAN_PACK_STORE); - smanager->dma_store(spack, (uint32)spackList[prev_index], + smanager->dma_store(g->spack, (uint32)spackList[g->prev_index], sizeof(SpanPack), SPAN_PACK_STORE); smanager->dma_wait(SPAN_PACK_STORE); - smanager->__debug_spe("CreateSpan spack_stored 0x%x\n",(uint32)spackList[prev_index]); + __debug_spe("CreateSpan spack_stored 0x%x\n",(uint32)spackList[g->prev_index]); // smanager で allocate したのだから free も smanager でやるべき free(free_pp); free(free_spack); free(vMid10); + free(g); return 0; }
--- a/TaskManager/Test/test_render/spe/DrawBack.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/DrawBack.cc Fri Oct 02 23:20:25 2009 +0900 @@ -9,7 +9,7 @@ SchedDefineTask(DrawBack); static void -DrawBack::linebuf_init(int *buf, int x, int rgb) +linebuf_init(int *buf, int x, int rgb) { for (int i = 0; i < x; i++) { buf[i] = rgb;
--- a/TaskManager/Test/test_render/spe/DrawSpan.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cc Fri Oct 02 23:20:25 2009 +0900 @@ -12,20 +12,23 @@ #include "global_alloc.h" SchedDefineTask(DrawSpan); +SchedDefineTask1(DrawSpanEnd,draw_span_end); #define TEX_LOAD1 0 #define TEX_LOAD2 1 #define SPAN_PACK_LOAD 2 #define FB_STORE 3 -/* - * done in post func? -DrawSpan::~DrawSpan(void) +static int +draw_span_end(SchedTask *s, void *rbuf, void *wbuf) { - smanager->dma_wait(FB_STORE); // 誰のために待ってるの? - free((void*)((int)linebuf*doneWrite)); + Gptr g = (Gptr)s->get_param(0); + s->dma_wait(FB_STORE); + free((void*)((int)g->linebuf*g->doneWrite)); + free(g); + return 0; } - */ + inline vector float spu_re_nrm(vector float a) @@ -39,6 +42,7 @@ } +#if 0 static vector signed int getLocalPositionVec(vector signed int d, signed int offset) { @@ -50,6 +54,7 @@ { return getLocalPositionVec(x, split_screen_w); } +#endif /** @@ -119,7 +124,7 @@ * @return Buffer */ static int* -linebuf_init(int width, int height, int rgb) +linebuf_init(SchedTask *smanager, int width, int height, int rgb) { int *buf = (int*)smanager->allocate(sizeof(int)*width*height); @@ -138,7 +143,7 @@ * @return Z-Buffer */ static float* -zRow_init(int width, int height) +zRow_init(SchedTask *smanager, int width, int height) { float *buf = (float*)smanager->allocate(sizeof(float)*width*height); float def = 65535.0f; @@ -213,16 +218,16 @@ #endif static void -writebuffer(unsigned int display, int buf_width, int height, - int screen_width) +writebuffer(SchedTask *smanager, Gptr g, unsigned int display, + int buf_width, int height, int screen_width) { for (int i = 0; i < height; i++) { - smanager->dma_store(&linebuf[i*buf_width], + smanager->dma_store(&g->linebuf[i*buf_width], display + (sizeof(int)*screen_width*i), sizeof(int)*buf_width, FB_STORE); } - doneWrite = 1; + g->doneWrite = 1; } /** @@ -237,13 +242,13 @@ * @param tex_addr テクスチャのアドレス(MainMemory) */ static void -updateBuffer(float zpos, int rangex, int x, int y, +updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, TilePtr tile) { int rgb = get_rgb(tex_x, tex_y, tile); - zRow[x + (rangex*y)] = zpos; - linebuf[x + (rangex*y)] = rgb; + g->zRow[x + (rangex*y)] = zpos; + g->linebuf[x + (rangex*y)] = rgb; } /** @@ -255,7 +260,7 @@ */ static int -drawDot1(SpanPtr span, int startx, int endx, int wait_tag) +drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) { int rangex = endx - startx + 1; @@ -288,16 +293,16 @@ tex_xpos = (int)((span->tex_width-1) * tex); tex_ypos = (int)((span->tex_height-1) * tey); - if (zpos < zRow[localx + (rangex*localy)]) { + if (zpos < g->zRow[localx + (rangex*localy)]) { tex_addr = getTile(tex_xpos, tex_ypos, span->tex_width, (memaddr)span->tex_addr); tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; - TilePtr tile = smanager->get_segment(tex_addr,tileList); + TilePtr tile = smanager->get_segment(tex_addr,g->tileList); smanager->wait_segment(tile); - updateBuffer(zpos, rangex, localx, localy, + updateBuffer(g, zpos, rangex, localx, localy, tex_localx, tex_localy, tile); } @@ -323,7 +328,7 @@ * @return 「span のどの位置まで rendering が終わったか」の x 座標 */ static int -drawLine1(SpanPtr span, int startx, int endx, int wait_tag) +drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) { int x = span->x; int rangex = endx - startx + 1; @@ -369,7 +374,7 @@ 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)]) { + if (tex_z < g->zRow[localx + (rangex*localy)]) { // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と // そのブロックのアドレス(MainMemory) memaddr tex_addr; @@ -381,10 +386,10 @@ tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; - TilePtr tile = smanager->get_segment(tex_addr,tileList); + TilePtr tile = smanager->get_segment(tex_addr,g->tileList); smanager->wait_segment(tile); - updateBuffer(tex_z, rangex, localx, localy, + updateBuffer(g, tex_z, rangex, localx, localy, tex_localx, tex_localy, tile); } } @@ -392,11 +397,31 @@ return ret; } +#if 1 +void +fix_relocation(char **addr,int count) +{ + unsigned int pc; + unsigned int label; + __asm__ __volatile__( +" brsl %0,____LLLL\n" +"____LLLL:" +" ila %1,____LLLL" + : "=r" (pc), "=r" (label)); + int offset = pc-label; + int i; + for(i=0;i<count;i++) { + addr[i] += offset; + } +} +#endif + static int run(SchedTask *smanager, void *rbuf, void *wbuf) { __debug_spe("DrawSpan\n"); - this->smanager = smanager; + Gptr g = (Gptr)smanager->allocate(sizeof(G)); + SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); SpanPackPtr free_spack = next_spack; // next_spack の free() 用 @@ -405,9 +430,10 @@ Span nop_span; nop_span.length_x = 1; - int (DrawSpan::*drawFunc1[2])(SpanPtr, int, int, int) = { - &DrawSpan::drawDot1, &DrawSpan::drawLine1 - }; +// int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = { +// &drawDot1, &drawLine1 +// }; +// fix_relocation((void**)drawFunc1,2); uint32 display = smanager->get_param(0); int screen_width = smanager->get_param(1); @@ -420,13 +446,13 @@ // y の範囲 int rangey = smanager->get_param(4); - tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); + g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); - zRow = zRow_init(rangex, rangey); + g->zRow = zRow_init(smanager, rangex, rangey); //linebuf = linebuf_init(rangex, rangey, 0x00ffffff); - linebuf = linebuf_init(rangex, rangey, 0); + g->linebuf = linebuf_init(smanager, rangex, rangey, 0); - doneWrite = 0; + g->doneWrite = 0; int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2}; int tl_tag_flg1 = 0; @@ -457,9 +483,15 @@ /** * span の長さによって、drawLine か drawDot を選択している */ - next_span_x - = (this->*drawFunc1[(span->length_x != 1)])( - span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + if (span->length_x != 1) { + next_span_x + = drawLine1( smanager, g, + span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + } else { + next_span_x + = drawDot1( smanager, g, + span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + } next_span = span; resume_span = next_span; @@ -483,12 +515,12 @@ next_spack = tmp_spack; } while (spack); - writebuffer(display, rangex, rangey, screen_width); + writebuffer(smanager, g, display, rangex, rangey, screen_width); // linebuf は、writebuffer() の dma_store を wait する // DrawSpan::~DrawSpan() 内で free する。 //free(linebuf); - free(zRow); + free(g->zRow); //FINISH: /** @@ -497,5 +529,10 @@ */ free(free_spack); + + TaskPtr nextTask = smanager->create_task(TASK_DRAW_SPAN_END); + nextTask->add_param((int)g); + smanager->wait_task(nextTask); + return 0; }
--- a/TaskManager/Test/test_render/spe/DrawSpan.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.h Fri Oct 02 23:20:25 2009 +0900 @@ -5,7 +5,7 @@ #include "Tapestry.h" #include "SpanPack.h" -struct g { +typedef struct g { int *linebuf; float *zRow; TileListPtr tileList; @@ -15,25 +15,24 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf); -static int* linebuf_init(int width, int height, int rgb); -static float* zRow_init(int width, int height); +static int* linebuf_init(SchedTask *s, int width, int height, int rgb); +static float* zRow_init(SchedTask *s, int width, int height); static uint32 get_rgb(int tx, int ty, TilePtr tile); static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); static int getTexBlock(int tx, int ty, int twidth); -static void writebuffer(unsigned int display, int width, int height, +static void writebuffer(SchedTask *s, Gptr g, unsigned int display, int width, int height, int screen_width); -static void updateBuffer(float zpos, int rangex, int x, int y, +static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, TilePtr tile); #if 0 static void reboot(SpanPackPtr spack, int cur_span_x); #endif -static int drawDot1(SpanPtr span, int startx, int endx, int wait_tag); -static void drawDot2(SpanPtr span, int startx, int endx, int js, int wait_tag); -static int drawLine1(SpanPtr span, int startx, int endx, int wait_tag); -static void drawLine2(SpanPtr span, int startx, int endx, int js, int wait_tag); -}; +static int drawDot1(SchedTask *s, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +//static void drawDot2(SpanPtr span, int startx, int endx, int js, int wait_tag); +static int drawLine1(SchedTask *s, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +//static void drawLine2(SpanPtr span, int startx, int endx, int js, int wait_tag); typedef struct { uint32 display;
--- a/TaskManager/Test/test_render/spe/Load_Texture.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/Load_Texture.cc Fri Oct 02 23:20:25 2009 +0900 @@ -20,7 +20,7 @@ static int run(SchedTask *smanager, void *rbuf , void *wbuf) { - smanager->__debug_spe("LoadTexture\n"); + __debug_spe("LoadTexture\n"); MemList *ml = smanager->createMemList(sizeof(uint32) * TEXTURE_BLOCK_SIZE, MAX_TILE); smanager->global_set(GLOBAL_TILE_LIST, (void *)ml);
--- a/TaskManager/Test/test_render/spe/TileHash.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/TileHash.h Fri Oct 02 23:20:25 2009 +0900 @@ -24,9 +24,9 @@ typedef TileHash* TileHashPtr; -#endif const int hashSize = 263; const int tableSize = sizeof(TilePtr)*hashSize; +#endif #endif
--- a/TaskManager/Test/test_render/spe/spe-main.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/spe/spe-main.cc Fri Oct 02 23:20:25 2009 +0900 @@ -4,6 +4,7 @@ SchedExternTask(LoadTexture); SchedExternTask(SetTexture); SchedExternTask(DrawSpan); +SchedExternTask(DrawSpanEnd); SchedExternTask(DrawSpanRenew); SchedExternTask(DrawBack); @@ -24,6 +25,7 @@ SchedRegisterTask(TASK_INIT_TEXTURE, LoadTexture); SchedRegisterTask(TASK_SET_TEXTURE, SetTexture); SchedRegisterTask(TASK_DRAW_SPAN, DrawSpan); + SchedRegisterTask(TASK_DRAW_SPAN_END, DrawSpanEnd); SchedRegisterTask(CHAINCAL_TASK, ChainCal); SchedRegisterTask(CHAININIT_TASK, ChainInit);
--- a/TaskManager/Test/test_render/task/ChainMove.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/ChainMove.cc Fri Oct 02 23:20:25 2009 +0900 @@ -1,5 +1,12 @@ #include <stdlib.h> #include <string.h> #include "ChainMove.h" -#include "viewer_types.h" + + +SchedDefineTask(ChainMove); +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + return 0; +}
--- a/TaskManager/Test/test_render/task/CreateSpan.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreateSpan.cc Fri Oct 02 23:20:25 2009 +0900 @@ -194,8 +194,8 @@ * @param[in] tex_y_len 分割する前の Triangle に貼られている Texture の * 長さの割合 (0 ... 1) */ -void -CreateSpan::half_triangle(SchedTask *smanager, SpanPackPtr *spackList, +static void +half_triangle(SchedTask *smanager, SpanPackPtr *spackList, int charge_y_top, int charge_y_end, TriangleTexInfoPtr tex_info, VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10,
--- a/TaskManager/Test/test_render/task/DrawSpan.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cc Fri Oct 02 23:20:25 2009 +0900 @@ -9,21 +9,22 @@ #include "global_alloc.h" SchedDefineTask(DrawSpan); +SchedDefineTask1(DrawSpanEnd,draw_span_end); #define TEX_LOAD1 0 #define TEX_LOAD2 1 #define SPAN_PACK_LOAD 2 #define FB_STORE 3 -/* - * - * should be done in some where... -DrawSpan::~DrawSpan() +static int +draw_span_end(SchedTask *s, void *rbuf, void *wbuf) { - dma_wait(FB_STORE); - free((void*)((int)linebuf*doneWrite)); + Gptr g = (Gptr)s->get_param(0); + s->dma_wait(FB_STORE); + free((void*)((int)g->linebuf*g->doneWrite)); + free(g); + return 0; } - */ /** * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する @@ -133,16 +134,16 @@ static void -writebuffer(SchedTask *smanager, unsigned int display, +writebuffer(SchedTask *smanager, Gptr g, unsigned int display, int buf_width, int height, int screen_width) { for (int i = 0; i < height; i++) { - smanager->dma_store(&linebuf[i*buf_width], + smanager->dma_store(&g->linebuf[i*buf_width], display + (sizeof(int)*screen_width*i), sizeof(int)*buf_width, FB_STORE); } - doneWrite = 1; + g->doneWrite = 1; } /** @@ -157,7 +158,7 @@ * @param tex_addr テクスチャのアドレス(MainMemory) */ static void -updateBuffer(float zpos, int rangex, int x, int y, int tex_x, int tex_y, +updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, float normal_x, float normal_y, float normal_z, TilePtr tile) { @@ -169,8 +170,8 @@ color = infinity_light_calc(color,normal_x,normal_y,normal_z); - zRow[x + (rangex*y)] = zpos*flag + zRow[x + (rangex*y)]*(1-flag); - linebuf[x + (rangex*y)] = color*flag + linebuf[x + (rangex*y)]*(1-flag); + g->zRow[x + (rangex*y)] = zpos*flag + g->zRow[x + (rangex*y)]*(1-flag); + g->linebuf[x + (rangex*y)] = color*flag + g->linebuf[x + (rangex*y)]*(1-flag); } @@ -182,7 +183,7 @@ * @param endx 描画終了範囲 */ static int -drawDot1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) +drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) { int rangex = endx - startx + 1; @@ -220,16 +221,16 @@ tex_xpos = (int)((span->tex_width-1) * tex); tex_ypos = (int)((span->tex_height-1) * tey); - if (zpos < zRow[localx + (rangex*localy)]) { + if (zpos < g->zRow[localx + (rangex*localy)]) { tex_addr = getTile(tex_xpos, tex_ypos, span->tex_width, (memaddr)span->tex_addr); tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; - TilePtr tile = smanager->get_segment(tex_addr,tileList); + TilePtr tile = smanager->get_segment(tex_addr,g->tileList); smanager->wait_segment(tile); - updateBuffer(zpos, rangex, localx, localy, + updateBuffer(g, zpos, rangex, localx, localy, tex_localx, tex_localy, normal_x,normal_y,normal_z,tile); } @@ -237,11 +238,13 @@ return -1; } +#if 0 static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag) { //printf("%d\n", js); } +#endif /** * 長さが 1 より大きい Span の描画 @@ -261,7 +264,7 @@ * @return 「span のどの位置まで rendering が終わったか」の x 座標 */ static int -drawLine1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) +drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) { int x = span->x; int rangex = endx - startx + 1; @@ -312,7 +315,7 @@ 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)]) { + if (tex_z < g->zRow[localx + (rangex*localy)]) { // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と // そのブロックのアドレス(MainMemory) memaddr tex_addr; @@ -323,10 +326,10 @@ span->tex_width, (memaddr)span->tex_addr); tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; - TilePtr tile = smanager->get_segment(tex_addr,tileList); + TilePtr tile = smanager->get_segment(tex_addr,g->tileList); smanager->wait_segment(tile); - updateBuffer(tex_z, rangex, localx, localy, + updateBuffer(g, tex_z, rangex, localx, localy, tex_localx, tex_localy, normal_x, normal_y, normal_z, tile); } @@ -372,6 +375,8 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { + Gptr g = (Gptr)smanager->allocate(sizeof(G)); + SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); SpanPackPtr free_spack = next_spack; // next_spack の free() 用 @@ -380,8 +385,8 @@ Span nop_span; nop_span.length_x = 1; - int (DrawSpan::*drawFunc1[2])(SchedTask *, SpanPtr, int, int, int) = { - &DrawSpan::drawDot1, &DrawSpan::drawLine1 + int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = { + &drawDot1, &drawLine1 }; uint32 display = smanager->get_param(0); @@ -394,13 +399,13 @@ // y の範囲 int rangey = smanager->get_param(4); - tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); + g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); - zRow = zRow_init(smanager, rangex, rangey); + g->zRow = zRow_init(smanager, rangex, rangey); //linebuf = linebuf_init(rangex, rangey, 0x00ffffff); - linebuf = linebuf_init(smanager, rangex, rangey, 0); + g->linebuf = linebuf_init(smanager, rangex, rangey, 0); - doneWrite = 0; + g->doneWrite = 0; int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2}; int tl_tag_flg1 = 0; @@ -432,8 +437,8 @@ * span の長さによって、drawLine か drawDot を選択している */ next_span_x - = (this->*drawFunc1[(span->length_x != 1)])( - smanager, + = (*drawFunc1[(span->length_x != 1)])( + smanager, g, span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); next_span = span; @@ -458,12 +463,12 @@ next_spack = tmp_spack; } while (spack); - writebuffer(smanager, display, rangex, rangey, screen_width); + writebuffer(smanager, g, display, rangex, rangey, screen_width); // linebuf は、writebuffer() の dma_store を wait する // DrawSpan::~DrawSpan() 内で free する。 //free(linebuf); - free(zRow); + free(g->zRow); //FINISH: /** @@ -472,6 +477,11 @@ */ free(free_spack); + + TaskPtr nextTask = smanager->create_task(TASK_DRAW_SPAN_END); + nextTask->add_param((int)g); + smanager->wait_task(nextTask); + return 0; }
--- a/TaskManager/Test/test_render/task/DrawSpan.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.h Fri Oct 02 23:20:25 2009 +0900 @@ -4,41 +4,35 @@ #include "SchedTask.h" #include "Tapestry.h" #include "SpanPack.h" -#if !USE_MEMHASH -#include "TileHash.h" -#endif -struct g { +typedef struct { int *linebuf; float *zRow; TileListPtr tileList; int doneWrite; } G, *Gptr; - - static int* linebuf_init(SchedTask *smanager, int width, int height, int rgb); static float* zRow_init(SchedTask *smanager, int width, int height); -static TilePtr set_rgb(memaddr addr, int wait_tag); -static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); +// static TilePtr set_rgb(memaddr addr, int wait_tag); +// static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); static uint32 get_rgb(int tx, int ty, TilePtr tile); -static TilePtr isAvailableTile(memaddr addr); +// static TilePtr isAvailableTile(memaddr addr); static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); static int getTexBlock(int tx, int ty, int twidth); -static void writebuffer(SchedTask *smanager, unsigned int display, +static void writebuffer(SchedTask *smanager, Gptr g, unsigned int display, int width, int height, int screen_width); -static void updateBuffer(float zpos, int rangex, int x, int y, +static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); -static void reboot(SpanPackPtr spack, int cur_span_x); +// static void reboot(SpanPackPtr spack, int cur_span_x); -static int drawDot1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag); -static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); -static int drawLine1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag); -static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); +static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +//static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); +static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +// static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z); -}; typedef struct { uint32 display;
--- a/TaskManager/Test/test_render/task/InitKey.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/InitKey.cc Fri Oct 02 23:20:25 2009 +0900 @@ -11,7 +11,7 @@ run(SchedTask *smanager, void *rbuf , void *wbuf) { - void *key = smanager->global_alloc(KEY_STATUS, sizeof(key_stat)); + smanager->global_alloc(KEY_STATUS, sizeof(key_stat)); return 0; }
--- a/TaskManager/Test/test_render/task/Set_Texture.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/Set_Texture.cc Fri Oct 02 23:20:25 2009 +0900 @@ -11,16 +11,16 @@ { void *src[4]; - src[0] = get_input(rbuf, 0); - src[1] = get_input(rbuf, 1); - src[2] = get_input(rbuf, 2); - src[3] = get_input(rbuf, 3); + src[0] = s->get_input(rbuf, 0); + src[1] = s->get_input(rbuf, 1); + src[2] = s->get_input(rbuf, 2); + src[3] = s->get_input(rbuf, 3); - if (global_get(TEXTURE_ID)) { + if (s->global_get(TEXTURE_ID)) { return 0; } else { //タスクが共有できる領域確保 - void *data = global_alloc(TEXTURE_ID, MAX_LOAD_SIZE*4); + void *data = s->global_alloc(TEXTURE_ID, MAX_LOAD_SIZE*4); memcpy(data, src[0], MAX_LOAD_SIZE); memcpy((void*)((int)data + MAX_LOAD_SIZE), src[1], MAX_LOAD_SIZE);
--- a/TaskManager/Test/test_render/task/UpdateKey.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/UpdateKey.h Fri Oct 02 23:20:25 2009 +0900 @@ -4,6 +4,6 @@ #include "SchedTask.h" #include "SceneGraphRoot.h" -static void setKeyStat(); +// static void setKeyStat(); #endif
--- a/TaskManager/Test/test_render/task/task_init.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/task_init.cc Fri Oct 02 23:20:25 2009 +0900 @@ -8,6 +8,7 @@ SchedExternTask(CreateSpan); SchedExternTask(DrawSpan); +SchedExternTask(DrawSpanEnd); SchedExternTask(DrawSpanRenew); SchedExternTask(DrawBack); @@ -26,7 +27,6 @@ SchedExternTask(UpdateKey); SchedExternTask(InitKey); -SchedExternTask(ChainMove); SchedExternTask(Switch); @@ -43,6 +43,7 @@ SchedRegisterTask(TASK_CREATE_SPAN, CreateSpan); SchedRegisterTask(TASK_DRAW_SPAN, DrawSpan); + SchedRegisterTask(TASK_DRAW_SPAN_END, DrawSpanEnd); // SchedRegisterTask(TASK_DRAW_SPAN2, DrawSpanRenew); SchedRegisterTask(TASK_DRAW_BACK, DrawBack);
--- a/TaskManager/Test/test_render/task/update_sgp.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/task/update_sgp.cc Fri Oct 02 23:20:25 2009 +0900 @@ -12,8 +12,8 @@ run(SchedTask *s,void *rbuf, void *wbuf) { SceneGraphNodePtr node; - SceneGraphPack *sgp = (SceneGraphPack*)get_input(rbuf, 0); - SceneGraphPack *_sgp = (SceneGraphPack*)get_output(wbuf, 0); + SceneGraphPack *sgp = (SceneGraphPack*)s->get_input(rbuf, 0); + SceneGraphPack *_sgp = (SceneGraphPack*)s->get_output(wbuf, 0); //int screen_width = get_param(0); //int screen_height = get_param(1);
--- a/TaskManager/Test/test_render/viewer.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Fri Oct 02 23:20:25 2009 +0900 @@ -509,6 +509,9 @@ (uint32)&pixels[(startx-1) + this->width*(starty-1)]); task_draw->add_param(this->width); } else { + // 7.7.3 SL1 Data Cache Range Set to Zero コマンド + // を使って、DMAでclearするべき... ということは、 + // それもSPEでやる方が良い? memset(&pixels[(startx-1)+this->width*(starty-1)], 0, (this->width)*sizeof(int)*rangey); break;
--- a/TaskManager/kernel/schedule/SchedTask.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Oct 02 23:20:25 2009 +0900 @@ -321,7 +321,7 @@ { __debug("[SchedTask:%s]\n", __FUNCTION__); - delete p; + // delete p; move to Scheduler return (this->*ex_next)(); }
--- a/TaskManager/kernel/schedule/Scheduler.cc Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Oct 02 23:20:25 2009 +0900 @@ -55,8 +55,6 @@ void Scheduler::run(void) { - SchedTaskBase* taskTmp; - task1 = new SchedNop(); task2 = new SchedNop(); task3 = new SchedNop(); @@ -67,11 +65,11 @@ task3->write(); task2->exec(); task1->read(); + delete task3; - taskTmp = task3; task3 = task2; task2 = task1; - task1 = task1->next(this, taskTmp); + task1 = task1->next(this, 0); } while (task1); delete task3;
--- a/TaskManager/kernel/schedule/Scheduler.h Thu Oct 01 19:28:52 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Fri Oct 02 23:20:25 2009 +0900 @@ -191,7 +191,9 @@ str() {} \ BASE_NEW_DELETE(str) \ -#define SchedDefineTask(str) \ +#define SchedDefineTask(str) SchedDefineTask1(str,run) \ + +#define SchedDefineTask1(str,run) \ static int run(SchedTask *smanager, void *rbuf, void *wbuf); \ extern "C" { \ int runTask_##str(SchedTask *smanager, void *rbuf, void *wbuf) \