# HG changeset patch # User koba # Date 1288081790 -32400 # Node ID 295b3c79fb4448e21a02aa4a6e0f6fb8c331497f # Parent c79651141045c12300f416775211d8b52eacd245 game_task keep up with task_array. diff -r c79651141045 -r 295b3c79fb44 Renderer/Engine/SceneGraphRoot.cc --- a/Renderer/Engine/SceneGraphRoot.cc Sun Oct 24 19:00:47 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Tue Oct 26 17:29:50 2010 +0900 @@ -44,17 +44,19 @@ light_sysswitch = 0; for (int i = 0; i < light_num; i++) { - light[i] = new SceneGraph; - light[i]->xyz[0] = 0; - light[i]->xyz[1] = 0; - light[i]->xyz[2] = 0; + light[i] = new SceneGraph; + light[i]->xyz[0] = 0; + light[i]->xyz[1] = 0; + light[i]->xyz[2] = 0; - light_switch[i] = 0; + light_switch[i] = 0; } move_finish_flag = 0; + gtask_array = NULL; + // TODO // 今はとりあえず camera を Root にしています // 今はそれすらもしてません @@ -66,29 +68,33 @@ SceneGraphPtr p = sg_available_list; while (p) { - SceneGraphPtr tmp = p->next; - delete p; - p = tmp; - cnt--; + SceneGraphPtr tmp = p->next; + delete p; + p = tmp; + cnt--; } p = sg_remove_list; while (p) { - SceneGraphPtr tmp = p->next; - delete p; - p = tmp; - cnt--; + SceneGraphPtr tmp = p->next; + delete p; + p = tmp; + cnt--; } free(sg_src); delete camera; int light_num = 4; for (int i = 0; i < light_num; i++) { - delete light[i]; + delete light[i]; } delete iterator; delete controller; + + if (gtask_array != NULL) { + delete gtask_array; + } } /** @@ -119,13 +125,13 @@ SceneGraphPtr last = sg_available_list; if (!last) { - sg_available_list = sg; + sg_available_list = sg; } else { - while (last->next) { - last = last->next; - } - last->next = sg; - sg->prev = last; + while (last->next) { + last = last->next; + } + last->next = sg; + sg->prev = last; } cnt++; @@ -177,15 +183,15 @@ /* XMLのノードを一つずつ解析 */ for (cur=cur->children; cur; cur=cur->next) { - /* 扱うのはsurfaceオンリー */ - if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { - continue; - } - /* ポリゴン(SceneGraph)生成 */ - SceneGraphPtr original = new SceneGraph(manager, cur); - registSceneGraph(original); - SceneGraphPtr clone = createSceneGraph(original->sgid); - node->addChild(clone); + /* 扱うのはsurfaceオンリー */ + if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) { + continue; + } + /* ポリゴン(SceneGraph)生成 */ + SceneGraphPtr original = new SceneGraph(manager, cur); + registSceneGraph(original); + SceneGraphPtr clone = createSceneGraph(original->sgid); + node->addChild(clone); } xmlFreeDoc(doc); } @@ -197,8 +203,8 @@ SceneGraphPtr p; if (id < 0 || id > sg_src_size) { - printf("error: createSceneGraph(int id): id not found.\n"); - return NULL; + printf("error: createSceneGraph(int id): id not found.\n"); + return NULL; } /* オリジナルの SceneGraph */ @@ -226,8 +232,8 @@ int id = getSgid(name); if (id < 0) { - printf("error: createSceneGraph(name): name object not found.\n"); - return NULL; + printf("error: createSceneGraph(name): name object not found.\n"); + return NULL; } /* オリジナルの SceneGraph */ @@ -313,17 +319,17 @@ list = list->next; if(sg_exec_tree != NULL) { - return; + return; } /*removeのflagをもとにtreeを形成*/ /* spe から送り返されてきた property の配列を見て生成する for()*/ /* - 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 する - } + 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 する + } */ @@ -378,21 +384,21 @@ int light_num = 4; for (int i = 0; i < light_num; i++) { - get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); + get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); - light_vector[i*4] = 0.0f; - light_vector[i*4+1] = 0.0f; - light_vector[i*4+2] = 0.0f; - light_vector[i*4+3] = 1.0f; + light_vector[i*4] = 0.0f; + light_vector[i*4+1] = 0.0f; + light_vector[i*4+2] = 0.0f; + light_vector[i*4+3] = 1.0f; - ApplyMatrix(&light_vector[i*4], light[i]->matrix); + ApplyMatrix(&light_vector[i*4], light[i]->matrix); - light_vector[i*4] /= light_vector[i*4+2]; - light_vector[i*4+1] /= light_vector[i*4+2]; + light_vector[i*4] /= light_vector[i*4+2]; + light_vector[i*4+1] /= light_vector[i*4+2]; - /*SIMD演算のため*/ - light_vector[i*4+2] *= -1; - light_vector[i*4+3] *= -1; + /*SIMD演算のため*/ + light_vector[i*4+2] *= -1; + light_vector[i*4+3] *= -1; } @@ -498,17 +504,17 @@ int light_num = 4; for (int i = 0; i < light_num; i++) { - get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); + get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); - light_vector[i*4] = 0.0f; - light_vector[i*4+1] = 0.0f; - light_vector[i*4+2] = 0.0f; - light_vector[i*4+3] = 1.0f; + light_vector[i*4] = 0.0f; + light_vector[i*4+1] = 0.0f; + light_vector[i*4+2] = 0.0f; + light_vector[i*4+3] = 1.0f; - ApplyMatrix(&light_vector[i*4], light[i]->matrix); + ApplyMatrix(&light_vector[i*4], light[i]->matrix); - light_vector[i*4] /= light_vector[i*4+2]; - light_vector[i*4+1] /= light_vector[i*4+2]; + light_vector[i*4] /= light_vector[i*4+2]; + light_vector[i*4+1] /= light_vector[i*4+2]; } @@ -519,7 +525,7 @@ /* ExecMove task の post func として呼んでやる - */ +*/ void SceneGraphRoot::move_finish() { @@ -531,20 +537,20 @@ int light_num = 4; for (int i = 0; i < light_num; i++) { - get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); + get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); - light_vector[i*4] = 0.0f; - light_vector[i*4+1] = 0.0f; - light_vector[i*4+2] = 0.0f; - light_vector[i*4+3] = 1.0f; + light_vector[i*4] = 0.0f; + light_vector[i*4+1] = 0.0f; + light_vector[i*4+2] = 0.0f; + light_vector[i*4+3] = 1.0f; - ApplyMatrix(&light_vector[i*4], light[i]->matrix); + ApplyMatrix(&light_vector[i*4], light[i]->matrix); - light_vector[i*4] /= light_vector[i*4+2]; - light_vector[i*4+1] /= light_vector[i*4+2]; + light_vector[i*4] /= light_vector[i*4+2]; + light_vector[i*4+1] /= light_vector[i*4+2]; - light_vector[i*4+2] *= -1; - light_vector[i*4+3] *= -1; + light_vector[i*4+2] *= -1; + light_vector[i*4+3] *= -1; } //sgchange->viewer->light_xyz_stock = getLightVector(); @@ -648,7 +654,7 @@ SceneGraphRoot::getLight(int id) { - return light[id]; + return light[id]; } @@ -656,38 +662,38 @@ float* SceneGraphRoot::getLightVector() { - return light_vector; + return light_vector; } int* SceneGraphRoot::getLightSwitch() { - return light_switch; + return light_switch; } int SceneGraphRoot::getLightSysSwitch() { - return light_sysswitch; + return light_sysswitch; } void SceneGraphRoot::OnLightSwitch(int id) { - light_switch[id] = 1; + light_switch[id] = 1; } void SceneGraphRoot::OffLightSwitch(int id) { - light_switch[id] = 0; + light_switch[id] = 0; } void SceneGraphRoot::OnLightSysSwitch() { - light_sysswitch = 1; + light_sysswitch = 1; } @@ -695,95 +701,79 @@ SceneGraphRoot::OffLightSysSwitch() { - light_sysswitch = 0; + light_sysswitch = 0; } +void +SceneGraphRoot::task_array_init(int id, int task_num, int param, int inData_num, int outData_num) +{ + gtask_array = new GTaskArray; + gtask_array->init(id, task_num, param, inData_num, outData_num); +} + +void +SceneGraphRoot::create_task_array() +{ + gtask_array->create_task_array(this->tmanager); +} + +void +SceneGraphRoot::task_array_finish() +{ + gtask_array->finish(); +} void SceneGraphRoot::set_game_task(int id, void *property, int size, PostFunction post_func) { - game_task = game_task_array->next_task_array(id, game_task); + gtask_array->next_task_array(id); - game_task->set_inData(0, property, size); - game_task->set_outData(0, property, size); - - /* - HTask *task = sgroot->tmanager->create_task(id); - task->set_cpu(SPE_ANY); - task->set_inData(0, property, size); - task->set_outData(0, property, size); - task->set_post(post_func, (void*)property, 0); - wait_game_task->wait_for(task); - task->spawn(); - */ + gtask_array->game_task->set_inData(0, property, size); + gtask_array->game_task->set_outData(0, property, size); + } void SceneGraphRoot::set_game_task(int id, void *property, void *pad, int size, PostFunction post_func) { - game_task = game_task_array->next_task_array(id, game_task); - - game_task->set_inData(0, property, size); - game_task->set_inData(1, pad, sizeof(Pad)); - game_task->set_outData(0, property, size); + gtask_array->next_task_array(id); - /* - HTask *task = sgroot->tmanager->create_task(id); - task->set_cpu(SPE_ANY); - task->set_inData(0, property, size); - task->set_inData(0, pad, sizeof(Pad)); - task->set_outData(0, property, size); - task->set_post(post_func, (void*)property, 0); - wait_game_task->wait_for(task); - task->spawn(); - */ -} + gtask_array->game_task->set_inData(0, property, size); + gtask_array->game_task->set_inData(1, pad, sizeof(Pad)); + gtask_array->game_task->set_outData(0, property, size); -void -SceneGraphRoot::task_array_init(int id, int task_num, int param, int inData_num, int outData_num) -{ - game_task_array = tmanager->create_task_array(id, task_num, param, inData_num, outData_num); - game_task = 0; -} - -void -SceneGraphRoot::task_array_finish() -{ - game_task_array->spawn_task_array(game_task->next()); - game_task_array->set_cpu(SPE_ANY); - game_task_array->spawn(); } void main_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - int size = node->property_size; - void *e = node->propertyptr; - int move = node->move_id; - PostFunction post_func = node->post_func; - ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; - property->root = node; + int size = node->property_size; + void *e = node->propertyptr; + int move = node->move_id; + PostFunction post_func = node->post_func; + ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; + property->root = node; - SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; + SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; - sgroottmp->set_game_task(move, (void*)e, size, post_func); + sgroottmp->set_game_task(move, (void*)e, size, post_func); } void pad_task_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { - int size = node->property_size; - void *e = node->propertyptr; - int move = node->move_id; - PostFunction post_func = node->post_func; - ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; - property->root = node; + int size = node->property_size; + void *e = node->propertyptr; + int move = node->move_id; + PostFunction post_func = node->post_func; + ObjPropertyPtr property = (ObjPropertyPtr)node->propertyptr; + property->root = node; - SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; - void *pad = (void*)sgroottmp->getController(); + SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; + void *pad = (void*)sgroottmp->getController(); - sgroottmp->set_game_task(move, (void*)e, pad, size, post_func); + sgroottmp->set_game_task(move, (void*)e, pad, size, post_func); } void @@ -799,7 +789,7 @@ void SceneGraphRoot::set_pad_task(SceneGraphPtr node, int move, void *property, int size, - PostFunction post_func) + PostFunction post_func) { node->move = pad_task_move; node->post_func = post_func; diff -r c79651141045 -r 295b3c79fb44 Renderer/Engine/SceneGraphRoot.h --- a/Renderer/Engine/SceneGraphRoot.h Sun Oct 24 19:00:47 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.h Tue Oct 26 17:29:50 2010 +0900 @@ -5,6 +5,7 @@ #include "SceneGraphArray.h" #include "Camera.h" #include "SceneGraphIterator.h" +#include "GTaskArray.h" #include typedef struct { @@ -106,10 +107,10 @@ void OnLightSysSwitch(); void OffLightSysSwitch(); - /* GameTask 生成用 */ - HTaskPtr game_task_array; - TaskPtr game_task; + /* GameTaskArray 生成用 */ + GTaskArrayPtr gtask_array; void task_array_init(int id, int task_num, int param, int inData_num, int outData_num); + void create_task_array(); void task_array_finish(); void set_game_task(int id, void *property, int size, PostFunction post_func); void set_game_task(int id, void *property, void* pad, int size, PostFunction post_func); diff -r c79651141045 -r 295b3c79fb44 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Sun Oct 24 19:00:47 2010 +0900 +++ b/Renderer/Engine/viewer.cc Tue Oct 26 17:29:50 2010 +0900 @@ -313,8 +313,16 @@ pixels = dev->flip_screen(pixels); sgroot->updateControllerState(); - sgroot->allExecute(width, height); - sgroot->task_array_finish(); + + //TaskArray を使うか使わないか + if (sgroot->gtask_array != NULL) { + sgroot->create_task_array(); + sgroot->allExecute(width, height); + sgroot->task_array_finish(); + } else { + sgroot->allExecute(width, height); + } + light_xyz_stock = sgroot->getLightVector(); light_switch_stock = sgroot->getLightSwitch(); light_sysswitch_stock = sgroot->getLightSysSwitch(); @@ -689,8 +697,12 @@ task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); task_create_pp->set_param(1,(memaddr)r[ppi].ppack); - /* GameTaskの終了を待ってからポリゴンを作る */ - task_create_pp->wait_for(sgroot->game_task_array); + + /* GameTask の処理の終了を待ってからポリゴンを作る */ + if (sgroot->gtask_array != NULL) { + HTaskPtr game_task_array = sgroot->gtask_array->get_task_array(); + task_create_pp->wait_for(game_task_array); + } task_next->wait_for(task_create_pp); @@ -788,7 +800,7 @@ int rangey = (starty + split_screen_h - 1 > this->height) ? this->height - starty + 1 : split_screen_h; -#if 0 +#if 1 // mem_flag は spe 側で黒い部分を 0 で埋めるフラグ if(spack->info.size > 0 || mem_flag == 1) { diff -r c79651141045 -r 295b3c79fb44 Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Sun Oct 24 19:00:47 2010 +0900 +++ b/Renderer/Engine/viewer.h Tue Oct 26 17:29:50 2010 +0900 @@ -108,10 +108,6 @@ { sgroot->task_array_init(id, task_num, param, inData_num, outData_num); } - void task_array_finish() - { - sgroot->task_array_finish(); - } void set_game_task(int id, void *property, int size, PostFunction post_func) { sgroot->set_game_task(id, property, size, post_func); @@ -120,9 +116,9 @@ { sgroot->set_game_task(id, property, pad, size, post_func); } - void set_move_task(SceneGraphPtr node, int move_id, void *titlep, int size, PostFunction post_func) + void set_move_task(SceneGraphPtr node, int move, void *titlep, int size, PostFunction post_func) { - sgroot->set_move_task(node, move_id, titlep, size, post_func); + sgroot->set_move_task(node, move, titlep, size, post_func); } void set_pad_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func) {