Mercurial > hg > Game > Cerium
changeset 509:9f23e9d4973f draft
Application ander constructing
author | game@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 20 Oct 2009 23:25:22 +0900 |
parents | 823532f263af |
children | eae20c3536ba |
files | TaskManager/Test/test_render/Application.cc TaskManager/Test/test_render/Application.h TaskManager/Test/test_render/Application/Chain.cc TaskManager/Test/test_render/Application/Chain.h TaskManager/Test/test_render/SceneGraphRoot.cc TaskManager/Test/test_render/TODO TaskManager/Test/test_render/spe/ChainCal.cc TaskManager/Test/test_render/spe/ChainInit.cc TaskManager/Test/test_render/viewer.cc TaskManager/kernel/ppe/HTask.h |
diffstat | 10 files changed, 204 insertions(+), 196 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Application.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/Application.cc Tue Oct 20 23:25:22 2009 +0900 @@ -34,7 +34,7 @@ } SceneGraphPtr -Application::scenegraph_factory(void *p, int size) +Application::scenegraph_factory(void *p) { SceneGraphPtr sgptr = p->scenegraph; apply_property(p, sgptr); @@ -43,8 +43,7 @@ } SceneGraphPtr -Application::scenegraph_connector(void *p, int size, SceneGraphPtr sg, - SceneGraphPtr sg_available_list) +Application::scenegraph_connector(void *p, SceneGraphPtr sg) { SceneGraphPtr last = sg_available_list; @@ -97,13 +96,19 @@ { } +SceneGraphPtr +Application::scenegraph_factory(void *p) +{ + return NULL; +} + void -Application::scenegraph_factory(void *p, int size) +Application::scenegraph_connector(void *p, SceneGraphPtr s) { } void -Application::scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list) +Application::property_loop() { }
--- a/TaskManager/Test/test_render/Application.h Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/Application.h Tue Oct 20 23:25:22 2009 +0900 @@ -14,13 +14,16 @@ void *propertyPtr; int property_size; int move_task_id_; + void *sg_available_list; + //void *properties[2]; + //void *property; int move_task_id(); - //void set_move_func(move_func move); - //void set_coll_func(coll_func coll); virtual void apply_property(void *p, SceneGraphPtr sgptr); - virtual void scenegraph_factory(void *p, int size); - virtual void scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list); + virtual SceneGraphPtr scenegraph_factory(void *p); + virtual void scenegraph_connector(void *p, SceneGraphPtr s); + virtual void property_loop(); + virtual void property_ope(SceneGraphPtr sg_available_list) {}; //virtual SceneGraphPtr scenegraph_factory(void *p, int size); //virtual SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list); virtual void init(TaskManager *manager, int w, int h) ;
--- a/TaskManager/Test/test_render/Application/Chain.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/Application/Chain.cc Tue Oct 20 23:25:22 2009 +0900 @@ -6,16 +6,17 @@ #include "TaskManager.h" #include "Func.h" #include "Chain.h" +#include "Application.h" #define FALSE 0 #define TRUE !FALSE #define CHAIN_LEN 50 static double chain_width = 10; - +static void post2propertyLoop(void *chain); /* SceneGraph の property */ -ChainPropertyPtr properties[2]; -ChainPropertyPtr property; +//ChainPropertyPtr c_properties[2]; +//ChainPropertyPtr c_property; //void createSceneGraphFromProperty(ChainPropertyPtr p) ; @@ -64,28 +65,26 @@ #endif void -Chain::chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h) +Chain::chain_switch() { - int id = sg->id; - //ChainPropertyPtr p = (ChainPropertyPtr)sg->propertyptr; HTaskPtr chain_cal; ChainPropertyPtr output; // SceneGraph の切り替えもここでやる if (property == properties[0]) { - property = properties[1]; - output = properties[0]; + property = (ChainPropertyPtr)properties[1]; + output = (ChainPropertyPtr)properties[0]; + }else{ - property = properties[0]; - output = properties[1]; + property = (ChainPropertyPtr)properties[0]; + output = (ChainPropertyPtr)properties[1]; } + chain_cal = manager->create_task(CHAINCAL_TASK); chain_cal->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN); - chain_cal->add_param(id); chain_cal->add_outData(output, sizeof(ChainProperty)*CHAIN_LEN); - chain_cal->set_post(createSceneGraphFromProperty, (void*)id); + chain_cal->set_post(post2propertyLoop, (void *)sg_available_list); chain_cal->spawn(); - } void @@ -117,19 +116,101 @@ sgptr->angle[0] = cp->angle[0]; sgptr->angle[1] = cp->angle[1]; sgptr->angle[2] = cp->angle[2]; + + cp->frame++; + sgptr->frame = cp->frame; +} - sgptr->frame++; +SceneGraphPtr +Chain::scenegraph_factory(void *p) +{ + ChainPropertyPtr cp = (ChainPropertyPtr)p; + SceneGraphPtr sgptr = (SceneGraphPtr)cp->scenegraph; + apply_property(p, sgptr); + + return sgptr; } void -Chain::init(TaskManager *manager, int w, int h) +Chain::scenegraph_connector(void *p, SceneGraphPtr sg) +{ + ChainPropertyPtr cp = (ChainPropertyPtr)p; + SceneGraphPtr last = sg_available_list; + + if (!last) { + sg_available_list = sg; + } else { + while (last->next) { + last = last->next; + } + last->next = sg; + sg->prev = last; + } + + ChainPropertyPtr p_curent = (ChainPropertyPtr)sg->propertyptr; + + // parent_id が 0 , NULL だったらどうすんだ? + // そこで試合終了じゃね? + // if ( p_curent_id->parent_id == 0) return -1; + ChainProperty p_parent = cp[p_curent->parent_id]; + SceneGraphPtr s_parent = (SceneGraphPtr)p_parent.scenegraph; + + /* childrenのリストの最後に加える (brother として)*/ + if (s_parent->lastChild != NULL) { + SceneGraphPtr last_child = s_parent->lastChild; + last_child->brother = sg; + } + + s_parent->lastChild = sg; + + if (s_parent->children == NULL) { + s_parent->children = sg; + } + + sg->parent = s_parent; +} + +int +is_end(ChainPropertyPtr t) +{ + // どうやって終了させよう? + // property の個数を保持する必要がある? + // or for文ではなくて、条件にする + + return 0; +} + +void +Chain::property_loop() +{ + for (ChainPropertyPtr t = &property[0]; is_end(t); t++){ + SceneGraphPtr sg = scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = (void *)sg; // property list には SceneGraphへのポインタが入っている + scenegraph_connector((void *)properties[0], sg); // add する + } +} + +void +post2propertyLoop(void *chain_) +{ + Application *chain = (Application *)chain_; + //chain->property_loop(chain->sg_available_list); + chain->property_loop(); +} + +void +Chain::property_ope(SceneGraphPtr sg_available_list_) +{ + sg_available_list = sg_available_list_; + chain_switch(); +} + +void +Chain::init(TaskManager *manager_, int w, int h) { SceneGraphPtr root_chain, chain; - ChainPropertyPtr rcv; - ChainProperty r; - HTaskPtr chain_init; - - rcv = &r; + ChainProperty r; + manager = manager_; sgroot->createFromXMLfile(manager, "xml_file/chain.xml"); @@ -139,41 +220,31 @@ property = properties[0]; root_chain = sgroot->createSceneGraph(CHAIN); - // set_move_collision()ではだめ -// root_chain->set_move_collision(chain_move_ope, chain_collision); - init_chain_vars(rcv); - rcv->next_x = w / 2; - rcv->next_y = 0.0; - rcv->angle[0] = 0; - rcv->angle[1] = 0; - rcv->angle[2] = 0; + init_chain_vars(&property[0]); + property[0].next_x = w / 2; + property[0].next_y = 0.0; + property[0].angle[0] = 0; + property[0].angle[1] = 0; + property[0].angle[2] = 0; - set_vector(rcv, root_chain); + set_vector(&property[0], root_chain); - for(int i = 0; i < CHAIN_LEN; i++) { + for(int i = 1; i < CHAIN_LEN; i++) { chain = sgroot->createSceneGraph(CHAIN); - property[i].id = i; + property[i].id = i; init_chain_vars(&property[i]); property[i].x = 0; property[i].y = chain_width * i; set_vector(&property[i], chain); - property->angle[1] = -90 * (i % 2); - //chain->set_move_collision(chain_move, chain_collision); - chain->propertyptr = &property[i]; - chain->property_size = sizeof(ChainProperty); + property[i].angle[1] = -90 * (i % 2); + chain->propertyptr = &property[i]; + chain->property_size = sizeof(ChainProperty); root_chain->addChild(chain); - property[i].parent = root_chain; + property[i].parent = root_chain; + property[i].parent_id = 0; } property[0].can_move = FALSE; - // property を SPU の共有領域へコピーする - chain_init = manager->create_task(CHAININIT_TASK); - chain_init->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN); - chain_init->add_param(CHAIN_LEN); - chain_init->set_cpu(SPE_0); - chain_init->set_post(createSceneGraphFromProperty, (void*)property); - chain_init->spawn(); - sgroot->setSceneData(root_chain); }
--- a/TaskManager/Test/test_render/Application/Chain.h Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/Application/Chain.h Tue Oct 20 23:25:22 2009 +0900 @@ -9,23 +9,37 @@ SceneGraphPtr parent; int id; int parent_id; + int frame; + void *scenegraph; } *ChainPropertyPtr, ChainProperty; class Chain : public Application { public: Chain(){} + + ChainPropertyPtr properties[2]; + ChainPropertyPtr property; + SceneGraphPtr sg_available_list; + //void *properties[2]; + //void *property; + + TaskManager *manager; + //SceneGraphPtr scenegraph_factory(void *p, int size); //SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list); // Application virtual func - void scenegraph_factory(void *p, int size) {}; - void scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list) {}; + void property_ope(SceneGraphPtr sg_available_list); + SceneGraphPtr scenegraph_factory(void *p); + void scenegraph_connector(void *p, SceneGraphPtr s); void apply_property(void *p, SceneGraphPtr sgptr); + void property_loop(); + void init(TaskManager *manager, int w, int h); void init_chain_vars(ChainPropertyPtr cv); - void chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h); + void chain_switch(); void chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg); };
--- a/TaskManager/Test/test_render/SceneGraphRoot.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraphRoot.cc Tue Oct 20 23:25:22 2009 +0900 @@ -199,14 +199,13 @@ /*removeのflagをもとにtreeを形成*/ /* spe から送り返されてきた property の配列を見て生成する for()*/ /* - for (Property *t = property[0]; is_end(t); t++){ - SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る - t->scenegraph = s; // property list には SceneGraphへのポインタが入っている - application->scenegraph_connector(property[0], s); // add する - } - */ - - + for (Property *t = (Property*)app->property[0]; is_end(t); t++){ + SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + app->scenegraph_connector(property[0], s); // add する + } + */ + // 現在、allExecute が終わった時点では // camera->children が User SceneGraph の root になる @@ -222,8 +221,6 @@ void SceneGraphRoot::speExecute(int screen_w, int screen_h, Application *app) { - - SceneGraphPtr list = sg_available_list; // SceneGraphPtr t = sg_exec_tree; // SceneGraphPtr cur_parent = camera; @@ -245,27 +242,26 @@ camera->children = NULL; camera->lastChild = NULL; - list->move_execute(screen_w, screen_h); - list->collision_check(screen_w, screen_h, list); - - list->frame++; - list = list->next; if(sg_exec_tree != NULL) { - return; + return; } /*removeのflagをもとにtreeを形成*/ /* spe から送り返されてきた property の配列を見て生成する for()*/ - /* - for (Property *t = property[0]; is_end(t); t++){ - SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る - t->scenegraph = s; // property list には SceneGraphへのポインタが入っている - application->scenegraph_connector(property[0], s); // add する - } + /* Application内に移動 */ + + app->property_ope(sg_available_list); + + /* + for (Property *t = (Property *)properties[0]; is_end(t); t++){ + SceneGraphPtr s = app->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + app->scenegraph_connector(property[0], s); // add する + } */ - - + + // 現在、allExecute が終わった時点では // camera->children が User SceneGraph の root になる
--- a/TaskManager/Test/test_render/TODO Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/TODO Tue Oct 20 23:25:22 2009 +0900 @@ -8,4 +8,22 @@ * lenear array から SceneGraph を再構築する :yutaka * rendering_task と task_next で待ち合わせる :kaito * ダブルバッファリングされている Property、SceneGraph を入れ替える :kaito -* rendering_task と move_task の起動 :kaito \ No newline at end of file +* rendering_task と move_task の起動 :kaito + + +Application:memo + +scenegraph_connector, scenegraph_factory, apply_property を virtual にして Chainに 移動 +(ユーザが定義した property があるので、app 毎に宣言する必要がある?) + +viewer で app を選択して, それを元に speExecute で app を判断させる + +speExecute 内の sg_available_list を辿って factory を行って箇所を Chain に移動 +(Property 型の問題) + + + + + + +
--- a/TaskManager/Test/test_render/spe/ChainCal.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainCal.cc Tue Oct 20 23:25:22 2009 +0900 @@ -30,7 +30,7 @@ static int run(SchedTask *s,void *rbuf, void *wbuf) { - ChainPropertyPtr property = (ChainPropertyPtr)s->get_input(rbuf, 0); + ChainPropertyPtr property = (ChainPropertyPtr)s->get_input(rbuf, 0); ChainPropertyPtr update_property = (ChainPropertyPtr)s->get_output(wbuf, 0); // ChainPropertyPtr property = (ChainPropertyPtr)rbuf;
--- a/TaskManager/Test/test_render/spe/ChainInit.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainInit.cc Tue Oct 20 23:25:22 2009 +0900 @@ -27,6 +27,6 @@ // property は spe 上で allocate している(global) 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/viewer.cc Mon Oct 12 11:27:13 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Tue Oct 20 23:25:22 2009 +0900 @@ -240,24 +240,18 @@ HTaskPtr task_next = initLoop(); // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS)) HTaskPtr init_key_task = manager->create_task(INIT_KEY_TASK); - init_key_task->set_cpu(SPE_0); + init_key_task->set_cpu(SPE_0); init_key_task->spawn(); // SPE に送信する KEY_STATUS の領域確保 key_stat *key = (key_stat*)manager->allocate(sizeof(key_stat)); this->keyPtr = key; - // post2runLoop は旧バージョン用なので post2speRunLoop の様なものを別につくるべき - //task_next->set_post(post2speRunLoop, (void*)this); // set_post(function(this->run_loop()), NULL) - //task_next->spawn(); - // TASK_INIT_TEXTURE が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ - - /* test */ - HTaskPtr task_switch = manager->create_task(TASK_SWITCH); task_switch->wait_for(task_next); task_switch->set_post(post2runMoveDrawLoop, (void*)this); task_switch->spawn(); + task_next->spawn(); } void @@ -314,6 +308,8 @@ //HTaskPtr send_key_task = viewer->manager->create_task(SEND_KEY); //send_key_task->add_param((int)sgroot); // set input data -> viewer keyPtr + + sgroot->updateControllerState(); viewer->getKey(); HTaskPtr update_key = viewer->manager->create_task(UPDATE_KEY); update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); @@ -321,7 +317,13 @@ update_key->spawn(); /* TASK_MOVE は外から引数で取ってくるべき */ - //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); + //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_task_id); + /* + DUMMY1 app->set_task(); + DUMMY2 wait_for(DUMMY1) + sgroot->speExectute(app); + app->property_loop(sg_avairable_list); + */ //HTaskPtr move_task = viewer->manager->create_task(TASK_MOVE); //move_task->add_param(sgroot); HTaskPtr move_task = viewer->manager->create_task(TASK_DUMMY); @@ -344,8 +346,7 @@ draw_task->spawn(); switch_task->set_post(post2runMoveDrawLoop, (void*)viewer); - switch_task->spawn(); - + switch_task->spawn(); } #if 0 @@ -381,7 +382,7 @@ void Viewer::run_move(HTaskPtr task_next) { - sgroot->updateControllerState(); + //sgroot->updateControllerState(); sgroot->speExecute(width, height, app); } @@ -401,56 +402,7 @@ void Viewer::rendering(HTaskPtr task_next) { -#if 0 - 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(); -#else common_rendering(task_next); -#endif // Barrier 同期 // run_draw() を呼ぶ post2runDraw @@ -506,59 +458,7 @@ void Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする { -#if 0 - 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; - } - } - } -#else common_draw(task_next); -#endif task_next->set_post(post2runLoop, (void*)this); // set_post(function(this->run_loop()), NULL) task_next->spawn();