changeset 990:30f2e77ecb36

merge
author root@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 01 Oct 2010 04:43:02 +0900
parents e40dd2384357 (current diff) 0b8f9d4d7dab (diff)
children 1b018a00cd17 8024a3a44832
files
diffstat 11 files changed, 102 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/Makefile.def	Fri Oct 01 04:43:02 2010 +0900
@@ -6,7 +6,7 @@
 ABI = -m$(ABIBIT)
 CC      = g++
 OPT	= -g -O9 #-DSPE_CREATE_POLYGON_CHECK -DSPE_CREATE_POLYGON=1
-CFLAGS  = -g -Wall $(ABI) $(OPT)  #  -DDEBUG
+CFLAGS  = -Wall $(ABI) $(OPT)  #  -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
 # LIBS = -L$(CERIUM)/TaskManager -m$(ABIBIT)
--- a/Renderer/Engine/Makefile.macosx	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/Makefile.macosx	Fri Oct 01 04:43:02 2010 +0900
@@ -13,7 +13,7 @@
 
 LIBS += -lFifoManager
 
-CFLAGS += `sdl-config --cflags` `xml2-config --cflags` 
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags`  -Drestrict=__restrict__
 LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL 
 
 .SUFFIXES: .cc .o
--- a/Renderer/Engine/SgChange.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/SgChange.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -24,12 +24,7 @@
 extern int frames;
 
 /* Data Pack sent to Other CPUs (ex. SPE) */
-extern SceneGraphPack *sgpack;
-extern SpanPackPtr spackList;
-extern SpanPackPtr *spackList_ptr;
-
-extern int spackList_length;
-extern int spackList_length_align;
+extern RederingData r[2];
 
 void
 SgChange::run_init()
@@ -95,15 +90,15 @@
     bool quit_flg;
     quit_flg = viewer->quit_check();
     if (quit_flg == true) {
-        this_time = viewer->get_ticks();
+        // this_time = viewer->get_ticks();
         viewer->run_finish();
         return;
     }
 
     viewer->dev->clean_pixels();
 
-    for (int i = 1; i <= spackList_length; i++) {
-        spackList[i-1].reinit(i*split_screen_h);
+    for (int i = 1; i <= r[spi].spackList_length; i++) {
+        r[spi].spackList[i-1].reinit(i*split_screen_h);
     }
 
     sgroot_A->updateControllerState();
--- a/Renderer/Engine/fb.h	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/fb.h	Fri Oct 01 04:43:02 2010 +0900
@@ -1,6 +1,7 @@
 #ifndef FB_H
 #define FB_H
 
+#include "types.h"
 #if defined(__linux__)
 
 #include <unistd.h>
@@ -12,7 +13,6 @@
 #include <sys/ioctl.h>
 #include <stdlib.h>
 #include <iostream>
-#include "types.h"
 using namespace std;
 
 
--- a/Renderer/Engine/spe/DataAllocate.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/spe/DataAllocate.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -10,14 +10,16 @@
 run(SchedTask *s, void *rbuf, void *wbuf)
 {
 
-  void *idata = s->get_input(rbuf, 0);
-  long size = (long)s->get_param(0);
-  long load_id = (long)s->get_param(1);
+  int count = (int)s->get_param(0);
+  for(int i=0;i<count;i++) {
+      void *idata = s->get_input(rbuf, i);
+      long size = (long)s->get_param(i*2+1);
+      long load_id = (long)s->get_param(i*2+2);
 
-  void *buff = s->global_alloc(load_id, size);
-
-  if (idata != NULL) {
-    memcpy(buff,idata,size);
+      void *buff = s->global_alloc(load_id, size);
+      if (idata != NULL) {
+	memcpy(buff,idata,size);
+      }
   }
 
   return 0;
--- a/Renderer/Engine/task/DataAllocate.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/task/DataAllocate.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -10,15 +10,17 @@
 run(SchedTask *s, void *rbuf, void *wbuf)
 {
 
-  long size = (long)s->get_param(0);
-  long load_id = (long)s->get_param(1);
-
-  //printf("size %d",sizeof(float)*length);
+  int count = (int)s->get_param(0);
+  for(int i=0;i<count;i++) {
+      void *idata = s->get_input(rbuf, i);
+      long size = (long)s->get_param(i*2+1);
+      long load_id = (long)s->get_param(i*2+2);
 
-  s->global_alloc(load_id, size);
-
-  //MemList *ml = s->createMemList(length,length);
-  //s->global_set(load_id, (void *)ml);
+      void *buff = s->global_alloc(load_id, size);
+      if (idata != NULL) {
+	memcpy(buff,idata,size);
+      }
+  }
 
   return 0;
 }
--- a/Renderer/Engine/viewer.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -20,8 +20,8 @@
 static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1);
 
 /* measure for FPS (Frame Per Second) */
-int start_time;
-int this_time;
+static int start_time;
+static int this_time;
 int frames;
 // static void post2speRunLoop(void *viewer);
 //static void post2runMove(void *viewer);
@@ -31,14 +31,10 @@
 //SceneGraphRootPtr sgroot_2;
 
 /* Data Pack sent to Other CPUs (ex. SPE) */
-SceneGraphPack *sgpack;
-PolygonPack *ppack;
-SpanPackPtr spackList;
-SpanPackPtr *spackList_ptr;
 
-int spackList_length;
-int spackList_length_align;
+RederingData r[2];
 
+int  ppi, spi;
 
 /**
  *
@@ -117,29 +113,24 @@
 
 
     for(int i = 0; i < spe_num; i++) {
-
-      HTaskPtr data_load = manager->create_task(DataAllocate);
-	data_load->set_param(0,(memaddr)size);
-	data_load->set_param(1,(memaddr)Light);
+        HTaskPtr data_load = manager->create_task(DataAllocate);
+	data_load->set_param(0,(memaddr)3);                         // num of allocate block
+	data_load->set_param(1,(memaddr)(sizeof(float)*4*light_num)); // 1st allocate size
+	data_load->set_param(2,(memaddr)Light);                     // 1st id
+	data_load->set_param(3,(memaddr)(light_num * sizeof(int)));   // 2nd size
+	data_load->set_param(4,(memaddr)LightSwitch);               // 2nd id
+	data_load->set_param(5,(memaddr)16);                        // 3rd size
+	data_load->set_param(6,(memaddr)LightSysSwitch);            // 3rd id
 	data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
 	data_load->spawn();
     }
 
-    size = light_num * sizeof(int);
     light_switch = (int*)manager->allocate(size);
 
     for (int i = 0; i < light_num; i++) {
         light_switch[i] = 0;
     }
 
-    for(int i = 0; i < spe_num; i++) {
-	HTaskPtr data_load = manager->create_task(DataAllocate);
-	data_load->set_param(0,(memaddr)size);
-	data_load->set_param(1,(memaddr)LightSwitch);
-	data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
-	data_load->spawn();
-    }
-
     size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
 
     light_sysswitch = (int*)manager->allocate(size);
@@ -148,14 +139,6 @@
       light_sysswitch[i] = 0;
     }
 
-    for(int i = 0; i < spe_num; i++) {
-	HTaskPtr data_load = manager->create_task(DataAllocate);
-	data_load->set_param(0,(memaddr)size);
-	data_load->set_param(1,(memaddr)LightSysSwitch);
-	data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
-	data_load->spawn();
-    }
-    
     start_time = get_ticks();
     this_time  = 0;
     frames     = 0;
@@ -171,43 +154,44 @@
     HTaskPtr task_next;
     HTaskPtr task_tex;
 
-    sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack));
-    sgpack->init();
-    ppack  = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
+    for(int i=0;i<2;i++) {
+	r[i].ppack  = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
+	r[i].ppack->next = 0;  
 
-    spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
-    spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length);
-    // printf("spackList %0lx height %d\n",(unsigned long)spackList, this->height);
+	r[i].spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
+	r[i].spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*r[i].spackList_length);
+	// printf("spackList %0lx height %d\n",(unsigned long)r[i].spackList, this->height);
 
-    /**
-     * SPU に送る address list は 16 バイト倍数でないといけない。
-     * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような
-     * length_align を求めている。はみ出した部分は使われない
-     * (ex) spackList_length が 13 の場合
-     *   spackList_length_align = 16;
-     *     実際に送るデータは64バイトになるのでOK
-     *     14,15,16 の部分は何も入らない。
-     */
-    spackList_length_align = (spackList_length + 3)&(~3);
+	/**
+	 * SPU に送る address list は 16 バイト倍数でないといけない。
+	 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような
+	 * length_align を求めている。はみ出した部分は使われない
+	 * (ex) spackList_length が 13 の場合
+	 *   spackList_length_align = 16;
+	 *     実際に送るデータは64バイトになるのでOK
+	 *     14,15,16 の部分は何も入らない。
+	 */
+	r[i].spackList_length_align = (r[i].spackList_length + 3)&(~3);
 
-    /* 各 SPU が持つ、SpanPack の address list */
-    spackList_ptr =
-        (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align);
+	/* 各 SPU が持つ、SpanPack の address list */
+	r[i].spackList_ptr =
+	    (SpanPack**)manager->allocate(sizeof(SpanPack*)*r[i].spackList_length_align);
 
-    for (int i = 0; i < spackList_length; i++) {
-        spackList_ptr[i] = &spackList[i];
-    }
+	for (int j = 0; j < r[i].spackList_length; j++) {
+	    r[i].spackList_ptr[j] = &r[i].spackList[j];
+	}
 
-    for (int i = 1; i <= spackList_length; i++) {
-        spackList[i-1].init(i*split_screen_h);
+	for (int j = 1; j <= r[i].spackList_length; j++) {
+	    r[i].spackList[j-1].init(j*split_screen_h);
+	}
     }
 
     task_next = manager->create_task(Dummy,0,0,0,0);
     
     // ここは、Iterator を用意するべきだよね
-    for (int i = 0; i < spe_num; i++) {
+    for (int j = 0; j < spe_num; j++) {
         task_tex = manager->create_task(LoadTexture,0,0,0,0);
-        task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i));
+        task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + j));
         task_next->wait_for(task_tex);
 	task_tex->spawn();	
     }
@@ -329,10 +313,6 @@
     dev->clean_pixels();
     pixels = dev->flip_screen(pixels);
 
-    for (int i = 1; i <= spackList_length; i++) {
-        spackList[i-1].reinit(i*split_screen_h);
-    }
-
     /* ここでGameTaskの終了を待つTaskを生成しておく */
     sgroot->wait_game_task = manager->create_task(Dummy,0,0,0,0);
     sgroot->updateControllerState();
@@ -711,7 +691,7 @@
     // SceneGraph(木構造) -> PolygonPack
 
     task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
-    task_create_pp->set_param(1,(memaddr)ppack);
+    task_create_pp->set_param(1,(memaddr)r[ppi].ppack);
     /* GameTaskの終了を待ってからポリゴンを作る */
     task_create_pp->wait_for(game_task);
 
@@ -722,12 +702,12 @@
     int  range_base = spe_num;
 
     // 切り上げのつもり
-    int range = (spackList_length + range_base - 1) / range_base;
+    int range = (r[spi].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;
+        int index_end = (index_start + range >= r[spi].spackList_length)
+            ? r[spi].spackList_length : index_start + range;
 
 	HTaskPtr task_create_sp = manager->create_task(CreateSpan);
 
@@ -746,10 +726,10 @@
         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_create_sp->add_inData(r[ppi].ppack, 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_next->wait_for(task_create_sp);
         task_create_sp->wait_for(task_create_pp);
@@ -799,11 +779,11 @@
 	data_update_wait->spawn();
     }
 
-    
-    ppack->clear();
+    ppi ^= 1; 
+    r[ppi].ppack->clear();
 
-    for (int i = 0; i < spackList_length; i++) {
-        SpanPack *spack = &spackList[i];
+    for (int i = 0; i < r[spi].spackList_length; i++) {
+        SpanPack *spack = &r[spi].spackList[i];
         int startx = 1;
         int endx = split_screen_w;
 
@@ -913,6 +893,11 @@
 #endif
 
     } 
+    spi ^= 1; 
+    for (int i = 1; i <= r[spi].spackList_length; i++) {
+        r[spi].spackList[i-1].reinit(i*split_screen_h);
+    }
+
 
     if (profile) {
 	if (frames % 50 == 49) {
--- a/Renderer/Engine/viewer.h	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/viewer.h	Fri Oct 01 04:43:02 2010 +0900
@@ -16,6 +16,19 @@
 
 class Application;
 
+typedef struct rendering_data {
+    PolygonPack *ppack;
+    SpanPackPtr spackList;
+    SpanPackPtr *spackList_ptr;
+
+    int spackList_length;
+    int spackList_length_align;
+} RederingData ;
+
+extern RederingData r[2];
+
+extern int  ppi, spi;
+
 class Viewer : public MainLoop {
 
 public:
--- a/Renderer/Engine/viewerPS3.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/viewerPS3.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -33,7 +33,8 @@
 }
 
 #else /* !defined(__linux__) */
-ScreenInfo get_fbdev_addr(void) { 
+ScreenInfo 
+ViewerPS3::get_fbdev_addr(void) { 
     ScreenInfo tmp = {0,0,0,0};
     return tmp;
 }
@@ -83,7 +84,9 @@
         // cp_fb_wait_vsync( &fb );
 
         // Send the frame just drawn to the CRT by the next vblank
+#ifdef __linux__
         cp_fb_flip( &fb, frame_ndx );
+#endif
 
         frame_ndx  = frame_ndx ^ 0x01;
 	return (uint32_t*)fb.draw_addr[ frame_ndx ];
@@ -93,8 +96,10 @@
 void
 ViewerPS3::free_device()
 {
+#ifdef __linux__
     cp_vt_close(&vt);
     cp_fb_close(&fb);
+#endif
 }
 
 /* end */
--- a/Renderer/Engine/viewerSDL.cc	Fri Oct 01 02:49:38 2010 +0900
+++ b/Renderer/Engine/viewerSDL.cc	Fri Oct 01 04:43:02 2010 +0900
@@ -47,9 +47,7 @@
 ViewerSDL::clean_pixels()
 {
     //bzero(pixels, sizeof(int)*width*height);
-#if !UGA
     SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
-#endif
 }
 
 void
--- a/TaskManager/Makefile.def	Fri Oct 01 02:49:38 2010 +0900
+++ b/TaskManager/Makefile.def	Fri Oct 01 04:43:02 2010 +0900
@@ -30,8 +30,8 @@
 ABIBIT = 32
 
 OPT = -g -O9 
-# OPT =  -g -DTASK_LIST_MAIL -O9
 # -DEARLY_TOUCH
+# -g -DTASK_LIST_MAIL -O9
 
 CC     = g++   
 CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT)   $(OPT)