changeset 31:6a77b5e755ab

*** empty log message ***
author gongo
date Tue, 12 Feb 2008 13:56:54 +0900
parents bd5fc2e3f8c7
children f7fd92a1d7bb
files TaskManager/Makefile.def TaskManager/Test/simple_render/create_sgp.cpp TaskManager/Test/simple_render/main.cpp TaskManager/Test/simple_render/span.cpp TaskManager/Test/simple_render/update_sgp.cpp TaskManager/Test/simple_render/viewer.cpp TaskManager/kernel/spe/SpeMail.cc TaskManager/kernel/spe/SpeManager.cc TaskManager/kernel/spe/SpeNop.cc TaskManager/kernel/spe/SpeNop2Ready.cc TaskManager/kernel/spe/SpeTask.cc TaskManager/kernel/spe/SpeTaskList.cc include/TaskManager/SpeMail.h include/TaskManager/SpeNop.h include/TaskManager/SpeNop2Ready.h include/TaskManager/SpeTaskList.h
diffstat 16 files changed, 132 insertions(+), 198 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Makefile.def	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Makefile.def	Tue Feb 12 13:56:54 2008 +0900
@@ -20,7 +20,7 @@
 IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cpp=.o)
 
 CC     = g++
-CFLAGS = -Wall -g -D_PPE_DEBUG
+CFLAGS = -Wall -g -D_PPE_DEBUG# -DDEBUG
 LIBS   = 
 
 INCLUDE = -I../include/TaskManager
\ No newline at end of file
--- a/TaskManager/Test/simple_render/create_sgp.cpp	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Test/simple_render/create_sgp.cpp	Tue Feb 12 13:56:54 2008 +0900
@@ -6,77 +6,77 @@
 
 int create_sgp(SceneGraphPack *sgp, Polygon *sg)
 {
-  int i = 0;
-  int nnpn = -1;
+    int i = 0;
+    int nnpn = -1;
 
-  Polygon *t;
-  t = sg;
+    Polygon *t;
+    t = sg;
 
-  while(t)
+    while(t)
     {
-      sgp->node[i].size = t->size;
-      int d,tex;
-      for(d=0,tex=0; d<t->size*3; d+=3,tex+=2)
+	sgp->node[i].size = t->size;
+	int d,tex;
+	for(d=0,tex=0; d<t->size*3; d+=3,tex+=2)
 	{
-	  sgp->node[i].vertex[d] = t->data[d];
-	  sgp->node[i].vertex[d+1] = t->data[d+1];
-	  sgp->node[i].vertex[d+2] = t->data[d+2];
-	  sgp->node[i].texture[tex] = t->data[d+t->size*6];
-	  sgp->node[i].texture[tex+1] = t->data[d+t->size*6+1];
+	    sgp->node[i].vertex[d] = t->data[d];
+	    sgp->node[i].vertex[d+1] = t->data[d+1];
+	    sgp->node[i].vertex[d+2] = t->data[d+2];
+	    sgp->node[i].texture[tex] = t->data[d+t->size*6];
+	    sgp->node[i].texture[tex+1] = t->data[d+t->size*6+1];
 	}
 
-      sgp->node[i].obj_pos[0] = 0;
-      sgp->node[i].obj_pos[1] = 0;
-      sgp->node[i].obj_pos[2] = 0;
-      sgp->node[i].obj_pos[3] = 1;
-      sgp->node[i].angle[0] = 0;
-      sgp->node[i].angle[1] = 0;
-      sgp->node[i].angle[2] = 0;
-      sgp->node[i].angle[3] = 1;
+	sgp->node[i].obj_pos[0] = 0;
+	sgp->node[i].obj_pos[1] = 0;
+	sgp->node[i].obj_pos[2] = 0;
+	sgp->node[i].obj_pos[3] = 1;
+	sgp->node[i].angle[0] = 0;
+	sgp->node[i].angle[1] = 0;
+	sgp->node[i].angle[2] = 0;
+	sgp->node[i].angle[3] = 1;
 
-      for(int tm=0; tm<16; tm++)
+	for(int tm=0; tm<16; tm++)
         {
-          sgp->node[i].translation[tm] = 0;
+	    sgp->node[i].translation[tm] = 0;
         }
-      sgp->node[i].id = 0;
-      sgp->node[i].move = 0;
-      sgp->node[i].interaction = 0;
-      sgp->node[i].pn = nnpn;
+	sgp->node[i].id = 0;
+	sgp->node[i].move = 0;
+	sgp->node[i].interaction = 0;
+	sgp->node[i].pn = nnpn;
 
-      if(t->child != NULL)
+	if(t->child != NULL)
 	{
-	  nnpn = i;
-	  t = t->child;
+	    nnpn = i;
+	    t = t->child;
 	}
-      else if(t->brother != NULL)
+	else if(t->brother != NULL)
 	{
-	  nnpn = sgp->node[i].pn;
-	  t = t->brother;
+	    nnpn = sgp->node[i].pn;
+	    t = t->brother;
 	}
-      else
+	else
 	{
-	  while(t)
+	    while(t)
 	    {
-	      if(t->brother != NULL)
+		if(t->brother != NULL)
 		{
-		  t = t->brother;
-		  break;
+		    t = t->brother;
+		    break;
 		}
-	      else
+		else
 		{
-		  if(t->parent == NULL)
+		    if(t->parent == NULL)
 		    {
-		      t = NULL;
-		      break;
+			t = NULL;
+			break;
 		    }
-		  nnpn = sgp->node[nnpn].pn;
-		  t = t->parent;
+		    nnpn = sgp->node[nnpn].pn;
+		    t = t->parent;
 		}
 	    }
 	}
-      i++;
+	i++;
     }
-  sgp->info.size = i;
+    sgp->info.size = i;
 
-  return sizeof(SceneGraphPack);
+    return sizeof(SceneGraphPack);
 }
--- a/TaskManager/Test/simple_render/main.cpp	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Test/simple_render/main.cpp	Tue Feb 12 13:56:54 2008 +0900
@@ -87,7 +87,7 @@
 }
 
 // 上の init() が代わりに動いてます
-int run_test( int argc, char* argv[], int bpp, int width, int height)
+int run_test(int bpp, int width, int height)
 {
     Viewer *screen;
     screen = new Viewer(bpp, width, height);
@@ -110,8 +110,6 @@
 
 int main(int argc, char *argv[])
 {
-    struct init_arg *arg = new struct init_arg;
-
     manager = new TaskManager(1);
     manager->init();
 
@@ -123,45 +121,45 @@
     manager->set_symbol("run", (void*)run);
     manager->set_symbol("finish", (void*)finish);
 
-
-    // 本当はここ以下も initialize function でやらせるべき
-    int i;
     int bpp = 0;
     int width = 640;
     int height = 480;
 
-    arg->bpp = 0;
-    arg->w = 640;
-    arg->h = 480;    
-
     for(int i = 1; argv[i]; ++i)
     {
 	if (strcmp(argv[i], "-bpp") == 0)
 	{
-	    arg->bpp = atoi(argv[++i]);
+	    bpp = atoi(argv[++i]);
 	}
 	if (strcmp(argv[i], "-width") == 0)
 	{
-	    arg->w = atoi(argv[++i]);
+	    width = atoi(argv[++i]);
 	} 
 	if (strcmp(argv[i], "-height") == 0) 
 	{
-	    arg->h = atoi(argv[++i]);
+	    height = atoi(argv[++i]);
 	}
     }
 
-    //run_test(bpp, width, height);
-
+#if 1
+    run_test(bpp, width, height);
+#else
     // 一番最初に行われる init 専用の task_run があってもいいけど。。
     // その場合は引数とか固定か。まあ引数は argc, argv を持つ
     // 構造体で固定しても問題はない・・・か?
     HTaskPtr task_init;
     int fd_init;
+    struct init_arg *arg = new struct init_arg;
+
+    arg->bpp = bpp;
+    arg->w = width;
+    arg->h = height;    
+
     fd_init = manager->open("init");
     task_init  = manager->create_task(fd_init, sizeof(struct init_arg),
 				      (unsigned int)arg, 0, NULL);
     manager->spawn_task(task_init);
     manager->run();
-
+#endif
     return 0;
 }
--- a/TaskManager/Test/simple_render/span.cpp	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Test/simple_render/span.cpp	Tue Feb 12 13:56:54 2008 +0900
@@ -41,7 +41,10 @@
 
 
 
-void Span::half_triangle(Vertex *vMin, Vertex *vMid, Vertex *vMid1,SDL_Surface *image) {
+void
+Span::half_triangle(Vertex *vMin, Vertex *vMid, Vertex *vMid1,
+		    SDL_Surface *image)
+{
 
 	float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
 	//tmp_x,tmp_y,tmp_ypos ......unused
@@ -55,10 +58,10 @@
 	int x,y;
 	int k =0;
 	int l = 1;
-	float incli_x1, incli_x2;
-	float incli_z1, incli_z2;
-	float base_x1, base_x2  , base_z1, base_z2;
-	int base_y;
+	//float incli_x1, incli_x2;
+	//float incli_z1, incli_z2;
+	//float base_x1, base_x2  , base_z1, base_z2;
+	//int base_y;
 
 	/*
 	incli_x1 = vMid1->x - vMin->x;
@@ -75,16 +78,16 @@
 	int end_y   = (int)vMin->y;
 	
 	if (start_y<end_y) { 
-		int i; i=end_y; end_y=start_y; start_y = i;   //y$B$NF~$lBX$((B 
-		//Vertex *v; v = vMin; vMin = vMid; vMid = v;	
-		/*
-		incli_x1 = vMin->x - vMid->x; incli_x2 = vMin->x - vMid1->x;
-		incli_z1 = vMin->z - vMid->z; incli_z2 = vMin->z - vMid1->z;
-		base_z1 = vMid->z; base_z2 = vMid1->z;
-		base_y = (int)vMid->y;
-		*/
-		k = 1;
-		l = -1;
+	    int i; i=end_y; end_y=start_y; start_y = i;   //y$B$NF~$lBX$((B 
+	    //Vertex *v; v = vMin; vMin = vMid; vMid = v;	
+	    /*
+	      incli_x1 = vMin->x - vMid->x; incli_x2 = vMin->x - vMid1->x;
+	      incli_z1 = vMin->z - vMid->z; incli_z2 = vMin->z - vMid1->z;
+	      base_z1 = vMid->z; base_z2 = vMid1->z;
+	      base_y = (int)vMid->y;
+	    */
+	    k = 1;
+	    l = -1;
 	}
 
 
--- a/TaskManager/Test/simple_render/update_sgp.cpp	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Test/simple_render/update_sgp.cpp	Tue Feb 12 13:56:54 2008 +0900
@@ -65,18 +65,13 @@
 update_sgp(SceneGraphPack *_sgp, SceneGraphPack *sgp)
 {
     SceneGraphNodePtr node;
-    float y_angle;
 
     for (int i = 0; i < sgp->info.size; i++) {
 	//(*my_func[node->move])(node);
 	//(*my_func[node->interaction])(node, sgp);
 
 	node = &sgp->node[i];
-#if 0
-	node->obj_pos[0] += 0.5f;
-	node->obj_pos[1] += 0.5f;
-	node->obj_pos[2] += 0.5f;
-#endif
+
 	if (node->pn != -1) {
 	    get_matrix(node->translation,
 		       node->angle, node->obj_pos,
--- a/TaskManager/Test/simple_render/viewer.cpp	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Tue Feb 12 13:56:54 2008 +0900
@@ -417,7 +417,7 @@
 	p->xyz[2] = z;
 	p->tree_draw();
 
-#if 1
+#if 0
 	create_sgp(sgp, p);
 	update_sgp(sgp, sgp);
 	create_pp(pp, sgp);
@@ -453,12 +453,13 @@
 
 	manager->run();
 #endif
-	//p->draw(sgp);
-	p->draw(pp);
 
-	bitmap =
-	    SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32, width*4,
-				     redMask, greenMask, blueMask, alphaMask);
+	//p->draw(sgp); // test draw of SceneGraphPack
+	p->draw(pp);    // test draw of PolygonPack
+	
+	bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
+					  width*4, redMask, greenMask,
+					  blueMask, alphaMask);
 	SDL_FillRect(screen, NULL, background);
 	SDL_BlitSurface(bitmap, NULL, screen, NULL);
 	SDL_UpdateRect(screen, 0, 0, 0, 0);
--- a/TaskManager/kernel/spe/SpeMail.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeMail.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -13,35 +13,19 @@
 SpeMail::read(void)
 {
 
-    __debug("SpeMail::read()");
+    __debug("[SpeMail:%s]\n", __FUNCTION__);
     
     params_addr = connector->mail_read();
     
-#ifdef DEBUG
-    printf("[SPE] SpeMail:[read] params_addr = 0x%x\n", params_addr);
-#endif
+    __debug("  params_addr = 0x%x\n", params_addr);
 }
 
-#ifdef DEBUG
-void
-SpeMail::exec(void)
-{
-    printf("SpeMail::exec()\n");
-}
-
-void
-SpeMail::write(void)
-{
-    printf("SpeMail::write()\n");
-}
-#endif
-
 SpeTaskBase*
 SpeMail::next(SpeManager *m, SpeTaskBase *p)
 {
     delete p;
 
-    __debug("SpeMail::next()");
+    __debug("[SpeMail:%s]\n", __FUNCTION__);
 
     // if 文なくすには・・・関数ポインタ?
     if ((int)params_addr == MY_SPE_COMMAND_EXIT) {
--- a/TaskManager/kernel/spe/SpeManager.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeManager.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -72,7 +72,7 @@
 
     // main loop
     do {
-	__debug("----------");
+	__debug("----------\n");
 	task3->write();
 	task2->exec();
 	task1->read();
--- a/TaskManager/kernel/spe/SpeNop.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeNop.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -3,29 +3,6 @@
 #include "SpeMail.h"
 #include "error.h"
 
-SpeNop::SpeNop(void)
-{
-}
-
-void
-SpeNop::read(void)
-{
-    __debug("SpeNop::read()");
-}
-
-void
-SpeNop::exec(void)
-{
-    __debug("SpeNop::exec()");
-}
-
-void
-SpeNop::write(void)
-{
-    __debug("SpeNop::write()");
-}
-
-
 SpeTaskBase*
 SpeNop::next(SpeManager *m, SpeTaskBase *p)
 {
--- a/TaskManager/kernel/spe/SpeNop2Ready.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeNop2Ready.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -9,30 +9,17 @@
 }
 
 void
-SpeNop2Ready::read(void)
-{
-    __debug("SpeNop2Ready::read()");
-}
-
-void
 SpeNop2Ready::exec(void)
 {
-    __debug("SpeNop2Ready::exec()");
+    __debug("[SpeNop2Ready:%s]\n", __FUNCTION__);
 
     connector->mail_write(MY_SPE_STATUS_READY);
 }
 
-void
-SpeNop2Ready::write(void)
-{
-    __debug("SpeNopReady::write()");
-}
-
-
 SpeTaskBase*
 SpeNop2Ready::next(SpeManager *m, SpeTaskBase *p)
 {
-    __debug("SpeNop2Ready::next()");
+    __debug("[SpeNop2Ready:%s]\n", __FUNCTION__);
     
     delete p;
 
--- a/TaskManager/kernel/spe/SpeTask.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeTask.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -22,7 +22,7 @@
 void
 SpeTask::read(void)
 {    
-    __debug("SpeTask::read()");
+    __debug("[SpeTask:%s]\n", __FUNCTION__);
 
     //task = &list->tasks[--list->length];
     connector->dma_load(readbuf, task->in_addr, task->in_size, DMA_READ);
@@ -31,18 +31,16 @@
 void
 SpeTask::exec(void)
 {
-    __debug("SpeTask::exec()");
+    __debug("[SpeTask:%s]\n", __FUNCTION__);
 
     connector->dma_wait(DMA_READ);
 
-#ifdef DEBUG
-    printf("  task->command  = %d\n", task->command);
-    printf("  task->in_size  = %d\n", task->in_size);
-    printf("  task->in_addr  = 0x%x\n", task->in_addr);
-    printf("  task->out_addr = 0x%x\n", task->out_addr);
-    printf("  list->next   = 0x%x\n", (unsigned int)list->next);
-    printf("  list->length = 0x%x\n", (unsigned int)list->length);
-#endif
+    __debug("  task->command  = %d\n", task->command);
+    __debug("  task->in_size  = %d\n", task->in_size);
+    __debug("  task->in_addr  = 0x%x\n", task->in_addr);
+    __debug("  task->out_addr = 0x%x\n", task->out_addr);
+    __debug("  list->next     = 0x%x\n", (unsigned int)list->next);
+    __debug("  list->length   = 0x%x\n", (unsigned int)list->length);
 
     // obsolute
     //   task->in_size = func_list[task->command](writebuf, readbuf);
@@ -58,7 +56,7 @@
 void
 SpeTask::write(void)
 {
-    __debug("SpeTask::write()");
+    __debug("[SpeTask:%s]\n", __FUNCTION__);
 
     connector->dma_wait(DMA_WRITE);
     connector->mail_write((unsigned int)task->self);
@@ -67,7 +65,7 @@
 SpeTaskBase*
 SpeTask::next(SpeManager *m, SpeTaskBase *p)
 {
-    __debug("SpeTask::next()");
+    __debug("[SpeTask:%s]\n", __FUNCTION__);
 
     delete p;
  
--- a/TaskManager/kernel/spe/SpeTaskList.cc	Tue Feb 12 11:18:48 2008 +0900
+++ b/TaskManager/kernel/spe/SpeTaskList.cc	Tue Feb 12 13:56:54 2008 +0900
@@ -15,32 +15,16 @@
 void
 SpeTaskList::read(void)
 {
-    __debug("SpeTaskList::read()");
+    __debug("[SpeTaskList:%s]\n", __FUNCTION__);
 
     connector->dma_load(list, params_addr, sizeof(TaskList), DMA_READ);
     connector->dma_wait(DMA_READ);
 }
 
-void
-SpeTaskList::exec(void)
-{
-    __debug("SpeTaskList::exec()");
-}
-
-#ifdef DEBUG
-void
-SpeTaskList::write(void)
-{
-    printf("SpeTaskList::exec()\n");
-}
-#endif
-
-
-
 SpeTaskBase*
 SpeTaskList::next(SpeManager *m, SpeTaskBase *p)
 {
-    __debug("SpeTaskList::next()");
+    __debug("[SpeTaskList:%s]\n", __FUNCTION__);
 
     delete p;
 
--- a/include/TaskManager/SpeMail.h	Tue Feb 12 11:18:48 2008 +0900
+++ b/include/TaskManager/SpeMail.h	Tue Feb 12 13:56:54 2008 +0900
@@ -5,6 +5,8 @@
 #  include "SpeManager.h"
 #endif
 
+#include "error.h"
+
 class SpeMail : public SpeTaskBase{
 public:
     /* constructor */
@@ -15,14 +17,12 @@
     DmaManager* connector;    
 
     /* functions */
+    void read(void);
     SpeTaskBase* next(SpeManager *, SpeTaskBase *);
 
-    /* override functions */
-    void read(void); // overwride
-
-#ifdef DEBUG
-    void exec(void);
-    void write(void);
+#if DEBUG
+    void exec(void)  { __debug("[SpeMail:%s]\n", __FUNCTION__); }
+    void write(void) { __debug("[SpeMail:%s]\n", __FUNCTION__); }
 #endif
 };
 
--- a/include/TaskManager/SpeNop.h	Tue Feb 12 11:18:48 2008 +0900
+++ b/include/TaskManager/SpeNop.h	Tue Feb 12 13:56:54 2008 +0900
@@ -5,18 +5,18 @@
 #  include "SpeManager.h"
 #endif
 
+#include "error.h"
+
 class SpeNop : public SpeTaskBase {
 public:
-    /* constructor */
-    SpeNop(void);
-
-    /* variables */
+    /* functions */
+    SpeTaskBase* next(SpeManager *, SpeTaskBase *);
 
-    /* functions */
-    void read(void);
-    void exec(void);
-    void write(void);
-    SpeTaskBase* next(SpeManager *, SpeTaskBase *);
+#if DEBUG
+    void read(void)  { __debug("[SpeNop:%s]\n", __FUNCTION__); }
+    void exec(void)  { __debug("[SpeNop:%s]\n", __FUNCTION__); }
+    void write(void) { __debug("[SpeNop:%s]\n", __FUNCTION__); }
+#endif
 };
 
 #endif
--- a/include/TaskManager/SpeNop2Ready.h	Tue Feb 12 11:18:48 2008 +0900
+++ b/include/TaskManager/SpeNop2Ready.h	Tue Feb 12 13:56:54 2008 +0900
@@ -9,6 +9,8 @@
 #  include "SpeNop.h"
 #endif
 
+#include "error.h"
+
 class SpeNop2Ready : public SpeNop {
 public:
     /* constructor */
@@ -18,10 +20,13 @@
     DmaManager* connector;    
 
     /* functions */
-    void read(void);
     void exec(void);
-    void write(void);
     SpeTaskBase* next(SpeManager *, SpeTaskBase *);
+
+#if DEBUG
+    void read(void)  { __debug("[SpeNop2Ready:%s]\n", __FUNCTION__); }
+    void write(void) { __debug("[SpeNop2Ready:%s]\n", __FUNCTION__); }
+#endif
 };
 
 #endif
--- a/include/TaskManager/SpeTaskList.h	Tue Feb 12 11:18:48 2008 +0900
+++ b/include/TaskManager/SpeTaskList.h	Tue Feb 12 13:56:54 2008 +0900
@@ -5,6 +5,8 @@
 #  include "SpeManager.h"
 #endif
 
+#include "error.h"
+
 class SpeTaskList : public SpeTaskBase {
 public:
     /* constructor */
@@ -20,10 +22,10 @@
     
     /* override functions */
     void read(void);
-    void exec(void);
 
 #ifdef DEBUG
-    void write(void);
+    void exec(void)  { __debug("[SpeTaskList:%s]\n", __FUNCTION__); }
+    void write(void) { __debug("[SpeTaskList:%s]\n", __FUNCTION__); }
 #endif
 
 };