Mercurial > hg > Game > Cerium
changeset 1069:19a1769343d6 draft
merge
author | yutaka@localhost.localdomain |
---|---|
date | Fri, 05 Nov 2010 22:43:25 +0900 |
parents | 99ce3a9818b0 (current diff) 54a74800d1a6 (diff) |
children | 262d9367848d |
files | |
diffstat | 18 files changed, 207 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def Fri Nov 05 22:42:26 2010 +0900 +++ b/Renderer/Engine/Makefile.def Fri Nov 05 22:43:25 2010 +0900 @@ -5,7 +5,7 @@ ABIBIT = 32 ABI = -m$(ABIBIT) CC = g++ -OPT = -g #-O9 -DSPE_CREATE_POLYGON_CHECK -DSPE_CREATE_POLYGON=1 +OPT = -g -O9 #-DSPE_CREATE_POLYGON_CHECK -DSPE_CREATE_POLYGON=1 CFLAGS = -Wall $(ABI) $(OPT) # -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Fri Nov 05 22:43:25 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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.h Fri Nov 05 22:43:25 2010 +0900 @@ -0,0 +1,7 @@ +#ifndef INCLUDED_CREATE_POLYGON +#define INCLUDED_CREATE_POLYGON + +#include "SchedTask.h" + + +#endif
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Nov 05 22:43:25 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];
--- a/Renderer/Engine/viewer.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Nov 05 22:43:25 2010 +0900 @@ -634,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); @@ -706,7 +711,6 @@ 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
--- a/TaskManager/Cell/SpeThreads.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/Cell/SpeThreads.cc Fri Nov 05 22:43:25 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; }
--- a/TaskManager/Cell/spe/CellDmaManager.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Fri Nov 05 22:43:25 2010 +0900 @@ -95,9 +95,6 @@ spu_write_out_mbox((uint32)data); } else { MailQueuePtr mail = mail_queue->poll(); - if (0 == mail->data) { - printf("hoge\n"); - } spu_write_out_mbox((uint32)mail->data); mail_queue->free_(mail); mail = mail_queue->create(); @@ -120,7 +117,7 @@ while (!mail_queue->empty()) { MailQueuePtr mail = mail_queue->poll(); - spu_write_out_mbox((uint32)mail->data); + spu_write_out_mbox((uint32)mail->data); mail_queue->free_(mail); }
--- a/TaskManager/Makefile.def Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/Makefile.def Fri Nov 05 22:43:25 2010 +0900 @@ -29,7 +29,7 @@ ABIBIT = 32 -OPT = -g -O9 #-DMAIL_QUEUE +OPT = -g -O9 -DMAIL_QUEUE # -DEARLY_TOUCH # -g -DTASK_LIST_MAIL -O9
--- a/TaskManager/kernel/schedule/SchedNop2Ready.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.cc Fri Nov 05 22:43:25 2010 +0900 @@ -16,8 +16,8 @@ } -SchedTaskBase* -SchedNop2Ready::next(Scheduler *scheduler,SchedTaskBase *p) +void +SchedNop2Ready::write(void) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); @@ -26,5 +26,16 @@ #else scheduler->mail_write((memaddr)MY_SPE_STATUS_READY); #endif - return new SchedMail(); + + } + +SchedTaskBase* +SchedNop2Ready::next(Scheduler *scheduler,SchedTaskBase *p) +{ + __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); + + + return new SchedNop(); + +}
--- a/TaskManager/kernel/schedule/SchedNop2Ready.h Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.h Fri Nov 05 22:43:25 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 };
--- a/TaskManager/kernel/schedule/SchedTask.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Nov 05 22:43:25 2010 +0900 @@ -129,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 が済んでないことがある @@ -149,6 +150,7 @@ memaddr nextList = (memaddr)list->next; if (nextList == 0) { // もう何もする必要がない + return new SchedNop2Ready(scheduler); } else { // 新しいリストに取り掛かる
--- a/TaskManager/kernel/schedule/Scheduler.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Nov 05 22:43:25 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);
--- a/example/HelloWorld/Func.h Fri Nov 05 22:42:26 2010 +0900 +++ b/example/HelloWorld/Func.h Fri Nov 05 22:43:25 2010 +0900 @@ -1,6 +1,6 @@ enum { #include "SysTasks.h" - HELLO_TASK, + Hello, RUN_FINISH, };
--- a/example/HelloWorld/main.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/example/HelloWorld/main.cc Fri Nov 05 22:43:25 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
--- a/example/HelloWorld/ppe/Hello.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/example/HelloWorld/ppe/Hello.cc Fri Nov 05 22:43:25 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);
--- a/example/HelloWorld/ppe/task_init.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/example/HelloWorld/ppe/task_init.cc Fri Nov 05 22:43:25 2010 +0900 @@ -13,5 +13,5 @@ void task_init() { - SchedRegisterTask(HELLO_TASK, Hello); + SchedRegister(Hello); }
--- a/example/dependency_task/Makefile.def Fri Nov 05 22:42:26 2010 +0900 +++ b/example/dependency_task/Makefile.def Fri Nov 05 22:43:25 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
--- a/example/dependency_task/spe/Exec.cc Fri Nov 05 22:42:26 2010 +0900 +++ b/example/dependency_task/spe/Exec.cc Fri Nov 05 22:43:25 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);