Mercurial > hg > Game > Cerium
diff Renderer/Engine/viewer.cc @ 915:aa9728394194 draft
create_polygon_task ..not worked yet.
author | yutaka@localhost.localdomain |
---|---|
date | Fri, 23 Jul 2010 18:05:40 +0900 |
parents | 6286b3baf744 |
children | e66a08b5cd83 |
line wrap: on
line diff
--- a/Renderer/Engine/viewer.cc Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Jul 23 18:05:40 2010 +0900 @@ -122,7 +122,7 @@ for(int i = 0; i < spe_num; i++) { - HTaskPtr data_load = manager->create_task(DataLoad); + HTaskPtr data_load = manager->create_task(DataAllocate); data_load->set_param(0,(memaddr)size); data_load->set_param(1,(memaddr)Light); data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); @@ -137,7 +137,7 @@ } for(int i = 0; i < spe_num; i++) { - HTaskPtr data_load = manager->create_task(DataLoad); + HTaskPtr data_load = manager->create_task(DataAllocate); data_load->set_param(0,(memaddr)size); data_load->set_param(1,(memaddr)LightSwitch); data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); @@ -153,7 +153,7 @@ } for(int i = 0; i < spe_num; i++) { - HTaskPtr data_load = manager->create_task(DataLoad); + HTaskPtr data_load = manager->create_task(DataAllocate); data_load->set_param(0,(memaddr)size); data_load->set_param(1,(memaddr)LightSysSwitch); data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); @@ -443,17 +443,22 @@ // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。 -void -copy_matrix(SceneGraphPtr sg) { +float* +copy_matrix(SceneGraphPtr sg, TaskManager *manager) { float *matrix = sg->matrix; float *real_matrix = sg->real_matrix; + //変換行列は4x4 なんで、16。が二つで32.と言い訳を書いてみる。 + float *sg_matrix = (float*)manager->allocate(sizeof(float)*32); + for (int i = 0; i < 16; i++) { - sg->sg_matrix[i] = matrix[i]; - sg->sg_matrix[i+16] = real_matrix[i]; + sg_matrix[i] = matrix[i]; + sg_matrix[i+16] = real_matrix[i]; } + return sg_matrix; + } void @@ -470,12 +475,11 @@ MatrixList *matrix_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); - copy_matrix(sg); #if SPE_CREATE_POLYGON_CHECK print_matrix(sg->sg_matrix); #endif - matrix_list->matrix = sg->sg_matrix; + matrix_list->matrix = copy_matrix(sg, manager);; matrix_list->next = NULL; @@ -484,6 +488,7 @@ } info->last = matrix_list; + info->list_length += 1; } @@ -495,6 +500,9 @@ if (info->id == -1) { info->id = sg->sgid; + info->list_length = 1; + info->coord_pack = sg->coord_pack; + info->coord_pack_size = sg->coord_pack_size; next = info; } else { @@ -506,17 +514,21 @@ next = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); next->id = sg->sgid; + next->list_length = 1; + next->coord_pack = sg->coord_pack; + next->coord_pack_size = sg->coord_pack_size; next->next = NULL; t->next = next; } MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); - copy_matrix(sg); - new_list->matrix = sg->sg_matrix; + new_list->matrix = copy_matrix(sg, manager); + #if SPE_CREATE_POLYGON_CHECK print_matrix(sg->sg_matrix); #endif + new_list->next = NULL; next->first = new_list; @@ -528,6 +540,7 @@ collect_matrix(SceneGraphPtr sg, MatrixListInfo *matrix_info, TaskManager *manager) { matrix_info->id = -1; + matrix_info->list_length = 0; matrix_info->next = NULL; matrix_info->first = NULL; matrix_info->last = NULL; @@ -574,7 +587,7 @@ } void -Viewer::check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) { +check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) { for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { for (MatrixList* u = t->first; u != NULL; u = u->next) { @@ -584,32 +597,90 @@ } + void -Viewer::create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next, - MatrixListInfo *matrix_info) +coord_allocate(int &cur_point, float *coord_pack, int spe_num, + int alloc_size, HTaskPtr alloc_wait, TaskManager *manager) +{ + + for (int i = 0; i < spe_num; i++) { + + HTaskPtr data_alloc = manager->create_task(DataAllocate); + //data_alloc->set_inData(0, &coord_pack[cur_point], alloc_size); + data_alloc->set_param(0,(memaddr)alloc_size); + data_alloc->set_param(1,(memaddr)SG_COORD); + data_alloc->set_cpu((CPU_TYPE)((int)SPE_0 + i)); + alloc_wait->wait_for(data_alloc); + data_alloc->spawn(); + + } + + cur_point += alloc_size / sizeof(float); + +} + +void +coord_free(int spe_num, TaskManager *manager, HTaskPtr alloc_wait) +{ + + for (int i = 0; i < spe_num; i++) { + + HTaskPtr data_free = manager->create_task(DataFree); + data_free->set_param(0,(memaddr)SG_COORD); + data_free->set_cpu((CPU_TYPE)((int)SPE_0 + i)); + data_free->wait_for(alloc_wait); + data_free->spawn(); + + } + +} + +void +create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next) { - //HTaskPtr create_pp_wait = manager->create_task(Dummy); - // どれくらい allocate するかわ、よくわからないけど。 - // とりあえず、16k ぐらいにしておく。 - // int sg_size = 16*1024; - -// for (int i = 0; i < spe_num; i++) { - -// HTaskPtr data_load = manager->create_task(DataLoad); -// data_load->set_param(0,(memaddr)sg_size); -// data_load->set_param(1,(memaddr)SG_COORD); -// task_next->wait_for(data_load); -// data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); -// data_load->spawn(); - -// } + MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); + collect_matrix(sg, matrix_info, manager); + + + //HTaskPtr phase_wait = manager->create_task(Dummy); + + for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { + + printf("list_length %d \n", t->list_length); + + int alloc_size = 16*1024; + + if (t->coord_pack_size < alloc_size) { + alloc_size = t->coord_pack_size; + } + + + int division_num = (t->coord_pack_size + alloc_size - 1) / alloc_size; + int phase_num = (division_num + spe_num -1) / spe_num; + int cur_point = 0; - float *cur_coord_pack = sg->coord_pack; - int coord_pack_size = sg->coord_pack_size; + for (int i = 0; i < phase_num; i++) { + + HTaskPtr alloc_wait = manager->create_task(Dummy); + coord_allocate(cur_point, t->coord_pack, spe_num, + alloc_size, alloc_wait, manager); + + + for (MatrixList* u = t->first; u != NULL; u = u->next) { - collect_matrix(sg, matrix_info, manager); + //HTaskPtr free_wait = manager->create_task(Dummy); + + //phase_wait = manager->create_task(Dummy); + + } + coord_free(spe_num, manager, alloc_wait); + alloc_wait->spawn(); + } + } + + printf("-----------------------\n"); //return create_pp_wait; } @@ -622,8 +693,7 @@ SceneGraphPtr sg = sgroot->getDrawSceneGraph(); - MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); - create_pp_task(sg, manager, spe_num, task_next, matrix_info); + create_pp_task(sg, manager, spe_num, task_next); #if SPE_CREATE_POLYGON_CHECK check_matrix(matrix_info,sg);