# HG changeset patch # User Shinji KONO # Date 1254469243 -32400 # Node ID bd5b93d39597581254580e0ca585070f73c5bf9a # Parent 44c0bce54dcfc7c1ce9bbd173baee3272d6bdc58 test_nogl on Mac OS X worked. diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/ChangeLog --- a/TaskManager/ChangeLog Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/ChangeLog Fri Oct 02 16:40:43 2009 +0900 @@ -1,3 +1,27 @@ +2009-10-02 Shinji KONO + + 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 で、MemList/MemHash が TaskManager 側に移ったので、 diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/Func.h --- a/TaskManager/Test/test_render/Func.h Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/Func.h Fri Oct 02 16:40:43 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, diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/ChainMove.cc --- a/TaskManager/Test/test_render/task/ChainMove.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/ChainMove.cc Fri Oct 02 16:40:43 2009 +0900 @@ -1,5 +1,12 @@ #include #include #include "ChainMove.h" -#include "viewer_types.h" + + +SchedDefineTask(ChainMove); +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + return 0; +} diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/CreateSpan.cc --- a/TaskManager/Test/test_render/task/CreateSpan.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreateSpan.cc Fri Oct 02 16:40:43 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, diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/DrawSpan.cc --- a/TaskManager/Test/test_render/task/DrawSpan.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cc Fri Oct 02 16:40:43 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; } diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/DrawSpan.h --- a/TaskManager/Test/test_render/task/DrawSpan.h Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.h Fri Oct 02 16:40:43 2009 +0900 @@ -8,7 +8,7 @@ #include "TileHash.h" #endif -struct g { +static typedef struct { int *linebuf; float *zRow; TileListPtr tileList; @@ -19,26 +19,25 @@ 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; diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/Set_Texture.cc --- a/TaskManager/Test/test_render/task/Set_Texture.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/Set_Texture.cc Fri Oct 02 16:40:43 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); diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/task_init.cc --- a/TaskManager/Test/test_render/task/task_init.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/task_init.cc Fri Oct 02 16:40:43 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); diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/task/update_sgp.cc --- a/TaskManager/Test/test_render/task/update_sgp.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/task/update_sgp.cc Fri Oct 02 16:40:43 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); diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/Test/test_render/viewer.cc --- a/TaskManager/Test/test_render/viewer.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Fri Oct 02 16:40:43 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; diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/kernel/schedule/SchedTask.cc --- a/TaskManager/kernel/schedule/SchedTask.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Oct 02 16:40:43 2009 +0900 @@ -321,7 +321,7 @@ { __debug("[SchedTask:%s]\n", __FUNCTION__); - delete p; + // delete p; move to Scheduler return (this->*ex_next)(); } diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Oct 02 16:40:43 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; diff -r 44c0bce54dcf -r bd5b93d39597 TaskManager/kernel/schedule/Scheduler.h --- a/TaskManager/kernel/schedule/Scheduler.h Thu Oct 01 19:25:25 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Fri Oct 02 16:40:43 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) \