Mercurial > hg > Game > Cerium
changeset 1169:b93ff55ba015 draft
free TaskArray rbuf
author | Yutaka_Kinjyo |
---|---|
date | Tue, 31 May 2011 13:57:03 +0900 |
parents | f308a6bd5479 |
children | 693e58f4a672 614562ada648 |
files | Renderer/Engine/Makefile.def Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraph.h Renderer/Test/Makefile.def TaskManager/Makefile.def TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h |
diffstat | 7 files changed, 40 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def Sun May 22 19:31:18 2011 +0900 +++ b/Renderer/Engine/Makefile.def Tue May 31 13:57:03 2011 +0900 @@ -5,8 +5,8 @@ ABIBIT = 64 ABI = -m$(ABIBIT) CC = g++ -#OPT = -g -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT - OPT = -O9 -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT +OPT = -g -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT +# OPT = -O9 -DUSE_TASKARRAY -DUSE_PIPELINE -DUSE_SEGMENT CFLAGS = -Wall $(ABI) $(OPT) # -DDEBUG
--- a/Renderer/Engine/SceneGraph.cc Sun May 22 19:31:18 2011 +0900 +++ b/Renderer/Engine/SceneGraph.cc Tue May 31 13:57:03 2011 +0900 @@ -123,9 +123,9 @@ init(); - this->matrix = (float*)manager->allocate(sizeof(float)*16); - this->real_matrix = (float*)manager->allocate(sizeof(float)*16); - this->texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + matrix = (float*)manager->allocate(sizeof(float)*16); + real_matrix = (float*)manager->allocate(sizeof(float)*16); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); texture_info->texture_id = -1; @@ -144,13 +144,24 @@ /** * orig のコピーとして SceneGraph を生成する */ -SceneGraph::SceneGraph(SceneGraphPtr orig) +SceneGraph::SceneGraph( TaskManager *manager, SceneGraphPtr orig) { init(); memcpy(this, orig, sizeof(SceneGraph)); + matrix = (float*)manager->allocate(sizeof(float)*16); + real_matrix = (float*)manager->allocate(sizeof(float)*16); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + + for (int i = 0; i < 16; i++) { + matrix[i] = orig->matrix[i]; + real_matrix[i] = orig->real_matrix[i]; + } + + memcpy(texture_info, orig->texture_info, sizeof(texture_list)); + // コピーしない //flag_remove = 0; //flag_drawable = 1; @@ -165,7 +176,6 @@ finalize = &SceneGraph::finalize_copy; - frame = 0; } @@ -176,9 +186,9 @@ init(); - this->matrix = (float*)manager->allocate(sizeof(float)*16); - this->real_matrix = (float*)manager->allocate(sizeof(float)*16); - this->texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + matrix = (float*)manager->allocate(sizeof(float)*16); + real_matrix = (float*)manager->allocate(sizeof(float)*16); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); texture_info->texture_id = -1; //size : 頂点の数かな @@ -275,7 +285,7 @@ free(matrix); free(real_matrix); - + free(texture_info); } @@ -734,19 +744,9 @@ */ SceneGraphPtr SceneGraph::clone(TaskManager *manager) { - SceneGraphPtr p = new SceneGraph(this); - - p->matrix = (float*)manager->allocate(sizeof(float)*16); - p->real_matrix = (float*)manager->allocate(sizeof(float)*16); - //これはいらない? - p->texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); - for (int i = 0; i < 16; i++) { - p->matrix[i] = this->matrix[i]; - p->real_matrix[i] = this->real_matrix[i]; - } + SceneGraphPtr p = new SceneGraph(manager, this); - memcpy(p->texture_info, this->texture_info, sizeof(texture_list)); return p; } @@ -758,9 +758,10 @@ * @param buf clone 領域 * @return clone SceneGraph */ + SceneGraphPtr -SceneGraph::clone(void *buf) { - SceneGraphPtr p = new(buf) SceneGraph(this); +SceneGraph::clone(TaskManager *manager, void *buf) { + SceneGraphPtr p = new(buf) SceneGraph(manager, this); return p; }
--- a/Renderer/Engine/SceneGraph.h Sun May 22 19:31:18 2011 +0900 +++ b/Renderer/Engine/SceneGraph.h Tue May 31 13:57:03 2011 +0900 @@ -20,7 +20,7 @@ public: SceneGraph(TaskManager *manager); SceneGraph(TaskManager *manager, xmlNodePtr surface); - SceneGraph(SceneGraphPtr orig); + SceneGraph(TaskManager *manager, SceneGraphPtr orig); ~SceneGraph(void); // add @@ -90,7 +90,7 @@ SceneGraphPtr addChild(SceneGraphPtr child); SceneGraphPtr addBrother(SceneGraphPtr bro); SceneGraphPtr clone(TaskManager *manager); - SceneGraphPtr clone(void *buf); + SceneGraphPtr clone(TaskManager *manager, void *buf); SceneGraphPtr searchSceneGraph(const char *name); void set_move_collision(move_func new_move); void set_move_collision(collision_func new_collision);
--- a/Renderer/Test/Makefile.def Sun May 22 19:31:18 2011 +0900 +++ b/Renderer/Test/Makefile.def Tue May 31 13:57:03 2011 +0900 @@ -4,8 +4,8 @@ ABIBIT = 64 ABI = -m$(ABIBIT) CC = g++ -#CFLAGS = -Wall $(ABI) -g -CFLAGS = -Wall $(ABI) -O9 #-g # -O -DDEBUG +CFLAGS = -Wall $(ABI) -g +#CFLAGS = -Wall $(ABI) -O9 #-g # -O -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I$(CERIUM)/Renderer/Engine -I. -I$(CERIUM)/include/Cerium
--- a/TaskManager/Makefile.def Sun May 22 19:31:18 2011 +0900 +++ b/TaskManager/Makefile.def Tue May 31 13:57:03 2011 +0900 @@ -29,8 +29,8 @@ ABIBIT = 64 -#OPT = -g -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE -OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE +OPT = -g -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE +#OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Sun May 22 19:31:18 2011 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Tue May 31 13:57:03 2011 +0900 @@ -292,6 +292,13 @@ wait_i->free_(p); // p->wait_i, p->wait_me は再利用される } + // TaskArray1 の場合、Task,rbuf共にtasklistに入る。 + // tasklistはどこかでfreeされてるはずなので、メモリリークしない。 + // TaskArray の rbuf はfreeされない見たいなので、ここでfreeしてみる。 + if (me->command == TaskArray) { + free(me->rbuf); + } + // me を誰かが持っていて、me が finish した後に、 // me->wait_for(i) とか、やられると気まずい。 // 特に、me が他人に再利用されていると。そういう時には、
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Sun May 22 19:31:18 2011 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Tue May 31 13:57:03 2011 +0900 @@ -78,6 +78,7 @@ void* allocate(int size, int alignment) { + void *buff = 0; if (size==0) return 0; #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN) @@ -92,6 +93,7 @@ void* allocate(int size) { + void *buff = 0; if (size==0) return 0; #if defined(__SPU__) || ! defined(HAS_POSIX_MEMALIGN)