changeset 910:9b60b956c8f6

merge
author Yutaka_Kinjyo
date Tue, 20 Jul 2010 04:46:27 +0900
parents 2683838396c6 (diff) 5710e5be29d6 (current diff)
children c15473540c11
files
diffstat 11 files changed, 305 insertions(+), 279 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/Camera.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -148,10 +148,6 @@
 
 #if SPE_CREATE_POLYGON
 
-    sg_matrix = (float*)malloc(sizeof(float)*32);
-    matrix = sg_matrix;
-    real_matrix = sg_matrix + 16;
-
 #endif
 
     for(int i = 0; i < 16; i++) {
--- a/Renderer/Engine/Makefile.def	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/Makefile.def	Tue Jul 20 04:46:27 2010 +0900
@@ -5,7 +5,7 @@
 ABIBIT = 32 
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT	= -g -O9 # -DSPE_CREATE_POLYGON=1
+OPT	= -g -DSPE_CREATE_POLYGON_CHECK -DSPE_CREATE_POLYGON=1
 CFLAGS  = -g -Wall $(ABI) $(OPT)  #  -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- a/Renderer/Engine/RenderingGlobal.h	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/RenderingGlobal.h	Tue Jul 20 04:46:27 2010 +0900
@@ -4,3 +4,7 @@
   Light,
   LightSwitch,
   LightSysSwitch,
+
+/*spe_create_polygon 用*/
+
+  SG_COORD,
--- a/Renderer/Engine/SceneGraph.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -101,14 +101,6 @@
     init();
     finalize = &SceneGraph::finalize_copy;
 
-#if SPE_CREATE_POLYGON
-
-    sg_matrix = (float*)malloc(sizeof(float)*32);
-    matrix = sg_matrix;
-    real_matrix = sg_matrix + 16;
-
-#endif 
-
     this->name = "NULLPO";
 }
 
@@ -117,6 +109,7 @@
  */
 SceneGraph::SceneGraph(SceneGraphPtr orig)
 {
+
     init();
     memcpy(this, orig, sizeof(SceneGraph));
 
@@ -150,35 +143,26 @@
     //texture_info = (texture_list_ptr)manager->allocate(sizeof(texture_list));
     //data = new float[size*3*3];
 
-#if SPE_CREATE_POLYGON
+    for (int i = 0; i < 16; i++) {
+      matrix[i] = 0;
+      real_matrix[i] = 0;
+    }
+
+#if SPE_CREATE_POLYGON_CHECK
 
-    /* CreatePolygon を spe 側でやるために。
-       size は頂点の数。speに渡す場合には、16の倍数にして
-       16Kbyte以上の場合、16Kbyte毎に分割できるようにしなければならない。
-       CreatePolygonFromSceneGraphTaskをspeで動かすために、speに渡すのは 
-       TrianglePackでよい。
-       polygon_pack 1つには triangle が 128 になってる。polygon_pack の
-       triangle 数に合わせる方が楽だよね。なんか変な気もするけど、polygon
-       クラスにもTrianglePackを持たす。SceneGraph は自分の polygon 数が入る
-       分だけ、TrianglePackを持つ。CreatePolygonTask にはSceneGraph 側の
-       TrianglePack を input に、polygon_pack の TriganlePack を output とする
-    */ 
+    for (int i = 0; i < 16; i++) {
+      printf("%f\n",matrix[i]);
+      printf("r %f\n",real_matrix[i]);
+    }
 
-    int tri_pack_size = sizeof(TrianglePack)*(size/3);
-    printf("tri_pack_size %d\n", tri_pack_size);    
-    tri_pack = (TrianglePackPtr)manager->allocate(tri_pack_size);
-    texture_info = (texture_list*)manager->allocate(sizeof(texture_list));
-    sg_matrix = (float*)manager->allocate(sizeof(float)*32);
-    matrix = sg_matrix;
-    real_matrix = sg_matrix + 16;
-
-#else 
+#endif
 
     coord_xyz = (float*)manager->allocate(sizeof(float)*size*3);
     coord_tex = (float*)manager->allocate(sizeof(float)*size*3);
     normal    = (float*)manager->allocate(sizeof(float)*size*3);
 
-#endif
+    coord_pack_size = sizeof(float)*8*size*3;     // coord_pack_vertex size is 32byte. vertex num 3.
+    coord_pack = (float*)manager->allocate(coord_pack_size);
 
     get_data(manager, surface->children);
 
@@ -206,7 +190,7 @@
 
     size = 0;
     //data = NULL;
-
+  
 #if SPE_CREATE_POLYGON
 
     //tri_pack = NULL;
@@ -251,11 +235,10 @@
 
 #if SPE_CREATE_POLYGON
 
-    free(tri_pack);
-    free(sg_matrix);
-    //free(matrix);
-    //free(real_matrix);
-    free(texture_info);
+    free(coord_pack);
+    free(coord_xyz);
+    free(coord_tex);
+    free(normal);
 
 #else 
 
@@ -560,19 +543,6 @@
         texture_id = tex_id;
     }
 
-
-#if SPE_CREATE_POLYGON
-
-    
-      texture_info->t_w = list[texture_id].t_w;
-      texture_info->t_h = list[texture_id].t_h;;
-      texture_info->pixels_orig = list[texture_id].pixels_orig;
-      texture_info->pixels = list[texture_id].pixels;
-      texture_info->scale_max = list[texture_id].scale_max;
-      
-
-#else
-
       // こんなことすると list[] のいみあるのかなーと
       // 微妙に思う、自分で書き換えた感想 by gongo
       texture_info.t_w = list[texture_id].t_w;
@@ -580,8 +550,6 @@
       texture_info.pixels_orig = list[texture_id].pixels_orig;
       texture_info.pixels = list[texture_id].pixels;
       texture_info.scale_max = list[texture_id].scale_max;
-      
-#endif
 
 }
 
--- a/Renderer/Engine/SceneGraphRoot.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -412,7 +412,7 @@
 	    /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
 	    get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
 	    //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
-	    
+
 	} 
 	
 	if (t->children != NULL && c != NULL) {
--- a/Renderer/Engine/polygon.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/polygon.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -190,47 +190,54 @@
 void Polygon::pickup_coordinate(char *cont)
 {
 
-#if SPE_CREATE_POLYGON
-
-    TrianglePackPtr cur = tri_pack;
-
-    for(int n=0; n<size; n+=3)
-    {
-
-        cont = pickup_float(cont, &cur->ver1.x);
-        cont = pickup_float(cont, &cur->ver1.y);
-        cont = pickup_float(cont, &cur->ver1.z);
+    char *tmp_cont = cont;
+    int bound = 8; // coord_vertex size is 8byte.
+    int offset = 0;
 
-        cont = pickup_float(cont, &cur->ver2.x);
-        cont = pickup_float(cont, &cur->ver2.y);
-        cont = pickup_float(cont, &cur->ver2.z);
+    for(int n=0; n<size*3; n+=3)
+    {
+        tmp_cont = pickup_float(tmp_cont, coord_xyz+n);
+        tmp_cont = pickup_float(tmp_cont, coord_xyz+n+1);
+        tmp_cont = pickup_float(tmp_cont, coord_xyz+n+2);
 
-        cont = pickup_float(cont, &cur->ver3.x);
-        cont = pickup_float(cont, &cur->ver3.y);
-        cont = pickup_float(cont, &cur->ver3.z);
-
-	cur = cur + 1;
-
-        if (cont == NULL)
+        if (tmp_cont == NULL)
         {
             cout << "Analyzing obj data failed coordinate\n";
         }
     }
 
-#else
+    tmp_cont = cont;
 
-    for(int n=0; n<size*3; n+=3)
+    for(int n=0; n<size; n++)
     {
-        cont = pickup_float(cont, coord_xyz+n);
-        cont = pickup_float(cont, coord_xyz+n+1);
-        cont = pickup_float(cont, coord_xyz+n+2);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+2);
 
-        if (cont == NULL)
+        if (tmp_cont == NULL)
         {
             cout << "Analyzing obj data failed coordinate\n";
         }
     }
 
+#if SPE_CREATE_POLYGON_CHECK
+
+    for (int i = 0; i < size; i++) {
+
+      if (*(coord_xyz+i*3) != *(coord_pack+i*bound+offset)) {
+	printf("hoge\n");
+      }
+
+      if (*(coord_xyz+i*3+1) != *(coord_pack+i*bound+offset+1)) {
+	printf("hoge\n");
+      }
+
+      if (*(coord_xyz+i*3+2) != *(coord_pack+i*bound+offset+2)) {
+	printf("hoge\n");
+      }
+
+    }
+
 #endif
 
 }
@@ -238,46 +245,52 @@
 void Polygon::pickup_normal(char *cont)
 {
 
-#if SPE_CREATE_POLYGON
-
-    TrianglePackPtr cur = tri_pack;
+    char *tmp_cont = cont;
+    int bound = 8; // coord_pack size is 8byte.
+    int offset = 5; // coord_pack (xyz(3) + tex_x,tex_y(2) + n_xyz(3))
 
-    for(int n=0; n<size; n+=3)
+    for (int n = 0; n<size*3; n += 3)
     {
-
-        cont = pickup_float(cont, &cur->normal1.x);
-        cont = pickup_float(cont, &cur->normal1.y);
-        cont = pickup_float(cont, &cur->normal1.z);
+        tmp_cont = pickup_float(tmp_cont, normal+n);
+        tmp_cont = pickup_float(tmp_cont, normal+n+1);
+        tmp_cont = pickup_float(tmp_cont, normal+n+2);
 
-        cont = pickup_float(cont, &cur->normal2.x);
-        cont = pickup_float(cont, &cur->normal2.y);
-        cont = pickup_float(cont, &cur->normal2.z);
+        if (tmp_cont == NULL)
+        {
+            cout << "Analyzing obj data failed normal\n";
+        }
+    }
+
+    tmp_cont = cont;
 
-        cont = pickup_float(cont, &cur->normal3.x);
-        cont = pickup_float(cont, &cur->normal3.y);
-        cont = pickup_float(cont, &cur->normal3.z);
+    for(int n=0; n<size; n++)
+    {
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+2);
 
-	cur = cur + 1;
-
-        if (cont == NULL)
+        if (tmp_cont == NULL)
         {
             cout << "Analyzing obj data failed coordinate\n";
         }
     }
 
-#else
+#if SPE_CREATE_POLYGON_CHECK
+
+    for (int i = 0; i < size; i++) {
 
+      if (*(normal+i*3) != *(coord_pack+i*bound+offset)) {
+	printf("hoge\n");
+      }
 
-    for (int n = 0; n<size*3; n += 3)
-    {
-        cont = pickup_float(cont, normal+n);
-        cont = pickup_float(cont, normal+n+1);
-        cont = pickup_float(cont, normal+n+2);
+      if (*(normal+i*3+1) != *(coord_pack+i*bound+offset+1)) {
+	printf("hoge\n");
+      }
 
-        if (cont == NULL)
-        {
-            cout << "Analyzing obj data failed normal\n";
-        }
+      if (*(normal+i*3+2) != *(coord_pack+i*bound+offset+2)) {
+	printf("hoge\n");
+      }
+
     }
 
 #endif
@@ -299,42 +312,48 @@
 void Polygon::pickup_texture(char *cont)
 {
 
-#if SPE_CREATE_POLYGON
-
-    TrianglePackPtr cur = tri_pack;
+    char *tmp_cont = cont;
+    int bound = 8; // coord_pack size is 8byte.
+    int offset = 3; // coord_pack (xyz(3) + tex_x,tex_y(2) + n_xyz(3))
 
-    for(int n=0; n<size; n+=3)
+    for (int n = 0; n < size*3; n += 3)
     {
-
-        cont = pickup_float(cont, &cur->ver1.tex_x);
-        cont = pickup_float(cont, &cur->ver1.tex_y);
+        tmp_cont = pickup_float(tmp_cont, coord_tex+n);
+        tmp_cont = pickup_float(tmp_cont, coord_tex+n+1);
+        coord_tex[n+2] = 1.0;
 
-        cont = pickup_float(cont, &cur->ver2.tex_x);
-        cont = pickup_float(cont, &cur->ver2.tex_y);
+        if (tmp_cont == NULL)
+        {
+            cout << "Analyzing obj data failed texture\n";
+        }
+    }
 
-        cont = pickup_float(cont, &cur->ver3.tex_x);
-        cont = pickup_float(cont, &cur->ver3.tex_y);
+    tmp_cont = cont;
 
-	cur = cur + 1;
+    for(int n=0; n<size; n++)
+    {
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset);
+        tmp_cont = pickup_float(tmp_cont, coord_pack+n*bound+offset+1);
 
-        if (cont == NULL)
+        if (tmp_cont == NULL)
         {
             cout << "Analyzing obj data failed coordinate\n";
         }
     }
 
-#else
+#if SPE_CREATE_POLYGON_CHECK
+
+    for (int i = 0; i < size; i++) {
 
-    for (int n = 0; n < size*3; n += 3)
-    {
-        cont = pickup_float(cont, coord_tex+n);
-        cont = pickup_float(cont, coord_tex+n+1);
-        coord_tex[n+2] = 1.0;
+      if (*(coord_tex+i*3) != *(coord_pack+i*bound+offset)) {
+	printf("hoge\n");
+      }
 
-        if (cont == NULL)
-        {
-            cout << "Analyzing obj data failed texture\n";
-        }
+      if (*(coord_tex+i*3+1) != *(coord_pack+i*bound+offset+1)) {
+	printf("hoge\n");
+      }
+
+
     }
 
 #endif
--- a/Renderer/Engine/polygon.h	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/polygon.h	Tue Jul 20 04:46:27 2010 +0900
@@ -15,16 +15,7 @@
 
     //float *data;    //"vertex" and "normal" and "texture"
     int coord_pack_size;
-
-#if SPE_CREATE_POLYGON
-
-    TrianglePackPtr tri_pack;
-    float *sg_matrix;
-    float *matrix;
-    float *real_matrix;
-    texture_list *texture_info;
-
-#else
+    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
@@ -34,8 +25,6 @@
     float real_matrix[16];
     texture_list texture_info;
 
-#endif
-
     float xyz[4];     // position
     float angle[4];   // angle
     float c_xyz[4];   // center of rotation
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -15,7 +15,6 @@
 #define PP_LOAD 12
 #define PP_STORE 13
 
-#if !SPE_CREATE_POLYGON
 /**
  *  ベクトルに行列を乗算する
  * @param[out] v vector (float[4])
@@ -49,7 +48,6 @@
         v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8];
     }
 }
-#endif
 
 
 /**
@@ -76,7 +74,6 @@
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
 
-#if !SPE_CREATE_POLYGON
 
     float xyz1[4], xyz2[4], xyz3[4];
     float normal1[4],normal2[4],normal3[4];
@@ -249,8 +246,6 @@
     free(pp);
     free(send_pp);
 
-
-#endif
     return 0;
 
 }
--- a/Renderer/Engine/viewer.cc	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Tue Jul 20 04:46:27 2010 +0900
@@ -39,6 +39,7 @@
 int spackList_length;
 int spackList_length_align;
 
+
 /**
  *
  */
@@ -118,6 +119,7 @@
       light_xyz[i] = 0.0f;
     }
 
+
     for(int i = 0; i < spe_num; i++) {
 
 	HTaskPtr data_load = manager->create_task(DataLoad);
@@ -439,148 +441,198 @@
     frames++;
 }
 
-#if SPE_CREATE_POLYGON
+
+// 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。
+void
+copy_matrix(SceneGraphPtr sg) {
+
+  float *matrix = sg->matrix;
+  float *real_matrix = sg->real_matrix;
+
+  for (int i = 0; i < 16; i++) {
+    sg->sg_matrix[i] = matrix[i];
+    sg->sg_matrix[i+16] = real_matrix[i];
+  }
+
+}
+
+void
+print_matrix(float *matrix) {
+
+  for (int i = 0; i < 32; i++) {
+    printf("%f\n",matrix[i]);
+  }
+
+}
+
+void
+add_matrix_list(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) {
+
+    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->next = NULL;
+
+    
+    if (info->last != NULL) {
+        info->last->next = matrix_list;
+    }
+
+    info->last = matrix_list;
+
+}
 
 void
-Viewer::create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait,
-		       int &pp_index, int &sg_index, int tri_num) 
+new_matrix_info(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) {
+
+    MatrixListInfo *next = NULL;
+
+  if (info->id == -1) {
+
+    info->id = sg->sgid;
+    next = info;
+
+  } else {
+
+    MatrixListInfo* t;
+
+    for (t = info; t->next != NULL; t = t->next) {
+    }
+
+    next = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
+    next->id = sg->sgid;
+    next->next = NULL;
+    t->next = next;
+
+  }
+
+    MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList));
+    copy_matrix(sg);
+    new_list->matrix = sg->sg_matrix;
+#if SPE_CREATE_POLYGON_CHECK
+    print_matrix(sg->sg_matrix);
+#endif
+    new_list->next = NULL;
+
+    next->first = new_list;
+    next->last = new_list;
+
+}
+
+void
+collect_matrix(SceneGraphPtr sg, MatrixListInfo *matrix_info, TaskManager *manager) {
+  
+  matrix_info->id = -1;
+  matrix_info->next = NULL;
+  matrix_info->first = NULL;
+  matrix_info->last = NULL;
+
+  while (sg) {
+    
+    if (sg->flag_drawable) {
+      
+      int flag = 0;
+      
+      for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
+	if (sg->sgid == t->id) {
+	  add_matrix_list(sg, manager, t);
+	  flag = 1;
+	}	    	    	    
+      }
+      
+      if (flag != 1) {
+	new_matrix_info(sg, manager, matrix_info);  
+      }
+      
+      // search SceneGraph. でも、ただのリストがあったハズだから、あとでそれに直す。はず・・
+      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;
+	    }
+	  }
+	}
+      } 
+    } 
+  }
+}
+
+void
+Viewer::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) {
+      print_matrix(u->matrix);
+    }
+  }
+
+}
+
+void
+Viewer::create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next,
+	       MatrixListInfo *matrix_info)
 {
 
-    HTaskPtr create_pp = manager->create_task(CreatePolygon);
-    create_pp->set_inData(0, &sg->tri_pack[sg_index], sizeof(TrianglePack)*tri_num);
-    create_pp->set_inData(1, sg->texture_info, sizeof(texture_list));
-    create_pp->set_inData(2, sg->sg_matrix, sizeof(float)*32); //わーい、マジックナンバー
-    create_pp->set_outData(0, &pp_cur->tri[pp_index], sizeof(TrianglePack)*tri_num);
-    create_pp->set_param(0, (memaddr)tri_num);
-    //create_pp->set_cpu(SPE_ANY);
-    create_pp_wait->wait_for(create_pp);
-    create_pp->spawn();
+  //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();
+	  
+//   }
 
-    pp_index += tri_num;
-    sg_index += tri_num;
+  float *cur_coord_pack = sg->coord_pack;
+  int coord_pack_size = sg->coord_pack_size;
+
+  collect_matrix(sg, matrix_info, manager);  
+
+  //return create_pp_wait;
+
 }
 
-#endif
-
 void
 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
 
 #if SPE_CREATE_POLYGON
 
-  SceneGraphPtr sg = sgroot->getDrawSceneGraph();
-  PolygonPackPtr pp_cur = ppack;
-  HTaskPtr create_pp_wait = manager->create_task(Dummy);
-  int pp_index = 0;
-
-  pp_cur->init();
-
-  task_next->wait_for(create_pp_wait);
-
-  while (sg) {
-    
-    if (sg->flag_drawable) {
-
-      int sum_size = sg->size;
-      int tri_cur_num = MAX_SIZE_TRIANGLE;
-      int sg_index = 0;
+    SceneGraphPtr sg = sgroot->getDrawSceneGraph();
 
-      while (sum_size) {
-	
-	  tri_cur_num -= sg->size/3;
-	
-	  if (tri_cur_num < 0) {
-	    
-	      tri_cur_num = MAX_SIZE_TRIANGLE;
-	      create_pp_task(sg, pp_cur, create_pp_wait,
-			     pp_index, sg_index, tri_cur_num);
-	     
-	      PolygonPackPtr next = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack));
-	      next->init();
-
-	      pp_cur->next = next;
-	      pp_cur       = next;
-	      pp_index = 0;
-	      
-	  } else {
-	  
-	      create_pp_task(sg, pp_cur, create_pp_wait,
-			     pp_index, sg_index, tri_cur_num);
-
-	  }
-
-	  sum_size -= tri_cur_num*3;
+    MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
+    create_pp_task(sg, manager, spe_num, task_next, matrix_info);
 
-      }
-      
-      
-    }
-    
-    
-    
-    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;
-	  }
-	}
-      }
-    } 
-  }
-  
+#if SPE_CREATE_POLYGON_CHECK
+    check_matrix(matrix_info,sg);
+#endif
 
-  int  range_base = spe_num;
-  
-    // 切り上げのつもり
-  int range = (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;
-    
-    HTaskPtr task_create_sp = manager->create_task(CreateSpan);
-    
-    task_create_sp->set_param(0,index_start);
-    
-    /**
-     * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
-     *   [  1.. 80] [ 81..160] [161..240]
-     *   [241..320] [321..400] [401..480]
-     *
-     * ex. screen_height が 1080, spenum が 5 の場合、
-     *   [  1..216] [217..432] [433..648]
-     *   [649..864] [865..1080]
-     */
-    
-    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_next->wait_for(task_create_sp);
-    task_create_sp->wait_for(create_pp_wait);
-    
-    task_create_sp->set_cpu(SPE_ANY);
-    task_create_sp->spawn();
-  }
+
   
 #else
-
+    
     HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
     
     // SceneGraph(木構造) -> PolygonPack
@@ -590,6 +642,8 @@
 
     task_next->wait_for(task_create_pp);
 
+#endif
+
     int  range_base = spe_num;
 
     // 切り上げのつもり
@@ -631,8 +685,6 @@
 
     task_create_pp->spawn();
 
-#endif
-
 }
 
 HTaskPtr
--- a/Renderer/Engine/viewer.h	Mon Jul 19 20:28:58 2010 +0900
+++ b/Renderer/Engine/viewer.h	Tue Jul 20 04:46:27 2010 +0900
@@ -10,6 +10,7 @@
 #include "Application.h"
 #include "SceneGraphRoot.h"
 #include "ViewerDevice.h"
+#include "matrix.h"
 
 class SceneGraphRoot;
 
@@ -69,10 +70,12 @@
     void run_collision();
     void rendering(HTaskPtr task_next);
     void common_draw(HTaskPtr task_next);
-    void create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait,
-			int &pp_index, int &sg_index, int tri_num);
     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);
--- a/TaskManager/Makefile.def	Mon Jul 19 20:28:58 2010 +0900
+++ b/TaskManager/Makefile.def	Tue Jul 20 04:46:27 2010 +0900
@@ -30,7 +30,7 @@
 ABIBIT = 32
 
 #OPT = -O9
-OPT =  -g -O9  -DTASK_LIST_MAIL
+OPT =  -g -DTASK_LIST_MAIL #-O9
 
 CC     = g++   
 CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT)   $(OPT)