changeset 1032:8892d0ea7985

merge
author Yutaka_Kinjyo
date Tue, 16 Nov 2010 14:59:28 +0900
parents 7fafe412c28f (diff) cda812a1a66b (current diff)
children a0faa0cfc271
files
diffstat 24 files changed, 300 insertions(+), 148 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -8,7 +8,7 @@
 #include "polygon_pack.h"
 #include "scene_graph_pack.h"
 
-SchedDefineTask(CreatePolygonFromSceneGraph);
+SchedDefineTask1(CreatePolygonFromSceneGraph, createPolygonFromSceneGraph);
 
 #define SG_PACK_LOAD 10
 #define SG_NODE_LOAD 11
@@ -50,20 +50,61 @@
 }
 
 static int 
-run(SchedTask *smanager, void *rbuf, void *wbuf)
+createPolygonFromSceneGraph(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);
+    float *coord_xyz   = (float*)smanager->get_input(rbuf, 0);
+    float *coord_tex   = (float*)smanager->get_input(rbuf, 1);
+    float *normal      = (float*)smanager->get_input(rbuf, 2);
+    float *matrix      = (float*)smanager->get_input(rbuf, 3);
+    float *real_matrix = (float*)smanager->get_input(rbuf, 4);
+    uint32 *pixels     = (uint32*)smanager->get_input(rbuf, 5);
+
+    int sg_size   = (int)smanager->get_param(0);
+    int width     = (int)smanager->get_param(1);
+    int height    = (int)smanager->get_param(2);
+    int scale_max = (int)smanager->get_param(3);
+
+    // triangle を書き戻す
+    //TrianglePackPtr triangle = (TrianglePackPtr)smanager->get_output(wbuf, 0);
+
+    PolygonPackPtr pp
+	= (PolygonPackPtr)smanager->allocate(sizeof(PolygonPack));
+    PolygonPackPtr send_pp
+	= (PolygonPackPtr)smanager->allocate(sizeof(PolygonPack));
+    PolygonPackPtr pp_addr = (PolygonPackPtr)smanager->get_param(1);
+    PolygonPackPtr tmp_pp;
+
 
-    for (int i = 0; i < sg->size; i += 3) {
+    for (int i = 0; i < sg_size; i += 3) {
+      if (pp->info.size >= MAX_SIZE_TRIANGLE) {
+	PolygonPackPtr next;
+	
+	smanager->mainMem_alloc(0, sizeof(PolygonPack));
+	smanager->mainMem_wait();
+	next = (PolygonPackPtr)smanager->mainMem_get(0);
+	
+	pp->next = next;
+	
+	tmp_pp = pp;
+	pp = send_pp;
+	send_pp = tmp_pp;
+	
+	smanager->dma_wait(PP_STORE);
+	smanager->dma_store(send_pp, (memaddr)pp_addr,
+			    sizeof(PolygonPack), PP_STORE);
+	
+	pp_addr = next;
+	
+	smanager->dma_wait(PP_LOAD);
+	smanager->dma_load(pp, (memaddr)pp_addr,
+			   sizeof(PolygonPack), PP_LOAD);
+	smanager->dma_wait(PP_LOAD);
+	pp->init();
+      }
       
       xyz1[0] = coord_xyz[(i+0)*3];
       xyz1[1] = coord_xyz[(i+0)*3+1];
@@ -92,6 +133,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];
@@ -110,20 +153,20 @@
       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[0] = normal[(i+0)*3];
+      normal1[1] = normal[(i+0)*3+1];
+      normal1[2] = 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[0] = normal[(i+1)*3];
+      normal2[1] = normal[(i+1)*3+1];
+      normal2[2] = 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[0] = normal[(i+2)*3];
+      normal3[1] = normal[(i+2)*3+1];
       normal3[2] = normal[(i+2)*3+2]*-1.0f;
       //normal3[3] = 1.0f;
       normal3[3] = 0.0f;
@@ -153,10 +196,18 @@
       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;
+      triangle->tex_info.addr   = pixels;
+      triangle->tex_info.width  = width;
+      triangle->tex_info.height = height;
+      triangle->tex_info.scale_max = scale_max;
     }
+    smanager->dma_wait(PP_STORE);
+    smanager->dma_store(pp, (memaddr)pp_addr,
+			sizeof(PolygonPack), PP_STORE);
+    smanager->dma_wait(PP_STORE);
+
+    free(pp);
+    free(send_pp);
+
     return 0;
 }
--- a/Renderer/Engine/spe/Makefile	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/spe/Makefile	Tue Nov 16 14:59:28 2010 +0900
@@ -5,7 +5,8 @@
 TOP = ../$(CERIUM)
 
 SRCS_TMP = $(wildcard *.cc)
-#SRCS_EXCLUDE = CreatePolygon.cc
+SRCS_EXCLUDE = CreatePolygonFromSceneGraph.cc #CreatePolygon.cc 
+#SRCS_EXCLUDE = CreatePolygon.cc 
 SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
 OBJS = $(SRCS:.cc=.o)
 
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -186,9 +186,13 @@
 		//normal3[3] = 1.0f;
                 normal3[3] = 0.0f;
 
-                ApplyNormalMatrix(normal1,sg->real_matrix);
-                ApplyNormalMatrix(normal2,sg->real_matrix);
-                ApplyNormalMatrix(normal3,sg->real_matrix);
+                //ApplyNormalMatrix(normal1,sg->real_matrix);
+                //ApplyNormalMatrix(normal2,sg->real_matrix);
+                //ApplyNormalMatrix(normal3,sg->real_matrix);
+
+		ApplyMatrix(normal1,sg->real_matrix);
+		ApplyMatrix(normal2,sg->real_matrix);
+		ApplyMatrix(normal3,sg->real_matrix);
 
                 normal1[0] /= normal1[2];
                 normal1[1] /= normal1[2];
--- a/Renderer/Engine/task/DrawSpan.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/task/DrawSpan.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -199,7 +199,8 @@
 
 
     /*完全に透けているか判断, 法線ベクトルが奥を向いてるかどうか*/
-    int flag = (alpha != 0 && normal_z < 0);
+    //int flag = (alpha != 0 && normal_z < 0);
+    int flag = (alpha != 0);
 
     //printf("light_sysswitch %d\n",light_sysswitch);
 
--- a/Renderer/Engine/viewer.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -627,12 +627,43 @@
 
 }
 
-void
-create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next)
+/* flag_drawable な Scenegraph の総数を求める */
+int
+sg_drawable_num(SceneGraphPtr scenegraph)
 {
+  SceneGraphPtr sg = scenegraph;
 
-  MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
-  collect_matrix(sg, matrix_info, manager);
+  int sg_count = 0;
+  while (sg) {
+    if (sg->flag_drawable) {
+      sg_count++;
+    }
+    if (sg->children != NULL) {
+      sg = sg->children;
+    } else if (sg->brother != NULL) {
+      sg = sg->brother;
+    } else {
+      while (sg) {
+	if (sg->brother != NULL) {
+	  sg = sg->brother;
+	  break;
+	} else {
+	  if (sg->parent == NULL) {
+	    sg = NULL;
+	    break;
+	  } else {
+	    sg = sg->parent;
+	  }
+	}
+      }
+    }  
+  }
+  return sg_count;
+}
+
+void
+create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next, SceneGraphRootPtr sgroot)
+{
 
   /*
    * SceneGraph を辿って coord_xyz, coord_tex, normal, matrix, real_matrix 及び、
@@ -640,46 +671,76 @@
    * 
    */
 
-  //HTaskPtr phase_wait = manager->create_task(Dummy);
-
-  for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
+  int sg_num = sg_drawable_num(sg);
+  int sg_division = sg_num / spe_num;
+  int residue = sg_num % spe_num;
 
-    printf("list_length %d \n", t->list_length);
+  HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num);
+  Task **pptask = (Task**)manager->allocate(sizeof(Task*)*spe_num);
+  
+  for (int k = 0; k < spe_num-1; k++) {
+    task_array[k] = manager->create_task_array(CreatePolygonFromSceneGraph,sg_division,4,6,1);
+    pptask[k] = 0;
+  }
+  
+  task_array[spe_num] = manager->create_task_array(CreatePolygonFromSceneGraph,
+						   sg_division+residue,4,6,1);
+  pptask[spe_num] = 0;
 
-    int alloc_size = 16*1024;
+  int k = 0;
 
-    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;
-
-    for (int i = 0; i < phase_num; i++) {
+  while (sg) {
+    if (sg->flag_drawable) {
+      if(k < spe_num * sg_division) {
+	k %= spe_num-1;
+      } else {
+	k = spe_num;
+      }
+      pptask[k] = task_array[k]->next_task_array(CreatePolygonFromSceneGraph,pptask[k]);
+      pptask[k]->set_inData(0, &sg->coord_xyz, sizeof(float)*sg->size/3);
+      pptask[k]->set_inData(1, &sg->coord_tex, sizeof(float)*sg->size/3);
+      pptask[k]->set_inData(2, &sg->normal   , sizeof(float)*sg->size/3);
+      pptask[k]->set_inData(3, &sg->matrix   , sizeof(float)*12);
+      pptask[k]->set_inData(4, &sg->real_matrix, sizeof(float)*8);
+      pptask[k]->set_inData(5, &sg->texture_info.pixels, sizeof(uint32));
+	
+      pptask[k]->set_param(0,(memaddr)sg->size);
+      pptask[k]->set_param(1,(memaddr)sg->texture_info.t_w);
+      pptask[k]->set_param(2,(memaddr)sg->texture_info.t_h);
+      pptask[k]->set_param(3,(memaddr)sg->texture_info.scale_max);
       
-      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) {
-
-	//HTaskPtr free_wait = manager->create_task(Dummy);
-	
-	//phase_wait = manager->create_task(Dummy);
-	
+    }
+    if (sg->children != NULL) {
+      sg = sg->children;
+    } else if (sg->brother != NULL) {
+      sg = sg->brother;
+    } else {
+      while (sg) {
+	if (sg->brother != NULL) {
+	  sg = sg->brother;
+	  break;
+	} else {
+	  if (sg->parent == NULL) {
+	    sg = NULL;
+	    break;
+	  } else {
+	    sg = sg->parent;
+	  }
+	}
       }
-
-      coord_free(spe_num, manager, alloc_wait);
-      alloc_wait->spawn();
     }
+    k++;
   }
-
-  printf("-----------------------\n");
-  //return create_pp_wait;
-
+  for (int k = 0; k < spe_num; k++) {
+    task_array[k]->spawn_task_array(pptask[k]->next());
+    task_array[k]->set_cpu(SPE_ANY);
+    task_array[k]->spawn();
+    if (sgroot->gtask_array != NULL) {
+      HTaskPtr game_task_array = sgroot->gtask_array->get_task_array();
+      task_array[k]->wait_for(game_task_array);
+    }
+    task_next->wait_for(task_array[k]);	
+  }
 }
 
 void
@@ -690,7 +751,7 @@
 
     SceneGraphPtr sg = sgroot->getDrawSceneGraph();
 
-    create_pp_task(sg, manager, spe_num, task_next);
+    create_pp_task(sg, manager, spe_num, task_next, sgroot);
 
 #if SPE_CREATE_POLYGON_CHECK
     check_matrix(matrix_info,sg);
@@ -699,7 +760,8 @@
 
   
 #else
-    
+    //SceneGraphPtr sg = sgroot->getDrawSceneGraph();
+    //printf("sg->size = %lld\n", sg->size);
     HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
     // SceneGraph(木構造) -> PolygonPack
 
--- a/Renderer/Engine/viewerGL.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Engine/viewerGL.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -127,7 +127,8 @@
     glLoadIdentity( );
     
     //正射影
-    glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::near, OPENGL_PARAM::far );
+    //glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::near, OPENGL_PARAM::far );
+    glOrtho( 0.0, width, height, 0.0, OPENGL_PARAM::far, OPENGL_PARAM::near );
     
     glMatrixMode( GL_MODELVIEW );
     glLoadIdentity( );
@@ -145,7 +146,7 @@
     glEnable(GL_ALPHA_TEST);
     glAlphaFunc(GL_GREATER, 0);
     glDepthFunc(GL_LESS);
-    glShadeModel(GL_SMOOTH);
+    //glShadeModel(GL_SMOOTH);
 }
 
 void
@@ -210,16 +211,19 @@
 	  xyz1[0] = sg->coord_xyz[(i+0)*3];
 	  xyz1[1] = sg->coord_xyz[(i+0)*3+1];
 	  xyz1[2] = sg->coord_xyz[(i+0)*3+2]*-1.0f;
+	  //xyz1[2] = sg->coord_xyz[(i+0)*3+2];
 	  xyz1[3] = 1.0f;
 	  
 	  xyz2[0] = sg->coord_xyz[(i+1)*3];
 	  xyz2[1] = sg->coord_xyz[(i+1)*3+1];
 	  xyz2[2] = sg->coord_xyz[(i+1)*3+2]*-1.0f;
+	  //xyz2[2] = sg->coord_xyz[(i+1)*3+2];
 	  xyz2[3] = 1.0f;
 	  
 	  xyz3[0] = sg->coord_xyz[(i+2)*3];
 	  xyz3[1] = sg->coord_xyz[(i+2)*3+1];
 	  xyz3[2] = sg->coord_xyz[(i+2)*3+2]*-1.0f;
+	  //xyz3[2] = sg->coord_xyz[(i+2)*3+2];
 	  xyz3[3] = 1.0f;
 	  
 	  // sg->matrix = 回転行列*透視変換行列
@@ -227,47 +231,42 @@
 	  ApplyMatrix(xyz2, sg->matrix);
 	  ApplyMatrix(xyz3, sg->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];
-	  
+	  	  
 	  tex_xy1[0] = sg->coord_tex[(i+0)*3];
 	  tex_xy1[1] = sg->coord_tex[(i+0)*3+1];
 	  tex_xy2[0] = sg->coord_tex[(i+1)*3];
 	  tex_xy2[1] = sg->coord_tex[(i+1)*3+1];
 	  tex_xy3[0] = sg->coord_tex[(i+2)*3];
 	  tex_xy3[1] = sg->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[2] = sg->normal[(i+0)*3+2];
 	  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[2] = sg->normal[(i+1)*3+2];
 	  normal2[3] = 0.0f;
 	  
 	  normal3[0] = sg->normal[(i+2)*3];
 	  normal3[1] = sg->normal[(i+2)*3+1];
 	  normal3[2] = sg->normal[(i+2)*3+2]*-1.0f;
+	  //normal3[2] = sg->normal[(i+2)*3+2];
 	  normal3[3] = 0.0f;
 	  
-	  ApplyNormalMatrix(normal1,sg->real_matrix);
-	  ApplyNormalMatrix(normal2,sg->real_matrix);
-	  ApplyNormalMatrix(normal3,sg->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];
+	  ApplyMatrix(normal1,sg->real_matrix);
+	  ApplyMatrix(normal2,sg->real_matrix);
+	  ApplyMatrix(normal3,sg->real_matrix);
 	  
 	  obj_draw(xyz1, tex_xy1, normal1);
 	  obj_draw(xyz2, tex_xy2, normal2);
@@ -302,6 +301,8 @@
 void
 ViewerGL::obj_draw(float *xyz, float *tex_xyz, float *normal_xyz)
 {  
+
+
     glTexCoord2f(tex_xyz[0], tex_xyz[1]);
     glVertex3f(xyz[0], xyz[1], xyz[2]);
     glNormal3f(normal_xyz[0], normal_xyz[1], normal_xyz[2]);
--- a/Renderer/Test/Makefile.cell	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Test/Makefile.cell	Tue Nov 16 14:59:28 2010 +0900
@@ -14,7 +14,7 @@
 %.pb.cc: $(PROTODIR)/%.proto
 	$(PROTO) $(PROTOFLAGS) $<
 
-ALL = spe-main ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer SgRootChange property_test create_task property_universe chain_old property_chain aquarium network init_aquarium 
+ALL = spe-main ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer SgRootChange property_test create_task property_universe chain_old property_chain aquarium network init_aquarium
 
 all: $(ALL)
 
--- a/Renderer/Test/Makefile.macosx	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Test/Makefile.macosx	Tue Nov 16 14:59:28 2010 +0900
@@ -13,7 +13,7 @@
 %.pb.cc: $(PROTODIR)/%.proto
 	$(PROTO) $(PROTOFLAGS) $<
 
-ALL =  ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium network init_aquarium test_linda
+ALL =  ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium network init_aquarium test_linda 
 
 oFLAGS=-g -O2
 CFLAGt=-g -O2
@@ -103,6 +103,7 @@
 test_linda : $(TEST_LINDA_OBJ)
 	$(CC) -o $@ $? $(LIBS) $(PROTOLIBS)
 
+
 run: $(TARGET)
 	sudo ./$(TARGET) -width 576 -height 384 -bpp 32
 
--- a/Renderer/Test/ball_bound.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/Renderer/Test/ball_bound.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -81,8 +81,8 @@
 static void
 ball_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h)
 {
-    vy += g * dt;
-    node->xyz[1] += vy * dt;
+  vy += g * dt;
+   node->xyz[1] += vy * dt;
     //    node->xyz[0] += 10.0f;
 }
 
@@ -95,15 +95,15 @@
 ball_collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h,
 			   SceneGraphPtr tree)
 {
-    if (node->xyz[1] > screen_h - ball_radius) {
-		node->xyz[1] = screen_h - ball_radius;
-
-		vy *= e;
-		if (vy > -g && vy < 0) {
-			vy = 0.0;
-			node->set_move_collision(ball_move_idle, ball_collision_idle);
-		}
-    }
+  if (node->xyz[1] > screen_h - ball_radius) {
+  		node->xyz[1] = screen_h - ball_radius;
+  
+  		vy *= e;
+  		if (vy > -g && vy < 0) {
+  			vy = 0.0;
+  			node->set_move_collision(ball_move_idle, ball_collision_idle);
+  		}
+  }
 }
 
 MainLoopPtr 
--- a/SceneGraph/BlenderScript/export_xml.py	Sat Nov 06 22:41:12 2010 +0900
+++ b/SceneGraph/BlenderScript/export_xml.py	Tue Nov 16 14:59:28 2010 +0900
@@ -447,8 +447,8 @@
 def loadTexture(texture):
 	global images, imageCount
 	name = texture.getName()
-	if name in images:
-		return "\t\t<image name=\"" + name + "\"/>\n"	
+	#if name in images:
+	#	return "\t\t<image name=\"" + name + "\"/>\n"	
 	out = "\t\t<image name=\"" + name + "\">\n"
 	imageCount += 1
 	images[name] = imageCount
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SceneGraph/BlenderScript/script_copy.sh	Tue Nov 16 14:59:28 2010 +0900
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+cp $1 /Applications/*blender*/blender.app/Contents/MacOS/.blender/scripts/
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -5,8 +5,6 @@
 
 
 unsigned long long alloc_flag = 0;
-// singleton
-QueueInfo<MailQueue> *MailPool = new QueueInfo<MailQueue>() ;
 
 /**
  * DMA Load
@@ -90,21 +88,22 @@
 void CellDmaManager::mail_write_queue(memaddr data)
 {
     (this->*start_dmawait_profile)();
+
     if (0 != spu_readchcnt(SPU_WrOutMbox)) {
-      if (mail_queue->empty()) {
+      if (mail_queue->count()) {
           spu_write_out_mbox((uint32)data);
       } else {
-	  MailQueuePtr mail = mail_queue->poll();
-	  spu_write_out_mbox((uint32)mail->data);
-	  mail_queue->free_(mail);
-	  mail = mail_queue->create();
-	  mail->data = data;
-	  mail_queue->addLast(mail);
+
+	//mail_queue から poll する
+	spu_write_out_mbox((uint32)mail_queue->recv());
+	//mail_queue に加える
+	mail_queue->send(data);
+
       }
     } else {
-        MailQueuePtr mail = mail_queue->create();
-	mail->data = data;
-	mail_queue->addLast(mail);
+
+      mail_queue->send(data);
+
     }
     (this->*end_dmawait_profile)(&global_mail_time);
 }
@@ -115,31 +114,55 @@
 
     (this->*start_dmawait_profile)();
 
-    while (!mail_queue->empty()) {
-      MailQueuePtr mail = mail_queue->poll();
-      spu_write_out_mbox((uint32)mail->data);      
-      mail_queue->free_(mail);
+    while (mail_queue->count()) {
+
+      spu_write_out_mbox((uint32)mail_queue->recv());      
+
     }
 
     spu_write_out_mbox((uint32)data);
-    //mail_queue.freePool();
 
     (this->*end_dmawait_profile)(&global_mail_time);
+
+
 }
 
 memaddr CellDmaManager::mail_read()
 {
+
+
     (this->*start_dmawait_profile)();
     memaddr data = (memaddr)spu_read_in_mbox();
+    
 #if 0 
     if (ABIBIT>32) {
 	data += (spu_read_in_mbox()<<32);
     }
 #endif
     (this->*end_dmawait_profile)(&global_mail_time);
+
+
+
     return data;
 }
 
+memaddr CellDmaManager::task_list_mail_read()
+{
+
+    unsigned long long wait = 0;
+
+    (this->*start_dmawait_profile)();
+    memaddr data = (memaddr)spu_read_in_mbox();
+    (this->*end_dmawait_profile)(&wait);
+
+    task_list_mail_time += wait;
+    global_mail_time += wait;
+
+    return data;
+}
+
+
+
 void CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask)
 {
     mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length,
@@ -156,7 +179,7 @@
 CellDmaManager::CellDmaManager() 
 {
 
-    mail_queue = new QueueInfo<MailQueue>(MailPool);
+    mail_queue = new MailManager();
     stop_profile();
 }
 void
@@ -166,6 +189,7 @@
     global_mail_time = 0;
     global_wait_time = 0;
     task_array_load_time = 0;
+    task_list_mail_time = 0;
     start_dmawait_profile =  &CellDmaManager::do_start_dmawait_profile;
     end_dmawait_profile =  &CellDmaManager::do_end_dmawait_profile;  
 
@@ -186,8 +210,10 @@
 void
 CellDmaManager::do_start_dmawait_profile()
 {
+
     wait_time = spu_readch(SPU_RdDec); 
     global_busy_time += busy_time - wait_time;
+
     spu_writech(SPU_WrDec, 0xffffffff);
 
     // Measurement of mainMem_alloc
@@ -225,14 +251,21 @@
 	global_busy_time+global_wait_time+global_mail_time
 	))*100.0;
 
+  double t = ((double)task_list_mail_time)/((double)(
+	global_busy_time+global_wait_time+global_mail_time
+	))*100.0;
+
+
   s->printf("spu%d: busy_time = %lld"
   " wait_time = %lld(%.3g%%), "
   " mail_time = %lld(%.3g%%), " 
-  " busy_ratio = %.3g%%"
-  " array_load_time = %lld\n"
+  " task_list_mail_time = %lld(%.3g%%), " 
+  " busy_ratio = %.3g%%, "
+  " array_load_time = %lld, "
   " mainMem_alloc_time = %lld\n"
     ,cpu, global_busy_time,
-    global_wait_time, d, global_mail_time, m, r,
+    global_wait_time, d, global_mail_time, m, 
+    task_list_mail_time, t, r,
     task_array_load_time,
     mainMemalloc_time);
 
@@ -240,6 +273,7 @@
     global_mail_time = 0;
     global_wait_time = 0;
     task_array_load_time = 0;
+    task_list_mail_time = 0;
     mainMemalloc_time = 0;
     alloc_flag = 0;
 }
--- a/TaskManager/Cell/spe/CellDmaManager.h	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.h	Tue Nov 16 14:59:28 2010 +0900
@@ -4,8 +4,7 @@
 #include "base.h"
 #include "types.h"
 #include "DmaManager.h"
-#include "QueueInfo.h"
-#include "MailQueue.h"
+#include "MailManager.h"
 
 #include <spu_mfcio.h>
 #include <spu_intrinsics.h>
@@ -23,7 +22,6 @@
 	uint32 size;
     }  __attribute__ ((aligned (DEFAULT_ALIGNMENT))) DmaList, *DmaListPtr;
 
-    QueueInfo<MailQueue> *mail_queue;
 
     CellDmaManager() ;
 
@@ -31,6 +29,7 @@
     unsigned int wait_time, busy_time, alloc_busy_time;
     unsigned long long global_busy_time, global_wait_time, global_mail_time, mainMemalloc_time;
     unsigned long long task_array_load_time;
+    unsigned long long task_list_mail_time;
 
     /* functions */
     void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
@@ -49,6 +48,7 @@
     void mail_write_queue(memaddr data);
     void mail_write_finish_list(memaddr data);
     memaddr mail_read();
+    memaddr task_list_mail_read();
     void dma_loadList(ListDataPtr list, void *buff, uint32 mask);
     void dma_storeList(ListDataPtr, void *buff, uint32 mask);
 
@@ -59,6 +59,8 @@
     void null_start_dmawait_profile();
     void null_end_dmawait_profile(unsigned long long *counter);
 
+    MailManagerPtr mail_queue;
+
 
 /* end */
 }  ;
--- a/TaskManager/Cell/spe/MailQueue.h	Sat Nov 06 22:41:12 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#ifndef INCLUDED_MAILQUEUE
-#define INCLUDED_MAILQUEUE
-
-class MailQueue {
-public:
-    memaddr data;
-    MailQueue *next; // 4 byte
-    MailQueue *prev; // 4 byte
-    MailQueue *waiter; // 4 byte
-
-    void init() { data = 0; }
-    void initOnce() {}
-    void freeOnce() {}
-
-} ;
-
-typedef MailQueue* MailQueuePtr;
-
-#endif
--- a/TaskManager/Fifo/FifoDmaManager.h	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Tue Nov 16 14:59:28 2010 +0900
@@ -34,6 +34,7 @@
     void mail_write_queue(memaddr data) { mail_queue1->send(data); }
     void mail_write_finish_list(memaddr data) { mail_queue1->send(data); }
     memaddr mail_read() { return mail_queue2->recv(); }
+    memaddr task_list_mail_read() { return mail_queue2->recv(); }
 
     void mail_write_from_host(memaddr data) { mail_queue2->send(data); }
     memaddr mail_read_from_host() { return mail_queue1->recv(); }
--- a/TaskManager/Makefile.cell	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/Makefile.cell	Tue Nov 16 14:59:28 2010 +0900
@@ -17,7 +17,8 @@
     $(CELL_SPE_DIR)/Scheduler.cc\
     $(CELL_SPE_DIR)/SchedNop.cc        \
     $(CELL_SPE_DIR)/MemList.cc        \
-    $(CELL_SPE_DIR)/MemHash.cc        
+    $(CELL_SPE_DIR)/MemHash.cc    \
+    $(CELL_SPE_DIR)/MailManager.cc        
 CELL_SPE_SCHEDULE_OBJ = $(CELL_SPE_SCHEDULE_SRC:.cc=.o)
 
 CELL_SPE_SRCS =  \
@@ -60,7 +61,7 @@
 $(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc kernel/memory/*.cc kernel/ppe/*.cc
 	cp kernel/schedule/*.cc $(CELL_SPE_DIR)/
 	cp kernel/memory/*.cc $(CELL_SPE_DIR)/
-	cp kernel/ppe/{TaskQueue.cc,Task.cc} $(CELL_SPE_DIR)/
+	cp kernel/ppe/{TaskQueue.cc,Task.cc,MailManager.cc} $(CELL_SPE_DIR)/
 
 $(CELL_SPE_OBJS): %.o : %.cc
 	$(SPUCC)  $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
--- a/TaskManager/kernel/schedule/DmaManager.h	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Tue Nov 16 14:59:28 2010 +0900
@@ -35,6 +35,7 @@
     virtual void mail_write_queue(memaddr data) {}
     virtual void mail_write_finish_list(memaddr data) {}
     virtual memaddr mail_read() { return 0; }
+    virtual memaddr task_list_mail_read() { return 0; }
     
     // API for MFC list DMA transfer
     virtual void dma_loadList(ListDataPtr list, void *,uint32 mask) {}
--- a/TaskManager/kernel/schedule/SchedMail.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/kernel/schedule/SchedMail.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -7,7 +7,7 @@
 SchedMail::next(Scheduler *scheduler, SchedTaskBase *p)
 {
     
-    params_addr = scheduler->mail_read();
+   params_addr = scheduler->task_list_mail_read();
 
     __debug("[SchedMail:%s]\n", __FUNCTION__);
 
--- a/TaskManager/kernel/schedule/Scheduler.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -174,6 +174,12 @@
     return connector->mail_read();
 }
 
+memaddr
+Scheduler::task_list_mail_read()
+{
+    return connector->task_list_mail_read();
+}
+
 
 
 /*
--- a/TaskManager/kernel/schedule/Scheduler.h	Sat Nov 06 22:41:12 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.h	Tue Nov 16 14:59:28 2010 +0900
@@ -126,6 +126,7 @@
     void mail_write_queue(memaddr data);
     void mail_write_finish_list(memaddr data);
     memaddr mail_read();
+    memaddr task_list_mail_read();
     void dma_loadList(ListDataPtr list, void *, uint32 mask);
     void dma_storeList(ListDataPtr list, void *, uint32 mask);
 
--- a/example/HelloWorld/spe/Hello.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/example/HelloWorld/spe/Hello.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -3,10 +3,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)
 {
     long task_id = (long)smanager->get_param(0);
 
--- a/example/HelloWorld/spe/spe-main.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/example/HelloWorld/spe/spe-main.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -10,5 +10,5 @@
 void
 task_init(Scheduler *s)
 {
-    SchedRegisterTask(HELLO_TASK, Hello);
+    SchedRegister(Hello);
 }
--- a/example/word_count/main.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/example/word_count/main.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -77,7 +77,7 @@
 static void
 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) 
 {
-  
+ 
   if (task_count < array_task_num) {
     array_task_num = task_count;
     if (task_count<=0) return;
@@ -172,7 +172,7 @@
   
   for (int i = 0; i < task_count; i += array_task_num) {
 
-  HTask *h_exec = 0;
+    HTask *h_exec = 0;
     for (int j = 0; j < array_task_num; j++) {
 	int i = w->task_spwaned++;
 	if (w->size < size) size = w->size;
@@ -183,6 +183,7 @@
 	    h_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
 	    h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size);
 
+
 	    if (all) {
 	      w->t_print->wait_for(h_exec);
 	    } else {
--- a/example/word_count/spe/Exec.cc	Sat Nov 06 22:41:12 2010 +0900
+++ b/example/word_count/spe/Exec.cc	Tue Nov 16 14:59:28 2010 +0900
@@ -17,7 +17,7 @@
     int word_num = 0;
     int line_num = 0;
     int i = 0;
-    
+
     head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A);
     word_num -= 1-head_tail_flag[0];