# HG changeset patch # User yutaka@localhost.localdomain # Date 1288966211 -32400 # Node ID 6a2c22cabe10c42a14eecd123b42253fefbf3388 # Parent e4e96ab3044db62fff9be286d28d69ca63093750# Parent 5418d809dc6aa1fe937fa782c320bb5fde4b487f merge diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/GTaskArray.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/GTaskArray.cc Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,56 @@ +#include "GTaskArray.h" + +GTaskArray::GTaskArray() +{ + game_task_array = NULL; + game_task = NULL; + + task_id = 0; + task_num = 0; + param_num = 0; + inData_num = 0; + outData_num = 0; +} + +GTaskArray::~GTaskArray() +{ + if (game_task_array !=NULL) { + delete game_task_array; + } + if (game_task !=NULL) { + delete game_task; + } +} + +void +GTaskArray::init(int id, int task, int param, int inData, int outData) +{ + game_task = 0; + + task_id = id; + task_num = task; + param_num = param; + inData_num = inData; + outData_num = outData; +} + +void +GTaskArray::create_task_array(TaskManager *manager) +{ + game_task_array = manager->create_task_array(task_id, task_num, param_num, inData_num, outData_num); + game_task = 0; +} + +void +GTaskArray::next_task_array(int id) +{ + game_task = game_task_array->next_task_array(id, game_task); +} + +void +GTaskArray::finish() +{ + game_task_array->spawn_task_array(game_task->next()); + game_task_array->set_cpu(SPE_ANY); + game_task_array->spawn(); +} diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/GTaskArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/GTaskArray.h Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,37 @@ +/** + * ゲームの TaskArray を管理するクラス + * 取りあえず TaskArray 1つでゲームの Task を格納するようにしてみた + * TaskArray って何?って人は Cerium/example/hello_array や word_count を参照 + **/ + +#ifndef INCLUDED_GTASK_ARRAY +#define INCLUDED_GTASK_ARRAY + +#include "TaskManager.h" + +class GTaskArray; + +class GTaskArray { +public: + GTaskArray(void); + ~GTaskArray(void); + + HTaskPtr game_task_array; + TaskPtr game_task; + + int task_id; + int task_num; + int param_num; + int inData_num; + int outData_num; + + void init(int id, int task, int param, int inData, int outData); + void create_task_array(TaskManager *manager); + void next_task_array(int id); + void finish(); + HTaskPtr get_task_array(){return game_task_array;} +}; + +typedef GTaskArray* GTaskArrayPtr; + +#endif diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/Makefile.def diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/SceneGraph.cc --- a/Renderer/Engine/SceneGraph.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Fri Nov 05 23:10:11 2010 +0900 @@ -453,12 +453,20 @@ SDL_Surface *texture_image = IMG_Load(image_name); if (!texture_image) return 0; SDL_Surface *tmpImage - = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, - texture_image->h, 32, redMask, - greenMask, blueMask, alphaMask); + = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_image->w, + texture_image->h, 32, redMask, + greenMask, blueMask, alphaMask); + + //= SDL_CreateRGBSurface(SDL_HWSURFACE, 0, + // 0, 32, redMask, + // greenMask, blueMask, alphaMask); + SDL_Surface *converted; converted = SDL_ConvertSurface(texture_image, tmpImage->format, SDL_HWSURFACE); + + //SDL_SetAlpha(converted, 0, 0); + if (converted != NULL) { SDL_FreeSurface(texture_image); texture_image = converted; diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/SceneGraphRoot.cc --- a/Renderer/Engine/SceneGraphRoot.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Fri Nov 05 23:10:11 2010 +0900 @@ -8,6 +8,7 @@ #include "texture.h" #include "Application.h" + static int cnt = 0; static const int SGLIST_LENGTH = 138; static int sg_src_size = SGLIST_LENGTH ; @@ -41,17 +42,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 にしています // 今はそれすらもしてません @@ -63,29 +66,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; + } } /** @@ -116,13 +123,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++; @@ -174,15 +181,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); } @@ -194,8 +201,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 */ @@ -223,8 +230,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 */ @@ -310,17 +317,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 する + } */ @@ -375,21 +382,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; } @@ -495,17 +502,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]; } @@ -516,7 +523,7 @@ /* ExecMove task の post func として呼んでやる - */ +*/ void SceneGraphRoot::move_finish() { @@ -528,20 +535,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(); @@ -645,7 +652,7 @@ SceneGraphRoot::getLight(int id) { - return light[id]; + return light[id]; } @@ -653,38 +660,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; } @@ -692,65 +699,87 @@ 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) -{ - HTask *task = sgroot->tmanager->create_task(id); - task->set_cpu(SPE_ANY); - task->add_inData(property, size); - task->add_outData(property, size); - task->add_param((memaddr)1); - task->set_post(post_func, (void*)property, 0); - wait_game_task->wait_for(task); - task->spawn(); +{ + gtask_array->next_task_array(id); + + 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) { - HTask *task = sgroot->tmanager->create_task(id); - task->set_cpu(SPE_ANY); - task->add_inData(property, size); - task->add_inData(pad, sizeof(Pad)); - task->add_outData(property, size); - task->set_post(post_func, (void*)property, 0); - wait_game_task->wait_for(task); - task->spawn(); + gtask_array->next_task_array(id); + + 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 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; + 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_; - sgroottmp->set_game_task(move, (void*)e, size, post_func); + SceneGraphRoot *sgroottmp = (SceneGraphRoot*)sgroot_; + + 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; + 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 -SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size, +SceneGraphRoot::set_move_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func) { node->move = main_task_move; @@ -762,7 +791,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 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/SceneGraphRoot.h --- a/Renderer/Engine/SceneGraphRoot.h Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.h Fri Nov 05 23:10:11 2010 +0900 @@ -5,6 +5,7 @@ #include "SceneGraphArray.h" #include "Camera.h" #include "SceneGraphIterator.h" +#include "GTaskArray.h" #include typedef struct { @@ -106,8 +107,11 @@ void OnLightSysSwitch(); void OffLightSysSwitch(); - /* GameTask 生成用 */ - HTaskPtr wait_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); void set_move_task(SceneGraphPtr node, int move, void *property, int size, PostFunction post_func); diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,162 @@ +/** + * SceneGraph が増えてくると動かなくなるかもしれない。 + * 一応 mainMem とかで動くようになるとは思うけど。 + * だめだったら、そこら辺が怪しいと思うべき + */ + +#include "CreatePolygonFromSceneGraph.h" +#include "polygon_pack.h" +#include "scene_graph_pack.h" + +SchedDefineTask(CreatePolygonFromSceneGraph); + +#define SG_PACK_LOAD 10 +#define SG_NODE_LOAD 11 +#define PP_LOAD 12 +#define PP_STORE 13 + +/** + * ベクトルに行列を乗算する + * @param[out] v vector (float[4]) + * @param[in] m matrix (float[16]) + */ +static void +ApplyMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + t[3] = v[3]; + + for (int i = 0; i < 4; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12]; + } +} + +static void +ApplyNormalMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + + for (int i = 0; i < 3; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8]; + } +} + +static int +run(SchedTask *smanager, void *rbuf, void *wbuf) +{ + float xyz1[4], xyz2[4], xyz3[4]; + float normal1[4],normal2[4],normal3[4]; + + //coord_xyz, coord_tex, normal, matrix, real_matrix を受け取る + float *coord_xyz = (float)smanager->get_inData(0); + float *coord_tex = (float)smanager->get_inData(1); + float *normal = (float)smanager->get_inData(2); + float *matrix = (float)smanager->get_inData(3); + float *real_matrix = (float)smanager->get_inData(4); + TrianglePackPtr triangle = (TrianglePackPtr)smanager->get_inData(5); + + for (int i = 0; i < sg->size; i += 3) { + + xyz1[0] = coord_xyz[(i+0)*3]; + xyz1[1] = coord_xyz[(i+0)*3+1]; + xyz1[2] = coord_xyz[(i+0)*3+2]*-1.0f; + xyz1[3] = 1.0f; + + xyz2[0] = coord_xyz[(i+1)*3]; + xyz2[1] = coord_xyz[(i+1)*3+1]; + xyz2[2] = coord_xyz[(i+1)*3+2]*-1.0f; + xyz2[3] = 1.0f; + + xyz3[0] = coord_xyz[(i+2)*3]; + xyz3[1] = coord_xyz[(i+2)*3+1]; + xyz3[2] = coord_xyz[(i+2)*3+2]*-1.0f; + xyz3[3] = 1.0f; + + // matrix = 回転行列*透視変換行列 + ApplyMatrix(xyz1, matrix); + ApplyMatrix(xyz2, matrix); + ApplyMatrix(xyz3, matrix); + + xyz1[0] /= xyz1[2]; + xyz1[1] /= xyz1[2]; + xyz2[0] /= xyz2[2]; + xyz2[1] /= xyz2[2]; + xyz3[0] /= xyz3[2]; + xyz3[1] /= xyz3[2]; + + triangle->ver1.x = xyz1[0]; + triangle->ver1.y = xyz1[1]; + triangle->ver1.z = xyz1[2]; + triangle->ver1.tex_x = coord_tex[(i+0)*3]; + triangle->ver1.tex_y = coord_tex[(i+0)*3+1]; + + triangle->ver2.x = xyz2[0]; + triangle->ver2.y = xyz2[1]; + triangle->ver2.z = xyz2[2]; + triangle->ver2.tex_x = coord_tex[(i+1)*3]; + triangle->ver2.tex_y = coord_tex[(i+1)*3+1]; + + triangle->ver3.x = xyz3[0]; + triangle->ver3.y = xyz3[1]; + triangle->ver3.z = xyz3[2]; + triangle->ver3.tex_x = coord_tex[(i+2)*3]; + triangle->ver3.tex_y = coord_tex[(i+2)*3+1]; + + normal1[0] = sg->normal[(i+0)*3]; + normal1[1] = sg->normal[(i+0)*3+1]; + normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; + //normal1[3] = 1.0f; + normal1[3] = 0.0f; + + normal2[0] = sg->normal[(i+1)*3]; + normal2[1] = sg->normal[(i+1)*3+1]; + normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; + //normal2[3] = 1.0f; + normal2[3] = 0.0f; + + normal3[0] = sg->normal[(i+2)*3]; + normal3[1] = sg->normal[(i+2)*3+1]; + normal3[2] = normal[(i+2)*3+2]*-1.0f; + //normal3[3] = 1.0f; + normal3[3] = 0.0f; + + ApplyNormalMatrix(normal1,real_matrix); + ApplyNormalMatrix(normal2,real_matrix); + ApplyNormalMatrix(normal3,real_matrix); + + normal1[0] /= normal1[2]; + normal1[1] /= normal1[2]; + + normal2[0] /= normal2[2]; + normal2[1] /= normal2[2]; + + normal3[0] /= normal3[2]; + normal3[1] /= normal3[2]; + + triangle->normal1.x = normal1[0]; + triangle->normal1.y = normal1[1]; + triangle->normal1.z = normal1[2]; + + triangle->normal2.x = normal2[0]; + triangle->normal2.y = normal2[1]; + triangle->normal2.z = normal2[2]; + + triangle->normal3.x = normal3[0]; + triangle->normal3.y = normal3[1]; + triangle->normal3.z = normal3[2]; + + triangle->tex_info.addr = sg->texture_info.pixels; + triangle->tex_info.width = sg->texture_info.t_w; + triangle->tex_info.height = sg->texture_info.t_h; + triangle->tex_info.scale_max = sg->texture_info.scale_max; + } + return 0; +} diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/spe/CreatePolygonFromSceneGraph.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.h Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,7 @@ +#ifndef INCLUDED_CREATE_POLYGON +#define INCLUDED_CREATE_POLYGON + +#include "SchedTask.h" + + +#endif diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/spe/DrawSpan.cc --- a/Renderer/Engine/spe/DrawSpan.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Fri Nov 05 23:10:11 2010 +0900 @@ -216,14 +216,15 @@ int world_x, int world_y, float world_z, SchedTask *smanager) { - int color = get_rgb(tex_x, tex_y, tile); + uint32 color = get_rgb(tex_x, tex_y, tile); /*下位4bitを抽出*/ #if LITTLEENDIAN int alpha = color & 0x000000ff; #else int alpha = color & 0xff000000; #endif - /*完全に透けているか判断*/ + + //完全に透けているか判断 int flag = (alpha != 0 && normal_z < 0); int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch); //smanager->printf("sys %d\n",light_sysswitch); @@ -235,11 +236,9 @@ } g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag); - int *point = &g->linebuf[localy][localx] ; + int *point = &g->linebuf[localy][localx]; *point = color*flag + *point *(1-flag); - - } /** @@ -514,7 +513,6 @@ } - G g0; Gptr g = &g0; @@ -566,13 +564,13 @@ span = &spack->span[t]; if (span->length_x != 1) { - drawLine1( - smanager, g, + drawLine1( + smanager, g, span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); } else { - drawDot1( - smanager, g, - span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + drawDot1( + smanager, g, + span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); } next_span = span; diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/task/CreatePolygonFromSceneGraph.cc --- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Nov 05 23:10:11 2010 +0900 @@ -120,7 +120,6 @@ pp->init(); } - TrianglePack *triangle = &pp->tri[pp->info.size++]; xyz1[0] = sg->coord_xyz[(i+0)*3]; xyz1[1] = sg->coord_xyz[(i+0)*3+1]; @@ -149,6 +148,8 @@ xyz3[0] /= xyz3[2]; xyz3[1] /= xyz3[2]; + TrianglePack *triangle = &pp->tri[pp->info.size++]; + triangle->ver1.x = xyz1[0]; triangle->ver1.y = xyz1[1]; triangle->ver1.z = xyz1[2]; diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/task/DataAllocate.cc --- a/Renderer/Engine/task/DataAllocate.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/task/DataAllocate.cc Fri Nov 05 23:10:11 2010 +0900 @@ -10,7 +10,7 @@ run(SchedTask *s, void *rbuf, void *wbuf) { - int count = (int)s->get_param(0); + int count = (long)s->get_param(0); for(int i=0;iget_input(rbuf, i); long size = (long)s->get_param(i*2+1); diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Nov 05 23:10:11 2010 +0900 @@ -34,7 +34,7 @@ RederingData r[2]; -int ppi, spi; +int ppi, spi = 0; /** * @@ -99,7 +99,6 @@ sgroot = new SceneGraphRoot(this->width, this->height); sgroot->tmanager = manager; - int light_num = 4; int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4) int light_size = size / sizeof(float); @@ -293,7 +292,7 @@ { HTaskPtr task_next = initLoop(); - task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) + task_next->set_post(&post2runLoop, (void *)this, (void*)pixels); // set_post(function(this->run_loop()), NULL) task_next->spawn(); } @@ -311,12 +310,20 @@ } dev->clean_pixels(); + pixels = dev->flip_screen(pixels); - /* ここでGameTaskの終了を待つTaskを生成しておく */ - sgroot->wait_game_task = manager->create_task(Dummy,0,0,0,0); sgroot->updateControllerState(); - sgroot->allExecute(width, height); + + //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(); @@ -357,6 +364,8 @@ static void post2runLoop(SchedTask *s, void *viewer_, void *arg) { + + Viewer *viewer = (Viewer*)viewer_; HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); viewer->run_loop(task_next); @@ -377,7 +386,7 @@ { common_draw(task_next); - task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) + task_next->set_post(post2runLoop, (void*)this, (void*)pixels); // set_post(function(this->run_loop()), NULL) task_next->spawn(); // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ @@ -625,6 +634,11 @@ MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); collect_matrix(sg, matrix_info, manager); + /* + * SceneGraph を辿って coord_xyz, coord_tex, normal, matrix, real_matrix 及び、 + * PolygonPack の TrianglePack (空) を送る。pp->info.size の計算もここで。 + * + */ //HTaskPtr phase_wait = manager->create_task(Dummy); @@ -687,14 +701,16 @@ #else HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); - HTaskPtr game_task = sgroot->wait_game_task; // SceneGraph(木構造) -> PolygonPack 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(game_task); + /* 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); #endif @@ -739,7 +755,6 @@ } task_create_pp->spawn(); - game_task->spawn(); } @@ -901,7 +916,7 @@ if (profile) { if (frames % 50 == 49) { - manager->show_profile(); + manager->show_profile(); this_time = get_ticks(); if (this_time != start_time) { printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time))); diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/viewer.h Fri Nov 05 23:10:11 2010 +0900 @@ -104,6 +104,10 @@ // void setSceneData(SceneGraph *g); virtual void mainLoop(); + void task_array_init(int id, int task_num, int param, int inData_num, int outData_num) + { + sgroot->task_array_init(id, task_num, param, inData_num, outData_num); + } void set_game_task(int id, void *property, int size, PostFunction post_func) { sgroot->set_game_task(id, property, size, post_func); @@ -112,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) { diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Engine/viewerSDL.cc --- a/Renderer/Engine/viewerSDL.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Engine/viewerSDL.cc Fri Nov 05 23:10:11 2010 +0900 @@ -2,6 +2,7 @@ #include "Func.h" #include "TaskManager.h" #include "viewer_types.h" +#include "fb.h" #define UGA 1 @@ -12,12 +13,50 @@ ViewerSDL::ViewerSDL() {} ViewerSDL::~ViewerSDL() {} +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + Uint32 * ViewerSDL::video_init(TaskManager *manager, int bpp, int width, int height) { + +#if defined(__linux__) + + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + + // 読み書き用にファイルを開く + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + // 固定スクリーン情報取得 + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } + + // 変動スクリーン情報取得 + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + + close(fd_framebuffer); + + width = vinfo.xres; + height = vinfo.yres; + bpp = vinfo.bits_per_pixel; + +#endif + Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; Uint32 *p; - + if (SDL_Init(sdl_flag) < 0) { fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); @@ -25,20 +64,16 @@ screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE); if (screen == NULL) { - fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); + fprintf(stderr, "Couldn't set SDL mode: %s\n", SDL_GetError()); SDL_Quit(); exit(1); } + this->width = screen->w; this->height = screen->h; this->bpp = screen->format->BitsPerPixel; p = (Uint32*)manager->allocate(screen->pitch*height); - bitmap = SDL_CreateRGBSurfaceFrom((void *)p, - screen->w, screen->h, - screen->format->BitsPerPixel, - screen->pitch, - redMask, greenMask, blueMask, alphaMask); return p; } @@ -47,25 +82,38 @@ ViewerSDL::clean_pixels() { //bzero(pixels, sizeof(int)*width*height); - SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); + + //SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); } void ViewerSDL::clear_screen() { + #if !UGA SDL_BlitSurface(bitmap, NULL, screen, NULL); SDL_UpdateRect(screen, 0, 0, 0, 0); #endif + } uint32_t * ViewerSDL::flip_screen(uint32_t *old) { #if UGA + + bitmap = SDL_CreateRGBSurfaceFrom((void *)old, + screen->w, screen->h, + screen->format->BitsPerPixel, + screen->pitch, + //redMask, greenMask, blueMask, alphaMask); + redMask, greenMask, blueMask, 0); + SDL_BlitSurface(bitmap,NULL,screen,NULL); SDL_UpdateRect(screen,0,0,0,0); + #endif + return old; } diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Test/aquarium.cc --- a/Renderer/Test/aquarium.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Test/aquarium.cc Fri Nov 05 23:10:11 2010 +0900 @@ -32,10 +32,13 @@ return new aquarium(); } +/* static void null_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { } +*/ + static void null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { diff -r 5418d809dc6a -r 6a2c22cabe10 Renderer/Test/network.cc --- a/Renderer/Test/network.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/Renderer/Test/network.cc Fri Nov 05 23:10:11 2010 +0900 @@ -32,10 +32,13 @@ return new NetworkGame(); } +/* static void null_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { } +*/ + static void null_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree) { diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Cell/SpeThreads.cc --- a/TaskManager/Cell/SpeThreads.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Cell/SpeThreads.cc Fri Nov 05 23:10:11 2010 +0900 @@ -127,7 +127,7 @@ * does not work. */ if (spe_out_mbox_status(spe_ctx[speid]) >= 1) { - return spe_out_mbox_read(spe_ctx[speid], (unsigned int*)ret, count*(sizeof(memaddr)/sizeof(int))); + return spe_out_mbox_read(spe_ctx[speid], (unsigned int*)ret, count*(sizeof(memaddr)/sizeof(int))); } else { return 0; } diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Cell/spe/CellDmaManager.cc --- a/TaskManager/Cell/spe/CellDmaManager.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Fri Nov 05 23:10:11 2010 +0900 @@ -4,6 +4,10 @@ #include "Scheduler.h" +unsigned long long alloc_flag = 0; +// singleton +QueueInfo *MailPool = new QueueInfo() ; + /** * DMA Load * @@ -80,6 +84,49 @@ (this->*end_dmawait_profile)(&global_mail_time); } +// mail を queue にしたみた。mailの書き出しの待ちあるのかわからないけど +//TASK_LIST_MAIL は仕事が最後に溜まってしまうけど、MailQueueなら出来る時にmailを書き出す +//ので多少は効果あるといいな。 +void CellDmaManager::mail_write_queue(memaddr data) +{ + (this->*start_dmawait_profile)(); + if (0 != spu_readchcnt(SPU_WrOutMbox)) { + if (mail_queue->empty()) { + spu_write_out_mbox((uint32)data); + } else { + MailQueuePtr mail = mail_queue->poll(); + spu_write_out_mbox((uint32)mail->data); + mail_queue->free_(mail); + mail = mail_queue->create(); + mail->data = data; + mail_queue->addLast(mail); + } + } else { + MailQueuePtr mail = mail_queue->create(); + mail->data = data; + mail_queue->addLast(mail); + } + (this->*end_dmawait_profile)(&global_mail_time); +} + +// tasklist おわりに、MailQueue 全部を書き出す +void CellDmaManager::mail_write_finish_list(memaddr data) +{ + + (this->*start_dmawait_profile)(); + + while (!mail_queue->empty()) { + MailQueuePtr mail = mail_queue->poll(); + spu_write_out_mbox((uint32)mail->data); + mail_queue->free_(mail); + } + + spu_write_out_mbox((uint32)data); + //mail_queue.freePool(); + + (this->*end_dmawait_profile)(&global_mail_time); +} + memaddr CellDmaManager::mail_read() { (this->*start_dmawait_profile)(); @@ -108,9 +155,10 @@ CellDmaManager::CellDmaManager() { + + mail_queue = new QueueInfo(MailPool); stop_profile(); } - void CellDmaManager::start_profile() { @@ -141,6 +189,9 @@ wait_time = spu_readch(SPU_RdDec); global_busy_time += busy_time - wait_time; spu_writech(SPU_WrDec, 0xffffffff); + + // Measurement of mainMem_alloc + mainMemalloc_time += (alloc_busy_time - wait_time)*alloc_flag; } @@ -151,6 +202,8 @@ *counter += 0xffffffff - wait_time; busy_time = wait_time; + // Measurement of mainMem_alloc + alloc_busy_time = wait_time; } void CellDmaManager::null_start_dmawait_profile() {} @@ -177,15 +230,18 @@ " mail_time = %lld(%.3g%%), " " busy_ratio = %.3g%%" " array_load_time = %lld\n" + " mainMem_alloc_time = %lld\n" ,cpu, global_busy_time, global_wait_time, d, global_mail_time, m, r, - task_array_load_time); + task_array_load_time, + mainMemalloc_time); global_busy_time = 0; global_mail_time = 0; global_wait_time = 0; task_array_load_time = 0; - + mainMemalloc_time = 0; + alloc_flag = 0; } diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Cell/spe/CellDmaManager.h --- a/TaskManager/Cell/spe/CellDmaManager.h Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Fri Nov 05 23:10:11 2010 +0900 @@ -4,8 +4,11 @@ #include "base.h" #include "types.h" #include "DmaManager.h" +#include "QueueInfo.h" +#include "MailQueue.h" #include +#include #define SPU_PROFILE 1 @@ -20,12 +23,13 @@ uint32 size; } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) DmaList, *DmaListPtr; + QueueInfo *mail_queue; CellDmaManager() ; /* variables */ - unsigned int wait_time, busy_time; - unsigned long long global_busy_time, global_wait_time, global_mail_time; + unsigned int wait_time, busy_time, alloc_busy_time; + unsigned long long global_busy_time, global_wait_time, global_mail_time, mainMemalloc_time; unsigned long long task_array_load_time; /* functions */ @@ -42,6 +46,8 @@ void show_dma_wait(Scheduler *s, int cpu); void mail_write(memaddr data); + void mail_write_queue(memaddr data); + void mail_write_finish_list(memaddr data); memaddr mail_read(); void dma_loadList(ListDataPtr list, void *buff, uint32 mask); void dma_storeList(ListDataPtr, void *buff, uint32 mask); diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Cell/spe/CellScheduler.cc --- a/TaskManager/Cell/spe/CellScheduler.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Cell/spe/CellScheduler.cc Fri Nov 05 23:10:11 2010 +0900 @@ -6,6 +6,7 @@ // ユーザプログラムで定義 // なんだけど、それは微妙じゃね? extern void task_init(Scheduler *scheduler); +extern unsigned long long alloc_flag; void CellScheduler::init_impl() @@ -30,6 +31,9 @@ CellScheduler::mainMem_alloc(int id, int size) { mainMemList[id] = (memaddr)NULL; + + // flag on. (unsigned long long) + alloc_flag = 1; mainMemNum++; mail_write((memaddr)MY_SPE_COMMAND_MALLOC); diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Cell/spe/MailQueue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/MailQueue.h Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,19 @@ +#ifndef INCLUDED_MAILQUEUE +#define INCLUDED_MAILQUEUE + +class MailQueue { +public: + memaddr data; + MailQueue *next; // 4 byte + MailQueue *prev; // 4 byte + MailQueue *waiter; // 4 byte + + void init() { data = 0; } + void initOnce() {} + void freeOnce() {} + +} ; + +typedef MailQueue* MailQueuePtr; + +#endif diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Fifo/FifoDmaManager.h --- a/TaskManager/Fifo/FifoDmaManager.h Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.h Fri Nov 05 23:10:11 2010 +0900 @@ -31,6 +31,8 @@ void dma_wait(uint32 mask) ; void mail_write(memaddr data) { mail_queue1->send(data); } + void mail_write_queue(memaddr data) { mail_queue1->send(data); } + void mail_write_finish_list(memaddr data) { mail_queue1->send(data); } memaddr mail_read() { return mail_queue2->recv(); } void mail_write_from_host(memaddr data) { mail_queue2->send(data); } diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/Makefile.def --- a/TaskManager/Makefile.def Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/Makefile.def Fri Nov 05 23:10:11 2010 +0900 @@ -29,7 +29,7 @@ ABIBIT = 32 -OPT = -g -O9 +OPT = -g -O9 -DMAIL_QUEUE # -DEARLY_TOUCH # -g -DTASK_LIST_MAIL -O9 diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/DmaManager.h --- a/TaskManager/kernel/schedule/DmaManager.h Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/DmaManager.h Fri Nov 05 23:10:11 2010 +0900 @@ -32,6 +32,8 @@ // API for SPU inbound/outbound mailbox virtual void mail_write(memaddr data) {} + virtual void mail_write_queue(memaddr data) {} + virtual void mail_write_finish_list(memaddr data) {} virtual memaddr mail_read() { return 0; } // API for MFC list DMA transfer diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/SchedNop2Ready.cc --- a/TaskManager/kernel/schedule/SchedNop2Ready.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.cc Fri Nov 05 23:10:11 2010 +0900 @@ -16,11 +16,26 @@ } +void +SchedNop2Ready::write(void) +{ + __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); + +#ifdef MAIL_QUEUE + scheduler->mail_write_finish_list((memaddr)MY_SPE_STATUS_READY); +#else + scheduler->mail_write((memaddr)MY_SPE_STATUS_READY); +#endif + + +} + SchedTaskBase* SchedNop2Ready::next(Scheduler *scheduler,SchedTaskBase *p) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); + + + return new SchedNop(); - scheduler->mail_write((memaddr)MY_SPE_STATUS_READY); - return new SchedMail(); } diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/SchedNop2Ready.h --- a/TaskManager/kernel/schedule/SchedNop2Ready.h Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.h Fri Nov 05 23:10:11 2010 +0900 @@ -20,11 +20,12 @@ /* functions */ void exec(void); + void write(void); SchedTaskBase* next(Scheduler *, SchedTaskBase *); #if DEBUG void read(void) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); } - void write(void) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); } + //void write(void) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); } #endif }; diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/SchedTask.cc --- a/TaskManager/kernel/schedule/SchedTask.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Nov 05 23:10:11 2010 +0900 @@ -109,9 +109,15 @@ #ifdef TASK_LIST_MAIL if (!(cur_index < list->length) ) scheduler->mail_write(waiter); + +#else + +#ifdef MAIL_QUEUE + scheduler->mail_write_queue(waiter); #else scheduler->mail_write(waiter); #endif +#endif } SchedTaskBase* @@ -123,6 +129,7 @@ // Task List が残っているので、次を準備 TaskPtr nextTask = &list->tasks[cur_index]; + SchedTask *nextSched = new SchedTask(); nextSched->init(list, nextTask, cur_index+1, scheduler, this->tag^1); // この時点で、TaskList は down load が済んでないことがある @@ -143,6 +150,7 @@ memaddr nextList = (memaddr)list->next; if (nextList == 0) { // もう何もする必要がない + return new SchedNop2Ready(scheduler); } else { // 新しいリストに取り掛かる diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/SchedTaskArrayNop.cc --- a/TaskManager/kernel/schedule/SchedTaskArrayNop.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskArrayNop.cc Fri Nov 05 23:10:11 2010 +0900 @@ -54,7 +54,8 @@ void SchedTaskArrayNop::write() { - savedTask ->write(); + savedTask->write(); + free(atask); delete savedTask; savedTask = 0; diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Nov 05 23:10:11 2010 +0900 @@ -75,14 +75,15 @@ // main loop do { - task3->write(); task1->read(); task2->exec(); + task3->write(); delete task3; task3 = task2; task2 = task1; + //SchedMailの場合、Mailの待ちが入る task1 = task1->next(this, 0); } while (task1); @@ -155,6 +156,18 @@ connector->mail_write(data); } +void +Scheduler::mail_write_queue(memaddr data) +{ + connector->mail_write_queue(data); +} + +void +Scheduler::mail_write_finish_list(memaddr data) +{ + connector->mail_write_finish_list(data); +} + memaddr Scheduler::mail_read() { diff -r 5418d809dc6a -r 6a2c22cabe10 TaskManager/kernel/schedule/Scheduler.h --- a/TaskManager/kernel/schedule/Scheduler.h Sat Oct 02 04:16:23 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Fri Nov 05 23:10:11 2010 +0900 @@ -123,6 +123,8 @@ void show_dma_wait() { connector->show_dma_wait(this, id); }; void start_profile() { connector->start_profile(); }; void mail_write(memaddr data); + void mail_write_queue(memaddr data); + void mail_write_finish_list(memaddr data); memaddr mail_read(); void dma_loadList(ListDataPtr list, void *, uint32 mask); void dma_storeList(ListDataPtr list, void *, uint32 mask); diff -r 5418d809dc6a -r 6a2c22cabe10 example/HelloWorld/Func.h --- a/example/HelloWorld/Func.h Sat Oct 02 04:16:23 2010 +0900 +++ b/example/HelloWorld/Func.h Fri Nov 05 23:10:11 2010 +0900 @@ -1,6 +1,6 @@ enum { #include "SysTasks.h" - HELLO_TASK, + Hello, RUN_FINISH, }; diff -r 5418d809dc6a -r 6a2c22cabe10 example/HelloWorld/main.cc --- a/example/HelloWorld/main.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/HelloWorld/main.cc Fri Nov 05 23:10:11 2010 +0900 @@ -38,7 +38,7 @@ * create_task(Task ID); */ - HTask *hello = manager->create_task(HELLO_TASK); + HTask *hello = manager->create_task(Hello); /** * Select CPU diff -r 5418d809dc6a -r 6a2c22cabe10 example/HelloWorld/ppe/Hello.cc --- a/example/HelloWorld/ppe/Hello.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/HelloWorld/ppe/Hello.cc Fri Nov 05 23:10:11 2010 +0900 @@ -4,10 +4,10 @@ #include "Func.h" /* これは必須 */ -SchedDefineTask(Hello); +SchedDefineTask1(Hello,hello); static int -run(SchedTask *smanager, void *rbuf, void *wbuf) +hello(SchedTask *smanager, void *rbuf, void *wbuf) { int task_id = (long)smanager->get_param(0); diff -r 5418d809dc6a -r 6a2c22cabe10 example/HelloWorld/ppe/task_init.cc --- a/example/HelloWorld/ppe/task_init.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/HelloWorld/ppe/task_init.cc Fri Nov 05 23:10:11 2010 +0900 @@ -13,5 +13,5 @@ void task_init() { - SchedRegisterTask(HELLO_TASK, Hello); + SchedRegister(Hello); } diff -r 5418d809dc6a -r 6a2c22cabe10 example/dependency_task/Makefile.def --- a/example/dependency_task/Makefile.def Sat Oct 02 04:16:23 2010 +0900 +++ b/example/dependency_task/Makefile.def Fri Nov 05 23:10:11 2010 +0900 @@ -10,7 +10,7 @@ ABIBIT=32 CC = g++ -m$(ABIBIT) -CFLAGS = -g -Wall -O9 +CFLAGS = -g -Wall #-O9 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager diff -r 5418d809dc6a -r 6a2c22cabe10 example/dependency_task/spe/Exec.cc --- a/example/dependency_task/spe/Exec.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/dependency_task/spe/Exec.cc Fri Nov 05 23:10:11 2010 +0900 @@ -8,6 +8,7 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { + int *idata = (int*)s->get_input(rbuf, 0); int *odata = (int*)s->get_output(wbuf, 0); int length = (long)s->get_param(0); diff -r 5418d809dc6a -r 6a2c22cabe10 example/hello_array/main.cc --- a/example/hello_array/main.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/hello_array/main.cc Fri Nov 05 23:10:11 2010 +0900 @@ -46,7 +46,7 @@ } twice_main->spawn_task_array(t->next()); twice_main->set_cpu(SPE_ANY); - twice_main->spawn(); + twice_main->spawn(); } int diff -r 5418d809dc6a -r 6a2c22cabe10 example/word_count/main.cc --- a/example/word_count/main.cc Sat Oct 02 04:16:23 2010 +0900 +++ b/example/word_count/main.cc Fri Nov 05 23:10:11 2010 +0900 @@ -296,7 +296,7 @@ printf("task_num %d\n",w->task_num); printf("out_task_num %d\n",w->out_task_num); - /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(8byte)を使用 */ + /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ w->division_out_size = sizeof(unsigned long long)*4; int out_size = w->division_out_size*out_task_num; diff -r 5418d809dc6a -r 6a2c22cabe10 old/sdl_test/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/Makefile Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,11 @@ +all: sdl_test fb_test + +sdl_test: sdl_test.cc + g++ -O9 `sdl-config --libs --cflags` -o sdl_test sdl_test.cc + +fb_test: fb_test.cc + g++ -O9 `sdl-config --libs --cflags` -o fb_test fb_test.cc + +clean: + rm -f sdl_test *.o + rm -f fb_test *.o \ No newline at end of file diff -r 5418d809dc6a -r 6a2c22cabe10 old/sdl_test/fb.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/fb.h Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,33 @@ +#ifndef FB_H +#define FB_H + +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct fb_t { + + char *pixels; + int size; + int width; + int height; + int bpp; + int fd; + +}; + +/* function prototype */ +void send_current_error_msg(const char *ptr); +void send_current_information(const char *ptr); +fb_t get_fbdev_addr(void); + +#endif diff -r 5418d809dc6a -r 6a2c22cabe10 old/sdl_test/fb_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/fb_test.cc Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,181 @@ +#include "fb.h" +#include +using namespace std; + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} + +const int redMask = 0x00ff0000; +const int greenMask = 0x0000ff00; +const int blueMask = 0x000000ff; +const int alphaMask = 0xff000000; + +fb_t +get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } + + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + printf("vinfo.yres %d \n", vinfo.yres); + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + sprintf( tmp , "%d(xoffset)x%d(yoffset)",vinfo.xoffset, vinfo.yoffset); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: 0x%x \n", (unsigned int)fbptr); + + fb_t fb; + fb.pixels = fbptr; + fb.size = screensize; + fb.width = xres; + fb.height = yres; + fb.bpp = vbpp; + fb.fd = fd_framebuffer; + + return fb; + +} + +int main() { + + fb_t fb = get_fbdev_addr(); + + void *p; + Uint32 *gUra; + + gUra = (Uint32*)fb.pixels; + //gUra = (Uint32*)malloc(fb.width*fb.height*4); + + printf("fb.height %d \n", fb.height); + + int i; + int color = 0; + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + //初期化 + if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0) { + printf("SDL_Init failed\n"); + return -1; + } + + printf("fb.width %d fb.height %d fb.bpp %d \n",fb.width, fb.height, fb.bpp); + + SDL_Surface *screen=SDL_SetVideoMode(fb.width,fb.height,fb.bpp,SDL_HWSURFACE); + if (screen == NULL) { + printf("SDL_Surface failed\n"); + SDL_Quit(); + return -1; + } + + int done = 0; + SDL_Event event; + + int fps=0; + + Uint32 t1=SDL_GetTicks(); + + while(!done){ + while(SDL_PollEvent(&event)){ + switch(event.type){ + case SDL_QUIT: + done = 1; + break; + case SDL_KEYDOWN: + if(event.key.keysym.sym == SDLK_ESCAPE){ + done = 1; + } + break; + } + } + + if (color == 0xffffffff) { + color = 0; + } else { + + char r = ((color & redMask) >> 16) + 1; + char g = ((color & greenMask) >> 8) + 1; + char b = (color & blueMask) + 1; + + color = alphaMask + (r << 16) + (g << 8) + b; + + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + if (SDL_GetTicks() < t1 + 1000){ + fps++; + } else{ + printf("fps=%d\n", fps); + fps=0; + t1=SDL_GetTicks(); + } + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = 0; + } + munmap(fb.pixels, fb.size); + close(fb.fd); + SDL_Quit(); + + + return 0; + +} + diff -r 5418d809dc6a -r 6a2c22cabe10 old/sdl_test/sdl_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/sdl_test.cc Fri Nov 05 23:10:11 2010 +0900 @@ -0,0 +1,175 @@ +#include "fb.h" +#include +using namespace std; + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} + + +const int redMask = 0x00ff0000; +const int greenMask = 0x0000ff00; +const int blueMask = 0x000000ff; +const int alphaMask = 0xff000000; + + +fb_t +get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } + + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + printf("vinfo.yres %d \n", vinfo.yres); + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + sprintf( tmp , "%d(xoffset)x%d(yoffset)",vinfo.xoffset, vinfo.yoffset); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + fb_t fb; + fb.size = screensize; + fb.width = xres; + fb.height = yres; + fb.bpp = vbpp; + fb.fd = fd_framebuffer; + + return fb; + +} + +int main() { + + fb_t fb = get_fbdev_addr(); + + close(fb.fd); + + void *p; + Uint32 *gUra; + + //posix_memalign((void**)&gUra, 16, fb.width*fb.height*4); + + gUra = (Uint32*)malloc(fb.width*fb.height*4); + + printf("fb.height %d \n", fb.height); + + int i; + int color = 0x000000ff; + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + //初期化 + if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0) { + printf("SDL_Init failed\n"); + return -1; + } + + printf("fb.width %d fb.height %d fb.bpp %d \n",fb.width, fb.height, fb.bpp); + + SDL_Surface *screen=SDL_SetVideoMode(fb.width,fb.height,fb.bpp,SDL_HWSURFACE); + if (screen == NULL) { + printf("SDL_Surface failed\n"); + SDL_Quit(); + return -1; + } + + int done = 0; + SDL_Event event; + + int fps=0; + + Uint32 t1=SDL_GetTicks(); + + while(!done){ + while(SDL_PollEvent(&event)){ + switch(event.type){ + case SDL_QUIT: + done = 1; + break; + case SDL_KEYDOWN: + if(event.key.keysym.sym == SDLK_ESCAPE){ + done = 1; + } + break; + } + } + + + if (color == 0xffffffff) { + color = 0x000000ff; + } else { + + char r = ((color & redMask) >> 16) + 1; + char g = ((color & greenMask) >> 8) + 1; + char b = (color & blueMask) + 1; + + color = alphaMask + (r << 16) + (g << 8) + b; + + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + //ここに処理を追加して変化を見る + SDL_Surface *bitmap = SDL_CreateRGBSurfaceFrom((void *)gUra,fb.width,fb.height,fb.bpp,fb.width*4,redMask,greenMask,blueMask,0); + SDL_BlitSurface(bitmap,NULL,screen,NULL); + SDL_UpdateRect(screen,0,0,0,0); + + + if (SDL_GetTicks() < t1 + 1000){ + fps++; + } else{ + printf("fps=%d\n", fps); + fps=0; + t1=SDL_GetTicks(); + } + } + + SDL_Quit(); + + return 0; + +} +