Mercurial > hg > Members > kono > Cerium
diff Renderer/Engine/viewer.cc @ 986:ac437c3cf766 akira
double buffering of spanpack/polgonpack
not yet worked.
author | root@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 01 Oct 2010 03:42:25 +0900 |
parents | e40dd2384357 |
children | 0b6f8c82625a |
line wrap: on
line diff
--- a/Renderer/Engine/viewer.cc Fri Oct 01 02:49:38 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Oct 01 03:42:25 2010 +0900 @@ -20,8 +20,8 @@ static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1); /* measure for FPS (Frame Per Second) */ -int start_time; -int this_time; +static int start_time; +static int this_time; int frames; // static void post2speRunLoop(void *viewer); //static void post2runMove(void *viewer); @@ -31,14 +31,10 @@ //SceneGraphRootPtr sgroot_2; /* Data Pack sent to Other CPUs (ex. SPE) */ -SceneGraphPack *sgpack; -PolygonPack *ppack; -SpanPackPtr spackList; -SpanPackPtr *spackList_ptr; -int spackList_length; -int spackList_length_align; +RederingData r[2]; +int ppi, spi; /** * @@ -117,29 +113,24 @@ for(int i = 0; i < spe_num; i++) { - - HTaskPtr data_load = manager->create_task(DataAllocate); - data_load->set_param(0,(memaddr)size); - data_load->set_param(1,(memaddr)Light); + HTaskPtr data_load = manager->create_task(DataAllocate); + data_load->set_param(0,(memaddr)3); // num of allocate block + data_load->set_param(0,(memaddr)(sizeof(float)*4*light_num)); // 1st allocate size + data_load->set_param(1,(memaddr)Light); // 1st id + data_load->set_param(0,(memaddr)(light_num * sizeof(int))); // 2nd size + data_load->set_param(1,(memaddr)LightSwitch); // 2nd id + data_load->set_param(0,(memaddr)16); // 3rd size + data_load->set_param(1,(memaddr)LightSysSwitch); // 3rd id data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); data_load->spawn(); } - size = light_num * sizeof(int); light_switch = (int*)manager->allocate(size); for (int i = 0; i < light_num; i++) { light_switch[i] = 0; } - for(int i = 0; i < spe_num; i++) { - 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)); - data_load->spawn(); - } - size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング light_sysswitch = (int*)manager->allocate(size); @@ -148,14 +139,6 @@ light_sysswitch[i] = 0; } - for(int i = 0; i < spe_num; i++) { - 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)); - data_load->spawn(); - } - start_time = get_ticks(); this_time = 0; frames = 0; @@ -171,43 +154,43 @@ HTaskPtr task_next; HTaskPtr task_tex; - sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack)); - sgpack->init(); - ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); + for(int i=0;i<2;i++) { + r[i].ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); - spackList_length = (this->height + split_screen_h - 1) / split_screen_h; - spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length); - // printf("spackList %0lx height %d\n",(unsigned long)spackList, this->height); + r[i].spackList_length = (this->height + split_screen_h - 1) / split_screen_h; + r[i].spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*r[i].spackList_length); + // printf("spackList %0lx height %d\n",(unsigned long)r[i].spackList, this->height); - /** - * SPU に送る address list は 16 バイト倍数でないといけない。 - * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような - * length_align を求めている。はみ出した部分は使われない - * (ex) spackList_length が 13 の場合 - * spackList_length_align = 16; - * 実際に送るデータは64バイトになるのでOK - * 14,15,16 の部分は何も入らない。 - */ - spackList_length_align = (spackList_length + 3)&(~3); + /** + * SPU に送る address list は 16 バイト倍数でないといけない。 + * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような + * length_align を求めている。はみ出した部分は使われない + * (ex) spackList_length が 13 の場合 + * spackList_length_align = 16; + * 実際に送るデータは64バイトになるのでOK + * 14,15,16 の部分は何も入らない。 + */ + r[i].spackList_length_align = (r[i].spackList_length + 3)&(~3); - /* 各 SPU が持つ、SpanPack の address list */ - spackList_ptr = - (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align); + /* 各 SPU が持つ、SpanPack の address list */ + r[i].spackList_ptr = + (SpanPack**)manager->allocate(sizeof(SpanPack*)*r[i].spackList_length_align); - for (int i = 0; i < spackList_length; i++) { - spackList_ptr[i] = &spackList[i]; - } + for (int j = 0; i < r[i].spackList_length; i++) { + r[i].spackList_ptr[j] = &r[i].spackList[j]; + } - for (int i = 1; i <= spackList_length; i++) { - spackList[i-1].init(i*split_screen_h); + for (int j = 1; j <= r[i].spackList_length; i++) { + r[i].spackList[j-1].init(j*split_screen_h); + } } task_next = manager->create_task(Dummy,0,0,0,0); // ここは、Iterator を用意するべきだよね - for (int i = 0; i < spe_num; i++) { + for (int j = 0; j < spe_num; j++) { task_tex = manager->create_task(LoadTexture,0,0,0,0); - task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i)); + task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + j)); task_next->wait_for(task_tex); task_tex->spawn(); } @@ -329,10 +312,6 @@ dev->clean_pixels(); pixels = dev->flip_screen(pixels); - for (int i = 1; i <= spackList_length; i++) { - spackList[i-1].reinit(i*split_screen_h); - } - /* ここでGameTaskの終了を待つTaskを生成しておく */ sgroot->wait_game_task = manager->create_task(Dummy,0,0,0,0); sgroot->updateControllerState(); @@ -711,7 +690,7 @@ // SceneGraph(木構造) -> PolygonPack task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); - task_create_pp->set_param(1,(memaddr)ppack); + task_create_pp->set_param(1,(memaddr)r[ppi].ppack); /* GameTaskの終了を待ってからポリゴンを作る */ task_create_pp->wait_for(game_task); @@ -722,12 +701,12 @@ int range_base = spe_num; // 切り上げのつもり - int range = (spackList_length + range_base - 1) / range_base; + int range = (r[spi].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; + int index_end = (index_start + range >= r[spi].spackList_length) + ? r[spi].spackList_length : index_start + range; HTaskPtr task_create_sp = manager->create_task(CreateSpan); @@ -746,10 +725,10 @@ task_create_sp->set_param(1,index_start*split_screen_h + 1); task_create_sp->set_param(2,index_end*split_screen_h); - 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_inData(r[ppi].ppack, sizeof(PolygonPack)); + task_create_sp->add_inData(r[spi].spackList_ptr, + sizeof(SpanPack*)*r[spi].spackList_length_align); + task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack)); task_next->wait_for(task_create_sp); task_create_sp->wait_for(task_create_pp); @@ -799,11 +778,11 @@ data_update_wait->spawn(); } - - ppack->clear(); + ppi ^= 1; + r[ppi].ppack->clear(); - for (int i = 0; i < spackList_length; i++) { - SpanPack *spack = &spackList[i]; + for (int i = 0; i < r[spi].spackList_length; i++) { + SpanPack *spack = &r[spi].spackList[i]; int startx = 1; int endx = split_screen_w; @@ -913,6 +892,11 @@ #endif } + spi ^= 1; + for (int i = 1; i <= r[spi].spackList_length; i++) { + r[spi].spackList[i-1].reinit(i*split_screen_h); + } + if (profile) { if (frames % 50 == 49) {