Mercurial > hg > Game > Cerium
changeset 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 | deed1449a5f4 |
files | Renderer/Engine/RenderingTasks.h Renderer/Engine/matrix.h Renderer/Engine/polygon.h Renderer/Engine/spe/DataAllocate.cc Renderer/Engine/spe/DataAllocate.h Renderer/Engine/spe/DataFree.cc Renderer/Engine/spe/DataFree.h Renderer/Engine/spe/DataLoad.cc Renderer/Engine/spe/DataLoad.h Renderer/Engine/spe/spe-main.cc Renderer/Engine/task/DataAllocate.cc Renderer/Engine/task/DataAllocate.h Renderer/Engine/task/DataFree.cc Renderer/Engine/task/DataFree.h Renderer/Engine/task/DataLoad.cc Renderer/Engine/task/DataLoad.h Renderer/Engine/task/task_init.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h |
diffstat | 19 files changed, 251 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/RenderingTasks.h Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/RenderingTasks.h Fri Jul 23 18:05:40 2010 +0900 @@ -2,8 +2,9 @@ SDL_INIT, FINISH, - DataLoad, + DataAllocate, DataUpdate, + DataFree, Create_SGP, Update_SGP,
--- a/Renderer/Engine/matrix.h Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/matrix.h Fri Jul 23 18:05:40 2010 +0900 @@ -2,7 +2,6 @@ #define INCLUDED_MATRIX struct MatrixList { - float *matrix; MatrixList *next; @@ -10,6 +9,9 @@ struct MatrixListInfo { int id; + float *coord_pack; + int coord_pack_size; + int list_length; MatrixList *first; MatrixList *last; MatrixListInfo *next;
--- a/Renderer/Engine/polygon.h Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/polygon.h Fri Jul 23 18:05:40 2010 +0900 @@ -15,7 +15,6 @@ //float *data; //"vertex" and "normal" and "texture" int coord_pack_size; - float sg_matrix[32]; float *coord_pack; //coord_xyz(4*3*size), coord_tex(4*3*size), normal(4*3*size), float *coord_xyz; // vertex coordinate array
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/DataAllocate.cc Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <string.h> +#include "DataAllocate.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(DataAllocate); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + + void *idata = s->get_input(rbuf, 0); + long size = (long)s->get_param(0); + long load_id = (long)s->get_param(1); + + void *buff = s->global_alloc(load_id, size); + + if (idata != NULL) { + memcpy(buff,idata,size); + } + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/DataAllocate.h Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_ALLOCATE +#define INCLUDED_TASK_ALLOCATE + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/DataFree.cc Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <string.h> +#include "DataFree.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(DataFree); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + + long load_id = (long)s->get_param(0); + + //printf("size %d",sizeof(float)*length); + + s->global_free(load_id); + + //MemList *ml = s->createMemList(length,length); + //s->global_set(load_id, (void *)ml); + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/DataFree.h Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_FREE +#define INCLUDED_TASK_FREE + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif
--- a/Renderer/Engine/spe/DataLoad.cc Thu Jul 22 00:23:37 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "DataLoad.h" -#include "Func.h" - -/* これは必須 */ -SchedDefineTask(DataLoad); - -static int -run(SchedTask *s, void *rbuf, void *wbuf) -{ - - long size = (long)s->get_param(0); - long load_id = (long)s->get_param(1); - - s->global_alloc(load_id, size); - - return 0; -} -
--- a/Renderer/Engine/spe/DataLoad.h Thu Jul 22 00:23:37 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_LOAD -#define INCLUDED_TASK_LOAD - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif
--- a/Renderer/Engine/spe/spe-main.cc Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/spe/spe-main.cc Fri Jul 23 18:05:40 2010 +0900 @@ -1,8 +1,9 @@ #include "../Func.h" #include "SchedTask.h" -SchedExternTask(DataLoad); +SchedExternTask(DataAllocate); SchedExternTask(DataUpdate); +SchedExternTask(DataFree); SchedExternTask(LoadTexture); SchedExternTask(DrawSpan); @@ -30,8 +31,9 @@ task_init(Scheduler *s) { - SchedRegister( DataLoad); + SchedRegister( DataAllocate); SchedRegister( DataUpdate); + SchedRegister( DataFree); SchedRegister( LoadTexture); SchedRegister( DrawSpan);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/DataAllocate.cc Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <string.h> +#include "DataAllocate.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(DataAllocate); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + + long size = (long)s->get_param(0); + long load_id = (long)s->get_param(1); + + //printf("size %d",sizeof(float)*length); + + s->global_alloc(load_id, size); + + //MemList *ml = s->createMemList(length,length); + //s->global_set(load_id, (void *)ml); + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/DataAllocate.h Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_ALLOCATE +#define INCLUDED_TASK_ALLOCATE + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/DataFree.cc Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <string.h> +#include "DataFree.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(DataFree); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + + long load_id = (long)s->get_param(0); + + //printf("size %d",sizeof(float)*length); + + s->global_free(load_id); + + //MemList *ml = s->createMemList(length,length); + //s->global_set(load_id, (void *)ml); + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/task/DataFree.h Fri Jul 23 18:05:40 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_FREE +#define INCLUDED_TASK_FREE + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif
--- a/Renderer/Engine/task/DataLoad.cc Thu Jul 22 00:23:37 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "DataLoad.h" -#include "Func.h" - -/* これは必須 */ -SchedDefineTask(DataLoad); - -static int -run(SchedTask *s, void *rbuf, void *wbuf) -{ - - long size = (long)s->get_param(0); - long load_id = (long)s->get_param(1); - - //printf("size %d",sizeof(float)*length); - - s->global_alloc(load_id, size); - - //MemList *ml = s->createMemList(length,length); - //s->global_set(load_id, (void *)ml); - - return 0; -} -
--- a/Renderer/Engine/task/DataLoad.h Thu Jul 22 00:23:37 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_LOAD -#define INCLUDED_TASK_LOAD - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif
--- a/Renderer/Engine/task/task_init.cc Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/task/task_init.cc Fri Jul 23 18:05:40 2010 +0900 @@ -1,8 +1,9 @@ #include "../Func.h" #include "Scheduler.h" -SchedExternTask(DataLoad); +SchedExternTask(DataAllocate); SchedExternTask(DataUpdate); +SchedExternTask(DataFree); SchedExternTask(Create_SGP); SchedExternTask(Update_SGP); @@ -41,8 +42,9 @@ void task_initialize() { - SchedRegister( DataLoad); + SchedRegister( DataAllocate); SchedRegister( DataUpdate); + SchedRegister( DataFree); SchedRegister( Create_SGP); SchedRegister( Update_SGP);
--- 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);
--- a/Renderer/Engine/viewer.h Thu Jul 22 00:23:37 2010 +0900 +++ b/Renderer/Engine/viewer.h Fri Jul 23 18:05:40 2010 +0900 @@ -74,10 +74,6 @@ void common_draw(HTaskPtr task_next); void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot); - void create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next, - MatrixListInfo *matrix_info); - void check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg); - void spe_rendering(HTaskPtr task_next); void spe_draw(HTaskPtr task_next); // void exchange_sgroot(TaskManager *manager);