changeset 1126:6043da6e48f1 draft

complete compile but not work yet.
author yutaka@localhost.localdomain
date Sat, 12 Feb 2011 08:39:35 +0900
parents b733c7903d07
children c4287bf771a0
files Renderer/Engine/SceneGraph.cc Renderer/Engine/polygon.cc Renderer/Engine/polygon.h Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Renderer/Engine/spe/Makefile Renderer/Engine/viewer.cc
diffstat 6 files changed, 249 insertions(+), 247 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Sat Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Sat Feb 12 08:39:35 2011 +0900
@@ -159,7 +159,7 @@
 {
     init();
     
-    //size : 面の数かな
+    //size : 頂点の数かな
     size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size"));
     name = (char *)xmlGetProp(surface,(xmlChar *)"name");
     parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent");
@@ -176,7 +176,11 @@
     coord_tex = (float*)manager->allocate(sizeof(float)*size*3);
     normal    = (float*)manager->allocate(sizeof(float)*size*3);
 
-    pp_num = (size + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
+    if (size % 3 != 0) {
+      printf("vertex size is error. size %% 3 = %lld\n", size % 3);
+    }
+
+    pp_num = (size/3 + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
     pp = (PolygonPack*)manager->allocate(sizeof(PolygonPack)*pp_num);
 
     get_data(manager, surface->children);
@@ -241,6 +245,7 @@
     free(coord_xyz);
     free(coord_tex);
     free(normal);
+    free(pp);
 
 }
 
--- a/Renderer/Engine/polygon.cc	Sat Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/polygon.cc	Sat Feb 12 08:39:35 2011 +0900
@@ -64,6 +64,51 @@
         }
     }
 
+    // size は頂点の数, count は面の数
+    tmp_cont = cont;
+    int count = size / 3;
+
+    for (int i = 0; i < pp_num; i++) {
+
+      TrianglePackPtr tri =  pp[i].tri;
+      // TrianglePack の size のチェック
+      int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
+      pp[i].info.size = tri_size;
+
+      for (int j = 0; j < tri_size; j++) {
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver1.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver1.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver1.z));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver2.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver2.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver2.z));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver3.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver3.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver3.z));
+
+	if ( *(coord_xyz + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri->ver1.x) {
+	  printf("miss pickup_coordinate vertex. coord %f, tri->ver1.x %f\n", *(coord_xyz+ i*MAX_SIZE_TRIANGLE*9 + j*9), tri->ver1.x);
+	}
+
+	if (tmp_cont == NULL)
+	  {
+            cout << "Analyzing obj data failed coordinate\n";
+	  }
+
+	count -= 1;
+	
+      }
+      
+    
+    }
+
+    if (count != 0) {
+          printf("miss pickup_coordinate size. diff size = %d\n", count);
+    }
+
 }
 
 void Polygon::pickup_normal(char *cont)
@@ -83,6 +128,51 @@
         }
     }
 
+    // size は頂点の数, count は面の数
+    tmp_cont = cont;
+    int count = size / 3;
+
+    for (int i = 0; i < pp_num; i++) {
+
+      TrianglePackPtr tri =  pp[i].tri;
+      // TrianglePack の size のチェック
+      int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
+      pp[i].info.size = tri_size;
+
+      for (int j = 0; j < tri_size; j++) {
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->normal1.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal1.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal1.z));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->normal2.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal2.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal2.z));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->normal3.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal3.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri->normal3.z));
+
+	if ( *(normal + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri->normal1.x) {
+	  printf("miss pickup_normal vertex. normal %f, tri->ver1.x %f\n", *(normal + i*MAX_SIZE_TRIANGLE*9 + j*9), tri->normal1.x);
+	}
+
+	if (tmp_cont == NULL)
+	  {
+            cout << "Analyzing obj data failed coordinate\n";
+	  }
+
+	count -= 1;
+	
+      }
+      
+    
+    }
+
+    if (count != 0) {
+          printf("miss pickup_normal size. diff size = %d\n", count);
+    }
+
 }
 
 void Polygon::pickup_model(char *cont)
@@ -115,6 +205,48 @@
     }
 
     tmp_cont = cont;
+    int count = size / 3;
+
+    for (int i = 0; i < pp_num; i++) {
+
+      TrianglePackPtr tri =  pp[i].tri;
+      // TrianglePack の size のチェック
+      int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
+      pp[i].info.size = tri_size;
+
+      for (int j = 0; j < tri_size; j++) {
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver1.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver1.tex_y));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver2.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver2.tex_y));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri->ver3.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri->ver3.tex_y));
+
+	if ( *(coord_tex + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri->ver1.tex_x) {
+	  printf("miss pickup_texture vertex. texture %f, tri->ver1.tex_x %f\n", *(coord_tex + i*MAX_SIZE_TRIANGLE*9 + j*9), tri->ver1.tex_x);
+	}
+
+	if (tmp_cont == NULL)
+	  {
+            cout << "Analyzing obj data failed coordinate\n";
+	  }
+
+	count -= 1;
+	
+      }
+      
+    
+    }
+
+    if (count != 0) {
+          printf("miss pickup_texture size. diff size = %d\n", count);
+    }
+
+
+
 }
 
 char *get_pixel(int tx, int ty, SDL_Surface *texture_image)
--- a/Renderer/Engine/polygon.h	Sat Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/polygon.h	Sat Feb 12 08:39:35 2011 +0900
@@ -18,9 +18,9 @@
     float *coord_xyz; // vertex coordinate array
     float *coord_tex; // texture coordinate array
     float *normal;    // normal vector array
-    float matrix[16];
-    float real_matrix[16];
-    texture_list texture_info;
+    float matrix[16] __attribute__((aligned(16)));;
+    float real_matrix[16] __attribute__((aligned(16)));;
+    texture_list texture_info __attribute__((aligned(16)));;
 
     PolygonPackPtr pp;
     int pp_num;
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Sat Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Sat Feb 12 08:39:35 2011 +0900
@@ -6,14 +6,10 @@
 
 #include "CreatePolygonFromSceneGraph.h"
 #include "polygon_pack.h"
-#include "scene_graph_pack.h"
+#include "texture.h"
 
 SchedDefineTask1(CreatePolygonFromSceneGraph, createPolygonFromSceneGraph);
 
-#define SG_PACK_LOAD 10
-#define SG_NODE_LOAD 11
-#define PP_LOAD 12
-#define PP_STORE 13
 
 /**
  *  ベクトルに行列を乗算する
@@ -55,70 +51,33 @@
     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_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;
+    //pp, matrix, real_matrix を受け取る
+    PolygonPackPtr in_pp      = (PolygonPackPtr)smanager->get_input(rbuf, 0);
+    float *matrix             = (float*)smanager->get_input(rbuf, 1);
+    float *real_matrix        = (float*)smanager->get_input(rbuf, 2);
+    texture_list *tritexinfo  = (texture_list*)smanager->get_input(rbuf, 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();
-      }
+    PolygonPackPtr out_pp = (PolygonPackPtr)smanager->get_output(wbuf, 0);
+    out_pp->info.size = in_pp->info.size;
+
+    for (int i = 0; i < in_pp->info.size; i++) {
+
+      TrianglePack tri = in_pp->tri[i];
       
-      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[0] = tri.ver1.x;
+      xyz1[1] = tri.ver1.y;
+      xyz1[2] = tri.ver1.z;
       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[0] = tri.ver2.x;
+      xyz2[1] = tri.ver2.y;
+      xyz2[2] = tri.ver2.z;
       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[0] = tri.ver3.x;
+      xyz3[1] = tri.ver3.y;
+      xyz3[2] = tri.ver3.z;
       xyz3[3] = 1.0f;
       
       // matrix = 回転行列*透視変換行列
@@ -133,41 +92,41 @@
       xyz3[0] /= xyz3[2];
       xyz3[1] /= xyz3[2];
    
-      TrianglePack *triangle = &pp->tri[pp->info.size++];
+      TrianglePack triangle = out_pp->tri[i];
 
-      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.ver1.x = xyz1[0];
+      triangle.ver1.y = xyz1[1];
+      triangle.ver1.z = xyz1[2];
+      triangle.ver1.tex_x = tri.ver1.tex_x;
+      triangle.ver1.tex_y = tri.ver1.tex_y;
       
-      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.ver2.x = xyz2[0];
+      triangle.ver2.y = xyz2[1];
+      triangle.ver2.z = xyz2[2];
+      triangle.ver2.tex_x = tri.ver2.tex_x;
+      triangle.ver2.tex_y = tri.ver2.tex_y;
       
-      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];
+      triangle.ver3.x = xyz3[0];
+      triangle.ver3.y = xyz3[1];
+      triangle.ver3.z = xyz3[2];
+      triangle.ver3.tex_x = tri.ver3.tex_x;
+      triangle.ver3.tex_y = tri.ver3.tex_y;
       
-      normal1[0] = normal[(i+0)*3];
-      normal1[1] = normal[(i+0)*3+1];
-      normal1[2] = normal[(i+0)*3+2]*-1.0f;
+      normal1[0] = tri.normal1.x;
+      normal1[1] = tri.normal1.y;
+      normal1[2] = tri.normal1.z * -1.0f;
       //normal1[3] = 1.0f;
       normal1[3] = 0.0f;
       
-      normal2[0] = normal[(i+1)*3];
-      normal2[1] = normal[(i+1)*3+1];
-      normal2[2] = normal[(i+1)*3+2]*-1.0f;
+      normal2[0] = tri.normal2.x;
+      normal2[1] = tri.normal2.y;
+      normal2[2] = tri.normal2.z * -1.0f;
       //normal2[3] = 1.0f;
       normal2[3] = 0.0f;
       
-      normal3[0] = normal[(i+2)*3];
-      normal3[1] = normal[(i+2)*3+1];
-      normal3[2] = normal[(i+2)*3+2]*-1.0f;
+      normal3[0] = tri.normal3.x;
+      normal3[1] = tri.normal3.y;
+      normal3[2] = tri.normal3.z * -1.0f;
       //normal3[3] = 1.0f;
       normal3[3] = 0.0f;
       
@@ -184,30 +143,23 @@
       normal3[0] /= normal3[2];
       normal3[1] /= normal3[2];
       
-      triangle->normal1.x = normal1[0];
-      triangle->normal1.y = normal1[1];
-      triangle->normal1.z = normal1[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.normal2.x = normal2[0];
+      triangle.normal2.y = normal2[1];
+      triangle.normal2.z = normal2[2];
       
-      triangle->tex_info.addr   = pixels;
-      triangle->tex_info.width  = width;
-      triangle->tex_info.height = height;
-      triangle->tex_info.scale_max = scale_max;
+      triangle.normal3.x = normal3[0];
+      triangle.normal3.y = normal3[1];
+      triangle.normal3.z = normal3[2];
+      
+      triangle.tex_info.addr   = tritexinfo->pixels;
+      triangle.tex_info.width  = tritexinfo->t_w;
+      triangle.tex_info.height = tritexinfo->t_h;
+      triangle.tex_info.scale_max = tritexinfo->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 Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/spe/Makefile	Sat Feb 12 08:39:35 2011 +0900
@@ -5,7 +5,7 @@
 TOP = ../$(CERIUM)
 
 SRCS_TMP = $(wildcard *.cc)
-SRCS_EXCLUDE = CreatePolygonFromSceneGraph.cc #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/viewer.cc	Sat Feb 12 04:03:25 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Sat Feb 12 08:39:35 2011 +0900
@@ -398,43 +398,6 @@
 }
 
 
-void
-coord_allocate(int &cur_point, float *coord_pack, int spe_num,
-	       int alloc_size, HTaskPtr alloc_wait, TaskManager *manager)
-{
-
-  for (int i = 0; i < spe_num; i++) {
-
-    HTaskPtr data_alloc = manager->create_task(DataAllocate);
-    //data_alloc->set_inData(0, &coord_pack[cur_point], alloc_size);
-    data_alloc->set_param(0,(memaddr)alloc_size);
-    data_alloc->set_param(1,(memaddr)SG_COORD);
-    data_alloc->set_cpu((CPU_TYPE)((int)SPE_0 + i));
-    alloc_wait->wait_for(data_alloc);
-    data_alloc->spawn();
- 
-  } 
-
-  cur_point += alloc_size / sizeof(float);
-
-}
-
-void
-coord_free(int spe_num, TaskManager *manager, HTaskPtr alloc_wait)
-{
-
-  for (int i = 0; i < spe_num; i++) {
-
-    HTaskPtr data_free = manager->create_task(DataFree);
-    data_free->set_param(0,(memaddr)SG_COORD);
-    data_free->set_cpu((CPU_TYPE)((int)SPE_0 + i));
-    data_free->wait_for(alloc_wait);
-    data_free->spawn();
- 
-  } 
-
-}
-
 /* flag_drawable な Scenegraph の総数を求める */
 int
 sg_drawable_num(SceneGraphPtr scenegraph)
@@ -469,110 +432,17 @@
   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 及び、
-   * PolygonPack の TrianglePack (空) を送る。pp->info.size の計算もここで。
-   * 
-   */
-
-  int sg_num = sg_drawable_num(sg);
-  int sg_division = sg_num / spe_num;
-  int residue = sg_num % spe_num;
-
-  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 k = 0;
-
-  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);
-      pptask[k]->set_inData(1, &sg->coord_tex, sizeof(float)*sg->size);
-      pptask[k]->set_inData(2, &sg->normal   , sizeof(float)*sg->size);
-      pptask[k]->set_inData(3, &sg->matrix   , sizeof(float)*16);
-      pptask[k]->set_inData(4, &sg->real_matrix, sizeof(float)*12);
-      pptask[k]->set_inData(5, &sg->texture_info.pixels, sizeof(uint32)); // 4 byte
-
-      // 4 byte * 4 = 16 byte
-      pptask[k]->set_param(0,(memaddr)sg->size); // 4byte
-      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);
-      
-    }
-    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;
-	  }
-	}
-      }
-    }
-    k++;
-  }
-  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
 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
 
-#if SPE_CREATE_POLYGON
 
-    SceneGraphPtr sg = sgroot->getDrawSceneGraph();
-
-    create_pp_task(sg, manager, spe_num, task_next, sgroot);
 
-#if SPE_CREATE_POLYGON_CHECK
-    check_matrix(matrix_info,sg);
-#endif
-  
-#else
-    //SceneGraphPtr sg = sgroot->getDrawSceneGraph();
-    //printf("sg->size = %lld\n", sizeof(pixels));
+#if 1
+
+    // SceneGraph(木構造) -> PolygonPack
     HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
-    // SceneGraph(木構造) -> PolygonPack
-
     task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
     task_create_pp->set_param(1,(memaddr)r[ppi].ppack);
 
@@ -583,6 +453,49 @@
     }
     task_next->wait_for(task_create_pp);
 
+#else 
+
+    HTaskPtr game_task_array = 0;
+    /* GameTask の処理の終了を待ってからポリゴンを作る */
+    if (sgroot->gtask_array != NULL) {
+      game_task_array = sgroot->gtask_array->get_task_array();
+    }
+
+    PolygonPackPtr out_pp = r[ppi].ppack;
+    HTaskPtr task_create_pp = manager->create_task(Dummy);
+    task_create_pp->set_cpu(CPU_PPE);
+
+    //多分このsg_remove_listであってる。チェック対象かも
+    for (SceneGraphPtr t = sgroot->sg_remove_list; t != NULL; t = t->next) {
+      for (int i = 0; i < t->pp_num; i++) {
+	HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph);
+	create_pp->set_inData(0, &(t->pp[i]), sizeof(PolygonPack));
+	create_pp->set_inData(1, t->matrix, sizeof(float)*16);
+	create_pp->set_inData(2, t->real_matrix, sizeof(float)*16);
+	create_pp->set_inData(3, &(t->texture_info), sizeof(texture_list));
+	
+	create_pp->set_outData(0, out_pp, sizeof(PolygonPack));
+
+	if (game_task_array != NULL) {
+	  create_pp->wait_for(game_task_array);
+	}
+
+	task_create_pp->wait_for(create_pp);
+
+	create_pp->set_cpu(SPE_ANY);
+	create_pp->spawn();
+
+      }
+
+      PolygonPackPtr tmp_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack));
+      tmp_pp->next = 0;
+      out_pp->next = tmp_pp;
+      out_pp = tmp_pp;
+
+    }
+
+    task_next->wait_for(task_create_pp);
+
 #endif
 
     int  range_base = spe_num;