changeset 1127:c4287bf771a0 draft

CreatePolygonFromSceneGraph can work on Mac OSX.
author Yutaka_Kinjyo
date Sun, 13 Feb 2011 23:27:22 +0900
parents 6043da6e48f1
children 293b36802714
files Renderer/Engine/Makefile.def Renderer/Engine/RenderingTasks.h Renderer/Engine/SceneGraph.cc Renderer/Engine/polygon.cc Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/task_init.cc Renderer/Engine/viewer.cc
diffstat 7 files changed, 126 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/Makefile.def	Sun Feb 13 23:27:22 2011 +0900
@@ -5,7 +5,7 @@
 ABIBIT = 64 
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT	= -O9  #-DSPE_CREATE_POLYGON_CHECK -DSPE_CREATE_POLYGON=1
+OPT	=  -g #-O9 
 CFLAGS  = -Wall $(ABI) $(OPT)  #  -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- a/Renderer/Engine/RenderingTasks.h	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/RenderingTasks.h	Sun Feb 13 23:27:22 2011 +0900
@@ -10,8 +10,11 @@
      Update_SGP,
      CreatePolygon,
      CreatePolygonFromSceneGraph,
+     CreatePolygonFromSceneGraph2,
      CreateSpan,
 
+     TEST,
+
      DrawSpan,
      DrawBack,
 
--- a/Renderer/Engine/SceneGraph.cc	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Sun Feb 13 23:27:22 2011 +0900
@@ -185,6 +185,10 @@
 
     get_data(manager, surface->children);
 
+    printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[0] , pp[pp_num-1].tri[0].ver1.x );
+    printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[1] , pp[pp_num-1].tri[0].ver1.y );
+    printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[2] , pp[pp_num-1].tri[0].ver1.z );
+
     finalize = &SceneGraph::finalize_original;
 
 }
--- a/Renderer/Engine/polygon.cc	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/polygon.cc	Sun Feb 13 23:27:22 2011 +0900
@@ -77,20 +77,24 @@
 
       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[j].ver1.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.z));
+
+	tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.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[j].ver3.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.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[j].ver1.x) {
+	  printf("miss match pickup_coordinate vertex. coord %f, tri->ver1.x %f\n", *(coord_xyz+ i*MAX_SIZE_TRIANGLE*9 + j*9), tri[j].ver1.x);
+	}
 
-	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 ( *(coord_xyz + i*MAX_SIZE_TRIANGLE*9 + j*9+1) != tri[j].ver1.y) {
+	  printf("miss match pickup_coordinate vertex. coord %f, tri->ver1.y %f\n", *(coord_xyz+ i*MAX_SIZE_TRIANGLE*9 + j*9+1), tri[j].ver1.y);
 	}
 
 	if (tmp_cont == NULL)
@@ -141,20 +145,20 @@
 
       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[j].normal1.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].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[j].normal2.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].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));
+	tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.y));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].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 ( *(normal + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri[j].normal1.x) {
+	  printf("miss pickup_normal vertex. normal %f, tri->ver1.x %f\n", *(normal + i*MAX_SIZE_TRIANGLE*9 + j*9), tri[j].normal1.x);
 	}
 
 	if (tmp_cont == NULL)
@@ -216,17 +220,17 @@
 
       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[j].ver1.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].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[j].ver2.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_y));
 
-	tmp_cont = pickup_float(tmp_cont, &(tri->ver3.tex_x));
-        tmp_cont = pickup_float(tmp_cont, &(tri->ver3.tex_y));
+	tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_x));
+        tmp_cont = pickup_float(tmp_cont, &(tri[j].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 ( *(coord_tex + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri[j].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[j].ver1.tex_x);
 	}
 
 	if (tmp_cont == NULL)
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Sun Feb 13 23:27:22 2011 +0900
@@ -34,42 +34,7 @@
 	v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12];
     }
 }
-#if 0
-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];
-    }
-}
-#endif
-
-/**
- * 行列の積
- *
- * @param[out] m0 output matrix
- * @param[in] m1 input left matrix
- * @param[in] m2 input right matrix
- */
-/*
-static void
-MulMatrix(float *m0, float *m1, float *m2) //xyz[16]
-{
-    for(int t = 0; t < 16; t += 4) {
-	for (int i = 0; i < 4; i++) {
-	    m0[t+i] =
-		m1[t+0]*m2[ i ] + m1[t+1]*m2[i+ 4] +
-		m1[t+2]*m2[i+8] + m1[t+3]*m2[i+12];
-	}
-    }
-}
-*/
 static int 
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
--- a/Renderer/Engine/task/task_init.cc	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/task/task_init.cc	Sun Feb 13 23:27:22 2011 +0900
@@ -9,8 +9,11 @@
 SchedExternTask(Update_SGP);
 SchedExternTask(CreatePolygon);
 SchedExternTask(CreatePolygonFromSceneGraph);
+SchedExternTask(CreatePolygonFromSceneGraph2);
 SchedExternTask(CreateSpan);
 
+SchedExternTask(TEST);
+
 SchedExternTask(DrawSpan);
 SchedExternTask(DrawSpanRenew);
 SchedExternTask(DrawBack);
@@ -54,9 +57,12 @@
     SchedRegister( Create_SGP);
     SchedRegister( Update_SGP);
     SchedRegister(CreatePolygonFromSceneGraph);
+    SchedRegister(CreatePolygonFromSceneGraph2);
     SchedRegister(CreatePolygon);
     SchedRegister( CreateSpan);
 
+    SchedRegister(TEST);
+
     SchedRegister( DrawSpan);
     SchedRegister( DrawBack);
 
--- a/Renderer/Engine/viewer.cc	Sat Feb 12 08:39:35 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Sun Feb 13 23:27:22 2011 +0900
@@ -433,13 +433,14 @@
 }
 
 
+
+
 void
 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
 
-
-
-#if 1
+    HTaskPtr game_task_array = 0;
+    HTaskPtr task_test = manager->create_task(TEST);
 
     // SceneGraph(木構造) -> PolygonPack
     HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
@@ -448,55 +449,88 @@
 
     /* GameTask の処理の終了を待ってからポリゴンを作る */
     if (sgroot->gtask_array != NULL) {
-	HTaskPtr game_task_array = sgroot->gtask_array->get_task_array();
+	game_task_array = sgroot->gtask_array->get_task_array();
 	task_create_pp->wait_for(game_task_array);
     }
-    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);
+    task_next->wait_for(task_create_pp);
+    task_test->wait_for(task_create_pp);
+
+    //PolygonPackPtr out_pp = r[ppi].ppack;
+    PolygonPackPtr top_out_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack));
+    PolygonPackPtr out_pp = top_out_pp;
+    HTaskPtr wait = manager->create_task(Dummy);
+    wait->set_cpu(CPU_PPE);
+
+    SceneGraphPtr sg = sgroot->getDrawSceneGraph();
+    SceneGraphPtr t = sgroot->sg_remove_list;
+
+    while(sg) {
+
+      if (sg != t) {
+	printf("miss match sg %x t %x\n",sg,t);
+      }
+
+      t = t->next;
 
-    //多分このsg_remove_listであってる。チェック対象かも
+      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;
+	    }
+	  }
+	}
+      }
+    }
+    
+      
+      
+    //多分この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));
+	HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph2);
+	create_pp->add_inData(&t->pp[i], sizeof(PolygonPack));
+	create_pp->add_inData(t->matrix, sizeof(float)*16);
+	create_pp->add_inData(t->real_matrix, sizeof(float)*16);
+	create_pp->add_inData(&t->texture_info, sizeof(texture_list));
 	
-	create_pp->set_outData(0, out_pp, sizeof(PolygonPack));
+	create_pp->add_outData(out_pp, sizeof(PolygonPack));
 
 	if (game_task_array != NULL) {
 	  create_pp->wait_for(game_task_array);
 	}
 
-	task_create_pp->wait_for(create_pp);
+	wait->wait_for(create_pp);
+	task_test->wait_for(create_pp);
 
-	create_pp->set_cpu(SPE_ANY);
+	PolygonPackPtr tmp_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack));
+	tmp_pp->init();
+	create_pp->set_param(0, (memaddr)tmp_pp);
+	out_pp = tmp_pp;
+
+	create_pp->set_cpu(CPU_PPE);
 	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_test->add_inData(r[ppi].ppack, sizeof(PolygonPack));
+    task_test->add_inData(top_out_pp, sizeof(PolygonPack));
 
-    }
-
-    task_next->wait_for(task_create_pp);
-
-#endif
+    task_next->wait_for(wait);
+    task_next->wait_for(task_test);
 
     int  range_base = spe_num;
 
@@ -529,12 +563,17 @@
         task_create_sp->set_param(1,starty);
         task_create_sp->set_param(2,endy);
 
-        task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack));
+        //task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack));
+	task_create_sp->add_inData(top_out_pp, sizeof(PolygonPack));
         task_create_sp->add_inData(r[spi].spackList_ptr,
                                    sizeof(SpanPack*)*r[spi].spackList_length_align);
         task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack));
 
         task_create_sp->wait_for(task_create_pp);
+	//test用
+        task_create_sp->wait_for(wait);
+        task_create_sp->wait_for(task_test);
+
 	task_next->wait_for(task_create_sp);
 
 	task_create_sp->set_cpu(SPE_ANY);
@@ -542,6 +581,9 @@
     }
 
     task_create_pp->spawn();
+    //test用
+    wait->spawn();
+    task_test->spawn();
 }