Mercurial > hg > Members > kono > Cerium
changeset 490:892eff521871
merged..
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Oct 2009 15:33:08 +0900 |
parents | df499063ccda (current diff) a2bf77602343 (diff) |
children | 7cd207691af1 |
files | |
diffstat | 7 files changed, 194 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Makefile Tue Oct 06 15:32:15 2009 +0900 +++ b/TaskManager/Test/test_render/Makefile Tue Oct 06 15:33:08 2009 +0900 @@ -34,7 +34,7 @@ run-ps3: /usr/sbin/ps3-video-mode -v 133 - ./test_nogl -video fb -width 1920 -height 1080 + ./test_nogl -video fb -width 1920 -height 1080 $(CPU) $(SG) run-ps3tv: ./test_nogl -video fb -width 576 -height 384 -bpp 32
--- a/TaskManager/Test/test_render/spe/CreateSpan.cc Tue Oct 06 15:32:15 2009 +0900 +++ b/TaskManager/Test/test_render/spe/CreateSpan.cc Tue Oct 06 15:33:08 2009 +0900 @@ -14,7 +14,7 @@ typedef struct g { SpanPackPtr spack ; SpanPackPtr send_spack ; - int prev_index ; + int prev_index; } G, *Gptr; SchedDefineTask(CreateSpan); @@ -193,6 +193,7 @@ * @param[in] tex_y_len 分割する前の Triangle に貼られている Texture の * 長さの割合 (0 ... 1) */ + static void half_triangle(SchedTask *smanager, Gptr g, SpanPackPtr *spackList, int charge_y_top, int charge_y_end,
--- a/TaskManager/Test/test_render/viewer.cc Tue Oct 06 15:32:15 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Tue Oct 06 15:33:08 2009 +0900 @@ -13,6 +13,8 @@ static void post2runLoop(void *viewer); static void post2runDraw(void *viewer); +static void post2speRendering(void *viewer); +static void post2speDraw(void *viewer); // static void post2speRunLoop(void *viewer); //static void post2runMove(void *viewer); //static void post2exchange_sgroot(void *viewer); @@ -314,17 +316,24 @@ viewer->getKey(); HTaskPtr update_key = viewer->manager->create_task(UPDATE_KEY); update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); - update_key->set_cpu(SPE_0); + update_key->set_cpu(SPE_0); update_key->spawn(); - + /* TASK_MOVE は外から引数で取ってくるべき */ - //HTaskPtr move_task = viewer->manager->create_task(viewer->move_taskid); + //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); HTaskPtr move_task = viewer->manager->create_task(TASK_MOVE); //move_task->add_param(sgroot); - HTaskPtr draw_task = viewer->manager->create_task(TASK_DRAW); + //HTaskPtr draw_task = viewer->manager->create_task(TASK_DRAW); + + /* rendering task test */ + HTaskPtr draw_task = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr draw_dummy = viewer->manager->create_task(TASK_DUMMY); HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH); + viewer->draw_dummy = draw_dummy; + switch_task->wait_for(draw_dummy); + draw_task->set_post(post2speRendering, (void*)viewer); switch_task->wait_for(move_task); switch_task->wait_for(draw_task); @@ -378,9 +387,18 @@ { } +void +post2rendering(void *viewer_) +{ + Viewer *viewer = (Viewer *)viewer_; + HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + viewer->rendering(task_next); +} + void Viewer::rendering(HTaskPtr task_next) { +#if 0 HTaskPtr task_create_pp = manager->create_task(TASK_CREATE_PP2); // SceneGraph(木構造) -> PolygonPack @@ -406,7 +424,7 @@ task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); task_create_sp->add_param(index_start); - + /** * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 * [ 1.. 80] [ 81..160] [161..240] @@ -427,7 +445,10 @@ } task_create_pp->spawn(); - +#else + common_rendering(task_next); +#endif + // Barrier 同期 // run_draw() を呼ぶ post2runDraw task_next->set_post(post2runDraw, (void*)this); // set_post(function(this->run_draw()), NULL) @@ -483,6 +504,7 @@ void Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする { +#if 0 HTaskPtr task_draw; //task_next = manager->create_task(TASK_DUMMY); @@ -532,7 +554,9 @@ } } } - +#else + common_draw(task_next); +#endif task_next->set_post(post2runLoop, (void*)this); // set_post(function(this->run_loop()), NULL) task_next->spawn(); @@ -553,4 +577,148 @@ quit(); } +static void +post2speRendering(void *viewer_) +{ + Viewer *viewer = (Viewer*)viewer_; + HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + viewer->spe_rendering(task_next); +} + +void +Viewer::spe_rendering(HTaskPtr task_next) +{ + common_rendering(task_next); + + this->draw_dummy->wait_for(task_next); + task_next->set_post(post2speDraw, (void*)this); + task_next->spawn(); + +} + +static void +post2speDraw(void *viewer_) +{ + Viewer *viewer = (Viewer*)viewer_; + HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + viewer->spe_draw(task_next); +} + +void +Viewer::spe_draw(HTaskPtr task_next) +{ + common_draw(task_next); + + this->draw_dummy->wait_for(task_next); + task_next->spawn(); + this->draw_dummy->spawn(); + + frames++; +} + +void +Viewer::common_rendering(HTaskPtr task_next) +{ + HTaskPtr task_create_pp = manager->create_task(TASK_CREATE_PP2); + + // SceneGraph(木構造) -> PolygonPack + + task_create_pp->add_param((uint32)sgroot->getDrawSceneGraph()); + task_create_pp->add_param((uint32)ppack); + + task_next->wait_for(task_create_pp); + + int range_base = spe_num; + // 切り上げのつもり + int range = (spackList_length + range_base - 1) / range_base; + + for (int i = 0; i < range_base; i++) { + int index_start = range*i; + int index_end = (index_start + range >= spackList_length) + ? spackList_length : index_start + range; + + HTaskPtr task_create_sp = manager->create_task(TASK_CREATE_SPAN); + task_create_sp->add_inData(ppack, sizeof(PolygonPack)); + task_create_sp->add_inData(spackList_ptr, + sizeof(SpanPack*)*spackList_length_align); + task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); + + task_create_sp->add_param(index_start); + + /** + * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 + * [ 1.. 80] [ 81..160] [161..240] + * [241..320] [321..400] [401..480] + * + * ex. screen_height が 1080, spenum が 5 の場合、 + * [ 1..216] [217..432] [433..648] + * [649..864] [865..1080] + */ + task_create_sp->add_param(index_start*split_screen_h + 1); + task_create_sp->add_param(index_end*split_screen_h); + + task_next->wait_for(task_create_sp); + task_create_sp->wait_for(task_create_pp); + + task_create_sp->set_cpu(SPE_ANY); + task_create_sp->spawn(); + } + + task_create_pp->spawn(); +} + +void +Viewer::common_draw(HTaskPtr task_next) +{ + HTaskPtr task_draw; + + //task_next = manager->create_task(TASK_DUMMY); + //task_next->set_post(post2runLoop, (void*)this); + + ppack->clear(); + for (int i = 0; i < spackList_length; i++) { + SpanPack *spack = &spackList[i]; + int startx = 1; + int endx = split_screen_w; + + int starty = spack->info.y_top - split_screen_h + 1; + //int endy = spack->info.y_top; + int rangey = (starty + split_screen_h - 1 > this->height) + ? this->height - starty + 1 : split_screen_h; + + while (startx < this->width) { + if (spack->info.size > 0) { + // Draw SpanPack + task_draw = manager->create_task(TASK_DRAW_SPAN); + task_draw->add_inData(spack, sizeof(SpanPack)); + + task_draw->add_param( + (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; + } + + task_draw->add_param(startx); + task_draw->add_param(endx); + task_draw->add_param(rangey); + task_draw->set_cpu(SPE_ANY); + task_next->wait_for(task_draw); + task_draw->spawn(); + + startx += split_screen_w; + endx += split_screen_w; + + if (endx > this->width) { + endx = this->width; + } + } + } +} + /* end */
--- a/TaskManager/Test/test_render/viewer.h Tue Oct 06 15:32:15 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.h Tue Oct 06 15:33:08 2009 +0900 @@ -22,6 +22,7 @@ TaskManager *manager; key_stat *keyPtr; + HTaskPtr draw_dummy; /* screen info */ int width; @@ -51,6 +52,11 @@ virtual void run_move(HTaskPtr task_next); virtual void run_collision(); virtual void rendering(HTaskPtr task_next); + virtual void common_draw(HTaskPtr task_next); + virtual void common_rendering(HTaskPtr task_next); + + virtual void spe_rendering(HTaskPtr task_next); + virtual void spe_draw(HTaskPtr task_next); //virtual void exchange_sgroot(TaskManager *manager); void getKey();
--- a/example/HelloWorld/ppe/Hello.h Tue Oct 06 15:32:15 2009 +0900 +++ b/example/HelloWorld/ppe/Hello.h Tue Oct 06 15:33:08 2009 +0900 @@ -1,9 +1,7 @@ #ifndef INCLUDED_TASK_HELLO #define INCLUDED_TASK_HELLO -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif +#include "SchedTask.h" #endif
--- a/example/renew_task/spe/Renew1.cc Tue Oct 06 15:32:15 2009 +0900 +++ b/example/renew_task/spe/Renew1.cc Tue Oct 06 15:33:08 2009 +0900 @@ -13,6 +13,9 @@ profile->ProfStop(); profile->ProfPrint(); + int *test_num = (int *)s->get_input(0); + s->printf("[SPE] test_num = %d\n", *test_num); + s->printf("[SPE] ** running Renew1\n"); s->printf("[SPE] Create Task : Renew2\n");
--- a/example/renew_task/spe/RenewStart.cc Tue Oct 06 15:32:15 2009 +0900 +++ b/example/renew_task/spe/RenewStart.cc Tue Oct 06 15:33:08 2009 +0900 @@ -17,6 +17,12 @@ s->printf("[SPE] Create Task : Renew1\n"); TaskPtr nextTask = s->create_task(RENEW1); + + + int *test_num = (int *)s->allocate(sizeof(int)); + *test_num = 10; + nextTask->add_inData(test_num, sizeof(int)); + s->wait_task(nextTask); s->printf("[SPE] ** finish RenewStart\n\n");